add meta data to page
This commit is contained in:
parent
de0a66a2fd
commit
3bc7dd09da
@ -3,7 +3,7 @@ module Merged
|
|||||||
#and a method template_style
|
#and a method template_style
|
||||||
module Optioned
|
module Optioned
|
||||||
def has_option?(option)
|
def has_option?(option)
|
||||||
options.has_key?(option)
|
options.has_key?(option) and !options[option].blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
def option_definitions
|
def option_definitions
|
||||||
|
@ -19,19 +19,28 @@ module Merged
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :name , :content , :sections
|
attr_reader :name , :content , :sections , :size , :updated_at
|
||||||
|
|
||||||
alias :id :name
|
alias :id :name
|
||||||
|
|
||||||
def initialize( file_name )
|
def initialize( f_name )
|
||||||
@name = file_name.split(".").first
|
@name = f_name.split(".").first
|
||||||
@content = YAML.load_file(Rails.root.join(Page.cms_root , file_name))
|
@content = YAML.load_file( filename )
|
||||||
@sections = []
|
@sections = []
|
||||||
@content.each_with_index do |section_data, index|
|
@content.each_with_index do |section_data, index|
|
||||||
section = Section.new(self , index, section_data)
|
section = Section.new(self , index, section_data)
|
||||||
@sections << section
|
@sections << section
|
||||||
end
|
end
|
||||||
@@all[@name] = self
|
@@all[@name] = self
|
||||||
|
update_size
|
||||||
|
end
|
||||||
|
|
||||||
|
def filename
|
||||||
|
Rails.root.join(Page.cms_root , @name + ".yaml")
|
||||||
|
end
|
||||||
|
def update_size
|
||||||
|
@size = File.size(filename)
|
||||||
|
@updated_at = File.ctime(filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.check_name(name)
|
def self.check_name(name)
|
||||||
|
@ -7,21 +7,27 @@
|
|||||||
Name
|
Name
|
||||||
%th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900
|
%th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900
|
||||||
.flex.items-center.gap-2
|
.flex.items-center.gap-2
|
||||||
First Template
|
Sections
|
||||||
%th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900
|
%th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900
|
||||||
.flex.items-center.gap-2
|
.flex.items-center.gap-2
|
||||||
Size (Sections)
|
Bytes
|
||||||
%th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900
|
%th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900
|
||||||
Status
|
.flex.items-center.gap-2
|
||||||
|
Updated
|
||||||
|
%th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900
|
||||||
|
.flex.items-center.gap-2
|
||||||
|
Actions
|
||||||
%tbody.divide-y.divide-gray-200
|
%tbody.divide-y.divide-gray-200
|
||||||
- @pages.each do |merged_page|
|
- @pages.each do |merged_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 merged_page.name , page_sections_path(merged_page.name)
|
= link_to merged_page.name , page_sections_path(merged_page.name)
|
||||||
%td.whitespace-nowrap.px-4.py-2.text-gray-700
|
|
||||||
= merged_page.first_template
|
|
||||||
%td.whitespace-nowrap.px-4.py-2.text-gray-700
|
%td.whitespace-nowrap.px-4.py-2.text-gray-700
|
||||||
= merged_page.sections.length
|
= merged_page.sections.length
|
||||||
|
%td.whitespace-nowrap.px-4.py-2.text-gray-700
|
||||||
|
= merged_page.size
|
||||||
|
%td.whitespace-nowrap.px-4.py-2.text-gray-700
|
||||||
|
= distance_of_time_in_words_to_now(merged_page.updated_at)
|
||||||
%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 'Sections', page_sections_path(merged_page.name)
|
= link_to 'Sections', page_sections_path(merged_page.name)
|
||||||
|
Loading…
Reference in New Issue
Block a user