You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bloodhound.apache.org by pe...@apache.org on 2012/12/09 10:40:49 UTC
svn commit: r1418864 - in /incubator/bloodhound/trunk:
bloodhound_dashboard/bhdashboard/admin.py
bloodhound_dashboard/bhdashboard/wiki.py bloodhound_theme/bhtheme/theme.py
Author: peter
Date: Sun Dec 9 09:40:48 2012
New Revision: 1418864
URL: http://svn.apache.org/viewvc?rev=1418864&view=rev
Log:
#270 - Whitelabeling/detracify: Fix UI wiki documentation links
- Fix wiki guide links to point directly to renamed pages if they exist
Modified:
incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/admin.py
incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/wiki.py
incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py
Modified: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/admin.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/admin.py?rev=1418864&r1=1418863&r2=1418864&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/admin.py (original)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/admin.py Sun Dec 9 09:40:48 2012
@@ -31,15 +31,12 @@ from trac.util.text import printout
from trac.util.translation import _
from trac.wiki.admin import WikiAdmin
from trac.wiki.model import WikiPage
-
-GUIDE_NAME = 'Guide'
+from bhdashboard import wiki
class BloodhoundAdmin(Component):
"""Bloodhound administration commands.
"""
- RENAME_MAP = {'TracGuide': GUIDE_NAME + '/Index',}
-
implements(IAdminCommandProvider)
# IAdminCommandProvider methods
@@ -47,21 +44,19 @@ class BloodhoundAdmin(Component):
"""List available commands.
"""
yield ('wiki bh-upgrade', '',
- 'Move Trac* wiki pages to %s/*' % GUIDE_NAME,
+ 'Move Trac* wiki pages to %s/*' % wiki.GUIDE_NAME,
None, self._do_wiki_upgrade)
def _do_wiki_upgrade(self):
"""Move all wiki pages starting with Trac prefix to unbranded user
guide pages.
"""
- get_new_name = self.RENAME_MAP.get
wiki_admin = WikiAdmin(self.env)
pages = wiki_admin.get_wiki_list()
for old_name in pages:
if old_name.startswith('Trac'):
- new_name = get_new_name(old_name,
- GUIDE_NAME + '/' + old_name[4:])
+ new_name = wiki.new_name(old_name)
if not new_name:
continue
if new_name in pages:
Modified: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/wiki.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/wiki.py?rev=1418864&r1=1418863&r2=1418864&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/wiki.py (original)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/wiki.py Sun Dec 9 09:40:48 2012
@@ -34,6 +34,15 @@ from trac.wiki.macros import WikiMacroBa
from bhdashboard.web_ui import DashboardChrome, DashboardModule
+GUIDE_NAME = 'Guide'
+RENAME_MAP = {'TracGuide': GUIDE_NAME + '/Index',}
+
+def new_name(name, force=False):
+ if name.startswith('Trac'):
+ return RENAME_MAP.get(name, GUIDE_NAME + '/' + name[4:])
+ else:
+ return name
+
class WidgetMacro(WikiMacroBase):
"""Embed Bloodhound widgets using WikiFormatting.
"""
Modified: incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py?rev=1418864&r1=1418863&r2=1418864&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py (original)
+++ incubator/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py Sun Dec 9 09:40:48 2012
@@ -32,11 +32,13 @@ from trac.versioncontrol.web_ui.browser
from trac.web.api import IRequestFilter, IRequestHandler, ITemplateStreamFilter
from trac.web.chrome import (add_script, add_stylesheet, INavigationContributor,
ITemplateProvider, prevnext_nav)
+from trac.wiki.admin import WikiAdmin
from themeengine.api import ThemeBase, ThemeEngineSystem
from bhdashboard.util import dummy_request
from bhdashboard.web_ui import DashboardModule
+from bhdashboard import wiki
from pkg_resources import get_distribution
from urlparse import urlparse
@@ -115,6 +117,8 @@ class BloodhoundTheme(ThemeBase):
['table', 'table-condensed']),
)
+ _wiki_pages = None
+
implements(IRequestFilter, INavigationContributor, ITemplateProvider,
ITemplateStreamFilter)
@@ -162,6 +166,24 @@ class BloodhoundTheme(ThemeBase):
footer_right = c.get(
'labels', 'footer_right', ""),
application_version = ".".join(map(str, application_version)))
+
+ def hwiki(*args, **kw):
+
+ def new_name(name):
+ new_name = wiki.new_name(name)
+ if new_name != name:
+ if not self._wiki_pages:
+ wiki_admin = WikiAdmin(self.env)
+ self._wiki_pages = wiki_admin.get_wiki_list()
+ if new_name in self._wiki_pages:
+ return new_name
+ return name
+
+ a = tuple([new_name(x) for x in args])
+ return req.href.__call__("wiki", *a)
+
+ req.href.wiki = hwiki
+
return handler
def post_process_request(self, req, template, data, content_type):