-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removed excess /posts/ part from blog-posts resources and fixed localization bug. #463
Open
sintro
wants to merge
4
commits into
refinery:master
Choose a base branch
from
sintro:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
Refinery::Core::Engine.routes.draw do | ||
namespace :blog, :path => Refinery::Blog.page_url do | ||
root :to => "posts#index" | ||
resources :posts, :only => [:show] | ||
resources :posts, path: '', :only => [:show] do | ||
get 'comments', on: :member, to: :show | ||
get 'posts/:id(/comments)', on: :collection, to: redirect("#{Refinery::Blog.page_url}/%{id}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This way there will be the 301 redirect if someone tries to get the post from old uri |
||
end | ||
|
||
get 'feed.rss', :to => 'posts#index', :as => 'rss_feed', :defaults => {:format => "rss"} | ||
get 'categories/:id', :to => 'categories#show', :as => 'category' | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a breaking change. We should do a redirect from
blog/posts/1
toblog/1
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not? What is the point of this 'posts' level of url? And what redirect are you talking about (what action)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I've an existing blog indexed on google, all indexed posts will now point to a 404.
I suggest to add a permanent redirect from
blog/posts/*
to blog/*` in order to keep SEO index fine.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be
get "posts/:id", to: :show, on: :collection
is better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I don't know what I was thinking. What's wrong with
/blog/posts/:id
and/blog/posts
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok if we want to use blog urls without
posts
level but i would also like to add a redirect to be backward compatible with old urlsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@parndt, such url structure (without posts) even appers in this routes set in https://github.com/refinery/refinerycms-blog/blob/master/config/routes.rb#L8 , when you are trying to create the comment to post with invalid fields, you get failed validations and now see the url like 'http://example.com/blog/post-1/comment'. If you try to refresh the page, you will get 404 error. But as for me, this structure is perfect, and 'posts' is unnecessary (even non-friendly) part here, because 'blog' plays the role of 'posts' in this case.
Actually, the same (path: ' ') done in Refinery's extenstions generator, https://github.com/refinery/refinerycms/blob/master/core/lib/generators/refinery/engine/templates/config/routes.rb.erb#L5 , because there is no sense in urls like 'example.com/events/events/1',