Attachment 'CreateUserHomepage.py'

Download

   1 # -*- coding: iso-8859-1 -*-
   2 """
   3     MoinMoin - CreateUserHomepage
   4     
   5     Syntax:
   6        [[CreateUserHomepage]]
   7        Default text of the generated link for homepage ceration is "username"
   8 
   9        [[CreateUserHomepage(Link Text)]]
  10        Text of the generated link for homepage ceration is "Link Text"
  11 
  12     ToDo:
  13         Append "?action=edit&template=HomepageTemplate" as wikitail to force
  14         template usage for homepage creation. At least: create an option for that.
  15 
  16     CreateUserHomepage partly based on
  17     MoinMoin - Theme Package
  18     @copyright: 2003-2006 by MoinMoin:ThomasWaldmann
  19 
  20     MoinMoin - CreateUserHomepage
  21     @copyright: 2006 by Oliver Siemoneit
  22     @license: GNU GPL, see COPYING for details.
  23 """
  24 
  25 from MoinMoin import user, wikiutil
  26 
  27 def execute(macro, args):
  28     request = macro.request
  29     _ = request.getText
  30 
  31     if request.user.valid and request.user.name:
  32         interwiki = wikiutil.getInterwikiHomePage(request)
  33         name = request.user.name
  34         aliasname = request.user.aliasname
  35         if not aliasname:
  36             aliasname = name
  37         title = "%s @ %s" % (aliasname, interwiki[0])
  38         # link to (interwiki) user homepage
  39         if args is None:
  40             homelink = "%s%s%s" % (request.formatter.interwikilink(1, title=title, id="userhome", generated=True, *interwiki),
  41                         request.formatter.text(name),
  42                         request.formatter.interwikilink(0, title=title, id="userhome", *interwiki))
  43             return homelink
  44         else:
  45             homelink = "%s%s%s" % (request.formatter.interwikilink(1, title=title, id="userhome", generated=True, *interwiki),
  46                         request.formatter.text(args),
  47                         request.formatter.interwikilink(0, title=title, id="userhome", *interwiki))
  48             return homelink
  49     else:
  50         if args is None:
  51             return _('<unknown>')
  52         else:
  53             return args # or: "%s. %s" % (args, _('Please log in first'))

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2006-12-10 21:02:59, 1.9 KB) [[attachment:CreateUserHomepage.py]]
  • [get | view] (2006-12-10 16:08:04, 0.6 KB) [[attachment:CurrentUser.py]]
  • [get | view] (2006-12-10 16:09:19, 1.1 KB) [[attachment:MissingHomePage.txt]]
  • [get | view] (2007-01-18 20:32:31, 1.5 KB) [[attachment:ToggleWelcome.py]]
  • [get | view] (2007-01-08 16:09:44, 3.3 KB) [[attachment:User.py]]
  • [get | view] (2007-01-18 20:32:07, 2.1 KB) [[attachment:WelcomeUser.txt]]
  • [get | view] (2006-12-10 16:07:27, 0.8 KB) [[attachment:action__init__.diff]]
  • [get | view] (2006-12-10 16:07:10, 0.5 KB) [[attachment:multiconfig.diff]]
  • [get | view] (2007-01-18 20:31:25, 1.3 KB) [[attachment:request_init_.diff]]
  • [get | view] (2007-01-20 22:14:41, 1.2 KB) [[attachment:togglewelcome.py]]
  • [get | view] (2007-01-18 20:31:07, 0.7 KB) [[attachment:user.diff]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.