Skip to content

Commit

Permalink
Removed genshi usage from our trac plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
apollo13 authored and felixxm committed Jan 22, 2024
1 parent 17aac30 commit 4221609
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions DjangoPlugin/tracdjangoplugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from trac.web.api import IRequestFilter, IRequestHandler
from trac.wiki.web_ui import WikiModule
from trac.util import Markup
from trac.util.html import tag
from tracext.github import GitHubBrowser


class CustomWikiModule(WikiModule):
Expand Down Expand Up @@ -55,7 +57,7 @@ class CustomNavigationBar(Component):
implements(INavigationContributor)

def get_active_navigation_item(self, req):
return ""
return "custom_reports"

def get_navigation_items(self, req):
return [
Expand All @@ -67,22 +69,14 @@ def get_navigation_items(self, req):
]


try:
# Provided by https://github.com/aaugustin/trac-github
from tracext.github import GitHubBrowser
except ImportError:
pass
else:
from genshi.builder import tag

class GitHubBrowserWithSVNChangesets(GitHubBrowser):
def _format_changeset_link(self, formatter, ns, chgset, label, fullmatch=None):
# Dead-simple version for SVN changesets
if chgset.isnumeric():
href = formatter.href.changeset(chgset, None, "/")
return tag.a(label, class_="changeset", href=href)

# Fallback to the default implemntation
return super(GitHubBrowserWithSVNChangesets, self)._format_changeset_link(
formatter, ns, chgset, label, fullmatch
)
class GitHubBrowserWithSVNChangesets(GitHubBrowser):
def _format_changeset_link(self, formatter, ns, chgset, label, fullmatch=None):
# Dead-simple version for SVN changesets.
if chgset.isnumeric():
href = formatter.href.changeset(chgset, None, "/")
return tag.a(label, class_="changeset", href=href)

# Fallback to the default implementation.
return super(GitHubBrowserWithSVNChangesets, self)._format_changeset_link(
formatter, ns, chgset, label, fullmatch
)

0 comments on commit 4221609

Please sign in to comment.