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 !
change section/tag templates to layouts

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2153 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Sun Sep 10 21:47:22 -0700 2006
commit  b79ae4cba405ac4f2a80783c80eedbb49448cfbb
tree    0fe3d8097629bce631756672411b12d144a01b63
parent  5e0c253816d981c709f88c77499fcacfb637a31a
...
107
108
109
 
 
 
 
110
111
112
...
107
108
109
110
111
112
113
114
115
116
0
@@ -107,6 +107,10 @@ class Site < ActiveRecord::Base
0
     "/#{search_path}?q=#{CGI::escapeHTML(query)}#{%(&page=#{CGI::escapeHTML(page.to_s)}) unless page.blank?}"
0
   end
0
 
0
+ def tag_url(*tags)
0
+ ['', tag_path, *tags] * '/'
0
+ end
0
+
0
   def accept_comments?
0
     comment_age.to_i > -1
0
   end
...
55
56
57
58
 
59
60
 
61
62
63
64
 
 
65
66
67
...
69
70
71
72
 
73
74
 
75
76
77
78
 
 
79
80
81
...
55
56
57
 
58
59
 
60
61
62
 
 
63
64
65
66
67
...
69
70
71
 
72
73
 
74
75
76
 
 
77
78
79
80
81
0
@@ -55,13 +55,13 @@
0
       <label for="site_search_path">Url that the search area is available at.</label>
0
     </dt>
0
     <dd><%= f.text_field :search_path %></dd>
0
- <% if @templates.any? -%>
0
+ <% if @layouts.any? -%>
0
     <dt>
0
- <label for="site_search_template">Template used by the search area</label>
0
+ <label for="site_search_layout">Layout template used by the search area</label>
0
     </dt>
0
     <dd>
0
- <select name="site[search_template]">
0
- <%= options_from_templates_for_select(@templates, @site.search_template) %>
0
+ <select name="site[search_layout]">
0
+ <%= options_from_templates_for_select(@layouts, @site.search_layout) %>
0
       </select>
0
     </dd>
0
     <% end -%>
0
@@ -69,13 +69,13 @@
0
       <label for="site_tag_path">Url that the tag area is available at.</label>
0
     </dt>
0
     <dd><%= f.text_field :tag_path %></dd>
0
- <% if @templates.any? -%>
0
+ <% if @layouts.any? -%>
0
     <dt>
0
- <label for="site_tag_template">Template used by the tag area</label>
0
+ <label for="site_tag_layout">Layout template used by the tag area</label>
0
     </dt>
0
     <dd>
0
- <select name="site[tag_template]">
0
- <%= options_from_templates_for_select(@templates, @site.tag_template) %>
0
+ <select name="site[tag_layout]">
0
+ <%= options_from_templates_for_select(@layouts, @site.tag_layout) %>
0
       </select>
0
     </dd>
0
     <% end -%>
...
2
3
4
5
 
6
7
8
...
141
142
143
144
145
 
 
146
147
148
...
2
3
4
 
5
6
7
8
...
141
142
143
 
 
144
145
146
147
148
0
@@ -2,7 +2,7 @@
0
 # migrations feature of ActiveRecord to incrementally modify your database, and
0
 # then regenerate this schema definition.
0
 
0
-ActiveRecord::Schema.define(:version => 57) do
0
+ActiveRecord::Schema.define(:version => 58) do
0
 
0
   create_table "assets", :force => true do |t|
0
     t.column "content_type", :string
0
@@ -141,8 +141,8 @@ ActiveRecord::Schema.define(:version => 57) do
0
     t.column "permalink_style", :string
0
     t.column "search_path", :string
0
     t.column "tag_path", :string
0
- t.column "search_template", :string
0
- t.column "tag_template", :string
0
+ t.column "search_layout", :string
0
+ t.column "tag_layout", :string
0
   end
0
 
0
   create_table "taggings", :force => true do |t|
...
7
8
9
10
 
 
11
12
13
...
7
8
9
 
10
11
12
13
14
0
@@ -7,7 +7,8 @@ module Mephisto
0
         :single => [:single, :index],
0
         :archive => [:archive, :index],
0
         :search => [:search, :archive, :index],
0
- :error => [:error, :index]
0
+ :error => [:error, :index],
0
+ :tag => [:tag, :archive, :index]
0
       }
0
     
0
       @@template_types = (@@hierarchy.values.flatten.uniq << :layout).collect! { |f| "#{f}.liquid" }
...
105
106
107
108
 
109
110
 
 
 
 
 
111
112
113
...
105
106
107
 
108
109
 
110
111
112
113
114
115
116
117
0
@@ -105,9 +105,13 @@ module Mephisto
0
         File.join(section.url, section['archive_path'], date.year.to_s, date.month.to_s)
0
       end
0
       
0
- def tag_url(tags)
0
+ def tag_url(*tags)
0
         tags = [tags] ; tags.flatten!
0
- absolute_url @context['site']['tag_path'], *tags
0
+ absolute_url @context['site'].source.tag_url(*tags)
0
+ end
0
+
0
+ def search_url(query, page = nil)
0
+ absolute_url @context['site'].source.search_url(query, page)
0
       end
0
 
0
       def page_url(page)
...
29
30
31
 
 
 
 
 
 
 
 
 
 
 
32
33
...
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
0
@@ -29,4 +29,15 @@ context "Url Filter" do
0
     assert_equal "/stylesheets/foo.css", stylesheet_url('foo.css')
0
     assert_equal "/images/foo.gif", asset_url('foo.gif')
0
   end
0
+
0
+ specify "should generate tag urls" do
0
+ assert_equal "/tags", tag_url
0
+ assert_equal "/tags/foo", tag_url('foo')
0
+ assert_equal "/tags/foo/bar", tag_url('foo', 'bar')
0
+ end
0
+
0
+ specify "should generate search urls" do
0
+ assert_equal '/search?q=abc', search_url('abc')
0
+ assert_equal '/search?q=abc&page=2', search_url('abc', 2)
0
+ end
0
 end
0
\ No newline at end of file
...
36
37
38
 
 
 
 
 
 
39
40
41
...
36
37
38
39
40
41
42
43
44
45
46
47
0
@@ -36,6 +36,12 @@ context "Site" do
0
     assert_equal '/search?q=abc', sites(:first).search_url('abc')
0
     assert_equal '/search?q=abc&page=2', sites(:first).search_url('abc', 2)
0
   end
0
+
0
+ specify "should generate tag url" do
0
+ assert_equal '/tags', sites(:first).tag_url
0
+ assert_equal '/tags/foo', sites(:first).tag_url('foo')
0
+ assert_equal '/tags/foo/bar', sites(:first).tag_url('foo', 'bar')
0
+ end
0
 end
0
 
0
 context "Default Site Options" do

Comments

    No one has commented yet.