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 underscores in permalinks

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2221 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Tue Sep 19 08:34:33 -0700 2006
commit  98040c8c10c42a3d4ac17ab1aa111341d460802e
tree    f31d98707d085998a17691b9aefbdc6d6678344f
parent  7741a4b45372d96ac921fadc101ec592c17fb7c0
...
1
2
3
4
 
5
6
7
...
1
2
3
 
4
5
6
7
0
@@ -1,7 +1,7 @@
0
 class Site < ActiveRecord::Base
0
   @@theme_path = Pathname.new(RAILS_ROOT) + 'themes'
0
   cattr_reader :theme_path
0
- PERMALINK_OPTIONS = { 'year' => '\d{4}', 'month' => '\d{1,2}', 'day' => '\d{1,2}', 'permalink' => '[a-z0-9-]+', 'id' => '\d+' }
0
+ PERMALINK_OPTIONS = { 'year' => '\d{4}', 'month' => '\d{1,2}', 'day' => '\d{1,2}', 'permalink' => '[\w\-]+', 'id' => '\d+' }
0
   PERMALINK_VAR = /^:([a-z]+)$/
0
 
0
   cattr_accessor :multi_sites_enabled
...
64
65
66
67
68
69
70
...
80
81
82
83
 
84
85
86
87
88
 
 
 
 
 
 
 
 
89
90
91
92
 
 
93
94
95
96
97
 
98
99
100
101
 
 
 
102
103
104
...
111
112
113
114
115
116
117
...
64
65
66
 
67
68
69
...
79
80
81
 
82
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
...
114
115
116
 
117
118
119
0
@@ -64,7 +64,6 @@ context "Dispatcher" do
0
     assert_dispatch :error, sections(:home), '200', '9', '1', 'foo', %w(200 9 1 foo)
0
     assert_dispatch :error, sections(:home), '2006', '239', '1', 'foo', %w(2006 239 1 foo)
0
     assert_dispatch :error, sections(:home), '2006', '9', '123', 'foo', %w(2006 9 123 foo)
0
- assert_dispatch :error, sections(:home), '2006', '9', '1', 'a_b', %w(2006 9 1 a_b)
0
     assert_dispatch :error, sections(:home), '2006', '9', '1', 'foo', 'boo', %w(2006 9 1 foo boo)
0
     assert_dispatch :error, sections(:home), '2006', '9', '1', 'foo', 'comment', %w(2006 9 1 foo comment)
0
   end
0
@@ -80,25 +79,29 @@ end
0
 context "Dispatcher Permalink Recognition" do
0
   fixtures :sites
0
 
0
- specify "should recognize permalinks" do
0
+ def setup
0
     @site = sites(:first)
0
-
0
- options = {:year => '2006', :month => '9', :day => '1', :permalink => 'foo'}
0
- assert_equal [options, false, nil], Mephisto::Dispatcher.recognize_permalink(@site, %w(2006 9 1 foo))
0
-
0
+ end
0
+
0
+ specify "should recognize permalinks with default permalink style" do
0
+ options = {:year => '2006', :month => '9', :day => '1', :permalink => 'foo-bar_baz'}
0
+ assert_equal [options, false, nil], Mephisto::Dispatcher.recognize_permalink(@site, %w(2006 9 1 foo-bar_baz))
0
+ end
0
+
0
+ specify "should recognize permalinks with custom style" do
0
     @site.permalink_style = 'entries/:id/:permalink'
0
     @site.permalink_regex(true)
0
- options = {:id => '5', :permalink => 'foo-bar-baz'}
0
- assert_equal [options, false, nil], Mephisto::Dispatcher.recognize_permalink(@site, %w(entries 5 foo-bar-baz))
0
+ options = {:id => '5', :permalink => 'foo-bar_baz'}
0
+ assert_equal [options, false, nil], Mephisto::Dispatcher.recognize_permalink(@site, %w(entries 5 foo-bar_baz))
0
   end
0
 
0
- specify "should recognize permalinks with comment" do
0
- @site = sites(:first)
0
-
0
+ specify "should recognize permalinks with comment and default permalink style" do
0
     options = {:year => '2006', :month => '9', :day => '1', :permalink => 'foo'}
0
     assert_equal [options, true, nil], Mephisto::Dispatcher.recognize_permalink(@site, %w(2006 9 1 foo comments))
0
     assert_equal [options, true, '5'], Mephisto::Dispatcher.recognize_permalink(@site, %w(2006 9 1 foo comments 5))
0
-
0
+ end
0
+
0
+ specify "should recognize permalinks with comment and custom style" do
0
     @site.permalink_style = 'entries/:id/:permalink'
0
     @site.permalink_regex(true)
0
     options = {:id => '5', :permalink => 'foo-bar-baz'}
0
@@ -111,7 +114,6 @@ context "Dispatcher Permalink Recognition" do
0
     assert_nil Mephisto::Dispatcher.recognize_permalink(sites(:first), %w(200 9 1 foo))
0
     assert_nil Mephisto::Dispatcher.recognize_permalink(sites(:first), %w(2006 239 1 foo))
0
     assert_nil Mephisto::Dispatcher.recognize_permalink(sites(:first), %w(2006 9 123 foo))
0
- assert_nil Mephisto::Dispatcher.recognize_permalink(sites(:first), %w(2006 9 1 a_b))
0
     assert_nil Mephisto::Dispatcher.recognize_permalink(sites(:first), %w(2006 9 1 foo boo))
0
     assert_nil Mephisto::Dispatcher.recognize_permalink(sites(:first), %w(2006 9 1 foo comment))
0
   end
...
52
53
54
55
 
56
57
58
 
59
60
61
...
52
53
54
 
55
56
57
 
58
59
60
61
0
@@ -52,10 +52,10 @@ context "Site Permalink Regular Expression" do
0
   end
0
 
0
   specify "should create permalink regex" do
0
- assert_equal Regexp.new(%(^(\\d{4})\\/(\\d{1,2})\\/(\\d{1,2})\\/([a-z0-9-]+)(\/comments(\/(\\d+))?)?$)), @site.permalink_regex
0
+ assert_equal Regexp.new(%(^(\\d{4})\\/(\\d{1,2})\\/(\\d{1,2})\\/([\\w\\-]+)(\/comments(\/(\\d+))?)?$)), @site.permalink_regex
0
     
0
     @site.permalink_style = "articles/:id/:permalink"
0
- assert_equal Regexp.new(%(^articles\\/(\\d+)\\/([a-z0-9-]+)(\/comments(\/(\\d+))?)?$)), @site.permalink_regex(true)
0
+ assert_equal Regexp.new(%(^articles\\/(\\d+)\\/([\\w\\-]+)(\/comments(\/(\\d+))?)?$)), @site.permalink_regex(true)
0
   end
0
 end
0
 

Comments

    No one has commented yet.