public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
section archiving

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2137 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Sun Sep 10 02:57:39 -0700 2006
commit  5c8689501d48244377d315fc6028bbe25f803b41
tree    45e245f7c8c0b4fffcdeae200a135ca3d3383cd3
parent  4d4c2cd985b0e66568a430e170fb51de1049c7ea
...
21
22
23
24
 
25
26
27
...
21
22
23
 
24
25
26
27
0
@@ -21,7 +21,7 @@ module Mephisto
0
               'submit' => %(<input type="submit" value="Send" />)
0
             }
0
             
0
- result << %(<form id="comment-form" method="post" action="#{context['article']['url']}/comment#comment-form">#{[errors]+render_all(@nodelist, context)}</form>)
0
+ result << %(<form id="comment-form" method="post" action="#{context['article'].url}/comment#comment-form">#{[errors]+render_all(@nodelist, context)}</form>)
0
           else
0
             result << %(<p id="comment-message">#{context['message']}</p>)
0
           end
...
7
8
9
10
 
11
12
13
...
15
16
17
18
 
19
20
21
...
23
24
25
26
 
27
28
29
...
55
56
57
58
 
59
60
 
61
62
63
...
90
91
92
93
94
95
96
97
98
99
100
...
104
105
106
 
 
 
 
 
 
 
 
 
 
107
108
109
110
111
112
113
114
115
116
117
118
119
...
7
8
9
 
10
11
12
13
...
15
16
17
 
18
19
20
21
...
23
24
25
 
26
27
28
29
...
55
56
57
 
58
59
 
60
61
62
63
...
90
91
92
 
 
 
 
 
93
94
95
...
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
 
 
 
 
118
119
120
0
@@ -7,7 +7,7 @@ module Mephisto
0
       include ActionView::Helpers::AssetTagHelper
0
 
0
       def link_to_article(article)
0
- content_tag :a, article['title'], :href => article['url']
0
+ content_tag :a, article['title'], :href => article.url
0
       end
0
       
0
       def link_to_page(page)
0
@@ -15,7 +15,7 @@ module Mephisto
0
       end
0
 
0
       def link_to_comments(article)
0
- content_tag :a, pluralize(article['comments_count'], 'comment'), :href => article['url']
0
+ content_tag :a, pluralize(article['comments_count'], 'comment'), :href => article.url
0
       end
0
       
0
       def link_to_section(section)
0
@@ -23,7 +23,7 @@ module Mephisto
0
       end
0
 
0
       def page_title(page)
0
- page['is_page_home'] ? 'Home' : page['title']
0
+ page['title']
0
       end
0
 
0
       def escape_html(html)
0
@@ -55,9 +55,9 @@ module Mephisto
0
 
0
       def format_date(date, format, ordinalized = false)
0
         if ordinalized
0
- date ? date.to_ordinalized_s(format.to_sym) : nil
0
+ date ? date.to_time.to_ordinalized_s(format.to_sym) : nil
0
         else
0
- date ? date.to_s(format.to_sym) : nil unless ordinalized
0
+ date ? date.to_time.to_s(format.to_sym) : nil unless ordinalized
0
         end
0
       end
0
       
0
@@ -90,11 +90,6 @@ module Mephisto
0
         javascript << '.js' unless javascript.include? '.'
0
         content_tag 'script', '', :type => 'text/javascript', :src => javascript_url(javascript)
0
       end
0
-
0
- def month_list
0
- # XXX cache this someday
0
- earliest = controller.site.articles.find(:first, :order => 'published_at').published_at.beginning_of_month
0
- end
0
 
0
       def gravatar(comment, size=80, default=nil)
0
         return '' unless comment['author_email']
0
@@ -104,16 +99,22 @@ module Mephisto
0
         image_tag url, :class => 'gravatar', :size => "#{size}x#{size}", :alt => comment['author']
0
       end
0
 
0
+ def monthly_url(section, date = nil)
0
+ date ||= Time.now.utc.beginning_of_month
0
+ date = Date.new(*date.split('-')) unless date.is_a?(Date)
0
+ section.url + "/#{@context['site']['archive_slug']}/#{date.year}/#{date.month}"
0
+ end
0
+
0
+ def page_url(page)
0
+ page[:is_page_home] ? current_page_section.url : [current_page_section.url, page[:permalink]].join('/')
0
+ end
0
+
0
       private
0
         # marks a page as class=selected
0
         def page_anchor_options(page)
0
           options = {:href => page_url(page)}
0
           current_page_article.source == page.source ? options.update(:class => 'selected') : options
0
         end
0
-
0
- def page_url(page)
0
- page[:is_page_home] ? current_page_section.url : [current_page_section.url, page[:permalink]].join('/')
0
- end
0
         
0
         def current_page_section
0
           @current_page_section ||= outer_context(:section)
...
12
13
14
 
15
16
17
...
21
22
23
24
25
26
27
28
29
30
 
 
31
32
33
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
36
37
...
12
13
14
15
16
17
18
...
22
23
24
 
 
 
 
25
 
 
26
27
28
 
 
 
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
0
@@ -12,6 +12,7 @@ module Mephisto
0
         @current = current
0
         @section_liquid = [:id, :name, :path].inject({}) { |h, k| h.update k.to_s => @source.send(k) }
0
         @section_liquid['articles_count'] = @source.send(:read_attribute, :articles_count)
0
+ {:is_blog => :blog?, :is_paged => :paged?, :is_home => :home?}.each { |k, v| @section_liquid[k.to_s] = @source.send(v) }
0
       end
0
 
0
       def before_method(method)
0
@@ -21,17 +22,24 @@ module Mephisto
0
       def url
0
         @url ||= absolute_url(*@source.to_url)
0
       end
0
-
0
- def is_blog
0
- @source.blog?
0
- end
0
       
0
- def is_paged
0
- @source.paged?
0
+ def earliest_month
0
+ @earliest_month ||= @source.articles.find(:first, :order => 'published_at').published_at.beginning_of_month.to_date rescue :false
0
       end
0
-
0
- def is_home
0
- @source.home?
0
+
0
+ def months
0
+ if @months.nil?
0
+ this_month = Time.now.utc.beginning_of_month.to_date
0
+ date = earliest_month.is_a?(Date) && earliest_month
0
+ @months = []
0
+ while date && date <= this_month
0
+ @months << date
0
+ date = date >> 1
0
+ end
0
+ @months.reverse!
0
+ end
0
+
0
+ @months
0
       end
0
     end
0
   end
...
10
11
12
13
 
14
15
16
...
10
11
12
 
13
14
15
16
0
@@ -10,7 +10,7 @@ module Mephisto
0
         @source = source
0
         @current_section = section
0
         @current_section_liquid = section ? section.to_liquid : nil
0
- @site_liquid = [:id, :host, :subtitle, :title, :articles_per_page].inject({}) { |h, k| h.merge k.to_s => @source.send(k) }
0
+ @site_liquid = [:id, :host, :subtitle, :title, :articles_per_page, :archive_slug, :tag_slug, :search_slug].inject({}) { |h, k| h.merge k.to_s => @source.send(k) }
0
         @site_liquid['accept_comments'] = @source.accept_comments?
0
       end
0
 
...
1
2
3
4
 
5
6
7
...
24
25
26
 
 
 
 
 
 
 
 
27
...
1
2
3
 
4
5
6
7
...
24
25
26
27
28
29
30
31
32
33
34
35
0
@@ -1,7 +1,7 @@
0
 require File.dirname(__FILE__) + '/../test_helper'
0
 
0
 class SectionDropTest < Test::Unit::TestCase
0
- fixtures :sites, :sections
0
+ fixtures :sites, :sections, :contents
0
 
0
   def test_should_convert_section_to_drop
0
     assert_kind_of Liquid::Drop, sections(:home).to_liquid
0
@@ -24,4 +24,12 @@ class SectionDropTest < Test::Unit::TestCase
0
     assert Mephisto::Liquid::SectionDrop.new(sections(:home)).is_blog
0
     [:about, :cupcake_home, :cupcake_about].each { |s| assert Mephisto::Liquid::SectionDrop.new(sections(s)).is_paged }
0
   end
0
+
0
+ def test_should_get_earliest_article_published_date
0
+ assert_equal contents(:welcome).published_at.beginning_of_month.to_date, Mephisto::Liquid::SectionDrop.new(sections(:home)).earliest_month
0
+ end
0
+
0
+ def test_should_get_month_array
0
+ assert_equal [contents(:welcome).published_at.beginning_of_month.to_date], Mephisto::Liquid::SectionDrop.new(sections(:home)).months
0
+ end
0
 end

Comments

    No one has commented yet.