Index: branches/release-29/lib/MT/Upgrade.pm
===================================================================
--- branches/release-29/lib/MT/Upgrade.pm (revision 1256)
+++ branches/release-29/lib/MT/Upgrade.pm (revision 1333)
@@ -776,4 +776,21 @@
                     $blog->page_layout($layout);
                     $blog->save;
+                },
+            },
+        },
+        'core_set_author_basename' => {
+            version_limit => 4.0037,
+            priority => 3.2,
+            updater => {
+                type => 'author',
+                label => 'Assigning author basename...',
+                condition => sub {
+                    $_[0]->type == 1;
+                },
+                code => sub {
+                    my ($author) = @_;
+                    my $basename = MT::Util::make_unique_author_basename($author);
+                    $author->basename($basename);
+                    $author->save;
                 },
             },
Index: branches/release-29/lib/MT/Core.pm
===================================================================
--- branches/release-29/lib/MT/Core.pm (revision 1242)
+++ branches/release-29/lib/MT/Core.pm (revision 1333)
@@ -496,4 +496,7 @@
             'UserpicMaxUpload' => { default => 0 },
             'UserpicThumbnailSize' => { default => 100 },
+
+            # Basename settings
+            'AuthorBansenameLimit' => { default => 30 },
         },
         upgrade_functions => \&load_upgrade_fns,
Index: branches/release-29/lib/MT/Author.pm
===================================================================
--- branches/release-29/lib/MT/Author.pm (revision 1174)
+++ branches/release-29/lib/MT/Author.pm (revision 1333)
@@ -36,4 +36,5 @@
         'auth_type' => 'string(255)',
         'userpic_asset_id' => 'integer',
+        'basename' => 'string(255)',
     },
     defaults => {
@@ -210,12 +211,17 @@
     my $auth = shift;
 
-    if ((!$auth->id) && ($auth->type == AUTHOR)) {
-        # New author, undefined API password. Generate one.
-        if (!defined $auth->api_password) {
-            my @pool = ('a'..'z', 0..9);
-            my $pass = '';
-            for (1..8) { $pass .= $pool[ rand @pool ] }
-            $auth->api_password($pass);
+    if ($auth->type == AUTHOR) {
+        if (!$auth->id) {
+            # New author, undefined API password. Generate one.
+            if (!defined $auth->api_password) {
+                my @pool = ('a'..'z', 0..9);
+                my $pass = '';
+                for (1..8) { $pass .= $pool[ rand @pool ] }
+                $auth->api_password($pass);
+            }
         }
+        # Generate basename
+        my $basename = MT::Util::make_unique_author_basename($auth);
+        $auth->basename($basename);
     }
 
Index: branches/release-29/lib/MT/Template/ContextHandlers.pm
===================================================================
--- branches/release-29/lib/MT/Template/ContextHandlers.pm (revision 1308)
+++ branches/release-29/lib/MT/Template/ContextHandlers.pm (revision 1333)
@@ -285,4 +285,5 @@
             AuthorNext => \&_hdlr_author_prev_next,
             AuthorPrevious => \&_hdlr_author_prev_next,
+            AuthorBasename => \&_hdlr_author_basename,
 
             BlogID => \&_hdlr_blog_id,
@@ -2366,7 +2367,7 @@
     }
     my %f = (
-        'a' => "<MTAuthorDisplayName $dir>",
-        '-a' => "<MTAuthorDisplayName dirify='-'>",
-        '_a' => "<MTAuthorDisplayName dirify='_'>",
+        'a' => "<MTAuthorBasename $dir>",
+        '-a' => "<MTAuthorBasename dirify='-'>",
+        '_a' => "<MTAuthorBasename dirify='_'>",
         'b' => "<MTEntryBasename $sep>",
         '-b' => "<MTEntryBasename separator='-'>",
@@ -3150,4 +3151,12 @@
     local $ctx->{__stash}{asset} = $asset;
     $builder->build($ctx, $tok, { %$cond });
+}
+
+sub _hdlr_author_basename {
+    my $author = $_[0]->stash('author')
+        or return $_[0]->_no_author_error('MTAuthorBasename');
+    my $name = $author->basename;
+    $name = MT::Util::make_unique_author_basename($author) if !$name;
+    return $name;
 }
 
Index: branches/release-29/lib/MT/Util.pm
===================================================================
--- branches/release-29/lib/MT/Util.pm (revision 1233)
+++ branches/release-29/lib/MT/Util.pm (revision 1333)
@@ -910,4 +910,23 @@
 }
 
+sub make_unique_author_basename {
+    my ($author) = @_;
+    my $name = MT::Util::dirify($author->nickname);
+    return "author" . $author->id if $name !~ /\w/;
+
+    my $limit = MT->instance->config('AuthorBasenameLimit');
+    $limit = 15 if $limit < 15; $limit = 250 if $limit > 250;
+    my $base = substr($name, 0, $limit);
+    $base =~ s/_+$//;
+    my $i = 1;
+    my $base_copy = $base;
+
+    my $author_class = ref $author;
+    while ($author_class->count({ basename => $base })) {
+        $base = $base_copy . '_' . $i++;
+    }
+    $base;
+}
+
 sub archive_file_for {
     MT->instance->publisher->archive_file_for(@_);
Index: branches/release-29/lib/MT/WeblogPublisher.pm
===================================================================
--- branches/release-29/lib/MT/WeblogPublisher.pm (revision 1254)
+++ branches/release-29/lib/MT/WeblogPublisher.pm (revision 1333)
@@ -2898,8 +2898,6 @@
     return "" unless $this_author;
 
-    my $name = dirify( $this_author->nickname );
-    $name = "author" . $this_author->id if $name !~ /\w/;
     if ( !$file_tmpl ) {
-        $file = sprintf( "%s/index", $name );
+        $file = sprintf( "%s/index", $this_author->basename );
     }
     $file;
