bit of pages link cleanup
This commit is contained in:
parent
a2d79d397d
commit
0d159912f9
@ -1,58 +1,60 @@
|
|||||||
class Cms::PagesController < ApplicationController
|
module Cms
|
||||||
before_action :set_cms_page, only: %i[ show edit update destroy ]
|
class PagesController < CmsController
|
||||||
|
before_action :set_cms_page, only: %i[ show edit update destroy ]
|
||||||
|
|
||||||
# GET /cms/pages
|
# GET /cms/pages
|
||||||
def index
|
def index
|
||||||
@cms_pages = Cms::Page.all
|
@cms_pages = Cms::Page.all
|
||||||
end
|
|
||||||
|
|
||||||
# GET /cms/pages/1
|
|
||||||
def show
|
|
||||||
end
|
|
||||||
|
|
||||||
# GET /cms/pages/new
|
|
||||||
def new
|
|
||||||
@cms_page = Cms::Page.new
|
|
||||||
end
|
|
||||||
|
|
||||||
# GET /cms/pages/1/edit
|
|
||||||
def edit
|
|
||||||
end
|
|
||||||
|
|
||||||
# POST /cms/pages
|
|
||||||
def create
|
|
||||||
@cms_page = Cms::Page.new(cms_page_params)
|
|
||||||
|
|
||||||
if @cms_page.save
|
|
||||||
redirect_to @cms_page, notice: "Page was successfully created."
|
|
||||||
else
|
|
||||||
render :new, status: :unprocessable_entity
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# PATCH/PUT /cms/pages/1
|
|
||||||
def update
|
|
||||||
if @cms_page.update(cms_page_params)
|
|
||||||
redirect_to @cms_page, notice: "Page was successfully updated."
|
|
||||||
else
|
|
||||||
render :edit, status: :unprocessable_entity
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# DELETE /cms/pages/1
|
|
||||||
def destroy
|
|
||||||
@cms_page.destroy
|
|
||||||
redirect_to cms_pages_url, notice: "Page was successfully destroyed."
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
|
||||||
def set_cms_page
|
|
||||||
@cms_page = Cms::Page.find(params[:id])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Only allow a list of trusted parameters through.
|
# GET /cms/pages/1
|
||||||
def cms_page_params
|
def show
|
||||||
params.fetch(:cms_page, {})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# GET /cms/pages/new
|
||||||
|
def new
|
||||||
|
@cms_page = Cms::Page.new
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /cms/pages/1/edit
|
||||||
|
def edit
|
||||||
|
end
|
||||||
|
|
||||||
|
# POST /cms/pages
|
||||||
|
def create
|
||||||
|
@cms_page = Cms::Page.new(cms_page_params)
|
||||||
|
|
||||||
|
if @cms_page.save
|
||||||
|
redirect_to @cms_page, notice: "Page was successfully created."
|
||||||
|
else
|
||||||
|
render :new, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# PATCH/PUT /cms/pages/1
|
||||||
|
def update
|
||||||
|
if @cms_page.update(cms_page_params)
|
||||||
|
redirect_to @cms_page, notice: "Page was successfully updated."
|
||||||
|
else
|
||||||
|
render :edit, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# DELETE /cms/pages/1
|
||||||
|
def destroy
|
||||||
|
@cms_page.destroy
|
||||||
|
redirect_to cms_pages_url, notice: "Page was successfully destroyed."
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
|
def set_cms_page
|
||||||
|
@cms_page = Cms::Page.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
# Only allow a list of trusted parameters through.
|
||||||
|
def cms_page_params
|
||||||
|
params.fetch(:cms_page, {})
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -33,5 +33,9 @@ module Cms
|
|||||||
@@files.collect{ |file| Page.new(file) }
|
@@files.collect{ |file| Page.new(file) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.find(name)
|
||||||
|
Page.new(name + ".yaml")
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
%h1 Editing cms_page
|
%h1 Editing #{@cms_page.name}
|
||||||
|
|
||||||
= render 'form'
|
= render 'form'
|
||||||
|
|
||||||
= link_to 'Show', @cms_page
|
= link_to 'Show', cms_page_url(@cms_page.name)
|
||||||
\|
|
\|
|
||||||
= link_to 'Back', cms_pages_path
|
= link_to 'Back', cms_pages_path
|
||||||
|
@ -17,15 +17,17 @@
|
|||||||
- @cms_pages.each do |cms_page|
|
- @cms_pages.each do |cms_page|
|
||||||
%tr
|
%tr
|
||||||
%td.whitespace-nowrap.px-4.py-2.text-gray-700
|
%td.whitespace-nowrap.px-4.py-2.text-gray-700
|
||||||
= link_to cms_page.name , cms_page.name
|
= link_to cms_page.name , cms_page_path(cms_page.name)
|
||||||
%td.whitespace-nowrap.px-4.py-2.text-gray-700
|
%td.whitespace-nowrap.px-4.py-2.text-gray-700
|
||||||
= cms_page.template
|
= cms_page.template
|
||||||
%td.whitespace-nowrap.px-4.py-2.text-gray-700
|
%td.whitespace-nowrap.px-4.py-2.text-gray-700
|
||||||
= cms_page.content.length
|
= cms_page.content.length
|
||||||
%td.whitespace-nowrap.px-4.py-2
|
%td.whitespace-nowrap.px-4.py-2
|
||||||
%strong.rounded.bg-green-100.px-3.text-xs.font-medium.text-green-700{:class => "py-1.5"}
|
%strong.rounded.bg-green-100.px-3.text-xs.font-medium.text-green-700{:class => "py-1.5"}
|
||||||
= link_to 'Show', cms_page_path(cms_page , id: cms_page.name)
|
= link_to 'Show', cms_page_path(cms_page.name)
|
||||||
%strong.rounded.bg-amber-100.px-3.text-xs.font-medium.text-amber-700{:class => "py-1.5"}
|
%strong.rounded.bg-amber-100.px-3.text-xs.font-medium.text-amber-700{:class => "py-1.5"}
|
||||||
= link_to 'Edit', edit_cms_page_path(cms_page , id: cms_page.name)
|
= link_to 'Edit', edit_cms_page_path(cms_page.name)
|
||||||
|
|
||||||
= link_to 'New Page', new_cms_page_path
|
%section
|
||||||
|
%a.inline-block.rounded.border.border-indigo-600.bg-indigo-600.px-12.py-3.text-sm.font-medium.text-white.hover:bg-transparent.hover:text-indigo-600.focus:outline-none.focus:ring.active:text-indigo-500{:href => new_cms_page_path}
|
||||||
|
New Page
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
%p#notice= notice
|
%p#notice= notice
|
||||||
|
|
||||||
|
|
||||||
= link_to 'Edit', edit_cms_page_path(@cms_page)
|
= link_to 'Edit', edit_cms_page_path(@cms_page.name)
|
||||||
\|
|
\|
|
||||||
= link_to 'Back', cms_pages_path
|
= link_to 'Back', cms_pages_path
|
||||||
|
Loading…
Reference in New Issue
Block a user