Attachment 'supplementation_page_patch.txt'

Download

   1 # HG changeset patch
   2 # User ReimarBauer <R.Bauer@fz-juelich.de>
   3 # Node ID 8b0a29e34f949b36c6ac0bf45f83d1cf81d1f3a6
   4 # Parent  b3a47164c22a16a37bb097a78e03342ecacf4d3b
   5 Feature for a suplementation page e.g. Discussion added, default editbar is [u'Edit', u'Info', u'Subscribe', u'Quicklink', u'Attachments', u'ActionsMenu', ] This feature could be enabled by adding the supplementation_page_name to this var. On default it is named Discussion. To change it you need to set 
   6 supplementation_page_name = u'Comment'
   7 supplementation_page_template = u'CommentTemplate'
   8 edit_bar = [u'Edit', u'Info', u'Subscribe', u'Quicklink', u'Attachments', supplementation_page_name, u'ActionsMenu', ]
   9 
  10 diff -r b3a47164c22a -r 8b0a29e34f94 MoinMoin/config/multiconfig.py
  11 --- a/MoinMoin/config/multiconfig.py	Tue Aug 29 17:01:55 2006 +0200
  12 +++ b/MoinMoin/config/multiconfig.py	Thu Aug 31 13:01:16 2006 +0200
  13 @@ -235,7 +235,9 @@ class DefaultConfig:
  14  
  15      default_markup = 'wiki'
  16      docbook_html_dir = r"/usr/share/xml/docbook/stylesheet/nwalsh/html/" # correct for debian sarge
  17 -
  18 +    
  19 +    edit_bar = [u'Edit', u'Info', u'Subscribe', u'Quicklink', u'Attachments', u'ActionsMenu', ]
  20 +    
  21      editor_default = 'text' # which editor is called when nothing is specified
  22      editor_ui = 'freechoice' # which editor links are shown on user interface
  23      editor_force = False
  24 @@ -372,6 +374,9 @@ reStructuredText Quick Reference
  25      siteid = 'default'
  26      stylesheets = [] # list of tuples (media, csshref) to insert after theme css, before user css
  27      superuser = [] # list of unicode user names that have super powers :)
  28 +    
  29 +    supplementation_page_name = u'Discussion'
  30 +    supplementation_page_template = u'DiscussionTemplate'
  31  
  32      surge_action_limits = {# allow max. <count> <action> requests per <dt> secs
  33          # action: (count, dt)
  34 diff -r b3a47164c22a -r 8b0a29e34f94 MoinMoin/theme/__init__.py
  35 --- a/MoinMoin/theme/__init__.py	Tue Aug 29 17:01:55 2006 +0200
  36 +++ b/MoinMoin/theme/__init__.py	Thu Aug 31 13:01:16 2006 +0200
  37 @@ -1027,13 +1027,19 @@ actionsMenuInit('%(label)s');
  38          This is separate method to make it easy to customize the
  39          edtibar in sub classes.
  40          """
  41 -        return [self.editorLink(page),
  42 -                self.infoLink(page),
  43 -                self.subscribeLink(page),
  44 -                self.quicklinkLink(page),
  45 -                self.attachmentsLink(page),
  46 -                self.actionsMenu(page),
  47 -               ]
  48 +        editbar_items = {'Edit': self.editorLink(page),
  49 +                        'Info': self.infoLink(page),
  50 +                        'Subscribe': self.subscribeLink(page),
  51 +                        'Quicklink': self.quicklinkLink(page),
  52 +                        'Attachments': self.attachmentsLink(page),
  53 +                        self.request.cfg.supplementation_page_name: self.supplementation_page_nameLink(page),
  54 +                        'ActionsMenu': self.actionsMenu(page)}
  55 +
  56 +        allowed_action = []
  57 +        for action in self.request.cfg.edit_bar:
  58 +            allowed_action.append(editbar_items[action])
  59 +        return allowed_action
  60 +
  61  
  62      def guiworks(self, page):
  63          """ Return whether the gui editor / converter can work for that page.
  64 @@ -1118,6 +1124,13 @@ var gui_editor_link_text = "%(text)s";
  65          return page.link_to(self.request,
  66                              text=_('Info', formatted=False),
  67                              querystr={'action': 'info'}, id='info', rel='nofollow')
  68 +
  69 +    def supplementation_page_nameLink(self, page):
  70 +        """  discussion for page """
  71 +        _ = self.request.getText
  72 +        return page.link_to(self.request,
  73 +                            text=_(self.request.cfg.supplementation_page_name, formatted=False),
  74 +                            querystr={'action': 'supplementation'}, id='supplementation', rel='nofollow')
  75  
  76      def subscribeLink(self, page):
  77          """ Return subscribe/unsubscribe link to valid users
  78 diff -r b3a47164c22a -r 8b0a29e34f94 MoinMoin/action/supplementation.py
  79 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
  80 +++ b/MoinMoin/action/supplementation.py	Thu Aug 31 13:01:16 2006 +0200
  81 @@ -0,0 +1,42 @@
  82 +"""
  83 +    MoinMoin - Action for supplementation pages
  84 +
  85 +    This Action is used to create a supplementation subpage e.g. a Discussion below a comon page
  86 +
  87 +    Install:
  88 +        put it into the 'action' directory and do create a supplementation Template e.g. DiscussionTemplate
  89 +        
  90 +    Note:
  91 +        derived from the newpage macro by Vito Miliano (vito_moinnewpagewithtemplate@perilith.com) et al
  92 +
  93 +    Modification History:
  94 +       2006-08-30 ReimarBauer initial version
  95 +                   
  96 +    License:
  97 +        @license: GNU GPL, see COPYING for details.  
  98 +        
  99 +"""
 100 +from MoinMoin.Page import Page
 101 +from MoinMoin.wikiutil import quoteWikinameURL
 102 +
 103 +def execute(pagename, request):
 104 +    _ = request.getText
 105 +    sub_page_name = request.cfg.supplementation_page_name
 106 +    sub_page_template = request.cfg.supplementation_page_template
 107 +    newpagename = "%s/%s" % (pagename, sub_page_name)
 108 +
 109 +    if pagename.endswith(sub_page_name): # sub_sub_page redirects to sub_page
 110 +        query = {}
 111 +        url = Page(request, pagename).url(request, query, escape=0, relative=False)
 112 +        request.http_redirect(url)
 113 +    elif request.user.may.read(newpagename) and request.user.may.write(newpagename):
 114 +       query = {}
 115 +       url = Page(request, newpagename).url(request, query, escape=0, relative=False)
 116 +       test = Page(request, newpagename)
 117 +       if test.exists(): # page is defined -> redirect
 118 +           request.http_redirect(url)
 119 +       else:  # page will be created from template
 120 +           query = {'action': 'edit', 'backto': newpagename}
 121 +           query['template'] = quoteWikinameURL(sub_page_template)
 122 +           url = Page(request, newpagename).url(request, query, escape=0, relative=False)
 123 +           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.