From 8af369539f94a25369ed82cb0078f4844f72babe Mon Sep 17 00:00:00 2001 From: Mike Date: Tue, 24 Feb 2009 14:03:00 -0800 Subject: [PATCH] Append username to URL when logging in or registering --- r2/r2/config/routing.py | 5 +++++ r2/r2/public/static/js/reddit.js | 26 ++++++++++++++++++++++++-- r2/r2/templates/login.html | 4 +++- r2/r2/templates/loginformwide.html | 4 +++- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/r2/r2/config/routing.py b/r2/r2/config/routing.py index 003ad9474..7d6b6e492 100644 --- a/r2/r2/config/routing.py +++ b/r2/r2/config/routing.py @@ -139,10 +139,15 @@ def make_map(global_conf={}, app_conf={}): mc('/resetpassword', controller='front', action='resetpassword') + mc('/post/:action/:url_user', controller='post', + requirements=dict(action="login|reg")) mc('/post/:action', controller='post', requirements=dict(action="options|over18|unlogged_options|optout|optin|login|reg")) + mc('/api/:action/:url_user', controller='api', + requirements=dict(action="login|register")) mc('/api/:action', controller='api') + mc('/d/:what', controller='api', action='bookmarklet') mc('/captcha/:iden', controller='captcha', action='captchaimg') diff --git a/r2/r2/public/static/js/reddit.js b/r2/r2/public/static/js/reddit.js index 5ef852e2a..fa8a657af 100644 --- a/r2/r2/public/static/js/reddit.js +++ b/r2/r2/public/static/js/reddit.js @@ -17,6 +17,27 @@ function close_menus() { function hover_open_menu(menu) { }; +function update_user(form) { + try { + var user = $(form).find("input[name=user]").val(); + form.action += "/" + user; + } catch (e) { + // ignore + } + + return true; +} + +function post_user(form, where) { + var user = $(form).find("input[name=user]").val(); + + if (user == null) { + return post_form (form, where); + } else { + return post_form (form, where + '/' + user); + } +} + function post_form(form, where, statusfunc, nametransformfunc, block) { try { if(statusfunc == null) @@ -526,13 +547,14 @@ function last_click(thing) { function login(elem) { if(cnameframe) return true; - return post_form(this, "login"); + + return post_user(this, "login"); }; function register(elem) { if(cnameframe) return true; - return post_form(this, "register"); + return post_user(this, "register"); }; /* The ready method */ diff --git a/r2/r2/templates/login.html b/r2/r2/templates/login.html index c2a5395d7..b381b8d41 100644 --- a/r2/r2/templates/login.html +++ b/r2/r2/templates/login.html @@ -46,7 +46,9 @@
%if c.cname: diff --git a/r2/r2/templates/loginformwide.html b/r2/r2/templates/loginformwide.html index 90524e3b6..2985dc8ce 100644 --- a/r2/r2/templates/loginformwide.html +++ b/r2/r2/templates/loginformwide.html @@ -31,7 +31,9 @@ %if c.cname: