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 !
allow rendering of custom per-section templates

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@1212 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Sun Jun 11 07:45:55 -0700 2006
commit  f372616a2eec7ef2c6fb4aed537fd1e3d9009313
tree    17c5c040792214d094f3f0088c89c14fd3d35c6e
parent  e3e888b2a1f2b1a8d7866caeb6b893b37bc90830
...
16
17
18
19
 
20
21
22
...
16
17
18
 
19
20
21
22
0
@@ -16,7 +16,7 @@ class ApplicationController < ActionController::Base
0
     end
0
     
0
     assigns.update 'site' => site.to_liquid
0
- render :text => site.templates.render_liquid_for(template_type, assigns, self)
0
+ render :text => site.templates.render_liquid_for(@section, template_type, assigns, self)
0
   end
0
   
0
   protected
...
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
...
52
53
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
0
@@ -52,40 +52,40 @@ class MephistoController < ApplicationController
0
   end
0
 
0
   protected
0
- def list_section_articles_with(template_type)
0
- @article_pages = Paginator.new self, @section.articles.size, 15, params[:page]
0
- @articles = @section.articles.find_by_date(
0
- :include => [:user],
0
- :limit => @article_pages.items_per_page,
0
- :offset => @article_pages.current.offset)
0
-
0
- self.cached_references << @section
0
- render_liquid_template_for(template_type, 'section' => @section.name,
0
- 'section_title' => @section.title,
0
- 'articles' => @articles,
0
- 'previous_page' => paged_section_url_for(@article_pages.current.previous),
0
- 'next_page' => paged_section_url_for(@article_pages.current.next))
0
- end
0
-
0
- def show_section_page_with(page_name, template_type)
0
- @article = page_name.nil? ? @section.articles.find_by_position : @section.articles.find_by_permalink(page_name)
0
-
0
- self.cached_references << @section << @article
0
- render_liquid_template_for(template_type, 'section' => @section.name,
0
- 'section_title' => @section.title,
0
- 'pages' => @section.articles.collect { |a| a.to_liquid },
0
- 'article' => @article.to_liquid(:single))
0
- end
0
-
0
- def paged_search_url_for(page)
0
- page ? paged_search_url(:q => params[:q], :page => page) : ''
0
- end
0
-
0
- def paged_monthly_url_for(page)
0
- page ? paged_monthly_url(:year => params[:year], :month => params[:month], :page => page) : ''
0
- end
0
-
0
- def paged_section_url_for(page)
0
- page ? section_url(:sections => @section.to_url << 'page' << page) : ''
0
- end
0
+ def list_section_articles_with(template_type)
0
+ @article_pages = Paginator.new self, @section.articles.size, 15, params[:page]
0
+ @articles = @section.articles.find_by_date(
0
+ :include => [:user],
0
+ :limit => @article_pages.items_per_page,
0
+ :offset => @article_pages.current.offset)
0
+
0
+ self.cached_references << @section
0
+ render_liquid_template_for(template_type, 'section' => @section.name,
0
+ 'section_title' => @section.title,
0
+ 'articles' => @articles,
0
+ 'previous_page' => paged_section_url_for(@article_pages.current.previous),
0
+ 'next_page' => paged_section_url_for(@article_pages.current.next))
0
+ end
0
+
0
+ def show_section_page_with(page_name, template_type)
0
+ @article = page_name.nil? ? @section.articles.find_by_position : @section.articles.find_by_permalink(page_name)
0
+
0
+ self.cached_references << @section << @article
0
+ render_liquid_template_for(template_type, 'section' => @section.name,
0
+ 'section_title' => @section.title,
0
+ 'pages' => @section.articles.collect { |a| a.to_liquid },
0
+ 'article' => @article.to_liquid(:single))
0
+ end
0
+
0
+ def paged_search_url_for(page)
0
+ page ? paged_search_url(:q => params[:q], :page => page) : ''
0
+ end
0
+
0
+ def paged_monthly_url_for(page)
0
+ page ? paged_monthly_url(:year => params[:year], :month => params[:month], :page => page) : ''
0
+ end
0
+
0
+ def paged_section_url_for(page)
0
+ page ? section_url(:sections => @section.to_url << 'page' << page) : ''
0
+ end
0
 end
...
36
37
38
39
40
41
 
 
 
 
42
43
 
44
45
46
...
36
37
38
 
 
 
39
40
41
42
43
 
44
45
46
47
0
@@ -36,11 +36,12 @@ class Template < Attachment
0
       nil
0
     end
0
 
0
- def render_liquid_for(template_type, assigns = {}, controller = nil)
0
- templates = templates_for(template_type)
0
- preferred_template = find_preferred(template_type, templates)
0
+ def render_liquid_for(section, template_type, assigns = {}, controller = nil)
0
+ templates = (section && section.template && section.layout) ? [] : templates_for(template_type)
0
+ preferred_template = (section && section.template) || find_preferred(template_type, templates)
0
+ layout_template = (section && section.layout) || templates['layout']
0
       assigns['content_for_layout'] = Liquid::Template.parse(preferred_template).render(assigns, :registers => {:controller => controller})
0
- Liquid::Template.parse(templates['layout']).render(assigns, :registers => {:controller => controller})
0
+ Liquid::Template.parse(layout_template).render(assigns, :registers => {:controller => controller})
0
     end
0
 
0
     def find_custom
...
14
15
16
17
 
18
19
20
...
14
15
16
 
17
18
19
20
0
@@ -14,7 +14,7 @@
0
       </select>
0
     </dd>
0
     <% if @templates.any? -%>
0
- <dt><label for="section_template">Section Template</label></dt>
0
+ <dt><label for="section_template"><%= 'Paged ' if @section.show_paged_articles? %>Section Template</label></dt>
0
     <dd>
0
       <select name="section[template]">
0
         <%= options_from_templates_for_select(@templates, @section.template) %>

Comments

    No one has commented yet.