diff --git a/alabaster/__init__.py b/alabaster/__init__.py index c88b2b5..a24405d 100644 --- a/alabaster/__init__.py +++ b/alabaster/__init__.py @@ -14,6 +14,27 @@ def get_path(): def update_context(app, pagename, templatename, context, doctree): context["alabaster_version"] = version.__version__ + set_up_travis_context(context) + + +def set_up_travis_context(context): + """Add complete Travis URLs to Jinja2 context.""" + github_slug = "/".join( + (context["theme_github_user"], context["theme_github_repo"]) + ) + + travis_button = str(context["theme_travis_button"]).lower() + travis_button_enabled = travis_button == "true" + + travis_slug = github_slug if travis_button_enabled else travis_button + + travis_tld = context["theme_travis_tld"].strip(".").lower() + travis_base_uri = "travis-ci.{}/{}".format(travis_tld, travis_slug) + context["theme_travis_build_url"] = "https://{}".format(travis_base_uri) + context["theme_travis_badge_url"] = "https://api.{}.svg?branch={}".format( + travis_base_uri, context["theme_badge_branch"] + ) + def setup(app): # add_html_theme is new in Sphinx 1.6+ diff --git a/alabaster/about.html b/alabaster/about.html index dbb4262..a271855 100644 --- a/alabaster/about.html +++ b/alabaster/about.html @@ -25,16 +25,11 @@

{{ project }}

{% endif %} {% if theme_travis_button|lower != 'false' %} -{% if theme_travis_button|lower == 'true' %} - {% set path = theme_github_user + '/' + theme_github_repo %} -{% else %} - {% set path = theme_travis_button %} -{% endif %}

- + https://secure.travis-ci.org/{{ path }}.svg?branch={{ theme_badge_branch }}

diff --git a/alabaster/theme.conf b/alabaster/theme.conf index b6cdc8d..c810c69 100644 --- a/alabaster/theme.conf +++ b/alabaster/theme.conf @@ -39,6 +39,7 @@ sidebar_width = 220px tidelift_url = touch_icon = travis_button = false +travis_tld = org gray_1 = #444 gray_2 = #EEE diff --git a/docs/changelog.rst b/docs/changelog.rst index e1e0c2e..5f14e3e 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -2,6 +2,7 @@ Changelog ========= +- :release:`0.7.12 <2018-10-02>` - :bug:`-` On some browsers/platforms, 'badge'-style sidebar elements were displaying dotted underlines. This was unintentional and explicit styling has been added to remove them. Credit to Steven Loria. diff --git a/docs/customization.rst b/docs/customization.rst index 11c245f..3a725f9 100644 --- a/docs/customization.rst +++ b/docs/customization.rst @@ -153,6 +153,9 @@ banners. string - used to display a `Travis-CI `_ build status button in the sidebar. If ``true``, uses your ``github_(user|repo)`` settings. +* ``travis_tld``: ``com`` or ``org`` (default). If ``com``, the badge points + to the new `travis-ci.com `_ platform, and points to + `travis-ci.org `_ otherwise. Non-service sidebar control ---------------------------