Changeset 1697
- Timestamp:
- 05/04/08 23:06:27 (1 week ago)
- Files:
-
- trunk/app/controllers/articles_controller.rb (modified) (3 diffs)
- trunk/app/models/article.rb (modified) (1 diff)
- trunk/app/models/blog.rb (modified) (1 diff)
- trunk/app/views/admin/content/show.html.erb (modified) (1 diff)
- trunk/config/routes.rb (modified) (2 diffs)
- trunk/spec/controllers/articles_controller_spec.rb (modified) (2 diffs)
- trunk/spec/controllers/comments_controller_spec.rb (modified) (4 diffs)
- trunk/spec/models/article_spec.rb (modified) (1 diff)
- trunk/spec/models/category_spec.rb (modified) (1 diff)
- trunk/spec/models/comment_spec.rb (modified) (1 diff)
- trunk/spec/models/ping_spec.rb (modified) (1 diff)
- trunk/spec/models/tag_spec.rb (modified) (1 diff)
- trunk/spec/models/url_policy_spec.rb (modified) (2 diffs)
- trunk/vendor/plugins/datestamped_resources/lib/datestamped_resources.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/app/controllers/articles_controller.rb
r1694 r1697 97 97 end 98 98 99 def strip_article 100 if request.request_uri =~ /articles\// 101 redirect_to request.request_uri.gsub('articles/', '') 102 end 103 end 104 99 105 private 100 106 … … 108 114 end 109 115 end 110 116 111 117 alias_method :rescue_action_in_public, :error 112 118 … … 140 146 end 141 147 end 142 148 143 149 def formatted_date_selector(prefix = '') 144 150 return '' unless params[:year] trunk/app/models/article.rb
r1694 r1697 84 84 :month => sprintf("%.2d", published_at.month), 85 85 :day => sprintf("%.2d", published_at.day), 86 :controller => 'article s',86 :controller => 'article', 87 87 :action => 'show', 88 88 (nesting ? :article_id : :id) => permalink} trunk/app/models/blog.rb
r1667 r1697 137 137 when Hash 138 138 unless RouteCache[options] 139 options.reverse_merge!(:only_path => true, :controller => ' /articles',139 options.reverse_merge!(:only_path => true, :controller => '', 140 140 :action => 'permalink') 141 141 @url ||= ActionController::UrlRewriter.new(BlogRequest.new(self.base_url), {}) trunk/app/views/admin/content/show.html.erb
r1688 r1697 1 <iframe src="<%= @article.permalink_url%>" width="100%" height="700px" border="0"></iframe>1 <iframe src="<%=article_path(@article) %>" width="100%" height="700px" border="0"></iframe> 2 2 <a href="#" class="lbAction" rel="deactivate">Close.</a> trunk/config/routes.rb
r1638 r1697 82 82 end 83 83 84 map.inflected_resource(:categories, :path_prefix => ' /articles')85 map.inflected_resource(:authors, :path_prefix => ' /articles')86 map.inflected_resource(:tags, :path_prefix => ' /articles')84 map.inflected_resource(:categories, :path_prefix => '') 85 map.inflected_resource(:authors, :path_prefix => '') 86 map.inflected_resource(:tags, :path_prefix => '') 87 87 map.resources(:feedback) 88 88 89 89 # allow neat perma urls 90 map.connect ' articles/page/:page',90 map.connect 'page/:page', 91 91 :controller => 'articles', :action => 'index', 92 92 :page => /\d+/ … … 97 97 get.with_options(date_options.merge(:controller => 'articles')) do |dated| 98 98 dated.with_options(:action => 'index') do |finder| 99 finder.connect ' articles/:year/page/:page',99 finder.connect ':year/page/:page', 100 100 :month => nil, :day => nil, :page => /\d+/ 101 finder.connect ' articles/:year/:month/page/:page',101 finder.connect ':year/:month/page/:page', 102 102 :day => nil, :page => /\d+/ 103 finder.connect 'articles/:year/:month/:day/page/:page', :page => /\d+/ 103 finder.connect ':year/:month/:day/page/:page', :page => /\d+/ 104 finder.connect ':year', 105 :month => nil, :day => nil 106 finder.connect ':year/:month', 107 :day => nil 108 finder.connect ':year/:month/:day', :page => nil 104 109 end 105 110 end trunk/spec/controllers/articles_controller_spec.rb
r1665 r1697 20 20 end 21 21 22 it "should redirect category to / articles/categories" do22 it "should redirect category to /categories" do 23 23 get 'category' 24 24 response.should redirect_to(categories_path) 25 25 end 26 26 27 it "should redirect tag to / articles/tags" do27 it "should redirect tag to /tags" do 28 28 get 'tag' 29 29 response.should redirect_to(tags_path) … … 62 62 end 63 63 64 specify "/ articles/yyyy/mm/dd/slug.atom should be an atom feed" do64 specify "/yyyy/mm/dd/slug.atom should be an atom feed" do 65 65 scoped_getter.get 'index', :format => 'atom' 66 66 response.should render_template("_atom_feed") 67 67 end 68 68 69 specify "/ articles/yyyy/mm/dd/slug.rss should be an rss20 feed" do69 specify "/yyyy/mm/dd/slug.rss should be an rss20 feed" do 70 70 scoped_getter.get 'index', :format => 'rss' 71 71 response.should render_template("_rss20_feed") trunk/spec/controllers/comments_controller_spec.rb
r1645 r1697 11 11 end 12 12 13 it "should recognize GET / articles/2007/10/11/slug/comments" do14 routes.recognize_path('/ articles/2007/10/11/slug/comments', :method => :get).should ==13 it "should recognize GET /2007/10/11/slug/comments" do 14 routes.recognize_path('/2007/10/11/slug/comments', :method => :get).should == 15 15 basic_result('index') 16 16 end … … 131 131 it "should redirect to the article" do 132 132 make_the_request 133 response.should redirect_to('/ articles/2007/10/11/slug')133 response.should redirect_to('/2007/10/11/slug') 134 134 end 135 135 end … … 157 157 it_should_behave_like "All Requests" 158 158 159 it "GET /articles/2007/10/11/slug/comments should redirect to /articles/2007/10/11/slug#comments" do159 it "GET 2007/10/11/slug/comments should redirect to /2007/10/11/slug#comments" do 160 160 do_request :get, 'index' 161 response.should redirect_to("/ articles/2007/10/11/slug#comments")162 end 163 164 it "GET / articles/2007/10/11/slug/comments.atom should return an atom feed" do161 response.should redirect_to("/2007/10/11/slug#comments") 162 end 163 164 it "GET /2007/10/11/slug/comments.atom should return an atom feed" do 165 165 do_request :get, 'index', :format => 'atom' 166 166 response.should be_success … … 168 168 end 169 169 170 it "GET / articles/2007/10/11/slug/comments.rss should return an rss feed" do170 it "GET /2007/10/11/slug/comments.rss should return an rss feed" do 171 171 do_request :get, 'index', :format => 'rss' 172 172 response.should be_success trunk/spec/models/article_spec.rb
r1679 r1697 20 20 def test_permalink_url 21 21 a = contents(:article3) 22 assert_equal 'http://myblog.net/ articles/2004/06/01/article-3', a.permalink_url22 assert_equal 'http://myblog.net/2004/06/01/article-3', a.permalink_url 23 23 end 24 24 trunk/spec/models/category_spec.rb
r1622 r1697 38 38 it 'A category knows its url' do 39 39 categories(:software).permalink_url.should == 40 'http://myblog.net/ articles/category/software'40 'http://myblog.net/category/software' 41 41 end 42 42 end trunk/spec/models/comment_spec.rb
r1665 r1697 10 10 def test_permalink_url 11 11 c = feedback(:old_comment) 12 assert_equal "http://myblog.net/ articles/2004/05/01/inactive-article#comment-#{c.id}", c.permalink_url12 assert_equal "http://myblog.net/2004/05/01/inactive-article#comment-#{c.id}", c.permalink_url 13 13 end 14 14 trunk/spec/models/ping_spec.rb
r1665 r1697 49 49 @mock_xmlrpc_response.should_receive(:call)\ 50 50 .with('pingback.ping', 51 %r{http://myblog.net/ articles/\d{4}/\d{2}/\d{2}/test-the-pinging},51 %r{http://myblog.net/\d{4}/\d{2}/\d{2}/test-the-pinging}, 52 52 referenced_url) 53 53 trunk/spec/models/tag_spec.rb
r1679 r1697 47 47 end 48 48 49 it 'permalink_url should be of form / articles/tag/<name>' do50 Tag.get('foo').permalink_url.should == 'http://myblog.net/ articles/tag/foo'49 it 'permalink_url should be of form /tag/<name>' do 50 Tag.get('foo').permalink_url.should == 'http://myblog.net/tag/foo' 51 51 end 52 52 trunk/spec/models/url_policy_spec.rb
r1672 r1697 10 10 end 11 11 12 it "#url_for(contents(:article3)) should == / articles/2004/06/01/article-3" do13 UrlPolicy.instance.url_for(contents(:article3)).should == '/ articles/2004/06/01/article-3'12 it "#url_for(contents(:article3)) should == /2004/06/01/article-3" do 13 UrlPolicy.instance.url_for(contents(:article3)).should == '/2004/06/01/article-3' 14 14 end 15 15 16 it "#url_for(<comment on article 3>).should == / articles/2004/06/01/article-3/comments/#\{comment.guid}" do16 it "#url_for(<comment on article 3>).should == /2004/06/01/article-3/comments/#\{comment.guid}" do 17 17 article = contents(:article3) 18 18 comment = article.comments.build(:author => 'Piers Cawley', :body => "body") 19 19 comment.save(false) 20 UrlPolicy.instance.url_for(comment).should == "/ articles/2004/06/01/article-3/comments/#{comment.guid}"20 UrlPolicy.instance.url_for(comment).should == "/2004/06/01/article-3/comments/#{comment.guid}" 21 21 end 22 22 23 it "#url_for(article3.comments).should == / articles/2004/06/01/article-3/comments" do23 it "#url_for(article3.comments).should == /2004/06/01/article-3/comments" do 24 24 article = contents(:article3) 25 25 comment = article.comments.build(:author => 'Piers Cawley', :body => "body") 26 26 comment.save(false) 27 27 UrlPolicy.instance.url_for(article.comments).should == 28 "/ articles/2004/06/01/article-3/comments"28 "/2004/06/01/article-3/comments" 29 29 end 30 30 31 it "#url_for(article3, Comment) should be / articles/2004/06/01/article-3/comments" do31 it "#url_for(article3, Comment) should be /2004/06/01/article-3/comments" do 32 32 UrlPolicy.instance.url_for(contents(:article3), Comment).should == 33 "/ articles/2004/06/01/article-3/comments"33 "/2004/06/01/article-3/comments" 34 34 end 35 35 … … 45 45 end 46 46 47 it "#url_for(<trackback on article 3>).should == / articles/2004/06/01/article-3/comments/#\{trackback.guid}" do47 it "#url_for(<trackback on article 3>).should == /2004/06/01/article-3/comments/#\{trackback.guid}" do 48 48 @trackback.save(false) 49 49 UrlPolicy.instance.url_for(@trackback).should == 50 "/ articles/2004/06/01/article-3/trackbacks/#{@trackback.guid}"50 "/2004/06/01/article-3/trackbacks/#{@trackback.guid}" 51 51 end 52 52 end 53 53 54 it "#url_for(Article.new) should == '/ articles/new'" do55 UrlPolicy.instance.url_for(Article.new).should == '/ articles/new'54 it "#url_for(Article.new) should == '/new'" do 55 UrlPolicy.instance.url_for(Article.new).should == '/new' 56 56 end 57 57 58 it "#edit_url_for(contents(:article3)) should == / articles/2004/06/01/article-3/edit" do59 UrlPolicy.instance.edit_url_for(contents(:article3)).should == '/ articles/2004/06/01/article-3/edit'58 it "#edit_url_for(contents(:article3)) should == /2004/06/01/article-3/edit" do 59 UrlPolicy.instance.edit_url_for(contents(:article3)).should == '/2004/06/01/article-3/edit' 60 60 end 61 61 62 it "#url_for(Article.new) should == '/ articles/new'" do63 UrlPolicy.instance.edit_url_for(Article.new).should == '/ articles/new'62 it "#url_for(Article.new) should == '/new'" do 63 UrlPolicy.instance.edit_url_for(Article.new).should == '/new' 64 64 end 65 65 end trunk/vendor/plugins/datestamped_resources/lib/datestamped_resources.rb
r1528 r1697 4 4 class DatestampedResource < ::ActionController::Resources::Resource 5 5 def path 6 @path ||= "#{path_prefix}/#{plural}" 6 # @path ||= "#{path_prefix}/#{plural}" replacing to get rid of articles 7 @path ||= "#{path_prefix}" 7 8 end 8 9
