fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-12-05 04:10 am

[dw-free] Revamp /update

[commit: http://hg.dwscoalition.org/dw-free/rev/394132d58cd6]

http://bugs.dwscoalition.org/show_bug.cgi?id=2524

Make exampleusername.dreamwidth.org/entry/new redirect to
www.dreamwidth.org/entry/exampleusername/new

Patch by [personal profile] fu.

Files modified:
  • cgi-bin/DW/Controller/Entry.pm
--------------------------------------------------------------------------------
diff -r 1869b6232370 -r 394132d58cd6 cgi-bin/DW/Controller/Entry.pm
--- a/cgi-bin/DW/Controller/Entry.pm	Mon Dec 05 12:09:39 2011 +0800
+++ b/cgi-bin/DW/Controller/Entry.pm	Mon Dec 05 12:11:00 2011 +0800
@@ -47,6 +47,15 @@
                              # /entry/username/ditemid/edit
 #DW::Routing->register_regex( '^/entry/(?:(.+)/)?(\d+)/edit$', \&edit_handler, app => 1 );
 
+DW::Routing->register_string( '/entry/new', \&_new_handler_userspace, user => 1 );
+
+# redirect to app-space
+sub _user_to_app_role {
+    my ( $path ) = @_;
+    return DW::Request->get->redirect( "$LJ::SITEROOT$path" );
+}
+
+sub _new_handler_userspace { return _user_to_app_role( "/entry/$_[0]->{username}/new" ) }
 
 =head2 C<< DW::Controller::Entry::new_handler( ) >>
 
--------------------------------------------------------------------------------