aboutsummaryrefslogtreecommitdiffstats
path: root/app/helpers/application_helper.rb
diff options
context:
space:
mode:
authorfrancis <francis>2007-10-30 17:31:31 +0000
committerfrancis <francis>2007-10-30 17:31:31 +0000
commit326c8c3b26ce95fb60cc3c519e00e1b178fada50 (patch)
treeefb61ca279a95a3f18928120100aff635613d94d /app/helpers/application_helper.rb
parent180ece0c3394c9cdd6de19dfb4860acbed550742 (diff)
Use nicer URLs for user names with funny characters in them.
Diffstat (limited to 'app/helpers/application_helper.rb')
-rw-r--r--app/helpers/application_helper.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 9c4c085dd..495c61b61 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -4,7 +4,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: application_helper.rb,v 1.9 2007-10-30 15:03:03 francis Exp $
+# $Id: application_helper.rb,v 1.10 2007-10-30 17:31:31 francis Exp $
module ApplicationHelper
@@ -40,6 +40,13 @@ module ApplicationHelper
end
# Simplified links to our objects
+ # XXX See controllers/user_controller.rb for inverse
+ def simplify_url_part(text)
+ text.downcase!
+ text.gsub!(/ /, "-")
+ text.gsub!(/[^a-z0-9_-]/, "")
+ text
+ end
def request_link(info_request)
link_to h(info_request.title), show_request_url(:id => info_request)
@@ -53,7 +60,11 @@ module ApplicationHelper
end
def user_link(user)
- link_to h(user.name), show_user_url(:name => user.name)
+ link_to h(user.name), show_user_url(:simple_name => simplify_url_part(user.name))
+ end
+
+ def info_request_link(info_request)
+ link_to h(info_request.title), show_request_url(:id => info_request)
end
end