Skip to content

First stab at Trac 1.4 #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 49 additions & 37 deletions DjangoPlugin/tracdjangoplugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
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 CustomTheme(Component):
implements(IRequestFilter)

def pre_process_request(self, req, handler):
return handler

def post_process_request(self, req, template, data, metadata):
req.chrome["theme"] = "django_theme.html"
return template, data, metadata


class CustomWikiModule(WikiModule):
Expand All @@ -12,70 +25,69 @@ class CustomWikiModule(WikiModule):
"""

def get_active_navigation_item(self, req):
pagename = req.args.get('page')
if pagename == 'Reports':
return 'custom_reports'
return 'wiki'
pagename = req.args.get("page")
if pagename == "Reports":
return "custom_reports"
return "wiki"


class CustomNewTicket(Component):
"""Hide certain options for the new ticket page"""

implements(IRequestFilter, IRequestHandler)
hidden_fields = frozenset(['stage', 'needs_tests', 'needs_docs',
'needs_better_patch'])
hidden_fields = frozenset(
["stage", "needs_tests", "needs_docs", "needs_better_patch"]
)

def match_request(self, req):
return req.path_info == '/simpleticket'
return req.path_info == "/simpleticket"

def process_request(self, req):
req.redirect(req.href.newticket())

def pre_process_request(self, req, handler):
return handler

def post_process_request(self, req, template, data, content_type):
def post_process_request(self, req, template, data, metadata):
if data is None:
data = {}
if req.path_info == '/newticket' and not data.get('preview_mode', False):
simple_interface = 'TICKET_BATCH_MODIFY' not in req.perm
if simple_interface and 'fields' in data:
data['fields'] = [f for f in data['fields']
if f['name'] not in self.hidden_fields]
data['simple_interface'] = simple_interface
template = 'custom_ticket.html'
return template, data, content_type
if req.path_info == "/newticket" and not data.get("preview_mode", False):
simple_interface = "TICKET_BATCH_MODIFY" not in req.perm
if simple_interface and "fields" in data:
data["fields"] = [
f for f in data["fields"] if f["name"] not in self.hidden_fields
]
data["simple_interface"] = simple_interface
template = "custom_ticket.html"
return template, data, metadata


class CustomNavigationBar(Component):
"""Implements some more items for the navigation bar."""

implements(INavigationContributor)

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

def get_navigation_items(self, req):
return [
('mainnav', 'custom_reports', Markup('<a href="%s">Reports</a>' % req.href.wiki('Reports'))),
(
"mainnav",
"custom_reports",
Markup('<a href="%s">Reports</a>' % req.href.wiki("Reports")),
),
]


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)
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))
# Fallback to the default implemntation
return super(GitHubBrowserWithSVNChangesets, self)._format_changeset_link(
formatter, ns, chgset, label, fullmatch
)
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ that can help:
the database creation).
* Use ``trac-admin ./trac-env/ permission add anonymous TRAC_ADMIN``
to give all permissions to the anonymous user.
* Use the command ``tracd --port 9000 -s trac-env`` to serve Trac locally.
* Use the command ``DJANGO_SETTINGS_MODULE=tracdjangoplugin.settings TRAC_ENV=`pwd`/trac-env gunicorn tracdjangoplugin.wsgi:application --bind 0.0.0.0:9000 --workers=1 --reload`` to serve Trac locally.
* If you've modified the ``trackhack.scss`` file, use
``sassc scss/trachacks.scss trac-env/htdocs/css/trachacks.css -s compressed``
to compile it to CSS.
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Trac==1.2.6
Trac==1.4.3
Pygments==2.5.2
dnspython==1.15
spambayes == 1.1b1
Expand All @@ -9,7 +9,7 @@ libsass==0.17.0

# Trac plugins
TracSpamFilter==1.2.7
TracXMLRPC==1.1.9
https://trac-hacks.org/browser/xmlrpcplugin/trunk?rev=18227&format=zip

oauthlib==2.1.0
requests==2.20.1
Expand All @@ -19,4 +19,4 @@ trac-github==2.3
gunicorn==19.10.0
newrelic

-e ./DjangoPlugin
-e ./DjangoPlugin
20 changes: 20 additions & 0 deletions scss/trachacks.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,22 @@ a:link, a:visited {
}

h1, h2, h3, h4, h5, h6, span {
&.section {
color: inherit;
background: none;
}
&.section + * {
margin-top: unset !important;
}
&:target {
background: $green-very-light;
}
}

[role="main"] .section {
padding-bottom: unset;
}

.inlinebuttons {
input {
border-radius: 5px;
Expand All @@ -48,6 +59,14 @@ div.trac-content {
}
}

#content.narrow #wikipage {
max-width: none;
}

#trac-wiki-expander {
display: none;
}

.full-width [role="main"] {
max-width: 1400px;
}
Expand Down Expand Up @@ -252,6 +271,7 @@ div[role="main"]{
background: none;
@include sans-serif;
color: $green-dark;
text-transform: none;
}
&.first {
padding-left: 0;
Expand Down
2 changes: 1 addition & 1 deletion trac-env/conf/trac.ini
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ always_notify_reporter = TicketReporterSubscriber
[project]
descr = The Web framework for perfectionists with deadlines.
footer =
icon = /favicon.ico
icon = site/favicon.ico
name = Django
url = https://code.djangoproject.com/

Expand Down
12 changes: 0 additions & 12 deletions trac-env/htdocs/js/lib/jquery.inview.js

This file was deleted.

5 changes: 0 additions & 5 deletions trac-env/htdocs/js/lib/jquery.js

This file was deleted.

4 changes: 0 additions & 4 deletions trac-env/htdocs/js/lib/modernizr.js

This file was deleted.

Loading