diff --git a/app/assets/images/merged/section_preview/blog_header.png b/app/assets/images/merged/section_preview/blog_header.png new file mode 100644 index 0000000..6d31b08 Binary files /dev/null and b/app/assets/images/merged/section_preview/blog_header.png differ diff --git a/app/controllers/merged/pages_controller.rb b/app/controllers/merged/pages_controller.rb index 7e80cb0..b5226d8 100644 --- a/app/controllers/merged/pages_controller.rb +++ b/app/controllers/merged/pages_controller.rb @@ -19,6 +19,15 @@ module Merged @page.edit_save(current_member.email) message = "Page renamed" end + options = params[:option] + if options + @page.option_definitions.each do |option| + puts "Option #{option.name}:#{options[option.name]}" + @page.set_option(option.name, options[option.name]) + end + @page.edit_save(current_member.email) + message = "Options saved" + end redirect_to page_url(@page) , notice: message end diff --git a/app/helpers/merged/options_helper.rb b/app/helpers/merged/options_helper.rb index 3b34fb7..85a7b16 100644 --- a/app/helpers/merged/options_helper.rb +++ b/app/helpers/merged/options_helper.rb @@ -11,6 +11,22 @@ module Merged all end + def date_precision(element , date_name) + precision = element.option("date_precision") + date = element.option(date_name) + if( precision == "precise") + return date.to_formatted_s(:short) + " " + date.year.to_s + end + if(date.day < 10) + attr = "Beginning" + elsif date.day < 20 + attr = "Middle" + else + attr = "End" + end + "#{attr} of #{date.strftime('%B')} #{date.year}" + end + def order_option(section , clazz = "") if section.has_option?("order") clazz += " order-last" if section.option('order') == "right" diff --git a/app/models/merged/view_base.rb b/app/models/merged/view_base.rb index 67571db..8aef863 100644 --- a/app/models/merged/view_base.rb +++ b/app/models/merged/view_base.rb @@ -24,7 +24,6 @@ module Merged last_section end - def has_option?(option) options.has_key?(option) and !options[option].blank? end @@ -43,6 +42,11 @@ module Merged end def set_option( option , value) + if( !value.is_a?(String) && value.respond_to?(:[]) && value[:month] ) + year = value[:year] || Time.new.year + value = Time.new( year , value[:month] , value[:day]).to_date + puts "date is #{value}" + end options[option] = value end diff --git a/app/views/merged/pages/show.haml b/app/views/merged/pages/show.haml index 6eff749..2298527 100644 --- a/app/views/merged/pages/show.haml +++ b/app/views/merged/pages/show.haml @@ -1,6 +1,6 @@ - content_for( :merged_menu ) do .text-xl.font-bold.text-gray-900 - Page + = @page.type.capitalize .text-xl.font-bold.text-gray-900 =@page.name %strong.rounded.bg-green-100.px-3.text-xs.font-medium.text-green-700{:class => "py-1.5"} diff --git a/app/views/merged/sections/_option_form_date.haml b/app/views/merged/sections/_option_form_date.haml new file mode 100644 index 0000000..30d8ca2 --- /dev/null +++ b/app/views/merged/sections/_option_form_date.haml @@ -0,0 +1,4 @@ +%label.block + .mt-4.text-lg.font-bold + = option.name.camelcase + = select_date section.option(option.name) , :prefix => "option[#{option.name}]" diff --git a/app/views/merged/sections/_sections_pagination.haml b/app/views/merged/sections/_sections_pagination.haml index 86d53a3..7a30549 100644 --- a/app/views/merged/sections/_sections_pagination.haml +++ b/app/views/merged/sections/_sections_pagination.haml @@ -1,5 +1,6 @@ .text-xl.font-bold.text-gray-900 - Page #{link_to section.page.name, merged.page_sections_path(section.page.id), class: "underline"} + = section.page.type.capitalize + =link_to section.page.name, merged.page_sections_path(section.page.id), class: "underline" .inline-flex.items-center.justify-center.gap-3 .text-xl.font-bold.text-gray-900 Section #{section.header} diff --git a/app/views/merged/sections/index.haml b/app/views/merged/sections/index.haml index 9d4f5dc..427a669 100644 --- a/app/views/merged/sections/index.haml +++ b/app/views/merged/sections/index.haml @@ -1,6 +1,6 @@ - content_for( :merged_menu ) do .text-xl.font-bold.text-gray-900 - Page + = @page.type.capitalize = link_to @page.name , merged.page_path(@page) .text-xl.text-gray-900 =link_to "View live" , "/#{@page.name}" , target: @page.name diff --git a/app/views/merged/view/_blog_header.haml b/app/views/merged/view/_blog_header.haml new file mode 100644 index 0000000..c68a84a --- /dev/null +++ b/app/views/merged/view/_blog_header.haml @@ -0,0 +1,11 @@ +%section.overflow-hidden.grid.grid-cols-2.m-20 + %div{ order_option(section)} + = image_for( section , "h-56 w-full object-cover sm:h-full") + .p-8.md:p-6.lg:px-16.lg:pt-10{ background_option(section)} + .mx-auto.max-w-xl{options(section , :text_align , :color)} + %h4.text-xl.mt-10.md:text-2xl + = date_precision(section.page , "published_date") + %h2.mt-12.text-2xl.font-bold.md:text-4xl + = section.header + .prose.mt-8.md:block + = markdown(section) diff --git a/app/views/merged/view/_form_section.haml b/app/views/merged/view/_form_section.haml index 8367f66..8b36b82 100644 --- a/app/views/merged/view/_form_section.haml +++ b/app/views/merged/view/_form_section.haml @@ -2,7 +2,7 @@ .flex.items-center.justify-center.flex-1 .max-w-prose.px-4.mt-16.mx-auto.text-center %h1.text-4xl.font-medium= section.header - %p.mt-4.text-lg.pt-10 + %p.prose.mt-4.text-lg.pt-10 = markdown(section) .flex.items-center.justify-start.m-20 .mx-auto.w-full.max-w-4xl{class: "max-w-[50%]"} diff --git a/config/merged/option_definitions.yml b/config/merged/option_definitions.yml index 4e2833e..5f612cb 100644 --- a/config/merged/option_definitions.yml +++ b/config/merged/option_definitions.yml @@ -98,8 +98,15 @@ :values: :default: :id: 18 -- :name: published +- :name: published_date :description: Date when the blog is published + :type: date :values: :default: :id: 19 +- :name: date_precision + :description: Either the axact day, or something like in the middle + of October, or the end of December + :values: precise rough + :default: precise + :id: 20 diff --git a/config/merged/page_styles.yml b/config/merged/page_styles.yml index 05eb37c..aa0772b 100644 --- a/config/merged/page_styles.yml +++ b/config/merged/page_styles.yml @@ -6,6 +6,7 @@ - meta - type: blog description: An news or similar article. - section_template: section_half_image + section_template: blog_header options: - - published + - published_date + - date_precision diff --git a/config/merged/section_styles.yml b/config/merged/section_styles.yml index 3ccb0f2..7993ca0 100644 --- a/config/merged/section_styles.yml +++ b/config/merged/section_styles.yml @@ -91,3 +91,15 @@ - handler - background - color +- template: blog_header + header: Start of blog, with image left or right + text: Image on one side, header and text on the other. + Order depends on order option. Date is subheader. + Extra text possible under both text and picture, as markdown. + fields: + - header + - text + options: + - order + - background + - color