diff --git a/app/controllers/cms/sections_controller.rb b/app/controllers/cms/sections_controller.rb new file mode 100644 index 0000000..b15d894 --- /dev/null +++ b/app/controllers/cms/sections_controller.rb @@ -0,0 +1,4 @@ +module Cms + class SectionsController < CmsController + end +end diff --git a/app/helpers/cms/section_helper.rb b/app/helpers/cms/section_helper.rb new file mode 100644 index 0000000..fe19bfe --- /dev/null +++ b/app/helpers/cms/section_helper.rb @@ -0,0 +1,2 @@ +module Cms::SectionHelper +end diff --git a/app/views/cms/pages/show.haml b/app/views/cms/pages/show.haml index 650c944..c0e3ee5 100644 --- a/app/views/cms/pages/show.haml +++ b/app/views/cms/pages/show.haml @@ -15,10 +15,10 @@ %button.mt-4.rounded-lg.bg-yellow-500.p-4 =link_to "Down" , "/index" %button.mt-4.rounded-lg.bg-blue-400.p-4 - =link_to "Edit" , "/index" + =link_to "Edit" , cms_page_section_path(@page.name , 1234) %button.mt-4.rounded-lg.bg-cyan-400.p-4 =link_to "New" , "/index" %button.mt-4.rounded-lg.bg-red-400.p-4 =link_to "Delete" , "/index" -section.content.each do |key , value| - = render "cms/sections/#{key}", section: section , key: key , value: value + = render "cms/sections/data/#{key}", section: section , key: key , value: value diff --git a/app/views/cms/sections/_form.html.haml b/app/views/cms/sections/_form.html.haml new file mode 100644 index 0000000..6687e49 --- /dev/null +++ b/app/views/cms/sections/_form.html.haml @@ -0,0 +1,10 @@ += form_for @cms_section do |f| + - if @cms_section.errors.any? + #error_explanation + %h2= "#{pluralize(@cms_section.errors.count, "error")} prohibited this cms_section from being saved:" + %ul + - @cms_section.errors.full_messages.each do |message| + %li= message + + .actions + = f.submit 'Save' diff --git a/app/views/cms/sections/_button.haml b/app/views/cms/sections/data/_button.haml similarity index 100% rename from app/views/cms/sections/_button.haml rename to app/views/cms/sections/data/_button.haml diff --git a/app/views/cms/sections/_card_template.haml b/app/views/cms/sections/data/_card_template.haml similarity index 100% rename from app/views/cms/sections/_card_template.haml rename to app/views/cms/sections/data/_card_template.haml diff --git a/app/views/cms/sections/_cards.haml b/app/views/cms/sections/data/_cards.haml similarity index 100% rename from app/views/cms/sections/_cards.haml rename to app/views/cms/sections/data/_cards.haml diff --git a/app/views/cms/sections/_header.haml b/app/views/cms/sections/data/_header.haml similarity index 100% rename from app/views/cms/sections/_header.haml rename to app/views/cms/sections/data/_header.haml diff --git a/app/views/cms/sections/_image.haml b/app/views/cms/sections/data/_image.haml similarity index 100% rename from app/views/cms/sections/_image.haml rename to app/views/cms/sections/data/_image.haml diff --git a/app/views/cms/sections/_template.haml b/app/views/cms/sections/data/_template.haml similarity index 100% rename from app/views/cms/sections/_template.haml rename to app/views/cms/sections/data/_template.haml diff --git a/app/views/cms/sections/_text.haml b/app/views/cms/sections/data/_text.haml similarity index 100% rename from app/views/cms/sections/_text.haml rename to app/views/cms/sections/data/_text.haml diff --git a/app/views/cms/sections/edit.html.haml b/app/views/cms/sections/edit.html.haml new file mode 100644 index 0000000..9d8cb7e --- /dev/null +++ b/app/views/cms/sections/edit.html.haml @@ -0,0 +1,7 @@ +%h1 Editing cms_section + += render 'form' + += link_to 'Show', @cms_section +\| += link_to 'Back', cms_sections_path diff --git a/app/views/cms/sections/index.html.haml b/app/views/cms/sections/index.html.haml new file mode 100644 index 0000000..5fc16ed --- /dev/null +++ b/app/views/cms/sections/index.html.haml @@ -0,0 +1,19 @@ +%h1 Listing cms_sections + +%table + %thead + %tr + %th + %th + %th + + %tbody + - @cms_sections.each do |cms_section| + %tr + %td= link_to 'Show', cms_section + %td= link_to 'Edit', edit_cms_section_path(cms_section) + %td= link_to 'Destroy', cms_section, method: :delete, data: { confirm: 'Are you sure?' } + +%br + += link_to 'New Section', new_cms_section_path diff --git a/app/views/cms/sections/new.html.haml b/app/views/cms/sections/new.html.haml new file mode 100644 index 0000000..ecfd998 --- /dev/null +++ b/app/views/cms/sections/new.html.haml @@ -0,0 +1,5 @@ +%h1 New cms_section + += render 'form' + += link_to 'Back', cms_sections_path diff --git a/app/views/cms/sections/show.html.haml b/app/views/cms/sections/show.html.haml new file mode 100644 index 0000000..becbe90 --- /dev/null +++ b/app/views/cms/sections/show.html.haml @@ -0,0 +1,6 @@ +%p#notice= notice + + += #link_to 'Edit', edit_cms_section_path(@cms_section) +\| += #link_to 'Back', cms_sections_path diff --git a/app/views/layouts/cms_layout.haml b/app/views/layouts/cms_layout.haml index 467fd65..2844465 100644 --- a/app/views/layouts/cms_layout.haml +++ b/app/views/layouts/cms_layout.haml @@ -29,17 +29,11 @@ %a.text-gray-500.transition{:class => "hover:text-gray-500/75", :href => cms_images_path} Images %li - %a.text-gray-500.transition{:class => "hover:text-gray-500/75", :href => "/"} - History + %a.text-gray-500.transition{:class => "hover:text-gray-500/75", :href => "/cms/styles"} + Styles %li - %a.text-gray-500.transition{:class => "hover:text-gray-500/75", :href => "/"} - Services - %li - %a.text-gray-500.transition{:class => "hover:text-gray-500/75", :href => "/"} - Projects - %li - %a.text-gray-500.transition{:class => "hover:text-gray-500/75", :href => "/"} - Blog + %a.text-gray-500.transition{:class => "hover:text-gray-500/75", :href => "/changes"} + Changes .flex.items-center.gap-4 .sm:flex.sm:gap-4 %a.rounded-md.bg-teal-600.px-5.text-sm.font-medium.text-white.shadow{:class => "py-2.5", :href => "/"} diff --git a/config/routes.rb b/config/routes.rb index 66b5cbc..83e7881 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,9 @@ Rails.application.routes.draw do namespace :cms do - resources :pages + resources :pages do + resources :sections + end resources :images end diff --git a/spec/helpers/cms/section_helper_spec.rb b/spec/helpers/cms/section_helper_spec.rb new file mode 100644 index 0000000..5a21ef7 --- /dev/null +++ b/spec/helpers/cms/section_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the Cms::SectionHelper. For example: +# +# describe Cms::SectionHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe Cms::SectionHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/requests/cms/section_spec.rb b/spec/requests/cms/section_spec.rb new file mode 100644 index 0000000..8722a60 --- /dev/null +++ b/spec/requests/cms/section_spec.rb @@ -0,0 +1,7 @@ +require 'rails_helper' + +RSpec.describe "Cms::Sections", type: :request do + describe "GET /index" do + pending "add some examples (or delete) #{__FILE__}" + end +end