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 !
remove 'pages' and 'comments' variables in page/single template types.  
Instead use 'section.pages' and 'article.comments', respectively.

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2168 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Wed Sep 13 13:46:52 -0700 2006
commit  90d345b70c66e642c89959418633b3d679bb7ef1
tree    8fdc79725d0c0ddc7b6af39ea456cc88ca339826
parent  ed80a86e4de1d6acb14544800605e1eeb8369f52
...
1
2
 
 
 
 
 
 
3
4
5
6
7
 
8
9
10
11
12
 
13
14
15
...
1
2
3
4
5
6
7
8
9
10
11
12
 
13
14
15
16
17
 
18
19
20
21
0
@@ -1,15 +1,21 @@
0
 * SVN *
0
 
0
+* remove 'pages' and 'comments' variables in page/single template types. Instead use 'section.pages' and 'article.comments', respectively.
0
+
0
+* Find child sections of a section
0
+
0
+ {{ 'projects' | child_sections }} # => any sections with a path like projects/*
0
+
0
 * Find articles in a section in Liquid
0
 
0
   {{ section | latest_articles }}
0
   
0
- {{ 'about' | find_section | latest_article | assign_to: 'bio' }}
0
+ {{ 'about' | section | latest_article | assign_to: 'bio' }}
0
   <div>{{ bio.body }}</div>
0
 
0
 * Find section by path in Liquid
0
 
0
- {{ 'about' | find_section }}
0
+ {{ 'about' | section }}
0
 
0
 * Support for assigning liquid variables.
0
 
...
25
26
27
28
29
30
31
32
33
34
35
36
...
121
122
123
124
125
126
127
128
 
129
130
131
...
25
26
27
 
 
 
 
28
 
29
30
31
...
116
117
118
 
119
120
121
 
122
123
124
125
0
@@ -25,12 +25,7 @@ class MephistoController < ApplicationController
0
     
0
       self.cached_references << @section << @article
0
       Mephisto::Liquid::CommentForm.article = @article
0
- articles = []
0
- @section.articles.each_with_index do |article, i|
0
- articles << article.to_liquid(:page => i.zero?, :site => site)
0
- end
0
       render_liquid_template_for(:page, 'section' => @section.to_liquid(true),
0
- 'pages' => articles,
0
                                         'article' => @article.to_liquid(:mode => :single, :site => site))
0
     end
0
 
0
@@ -121,11 +116,10 @@ class MephistoController < ApplicationController
0
     def show_article_with(assigns = {})
0
       find_article if @article.nil?
0
       show_404 and return unless @article
0
- @comments = @article.comments.reject(&:new_record?).collect(&:to_liquid)
0
       self.cached_references << @article
0
       Mephisto::Liquid::CommentForm.article = @article
0
       @article = @article.to_liquid(:mode => :single, :site => site)
0
- render_liquid_template_for(:single, assigns.merge('articles' => [@article], 'article' => @article, 'comments' => @comments))
0
+ render_liquid_template_for(:single, assigns.merge('articles' => [@article], 'article' => @article))
0
     end
0
 
0
     alias show_article show_article_with
...
29
30
31
 
 
 
 
32
33
34
...
29
30
31
32
33
34
35
36
37
38
0
@@ -29,6 +29,10 @@ module Mephisto
0
         @article_liquid[method.to_s]
0
       end
0
       
0
+ def comments
0
+ @comments ||= @source.comments.reject(&:new_record?).collect(&:to_liquid)
0
+ end
0
+
0
       def sections
0
         @sections ||= @source.sections.inject([]) { |all, s| s.home? ? all : all << s.to_liquid } # your days are numbered, home section!
0
       end
...
29
30
31
 
 
 
 
 
 
 
 
 
32
33
34
...
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
0
@@ -29,6 +29,15 @@ module Mephisto
0
         end
0
       end
0
 
0
+ def pages
0
+ return @pages if @pages
0
+ @pages = returning [] do |pages|
0
+ @source.articles.each_with_index do |article, i|
0
+ pages << article.to_liquid(:page => i.zero?, :site => @context['site'].source)
0
+ end
0
+ end
0
+ end
0
+
0
       def url
0
         @url ||= absolute_url(*@source.to_url)
0
       end
...
4
5
6
7
 
8
9
10
11
...
4
5
6
 
7
8
9
10
11
0
@@ -4,7 +4,7 @@
0
   {{ article.body }}
0
 </div>
0
 <ul id="nav">
0
-{% for page in pages %}
0
+{% for page in section.pages %}
0
 <li>{{ page | link_to_page }}</li>
0
 {% endfor %}
0
 </ul>
0
\ No newline at end of file
...
6
7
8
9
 
10
11
12
...
6
7
8
 
9
10
11
12
0
@@ -6,7 +6,7 @@
0
 
0
 <h3>Comments</h3>
0
 <ul class="comments">
0
-{% for comment in comments %}
0
+{% for comment in article.comments %}
0
 <li id="comment_{{ comment.id }}">
0
   <p>{{ comment.body }}</p>
0
   <p>by {{ comment.author }} on {{ comment.created_at | format_date: 'short' }}</p>
...
204
205
206
207
 
208
209
 
210
211
212
...
204
205
206
 
207
208
 
209
210
211
212
0
@@ -204,9 +204,9 @@ class MephistoControllerTest < Test::Unit::TestCase
0
 
0
   def test_should_set_home_page_on_paged_sections
0
     dispatch 'about'
0
- assert_equal 3, liquid(:pages).size
0
+ assert_equal 3, liquid(:section).pages.size
0
     [true, false, false].each_with_index do |expected, i|
0
- assert_equal expected, liquid(:pages)[i][:is_page_home]
0
+ assert_equal expected, liquid(:section).pages[i][:is_page_home]
0
     end
0
   end
0
 

Comments

    No one has commented yet.