diff --git a/app/models/merged/optioned.rb b/app/models/merged/optioned.rb index 0577f79..35c96b8 100644 --- a/app/models/merged/optioned.rb +++ b/app/models/merged/optioned.rb @@ -3,7 +3,7 @@ module Merged #and a method template_style module Optioned def has_option?(option) - options.has_key?(option) + options.has_key?(option) and !options[option].blank? end def option_definitions diff --git a/app/models/merged/page.rb b/app/models/merged/page.rb index 5adcb0c..ff57ec1 100644 --- a/app/models/merged/page.rb +++ b/app/models/merged/page.rb @@ -19,19 +19,28 @@ module Merged end end - attr_reader :name , :content , :sections + attr_reader :name , :content , :sections , :size , :updated_at alias :id :name - def initialize( file_name ) - @name = file_name.split(".").first - @content = YAML.load_file(Rails.root.join(Page.cms_root , file_name)) + def initialize( f_name ) + @name = f_name.split(".").first + @content = YAML.load_file( filename ) @sections = [] @content.each_with_index do |section_data, index| section = Section.new(self , index, section_data) @sections << section end @@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 def self.check_name(name) diff --git a/app/views/merged/pages/index.haml b/app/views/merged/pages/index.haml index cf4e7da..b6338c7 100644 --- a/app/views/merged/pages/index.haml +++ b/app/views/merged/pages/index.haml @@ -7,21 +7,27 @@ Name %th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900 .flex.items-center.gap-2 - First Template + Sections %th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900 .flex.items-center.gap-2 - Size (Sections) + Bytes %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 - @pages.each do |merged_page| %tr %td.whitespace-nowrap.px-4.py-2.text-gray-700 = 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 = 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 %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)