Patch #1901

RESTful URLs for everything

Added by Gerrit Kaiser over 9 years ago. Updated about 7 years ago.

Status:ClosedStart date:2008-09-15
Priority:NormalDue date:
Assignee:Eric Davis% Done:

100%

Category:-
Target version:0.9.0

Description

I did some work on making Redmine’s URLs adhere to Rails’s RESTful conventions. This is necessary if redmine wants to be ActiveResource-compatible. Imho its worthwhile anyway, as redmine’s current URLs aren’t particularly readable.

Attached is a patch against current SVN. It tries hard not to touch any views and is only minimally invasive in the controllers themselves and non-related tests.

If this generates enough interest, I would go on and modify the forms to iron out the last kinks (use DELETE and PUT HTTP methods where appropriate). Then it would be possible to gradually move the app to use named routes like new_issue_path or project_issues_path('ecookbook') instead of the params hash that is used anywhere. This would de-couple the views and unrelated tests from the URL scheme, allowing further changes. Apart from that it should prove much more readable.

I would propose refactoring the controllers to follow the rails convention of #create, #update etc. as a followup, but that is not even necessary in order to have a full ActiveResource-compliant API.

I made every effort to retain backwards compatibility, left all the old routes intact as a fallback. So incoming links should still work. As the old routing was completely untested, I can’t vouch for that though.

restful_urls_start.diff Magnifier (74.1 KB) Gerrit Kaiser, 2008-09-15 03:23


Related issues

Related to Redmine - Feature #296: REST API Closed
Related to Redmine - Feature #2275: provide a nice url for each project, with configurable re... Closed 2008-12-04
Related to Redmine - Feature #4119: Use /raw/ for url instead of format=raw for showing raw r... Closed 2009-10-27

Associated revisions

Revision 2317
Added by Eric Davis almost 9 years ago

Converted routing and urls to follow the Rails REST convention.

Patch supplied by commits from Gerrit Kaiser on Github. Existing routes will
still work (backwards compatible) but any new urls will be generated using the
new routing rules.

Changes listed below:

  • made the URLs for some project tabs and project settings follow the new rails RESTful conventions of /collection/:id/subcollection/:sub_id
  • prettier URL for project roadmap
  • more nice project URLs
  • use GET for filtering form
  • prettified URLs used on issues tab
  • custom route for activity atom feeds
  • prettier repository urls
  • fixed broken route definition
  • fixed failing tests for issuecontroller that were hardcoding the url string
  • more RESTful routes for boards and messages
  • RESTful routes for wiki pages
  • RESTful routes for documents
  • moved old routes that are retained for compatibility to the bottom and grouped them together
  • added RESTful URIs for issues
  • RESTfulness for the news section
  • fixed route order
  • changed hardcoded URLs in tests
  • fixed badly written tests
  • fixed forgotten parameter in routes
  • changed hardcoded URLS to new scheme
  • changed project add url to the standard POST to collection
  • create new issue by POSTing to collection
  • changed hardcoded URLs in integrations tests
  • made project add form work again
  • restful routes for project deletion
  • prettier routes for project (un)archival
  • made routes table more readable
  • fixed note quoting
  • user routing
  • fixed bug
  • always sort by GET
  • Fixed: cross-project issue list should not show issues of projects for which the issue tracking module was disabled.
  • prettified URLs used on issues tab
  • urls for time log
  • fixed reply routing
  • eliminate revision query paremeter for diff and entry actions
  • fixed test failures with hard-coded urls
  • ensure ajax links always use get
  • refactored ajax link generation into separate method

    #1901

Revision 3074
Added by Jean-Philippe Lang about 8 years ago

Use /raw/ for url instead of ?format=raw for getting raw repository files (#1901, #4119).

History

#1 Updated by Markus Knittig over 9 years ago

+1
Looks really good. I would help refactoring, in fact started some refactoring. See #296... ;)

#2 Updated by Eric Davis over 9 years ago

I'm wondering if there is an easier way to do these refactoring than large patches. I've pushed my developer svn git repository to GitHub. This is the repository I use to push changes back into the Redmine svn. If you want to clone it, I'll take pull requests and patches and push them back into Redmine's svn.

(I have to use a different git repository because git-svn uses the url to manage the changesets and Rubyforge has a different url for developer access.)

#3 Updated by Sergej Jegorov over 9 years ago

+1

#4 Updated by Stephanie Collett about 9 years ago

+1

#5 Updated by Christian Mayer about 9 years ago

+1

#6 Updated by Gerrit Kaiser almost 9 years ago

Finally got around to merging these changes into a git clone of Eric's semi-official git-svn-clone.

You can fetch the changes from github. As this is more or less a moving target and quite a large change, I agree with Eric that this is the best way to move on. I can create a patch file if needed, though.

#7 Updated by Eric Davis almost 9 years ago

  • Assignee set to Eric Davis

Gerrit Kaiser wrote:

As this is more or less a moving target and quite a large change, I agree with Eric that this is the best way to move on. I can create a patch file if needed, though.

I'll integrate it soon. Thanks for making a separate branch for them, it makes it a lot easier for me.

#8 Updated by Patrick Naubert almost 9 years ago

+1

#9 Updated by Eric Davis almost 9 years ago

  • Status changed from New to 7

Gerrit Kaiser,

I've very impressed with these patches. I'm reviewing them right now and I'm mostly concerned that the old routes are still available for backwards compatibility but I believe you handled that. The url format is very nice:

  • "http://www.redmine.org/issues/1901"
  • "http://www.redmine.org/projects/redmine"

#10 Updated by Eric Davis almost 9 years ago

  • Status changed from 7 to Resolved
  • Target version set to 0.8.1
  • % Done changed from 0 to 100

The set of patches have been commited in r2317. I squashed them into a single commit so they can be reverted in svn easily, if needed I can revert and split them into their individual commits. This commit could potentially cause bugs to appear so we'll need to keep an eye out for any link_to or routing errors. I'm going to deploy this update to my server so I can watch for exceptions as it's used.

Change log follows:


Converted routing and urls to follow the Rails REST convention.

Patch supplied by commits from Gerrit Kaiser on Github. Existing routes will still work (backwards compatible) but any new urls will be generated using the new routing rules.

Changes listed below:

  • made the URLs for some project tabs and project settings follow the new rails RESTful conventions of /collection/:id/subcollection/:sub_id
  • prettier URL for project roadmap
  • more nice project URLs
  • use GET for filtering form
  • prettified URLs used on issues tab
  • custom route for activity atom feeds
  • prettier repository urls
  • fixed broken route definition
  • fixed failing tests for issuecontroller that were hardcoding the url string
  • more RESTful routes for boards and messages
  • RESTful routes for wiki pages
  • RESTful routes for documents
  • moved old routes that are retained for compatibility to the bottom and grouped them together
  • added RESTful URIs for issues
  • RESTfulness for the news section
  • fixed route order
  • changed hardcoded URLs in tests
  • fixed badly written tests
  • fixed forgotten parameter in routes
  • changed hardcoded URLS to new scheme
  • changed project add url to the standard POST to collection
  • create new issue by POSTing to collection
  • changed hardcoded URLs in integrations tests
  • made project add form work again
  • restful routes for project deletion
  • prettier routes for project (un)archival
  • made routes table more readable
  • fixed note quoting
  • user routing
  • fixed bug
  • always sort by GET
  • Fixed: cross-project issue list should not show issues of projects for which the issue tracking module was disabled.
  • prettified URLs used on issues tab
  • urls for time log
  • fixed reply routing
  • eliminate revision query paremeter for diff and entry actions
  • fixed test failures with hard-coded urls
  • ensure ajax links always use get
  • refactored ajax link generation into separate method

#11 Updated by Gerrit Kaiser almost 9 years ago

thanks for applying this. but perhaps a major change like this would be better for a 0.9 release than a .1 point-release?

#12 Updated by Jean-Philippe Lang almost 9 years ago

  • Target version changed from 0.8.1 to 0.9.0

Indeed.

#13 Updated by Eric Davis almost 9 years ago

  • Status changed from Resolved to Closed

Gerrit Kaiser wrote:

thanks for applying this. but perhaps a major change like this would be better for a 0.9 release than a .1 point-release?

Jean-Philippe, is there any documentation on what is allowed in a point release (0.0.x) versus a major release (0.x.0)? I always thought only database migrations weren't allowed in point releases.

Closing issue as complete.

#14 Updated by Jean-Philippe Lang almost 9 years ago

A minor release should include fixes and some enhancements/features that do not require a database migration.
This change doesn't touch the database indeed but it's rather big and not a real feature (it doesn't bring new functionalities nor improve the existing ones). It's a first step for adding a rest API later but I don't think this API will be added in the 0.8 branch.

#15 Updated by Eric Davis almost 9 years ago

Jean-Philippe Lang wrote:

A minor release should include fixes and some enhancements/features that do not require a database migration.
This change doesn't touch the database indeed but it's rather big and not a real feature (it doesn't bring new functionalities nor improve the existing ones). It's a first step for adding a rest API later but I don't think this API will be added in the 0.8 branch.

Got it, I agree with the decision I just wanted to clarify it for reference. I started a basic wiki page describing the how the releases work: ReleaseManagement.

#16 Updated by Yohann Monnier over 8 years ago

Hello,
does it mean it will not be available until 0.9 release ?

#18 Updated by Alex G. about 8 years ago

Guys, could you make a conclusion on this feature?
In order to start using it, we'd like to know the final status on this if it is resolved or will be improved/changed somehow.

As i saw, Eric is working on practical approving of the feature.
Eric, could we have some feedback from time to time here or in a separated thread to be up to date?

Thanx in advance

#19 Updated by Eric Davis about 8 years ago

sunday walker wrote:

This is nice.
Can you change URL as follows, it is better than now ?

http://www.redmine.org/projects/redmine/repository/revisions/2317/entry/trunk/config/routes.rb?format=raw

http://www.redmine.org/projects/redmine/repository/revisions/2317/raw/trunk/config/routes.rb

I don't care for the "raw" url but it makes no different to me. Anyone else mind if I change it? Also, would you mind creating a new feature request if the issue has already been closed for more than 3 months? It helps cut down on the confusion and will make sure others notice the new request.

Alex G. wrote:

Guys, could you make a conclusion on this feature?
In order to start using it, we'd like to know the final status on this if it is resolved or will be improved/changed somehow.

It's complete other than the change sunday walker proposed. The urls will evolve over time but should be backwards compatible for the most part (i.e. go ahead and use these urls).

#20 Updated by sunday walker about 8 years ago

sunday walker wrote:

This is nice. Can you change URL as follows, it is better than now ?

http://www.redmine.org/projects/redmine/repository/revisions/2317/entry/trunk/config/routes.rb?format=raw

http://www.redmine.org/projects/redmine/repository/revisions/2317/raw/trunk/config/routes.rb

I don't care for the "raw" url but it makes no different to me.
Anyone else mind if I change it? Also, would you mind creating a new feature
request if the issue has already been closed for more than 3 months?
It helps cut down on the confusion and will make sure others notice the new request.

I am sorry to confuse you.
For example, it is very convenient to refer to the HTML and a picture file referring from the HTML .

Ex.

HTML Files:
http://www.redmine.org/projects/redmine/repository/revisions/2317/raw/trunk/test1.html

<html>
<head>
<title>test1</title>
</head>
<body>
<a href="test2.html"><img src="test2.png" /></a>
</body>
</html>

http://www.redmine.org/projects/redmine/repository/revisions/2317/raw/trunk/test2.html

<html>
<head>
<title>test2</title>
</head>
<body>
<a href="test1.html"><img src="test1.png" /></a>
</body>
</html>

Image Files:
http://www.redmine.org/projects/redmine/repository/revisions/2317/raw/trunk/test1.png
http://www.redmine.org/projects/redmine/repository/revisions/2317/raw/trunk/test2.png

Would you please make the copy of this issue if you want to make the another issue.

#21 Updated by sunday walker about 8 years ago

sunday walker wrote:

sunday walker wrote:

This is nice. Can you change URL as follows, it is better than now ?

http://www.redmine.org/projects/redmine/repository/revisions/2317/entry/trunk/config/routes.rb?format=raw

http://www.redmine.org/projects/redmine/repository/revisions/2317/raw/trunk/config/routes.rb

I don't care for the "raw" url but it makes no different to me.
Anyone else mind if I change it? Also, would you mind creating a new feature
request if the issue has already been closed for more than 3 months?
It helps cut down on the confusion and will make sure others notice the new request.

I am sorry to confuse you.
For example, it is very convenient to refer to the HTML and a image file referring from the HTML .

Ex.

HTML Files:
http://www.redmine.org/projects/redmine/repository/revisions/2317/raw/trunk/test1.html
[...]

http://www.redmine.org/projects/redmine/repository/revisions/2317/raw/trunk/test2.html
[...]

Image Files:
http://www.redmine.org/projects/redmine/repository/revisions/2317/raw/trunk/test1.png
http://www.redmine.org/projects/redmine/repository/revisions/2317/raw/trunk/test2.png

Would you please make the copy of this issue if you want to make the another issue.

#22 Updated by Eric Davis about 8 years ago

Filed #4119 for sunday walker's request

#23 Updated by sunday walker about 8 years ago

Eric Davis wrote:

Filed #4119 for sunday walker's request

Thank you.

#24 Updated by Jean-Philippe Lang about 8 years ago

  • Status changed from Reopened to Closed

Eric Davis wrote:

Filed #4119 for sunday walker's request

Done in r3074.

Also available in: Atom PDF