Changeset 1697

Show
Ignore:
Timestamp:
05/04/08 23:06:27 (1 week ago)
Author:
neuro
Message:

Getting rid of /articles in the URL. Still need to add a redirect from old to new url. method exists in article controller, however, must find the best way to call it (routes for every possible url ?).

Don't want to have it done by the web server anyway

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/app/controllers/articles_controller.rb

    r1694 r1697  
    9797  end 
    9898 
     99  def strip_article 
     100    if request.request_uri =~ /articles\// 
     101      redirect_to request.request_uri.gsub('articles/', '') 
     102    end 
     103  end 
     104 
    99105  private 
    100106 
     
    108114    end 
    109115  end 
    110  
     116   
    111117  alias_method :rescue_action_in_public, :error 
    112118 
     
    140146    end 
    141147  end 
    142  
     148   
    143149  def formatted_date_selector(prefix = '') 
    144150    return '' unless params[:year] 
  • trunk/app/models/article.rb

    r1694 r1697  
    8484     :month                        => sprintf("%.2d", published_at.month), 
    8585     :day                          => sprintf("%.2d", published_at.day), 
    86      :controller                   => 'articles', 
     86     :controller                   => 'article', 
    8787     :action                       => 'show', 
    8888     (nesting ? :article_id : :id) => permalink} 
  • trunk/app/models/blog.rb

    r1667 r1697  
    137137    when Hash 
    138138      unless RouteCache[options] 
    139         options.reverse_merge!(:only_path => true, :controller => '/articles', 
     139        options.reverse_merge!(:only_path => true, :controller => '', 
    140140                               :action => 'permalink') 
    141141        @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> 
    22<a href="#" class="lbAction" rel="deactivate">Close.</a> 
  • trunk/config/routes.rb

    r1638 r1697  
    8282  end 
    8383 
    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 => '') 
    8787  map.resources(:feedback) 
    8888 
    8989  # allow neat perma urls 
    90   map.connect 'articles/page/:page', 
     90  map.connect 'page/:page', 
    9191    :controller => 'articles', :action => 'index', 
    9292    :page => /\d+/ 
     
    9797    get.with_options(date_options.merge(:controller => 'articles')) do |dated| 
    9898      dated.with_options(:action => 'index') do |finder| 
    99         finder.connect 'articles/:year/page/:page', 
     99        finder.connect ':year/page/:page', 
    100100          :month => nil, :day => nil, :page => /\d+/ 
    101         finder.connect 'articles/:year/:month/page/:page', 
     101        finder.connect ':year/:month/page/:page', 
    102102          :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 
    104109      end 
    105110    end 
  • trunk/spec/controllers/articles_controller_spec.rb

    r1665 r1697  
    2020  end 
    2121 
    22   it "should redirect category to /articles/categories" do 
     22  it "should redirect category to /categories" do 
    2323    get 'category' 
    2424    response.should redirect_to(categories_path) 
    2525  end 
    2626 
    27   it "should redirect tag to /articles/tags" do 
     27  it "should redirect tag to /tags" do 
    2828    get 'tag' 
    2929    response.should redirect_to(tags_path) 
     
    6262  end 
    6363 
    64   specify "/articles/yyyy/mm/dd/slug.atom should be an atom feed" do 
     64  specify "/yyyy/mm/dd/slug.atom should be an atom feed" do 
    6565    scoped_getter.get 'index', :format => 'atom' 
    6666    response.should render_template("_atom_feed") 
    6767  end 
    6868 
    69   specify "/articles/yyyy/mm/dd/slug.rss should be an rss20 feed" do 
     69  specify "/yyyy/mm/dd/slug.rss should be an rss20 feed" do 
    7070    scoped_getter.get 'index', :format => 'rss' 
    7171    response.should render_template("_rss20_feed") 
  • trunk/spec/controllers/comments_controller_spec.rb

    r1645 r1697  
    1111  end 
    1212 
    13   it "should recognize GET /articles/2007/10/11/slug/comments" do 
    14     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 == 
    1515      basic_result('index') 
    1616  end 
     
    131131  it "should redirect to the article" do 
    132132    make_the_request 
    133     response.should redirect_to('/articles/2007/10/11/slug') 
     133    response.should redirect_to('/2007/10/11/slug') 
    134134  end 
    135135end 
     
    157157  it_should_behave_like "All Requests" 
    158158 
    159   it "GET /articles/2007/10/11/slug/comments should redirect to /articles/2007/10/11/slug#comments" do 
     159  it "GET 2007/10/11/slug/comments should redirect to /2007/10/11/slug#comments" do 
    160160    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" do 
     161    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 
    165165    do_request :get, 'index', :format => 'atom' 
    166166    response.should be_success 
     
    168168  end 
    169169 
    170   it "GET /articles/2007/10/11/slug/comments.rss should return an rss feed" do 
     170  it "GET /2007/10/11/slug/comments.rss should return an rss feed" do 
    171171    do_request :get, 'index', :format => 'rss' 
    172172    response.should be_success 
  • trunk/spec/models/article_spec.rb

    r1679 r1697  
    2020  def test_permalink_url 
    2121    a = contents(:article3) 
    22     assert_equal 'http://myblog.net/articles/2004/06/01/article-3', a.permalink_url 
     22    assert_equal 'http://myblog.net/2004/06/01/article-3', a.permalink_url 
    2323  end 
    2424 
  • trunk/spec/models/category_spec.rb

    r1622 r1697  
    3838  it 'A category knows its url' do 
    3939    categories(:software).permalink_url.should == 
    40       'http://myblog.net/articles/category/software' 
     40      'http://myblog.net/category/software' 
    4141  end 
    4242end 
  • trunk/spec/models/comment_spec.rb

    r1665 r1697  
    1010  def test_permalink_url 
    1111    c = feedback(:old_comment) 
    12     assert_equal "http://myblog.net/articles/2004/05/01/inactive-article#comment-#{c.id}", c.permalink_url 
     12    assert_equal "http://myblog.net/2004/05/01/inactive-article#comment-#{c.id}", c.permalink_url 
    1313  end 
    1414 
  • trunk/spec/models/ping_spec.rb

    r1665 r1697  
    4949    @mock_xmlrpc_response.should_receive(:call)\ 
    5050      .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}, 
    5252            referenced_url) 
    5353 
  • trunk/spec/models/tag_spec.rb

    r1679 r1697  
    4747  end 
    4848 
    49   it 'permalink_url should be of form /articles/tag/<name>' do 
    50     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' 
    5151  end 
    5252   
  • trunk/spec/models/url_policy_spec.rb

    r1672 r1697  
    1010  end 
    1111 
    12   it "#url_for(contents(:article3)) should == /articles/2004/06/01/article-3" do 
    13     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' 
    1414  end 
    1515 
    16   it "#url_for(<comment on article 3>).should == /articles/2004/06/01/article-3/comments/#\{comment.guid}" do 
     16  it "#url_for(<comment on article 3>).should == /2004/06/01/article-3/comments/#\{comment.guid}" do 
    1717    article = contents(:article3) 
    1818    comment = article.comments.build(:author => 'Piers Cawley', :body => "body") 
    1919    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}" 
    2121  end 
    2222 
    23   it "#url_for(article3.comments).should == /articles/2004/06/01/article-3/comments" do 
     23  it "#url_for(article3.comments).should == /2004/06/01/article-3/comments" do 
    2424    article = contents(:article3) 
    2525    comment = article.comments.build(:author => 'Piers Cawley', :body => "body") 
    2626    comment.save(false) 
    2727    UrlPolicy.instance.url_for(article.comments).should == 
    28       "/articles/2004/06/01/article-3/comments" 
     28      "/2004/06/01/article-3/comments" 
    2929  end 
    3030 
    31   it "#url_for(article3, Comment) should be /articles/2004/06/01/article-3/comments" do 
     31  it "#url_for(article3, Comment) should be /2004/06/01/article-3/comments" do 
    3232    UrlPolicy.instance.url_for(contents(:article3), Comment).should == 
    33       "/articles/2004/06/01/article-3/comments" 
     33      "/2004/06/01/article-3/comments" 
    3434  end 
    3535 
     
    4545    end 
    4646 
    47     it "#url_for(<trackback on article 3>).should == /articles/2004/06/01/article-3/comments/#\{trackback.guid}" do 
     47    it "#url_for(<trackback on article 3>).should == /2004/06/01/article-3/comments/#\{trackback.guid}" do 
    4848      @trackback.save(false) 
    4949      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}" 
    5151    end 
    5252  end 
    5353 
    54   it "#url_for(Article.new) should == '/articles/new'" do 
    55     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' 
    5656  end 
    5757 
    58   it "#edit_url_for(contents(:article3)) should == /articles/2004/06/01/article-3/edit" do 
    59     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' 
    6060  end 
    6161 
    62   it "#url_for(Article.new) should == '/articles/new'" do 
    63     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' 
    6464  end 
    6565end 
  • trunk/vendor/plugins/datestamped_resources/lib/datestamped_resources.rb

    r1528 r1697  
    44    class DatestampedResource < ::ActionController::Resources::Resource 
    55      def path 
    6         @path ||= "#{path_prefix}/#{plural}" 
     6        # @path ||= "#{path_prefix}/#{plural}" replacing to get rid of articles 
     7        @path ||= "#{path_prefix}" 
    78      end 
    89