Attachment 'supplementation_20061202_patch.txt'

Download

   1 # HG changeset patch
   2 # User ReimarBauer <R.Bauer@fz-juelich.de>
   3 # Date 1165053720 -3600
   4 # Node ID 7c291197f69538524c568a1c30dff4334cf59f77
   5 # Parent  a938bd2d6166d419dc01dafabcd7c9f0b1a73724
   6 supplementation page for discussion of a page added. controlled from wikiconfig with supplementation_page = True or a new pragma var from within a page '#pragma supplementation-page on'. No supplementation page on default.
   7 
   8 diff -r a938bd2d6166 -r 7c291197f695 MoinMoin/config/multiconfig.py
   9 --- a/MoinMoin/config/multiconfig.py	Fri Dec 01 19:53:43 2006 +0100
  10 +++ b/MoinMoin/config/multiconfig.py	Sat Dec 02 11:02:00 2006 +0100
  11 @@ -383,7 +383,9 @@ reStructuredText Quick Reference
  12      stylesheets = [] # list of tuples (media, csshref) to insert after theme css, before user css
  13      subscribed_pages_default = [] # preload user subscribed pages with this page list
  14      superuser = [] # list of unicode user names that have super powers :)
  15 -
  16 +    supplementation_page = False
  17 +    supplementation_page_name = u'Discussion'
  18 +    supplementation_page_template = u'DiscussionTemplate'
  19      surge_action_limits = {# allow max. <count> <action> requests per <dt> secs
  20          # action: (count, dt)
  21          'all': (30, 30),
  22 diff -r a938bd2d6166 -r 7c291197f695 MoinMoin/theme/__init__.py
  23 --- a/MoinMoin/theme/__init__.py	Fri Dec 01 19:53:43 2006 +0100
  24 +++ b/MoinMoin/theme/__init__.py	Sat Dec 02 11:02:00 2006 +0100
  25 @@ -1051,13 +1051,40 @@ actionsMenuInit('%(label)s');
  26          This is separate method to make it easy to customize the
  27          edtibar in sub classes.
  28          """
  29 -        return [self.editorLink(page),
  30 -                self.infoLink(page),
  31 -                self.subscribeLink(page),
  32 -                self.quicklinkLink(page),
  33 -                self.attachmentsLink(page),
  34 -                self.actionsMenu(page),
  35 -               ]
  36 +
  37 +        editbar_items = {'Edit': self.editorLink(page),
  38 +                          self.request.cfg.supplementation_page_name:
  39 +                          self.supplementation_page_nameLink(page),
  40 +                          'Info': self.infoLink(page),
  41 +                          'Subscribe': self.subscribeLink(page),
  42 +                          'Quicklink': self.quicklinkLink(page),
  43 +                          'Attachments': self.attachmentsLink(page),
  44 +                          'ActionsMenu': self.actionsMenu(page)
  45 +                          }
  46 +        edit_bar = [u'Edit', u'Info', u'Subscribe', u'Quicklink', u'Attachments', u'ActionsMenu', ]
  47 +        if self.request.cfg.supplementation_page == True:
  48 +            if self.request.getPragma('supplementation-page', 1) == 'off':
  49 +                edit_bar = edit_bar
  50 +            else:
  51 +                edit_bar.insert(1, self.request.cfg.supplementation_page_name)
  52 +        else:
  53 +            if self.request.getPragma('supplementation-page', 1) == 'on':
  54 +                edit_bar.insert(1, self.request.cfg.supplementation_page_name)
  55 +            else:
  56 +                edit_bar = edit_bar
  57 +
  58 +
  59 +        allowed_action = []
  60 +        for action in edit_bar:
  61 +            allowed_action.append(editbar_items[action])
  62 +        return allowed_action
  63 +
  64 +    def supplementation_page_nameLink(self, page):
  65 +        """  discussion for page """
  66 +        _ = self.request.getText
  67 +        return page.link_to(self.request,
  68 +                            text=_(self.request.cfg.supplementation_page_name, formatted=False),
  69 +                            querystr={'action': 'supplementation'}, id='supplementation', rel='nofollow')
  70  
  71      def guiworks(self, page):
  72          """ Return whether the gui editor / converter can work for that page.
  73 diff -r a938bd2d6166 -r 7c291197f695 MoinMoin/action/supplementation.py
  74 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
  75 +++ b/MoinMoin/action/supplementation.py	Sat Dec 02 11:02:00 2006 +0100
  76 @@ -0,0 +1,42 @@
  77 +"""
  78 +    MoinMoin - Action for supplementation pages
  79 +
  80 +    This Action is used to create a supplementation subpage e.g. a Discussion below a comon page
  81 +
  82 +    Install:
  83 +        put it into the 'action' directory and do create a supplementation Template e.g. DiscussionTemplate
  84 +        
  85 +    Note:
  86 +        derived from the newpage macro by Vito Miliano (vito_moinnewpagewithtemplate@perilith.com) et al
  87 +
  88 +    Modification History:
  89 +       2006-08-30 ReimarBauer initial version
  90 +                   
  91 +    License:
  92 +        @license: GNU GPL, see COPYING for details.  
  93 +        
  94 +"""
  95 +from MoinMoin.Page import Page
  96 +from MoinMoin.wikiutil import quoteWikinameURL
  97 +
  98 +def execute(pagename, request):
  99 +    _ = request.getText
 100 +    sub_page_name = request.cfg.supplementation_page_name
 101 +    sub_page_template = request.cfg.supplementation_page_template
 102 +    newpagename = "%s/%s" % (pagename, sub_page_name)
 103 +
 104 +    if pagename.endswith(sub_page_name): # sub_sub_page redirects to sub_page
 105 +        query = {}
 106 +        url = Page(request, pagename).url(request, query, escape=0, relative=False)
 107 +        request.http_redirect(url)
 108 +    elif request.user.may.read(newpagename) and request.user.may.write(newpagename):
 109 +       query = {}
 110 +       url = Page(request, newpagename).url(request, query, escape=0, relative=False)
 111 +       test = Page(request, newpagename)
 112 +       if test.exists(): # page is defined -> redirect
 113 +           request.http_redirect(url)
 114 +       else:  # page will be created from template
 115 +           query = {'action': 'edit', 'backto': newpagename}
 116 +           query['template'] = quoteWikinameURL(sub_page_template)
 117 +           url = Page(request, newpagename).url(request, query, escape=0, relative=False)
 118 +           request.http_redirect(url)

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-08-25 14:32:36, 1.5 KB) [[attachment:Discussion.py]]
  • [get | view] (2006-08-27 23:37:26, 5.6 KB) [[attachment:complete_discussion_patch.txt]]
  • [get | view] (2006-12-02 10:28:16, 3.7 KB) [[attachment:edit_bar.png]]
  • [get | view] (2007-01-10 20:46:57, 0.6 KB) [[attachment:editsupplementation.py]]
  • [get | view] (2006-08-26 16:54:52, 23.9 KB) [[attachment:proposal_buttom.png]]
  • [get | view] (2006-08-26 16:55:05, 21.2 KB) [[attachment:proposal_item.png]]
  • [get | view] (2006-08-26 16:55:18, 103.4 KB) [[attachment:proposal_menu.png]]
  • [get | view] (2006-08-26 16:55:29, 20.9 KB) [[attachment:proposal_tab.png]]
  • [get | view] (2007-01-10 20:46:43, 2.1 KB) [[attachment:supplementation.py]]
  • [get | view] (2006-12-02 10:11:48, 5.5 KB) [[attachment:supplementation_20061202_patch.txt]]
  • [get | view] (2006-08-31 11:03:34, 5.8 KB) [[attachment:supplementation_page_patch.txt]]
  • [get | view] (2007-01-10 20:48:51, 0.9 KB) [[attachment:theme_patch.txt]]
 All files | Selected Files: delete move to page copy to page

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