Edgewall Software

Opened 13 years ago

Closed 6 years ago

Last modified 3 years ago

#9487 closed enhancement (fixed)

Control the default wiki page through trac.ini

Reported by: a-h Owned by: Ryan J Ollos
Priority: normal Milestone: 1.3.2
Component: wiki system Version: 0.12
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:

Extracted variables in WikiModule for the start page and title index page, so they can be overridden by a plugin.

Internal Changes:

Description (last modified by Remy Blank)


Here's a way to change the default wiki page:

  • web_ui.

    old new  
    108108    def process_request(self, req):
    109109        action = req.args.get('action', 'view')
    110         pagename = req.args.get('page', 'WikiStart')
     110        pagename = req.args.get('page',
     111                                self.env.config['wiki'].get('default_page')
     112                                    or 'WikiStart')
    111113        version = req.args.get('version')
    112114        old_version = req.args.get('old_version')

Attachments (0)

Change History (13)

comment:1 by Remy Blank, 13 years ago

Description: modified (diff)
Milestone: unscheduled

Unfortunately, it's not quite that simple. The name "WikiStart" is hard-coded at various locations, e.g. for re-directing after deleting a page. I think there was even a more complete patch for this, but my search-fu seems to be severely lacking lately. I thought it was part of #1106, but no luck.

comment:2 by Peter Suter, 6 years ago

Possible duplicate of #5319.

comment:3 by Peter Suter, 6 years ago

And #10595 which has an attached patch.

comment:4 by Ryan J Ollos, 6 years ago

Closed #10595 as a duplicate. This ticket, if implemented, can also make customizable the location pointed to be TitleIndex.

comment:5 by Ryan J Ollos, 6 years ago

Milestone: unscheduled1.3.2
Owner: set to Ryan J Ollos
Status: newassigned

Since this is probably rarely customized, we could just extract variables like we did for default_tracker (comment:1:ticket:10898): [98dd2d30/rjollos.git].

# -*- coding: utf-8 -*-

from trac.wiki import web_ui

web_ui.WikiModule.START_PAGE = 'Trac/WikiStart'
web_ui.WikiModule.TITLE_INDEX = 'Trac/TitleIndex'

comment:6 by Ryan J Ollos, 6 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed to trunk in r15818.

comment:7 by Jun Omae, 6 years ago

At least, WikiStart is still remained at two locations:

mirror/trunk:trac/wiki/api.py:        pagename = pagename.rstrip('/') or 'WikiStart'
mirror/trunk:trac/wiki/templates/wiki_page_path.html:<a class="pathentry first" title="${_('View WikiStart')}"
$ git grep -w WikiStart mirror/trunk -- '*.py' '*.html' | egrep -v '/test(\.py|s/)'
mirror/trunk:contrib/checkwiki.py:            if name in ('SandBox', 'TitleIndex', 'WikiStart'):
mirror/trunk:contrib/help_guide_version_notice.py:                               'TitleIndex, SandBox, WikiStart',
mirror/trunk:trac/mimeview/api.py:        >>> context = RenderingContext('wiki', 'WikiStart')
mirror/trunk:trac/perm.py:        'WIKI_MODIFY' in perm('wiki', 'WikiStart')
mirror/trunk:trac/perm.py:        perm('wiki', 'WikiStart').require('WIKI_MODIFY')
mirror/trunk:trac/resource.py:        >>> main = Resource('wiki', 'WikiStart')
mirror/trunk:trac/resource.py:        "<Resource u'wiki:WikiStart'>"
mirror/trunk:trac/resource.py:        "<Resource u'wiki:WikiStart@3'>"
mirror/trunk:trac/resource.py:        "<Resource u'wiki:WikiStart@0'>"
mirror/trunk:trac/web/chrome.py:        The following example renames the link to WikiStart to //Home//,
mirror/trunk:trac/wiki/admin.py:                        ignore=['WikiStart'], create_only=['InterMapTxt'])
mirror/trunk:trac/wiki/api.py:        pagename = pagename.rstrip('/') or 'WikiStart'
mirror/trunk:trac/wiki/api.py:        >>> main = Resource('wiki', 'WikiStart')
mirror/trunk:trac/wiki/api.py:        'WikiStart'
mirror/trunk:trac/wiki/api.py:        'WikiStart'
mirror/trunk:trac/wiki/api.py:        'WikiStart'
mirror/trunk:trac/wiki/api.py:        >>> resource_exists(env, Resource('wiki', 'WikiStart'))
mirror/trunk:trac/wiki/api.py:        >>> main = WikiPage(env, 'WikiStart')
mirror/trunk:trac/wiki/templates/wiki_page_path.html:<a class="pathentry first" title="${_('View WikiStart')}"
mirror/trunk:trac/wiki/web_ui.py:    START_PAGE = 'WikiStart'
mirror/trunk:tracopt/perm/authz_policy.py:       Example: Match the WikiStart page::
mirror/trunk:tracopt/perm/authz_policy.py:         [wiki:WikiStart*]
mirror/trunk:tracopt/perm/authz_policy.py:         [wiki:WikiStart@*]
mirror/trunk:tracopt/perm/authz_policy.py:         [wiki:WikiStart]
mirror/trunk:tracopt/perm/authz_policy.py:       ``wiki:WikiStart@117/attachment/FOO.JPG@*`` on WikiStart::
mirror/trunk:tracopt/perm/authz_policy.py:         [wiki:WikiStart*]
mirror/trunk:tracopt/perm/authz_policy.py:         [wiki:WikiStart@*]
mirror/trunk:tracopt/perm/authz_policy.py:         [wiki:WikiStart@*/attachment/*]
mirror/trunk:tracopt/perm/authz_policy.py:         [wiki:WikiStart@117/attachment/FOO.JPG]
mirror/trunk:tracopt/perm/authz_policy.py:      [wiki:WikiStart@*]

comment:8 by Ryan J Ollos, 6 years ago

Resolution: fixed
Status: closedreopened

comment:9 by Ryan J Ollos, 6 years ago

Additional changes in [6c805489/rjollos.git].

comment:10 by Jun Omae, 6 years ago

IMO, I'd like to avoid to set values to class attribute in instance method __init__. How about using property() like this?

  • trac/wiki/web_ui.py

    diff --git a/trac/wiki/web_ui.py b/trac/wiki/web_ui.py
    index b1bcbf61b..266144cbb 100644
    a b class WikiModule(Component):  
    6262        """Default height of the textarea on the wiki edit page.
    6363        (//Since 1.1.5//)""")
    65     START_PAGE = None
    66     TITLE_INDEX_PAGE = None
     65    START_PAGE = property(lambda self: WikiSystem.START_PAGE)
     66    TITLE_INDEX_PAGE = property(lambda self: WikiSystem.TITLE_INDEX_PAGE)
    6767    PAGE_TEMPLATES_PREFIX = 'PageTemplates/'
    6868    DEFAULT_PAGE_TEMPLATE = 'DefaultPage'
    70     def __init__(self):
    71         self.__class__.START_PAGE = WikiSystem.START_PAGE
    72         self.__class__.TITLE_INDEX_PAGE = WikiSystem.TITLE_INDEX_PAGE
    7470    # IContentConverter methods
    7672    def get_supported_conversions(self):

comment:11 by Ryan J Ollos, 6 years ago

Resolution: fixed
Status: reopenedclosed

That looks good. Committed to trunk in r15822.

Revised plugin is:

# -*- coding: utf-8 -*-

from trac.wiki import api

api.WikiSystem.START_PAGE = 'Trac/WikiStart'
api.WikiSystem.TITLE_INDEX_PAGE = 'Trac/TitleIndex'

comment:12 by Ryan J Ollos, 6 years ago

Related, there are no permission checks done before adding the contextual navigation items: tags/trac-1.2.1/trac/wiki/web_ui.py@:728,729#L726. Fixed on 1.2-stable in r15851, merged to trunk in r15852.

comment:13 by Ryan J Ollos, 3 years ago

API Changes: modified (diff)
Release Notes: modified (diff)

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.