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 !
Bye bye PageNavigation block.

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@1603 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Sun Aug 13 19:17:08 -0700 2006
commit  30964c35c2da07582487e4c5c0379e1640a337d1
tree    f6037e86ff78aee206abb875ea78783f5c3773f2
parent  d2c4676e48a627ed86536efc54a5c580e601e2a7
...
1
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
4
5
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
0
@@ -1,5 +1,19 @@
0
 * SVN *
0
 
0
+* Bye bye PageNavigation block.
0
+
0
+ Change this:
0
+
0
+ {% pagenavigation %}
0
+ <li>{{ page.link }}</li>
0
+ {% endpagenavigation %}
0
+
0
+ to:
0
+
0
+ {% for page in pages %}
0
+ <li>{{ page | link_to_page }}</li>
0
+ {% endfor %}
0
+
0
 * Enhance the site host validations so it requires a valid domain name.
0
 
0
 * Add basic asset support [Justin, Rick]
...
24
25
26
27
 
28
29
30
...
24
25
26
 
27
28
29
30
0
@@ -24,7 +24,7 @@ class Admin::ArticlesController < Admin::BaseController
0
     @article = site.articles.find(params[:id])
0
     @comments = @article.comments.collect &:to_liquid
0
     Mephisto::Liquid::CommentForm.article = @article
0
- @article = @article.to_liquid(:single)
0
+ @article = @article.to_liquid(:mode => :single)
0
     
0
     render :text => Template.render_liquid_for(site, site.sections.home, :single, 'articles' => [@article], 'article' => @article, 'comments' => @comments, 'site' => site.to_liquid)
0
   end
...
50
51
52
53
 
54
55
56
...
50
51
52
 
53
54
55
56
0
@@ -50,7 +50,7 @@ class CommentsController < ApplicationController
0
     def show_article_with(assigns)
0
       Mephisto::Liquid::CommentForm.article = @article
0
       @comments = @article.comments.reject(&:new_record?).collect(&:to_liquid)
0
- @article = @article.to_liquid(:single)
0
+ @article = @article.to_liquid(:mode => :single)
0
       render_liquid_template_for(:single, assigns.merge('articles' => [@article],
0
                                           'article' => @article,
0
                                           'comments' => @comments))
...
41
42
43
44
 
45
46
47
...
83
84
85
 
 
 
 
86
87
88
 
 
89
90
91
...
41
42
43
 
44
45
46
47
...
83
84
85
86
87
88
89
90
 
 
91
92
93
94
95
0
@@ -41,7 +41,7 @@ class MephistoController < ApplicationController
0
     @comments = @article.comments.collect { |c| c.to_liquid }
0
     self.cached_references << @article
0
     Mephisto::Liquid::CommentForm.article = @article
0
- @article = @article.to_liquid(:single)
0
+ @article = @article.to_liquid(:mode => :single)
0
     render_liquid_template_for(:single, 'articles' => [@article], 'article' => @article, 'comments' => @comments)
0
   end
0
 
0
@@ -83,9 +83,13 @@ 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?)
0
+ end
0
       render_liquid_template_for(template_type, 'section' => @section.to_liquid(true),
0
- 'pages' => @section.articles.collect(&:to_liquid),
0
- 'article' => @article.to_liquid(:single),
0
+ 'pages' => articles,
0
+ 'article' => @article.to_liquid(:mode => :single),
0
                                                 'article_sections' => @article.sections.collect(&:to_liquid))
0
     end
0
 
...
99
100
101
102
103
 
 
 
 
104
105
106
...
99
100
101
 
 
102
103
104
105
106
107
108
0
@@ -99,8 +99,10 @@ class Article < Content
0
     @new_sections = new_sections
0
   end
0
 
0
- def to_liquid(mode = :list)
0
- Mephisto::Liquid::ArticleDrop.new self, mode
0
+ # :mode - single / list. Specifies whether the body is only the excerpt or not
0
+ # :page - true / false. Specifies whether the article is the main section page.
0
+ def to_liquid(options = {})
0
+ Mephisto::Liquid::ArticleDrop.new self, options
0
   end
0
 
0
   def hash_for_permalink(options = {})
...
12
13
14
15
 
16
17
18
...
12
13
14
 
15
16
17
18
0
@@ -12,7 +12,7 @@ ActionController::Routing::Routes.draw do |map|
0
   map.admin 'admin', :controller => 'admin/overview', :action => 'index'
0
   map.resources :assets, :path_prefix => '/admin', :controller => 'admin/assets'
0
   
0
- map.connect ':controller/:action/:id/:version', :version => nil, :controller => /referenced_page_caching|routing_navigator|account|(admin\/\w+)/
0
+ map.connect ':controller/:action/:id/:version', :version => nil, :controller => /routing_navigator|account|(admin\/\w+)/
0
   
0
   map.comment ':year/:month/:day/:permalink/comment', :controller => 'comments', :action => 'create',
0
       :year => /\d{4}/, :month => /\d{1,2}/, :day => /\d{1,2}/
...
5
6
7
8
 
9
10
11
12
13
14
15
 
16
17
18
19
20
 
 
21
22
23
...
5
6
7
 
8
9
10
11
12
13
14
 
15
16
17
18
19
 
20
21
22
23
24
0
@@ -5,19 +5,20 @@ module Mephisto
0
       
0
       def article() @source end
0
 
0
- def initialize(source, mode)
0
+ def initialize(source, options = {})
0
         @source = source
0
         @article_liquid = {
0
           'id' => @source.id,
0
           'title' => @source.title,
0
           'permalink' => @source.permalink,
0
           'url' => @source.full_permalink,
0
- 'body' => @source.send(:body_for_mode, mode),
0
+ 'body' => @source.send(:body_for_mode, options[:mode] || :list),
0
           'published_at' => @source.site.timezone.utc_to_local(@source.published_at),
0
           'updated_at' => @source.site.timezone.utc_to_local(@source.updated_at),
0
           'comments_count' => @source.comments_count,
0
           'author' => @source.user.to_liquid,
0
- 'accept_comments' => @source.accept_comments?
0
+ 'accept_comments' => @source.accept_comments?,
0
+ 'is_page_home' => (options[:page] == true)
0
         }
0
       end
0
 
...
8
9
10
11
 
12
13
14
...
19
20
21
 
 
 
 
22
23
24
...
79
80
81
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
84
85
...
8
9
10
 
11
12
13
14
...
19
20
21
22
23
24
25
26
27
28
...
83
84
85
 
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
0
@@ -8,7 +8,7 @@ module Mephisto
0
       end
0
       
0
       def link_to_page(page)
0
- content_tag :a, page['title'], :href => page['permalink']
0
+ content_tag :a, page_title(page), page_anchor_options(page)
0
       end
0
 
0
       def link_to_comments(article)
0
@@ -19,6 +19,10 @@ module Mephisto
0
         content_tag :a, section['name'], :href => section['url']
0
       end
0
 
0
+ def page_title(page)
0
+ page['is_page_home'] ? 'Home' : page['title']
0
+ end
0
+
0
       def escape_html(html)
0
         CGI::escapeHTML(html)
0
       end
0
@@ -79,7 +83,29 @@ module Mephisto
0
         earliest = controller.site.articles.find(:first, :order => 'published_at').published_at.beginning_of_month
0
       end
0
       
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)
0
+ end
0
+
0
+ def current_page_article
0
+ @current_page_article ||= outer_context(:article)
0
+ end
0
+
0
+ # pulls a variable out of the outermost context
0
+ def outer_context(key)
0
+ @context.assigns.last[key.to_s]
0
+ end
0
     end
0
   end
0
 end
...
9
10
11
12
13
14
15
...
9
10
11
 
12
13
14
0
@@ -9,7 +9,6 @@ class << Dispatcher
0
     Liquid::Template.register_filter(Mephisto::Liquid::Filters)
0
     Liquid::Template.register_tag(:textile, Mephisto::Liquid::Textile)
0
     Liquid::Template.register_tag(:commentform, Mephisto::Liquid::CommentForm)
0
- Liquid::Template.register_tag(:pagenavigation, Mephisto::Liquid::PageNavigation)
0
     Liquid::Template.register_tag(:head, Mephisto::Liquid::Head)
0
   end
0
   
...
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
-{% pagenavigation %}
0
-<li>{{ page.link }}</li>
0
-{% endpagenavigation %}
0
+{% for page in pages %}
0
+<li>{{ page | link_to_page }}</li>
0
+{% endfor %}
0
 </ul>
0
\ No newline at end of file
...
145
146
147
148
 
149
150
 
151
152
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
154
155
...
162
163
164
165
 
166
167
168
...
145
146
147
 
148
149
 
150
151
 
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
...
184
185
186
 
187
188
189
190
0
@@ -145,11 +145,33 @@ class MephistoControllerTest < Test::Unit::TestCase
0
   
0
   def test_should_show_navigation_on_paged_sections
0
     get_mephisto 'about'
0
- assert_tag :tag => 'ul', :attributes => { :id => 'nav' },
0
+ assert_tag 'ul', :attributes => { :id => 'nav' },
0
                :children => { :count => 3, :only => { :tag => 'li' } }
0
- assert_tag :tag => 'ul', :attributes => { :id => 'nav' },
0
+ assert_tag 'ul', :attributes => { :id => 'nav' },
0
                :descendant => { :tag => 'a', :attributes => { :class => 'selected' } }
0
- assert_tag :tag => 'a', :attributes => { :class => 'selected' }, :content => 'Home'
0
+ assert_tag 'a', :attributes => { :class => 'selected' }, :content => 'Home'
0
+ end
0
+
0
+ def test_should_set_home_page_on_paged_sections
0
+ get_mephisto 'about'
0
+ assert_equal 3, liquid(:pages).size
0
+ [true, false, false].each_with_index do |expected, i|
0
+ assert_equal expected, liquid(:pages)[i][:is_page_home]
0
+ end
0
+ end
0
+
0
+ def test_should_set_paged_permalinks
0
+ get_mephisto 'about'
0
+ assert_tag 'a', :attributes => { :href => '/about', :class => 'selected' }, :content => 'Home'
0
+ assert_tag 'a', :attributes => { :href => '/about/about-this-page' }, :content => 'About'
0
+ assert_tag 'a', :attributes => { :href => '/about/the-site-map' }, :content => 'The Site Map'
0
+ end
0
+
0
+ def test_should_set_paged_permalinks
0
+ get_mephisto 'about/the-site-map'
0
+ assert_tag 'a', :attributes => { :href => '/about' }, :content => 'Home'
0
+ assert_tag 'a', :attributes => { :href => '/about/about-this-page' }, :content => 'About'
0
+ assert_tag 'a', :attributes => { :href => '/about/the-site-map', :class => 'selected' }, :content => 'The Site Map'
0
   end
0
 
0
   def test_should_show_comments_form
0
@@ -162,7 +184,7 @@ class MephistoControllerTest < Test::Unit::TestCase
0
     assert_tag :tag => 'form', :descendant => {
0
                :tag => 'input', :attributes => { :type => 'text', :id => 'comment_author_email', :name => 'comment[author_email]' } }
0
     assert_tag :tag => 'form', :descendant => {
0
- :tag => 'textarea', :attributes => { :id => 'comment_body', :name => 'comment[body]' } }
0
+ :tag => 'textarea', :attributes => { :id => 'comment_body', :name => 'comment[body]' } }
0
   end
0
 
0
   def test_should_show_daily_entries
...
4
5
6
7
 
8
9
10
...
4
5
6
 
7
8
9
10
0
@@ -4,7 +4,7 @@ class ArticleDropTest < Test::Unit::TestCase
0
   fixtures :sites, :sections, :contents, :assigned_sections, :users
0
   
0
   def setup
0
- @article = Mephisto::Liquid::ArticleDrop.new(contents(:welcome), :single)
0
+ @article = Mephisto::Liquid::ArticleDrop.new(contents(:welcome), :mode => :single)
0
   end
0
   
0
   def test_should_convert_article_to_drop
...
13
14
15
16
 
17
18
19
...
22
23
24
25
 
26
27
28
...
32
33
34
35
 
36
37
38
...
40
41
42
43
 
44
45
46
...
13
14
15
 
16
17
18
19
...
22
23
24
 
25
26
27
28
...
32
33
34
 
35
36
37
38
...
40
41
42
 
43
44
45
46
0
@@ -13,7 +13,7 @@ class AssetTest < Test::Unit::TestCase
0
 
0
   def test_should_upload_file
0
     process_upload
0
- now = Time.now
0
+ now = Time.now.utc
0
     assert_file_exists File.join(ASSET_PATH, now.year.to_s, now.month.to_s, now.day.to_s, 'logo.png')
0
     assert_file_exists File.join(ASSET_PATH, now.year.to_s, now.month.to_s, now.day.to_s, 'logo_thumb.png')
0
     assert_file_exists File.join(ASSET_PATH, now.year.to_s, now.month.to_s, now.day.to_s, 'logo_tiny.png')
0
@@ -22,7 +22,7 @@ class AssetTest < Test::Unit::TestCase
0
   def test_should_upload_file_in_multi_sites_mode
0
     Site.multi_sites_enabled = true
0
     process_upload
0
- now = Time.now
0
+ now = Time.now.utc
0
     assert_file_exists File.join(ASSET_PATH, sites(:first).host, now.year.to_s, now.month.to_s, now.day.to_s, 'logo.png')
0
     assert_file_exists File.join(ASSET_PATH, sites(:first).host, now.year.to_s, now.month.to_s, now.day.to_s, 'logo_thumb.png')
0
     assert_file_exists File.join(ASSET_PATH, sites(:first).host, now.year.to_s, now.month.to_s, now.day.to_s, 'logo_tiny.png')
0
@@ -32,7 +32,7 @@ class AssetTest < Test::Unit::TestCase
0
 
0
   def test_should_show_correct_public_filename
0
     process_upload
0
- now = Time.now
0
+ now = Time.now.utc
0
     asset = Asset.find(1)
0
     assert_equal File.join('/assets', now.year.to_s, now.month.to_s, now.day.to_s, 'logo.png'), asset.public_filename
0
   end
0
@@ -40,7 +40,7 @@ class AssetTest < Test::Unit::TestCase
0
   def test_should_show_correct_public_filename_in_multi_sites_mode
0
     Site.multi_sites_enabled = true
0
     process_upload
0
- now = Time.now
0
+ now = Time.now.utc
0
     asset = Asset.find(1)
0
     assert_equal File.join('/assets', now.year.to_s, now.month.to_s, now.day.to_s, 'logo.png'), asset.public_filename
0
   ensure

Comments

    No one has commented yet.