blogheader ok, date formatting
This commit is contained in:
parent
0c2475de16
commit
d375bad897
BIN
app/assets/images/merged/section_preview/blog_header.png
Normal file
BIN
app/assets/images/merged/section_preview/blog_header.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 974 KiB |
@ -19,6 +19,15 @@ module Merged
|
|||||||
@page.edit_save(current_member.email)
|
@page.edit_save(current_member.email)
|
||||||
message = "Page renamed"
|
message = "Page renamed"
|
||||||
end
|
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
|
redirect_to page_url(@page) , notice: message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -11,6 +11,22 @@ module Merged
|
|||||||
all
|
all
|
||||||
end
|
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 = "")
|
def order_option(section , clazz = "")
|
||||||
if section.has_option?("order")
|
if section.has_option?("order")
|
||||||
clazz += " order-last" if section.option('order') == "right"
|
clazz += " order-last" if section.option('order') == "right"
|
||||||
|
@ -24,7 +24,6 @@ module Merged
|
|||||||
last_section
|
last_section
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def has_option?(option)
|
def has_option?(option)
|
||||||
options.has_key?(option) and !options[option].blank?
|
options.has_key?(option) and !options[option].blank?
|
||||||
end
|
end
|
||||||
@ -43,6 +42,11 @@ module Merged
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_option( option , value)
|
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
|
options[option] = value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
- content_for( :merged_menu ) do
|
- content_for( :merged_menu ) do
|
||||||
.text-xl.font-bold.text-gray-900
|
.text-xl.font-bold.text-gray-900
|
||||||
Page
|
= @page.type.capitalize
|
||||||
.text-xl.font-bold.text-gray-900
|
.text-xl.font-bold.text-gray-900
|
||||||
=@page.name
|
=@page.name
|
||||||
%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"}
|
||||||
|
4
app/views/merged/sections/_option_form_date.haml
Normal file
4
app/views/merged/sections/_option_form_date.haml
Normal file
@ -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}]"
|
@ -1,5 +1,6 @@
|
|||||||
.text-xl.font-bold.text-gray-900
|
.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
|
.inline-flex.items-center.justify-center.gap-3
|
||||||
.text-xl.font-bold.text-gray-900
|
.text-xl.font-bold.text-gray-900
|
||||||
Section #{section.header}
|
Section #{section.header}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
- content_for( :merged_menu ) do
|
- content_for( :merged_menu ) do
|
||||||
.text-xl.font-bold.text-gray-900
|
.text-xl.font-bold.text-gray-900
|
||||||
Page
|
= @page.type.capitalize
|
||||||
= link_to @page.name , merged.page_path(@page)
|
= link_to @page.name , merged.page_path(@page)
|
||||||
.text-xl.text-gray-900
|
.text-xl.text-gray-900
|
||||||
=link_to "View live" , "/#{@page.name}" , target: @page.name
|
=link_to "View live" , "/#{@page.name}" , target: @page.name
|
||||||
|
11
app/views/merged/view/_blog_header.haml
Normal file
11
app/views/merged/view/_blog_header.haml
Normal file
@ -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)
|
@ -2,7 +2,7 @@
|
|||||||
.flex.items-center.justify-center.flex-1
|
.flex.items-center.justify-center.flex-1
|
||||||
.max-w-prose.px-4.mt-16.mx-auto.text-center
|
.max-w-prose.px-4.mt-16.mx-auto.text-center
|
||||||
%h1.text-4xl.font-medium= section.header
|
%h1.text-4xl.font-medium= section.header
|
||||||
%p.mt-4.text-lg.pt-10
|
%p.prose.mt-4.text-lg.pt-10
|
||||||
= markdown(section)
|
= markdown(section)
|
||||||
.flex.items-center.justify-start.m-20
|
.flex.items-center.justify-start.m-20
|
||||||
.mx-auto.w-full.max-w-4xl{class: "max-w-[50%]"}
|
.mx-auto.w-full.max-w-4xl{class: "max-w-[50%]"}
|
||||||
|
@ -98,8 +98,15 @@
|
|||||||
:values:
|
:values:
|
||||||
:default:
|
:default:
|
||||||
:id: 18
|
:id: 18
|
||||||
- :name: published
|
- :name: published_date
|
||||||
:description: Date when the blog is published
|
:description: Date when the blog is published
|
||||||
|
:type: date
|
||||||
:values:
|
:values:
|
||||||
:default:
|
:default:
|
||||||
:id: 19
|
: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
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
- meta
|
- meta
|
||||||
- type: blog
|
- type: blog
|
||||||
description: An news or similar article.
|
description: An news or similar article.
|
||||||
section_template: section_half_image
|
section_template: blog_header
|
||||||
options:
|
options:
|
||||||
- published
|
- published_date
|
||||||
|
- date_precision
|
||||||
|
@ -91,3 +91,15 @@
|
|||||||
- handler
|
- handler
|
||||||
- background
|
- background
|
||||||
- color
|
- 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
|
||||||
|
Loading…
Reference in New Issue
Block a user