Skip to content
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

Use Font Awesome to provide a cute icon #129

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
18 changes: 15 additions & 3 deletions tracext/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from trac.versioncontrol.web_ui.changeset import ChangesetModule
from trac.web.api import IRequestHandler, RequestDone
from trac.web.auth import LoginModule
from trac.web.chrome import add_warning
from trac.web.chrome import add_warning, add_script
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Order of these should be switched per PEP8. No need to recreate pull request, I'll make the change before merging.


def _config_secret(value):
if re.match(r'[A-Z_]+', value):
Expand Down Expand Up @@ -68,6 +68,13 @@ class GitHubLoginModule(LoginModule):
'github', 'preferred_email_domain', '',
doc="Prefer email address under this domain over the primary address.")

fontawesome_url = Option(
'github', 'fontawesome_url',
'https://use.fontawesome.com/releases/v5.0.7/js/all.js',
doc='This plugin uses Font Awesome to provide the GitHub icon. '
'Set the URL to the FA JavaScript to use here, or set to empty '
'to disable the icon altogether.')

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change comment to:

Add a GitHub icon to the login/logout button. The icon is enabled by specifying the path to the Font Awesome script. Set the value to empty to remove the icon.

# INavigationContributor methods

def get_active_navigation_item(self, req):
Expand All @@ -90,9 +97,14 @@ def get_navigation_items(self, req):
action=logout_href, method='post', id='logout',
class_='trac-logout'))
else:
text = _('GitHub Login')
if self.fontawesome_url:
add_script(req, self.fontawesome_url)
text = tag(tag.i(class_='fab fa-github-alt'), ' ', text)

yield ('metanav', 'github_login',
tag.a(_('GitHub Login'),
href=req.href('%s/login' % self.auth_path_prefix)))
tag.a(text, href=req.href('%s/login' %
self.auth_path_prefix)))

# IRequestHandler methods

Expand Down