From 7d94bd592ab7d2876b0855d321995a557a9b1d5b Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Tue, 2 Oct 2018 18:38:28 -0700 Subject: [PATCH 1/7] Cut 0.8.0 --- docs/changelog.rst | 1 + 1 file changed, 1 insertion(+) 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. From 42fcaec692fbc42b1da3011a2cb3d62256c0045e Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Mon, 17 Dec 2018 16:07:44 +0100 Subject: [PATCH 2/7] Enable alabaster render Travis CI badges for .com Fixes #145 --- alabaster/__init__.py | 46 +++++++++++++++++++++++++++++++++++++++++++ alabaster/about.html | 11 +++-------- alabaster/theme.conf | 1 + 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/alabaster/__init__.py b/alabaster/__init__.py index c88b2b5..84161a9 100644 --- a/alabaster/__init__.py +++ b/alabaster/__init__.py @@ -1,5 +1,10 @@ import os +try: + import requests +except ImportError: + pass + from alabaster import _version as version @@ -14,6 +19,47 @@ 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"].lower() + if travis_button_enabled and travis_tld == "auto": + try: + travis_api_response = requests.get( + "https://api.travis-ci.com/repo/{}".format( + travis_slug.replace("/", "%2F") + ), + headers={ + "Travis-API-Version": "3", + "User-Agent": "Sphinx-Alabaster-Theme/{version} " + "(+https://github.com/bitprophet/alabaster)".format( + version=version.__version__ + ), + }, + ) + is_travis_com_repo = 200 <= travis_api_response.status_code < 300 + travis_tld = "com" if is_travis_com_repo else "org" + except NameError: + travis_tld = "com" + elif travis_tld != "com": + travis_tld = "org" + 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..b264ed4 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 From 78f11699cab12fa1f3f48f5f6e010fcc7aa612fd Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Mon, 17 Dec 2018 16:19:35 +0100 Subject: [PATCH 3/7] Show real alternative description on Travis badge --- alabaster/about.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alabaster/about.html b/alabaster/about.html index b264ed4..a271855 100644 --- a/alabaster/about.html +++ b/alabaster/about.html @@ -28,7 +28,7 @@

{{ project }}

{{ theme_travis_badge_url }} From 09125eb0937785f53187b4c6e31d12e35c67b585 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Thu, 20 Dec 2018 13:43:41 +0100 Subject: [PATCH 4/7] Strip dots around Travis CI TLD var value --- alabaster/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alabaster/__init__.py b/alabaster/__init__.py index 84161a9..2efe0ff 100644 --- a/alabaster/__init__.py +++ b/alabaster/__init__.py @@ -33,7 +33,7 @@ def set_up_travis_context(context): travis_slug = github_slug if travis_button_enabled else travis_button - travis_tld = context["theme_travis_tld"].lower() + travis_tld = context["theme_travis_tld"].strip('.').lower() if travis_button_enabled and travis_tld == "auto": try: travis_api_response = requests.get( From 9b756ef9b468094475f55ccf947cd6e6fc6d034b Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Thu, 20 Dec 2018 13:46:00 +0100 Subject: [PATCH 5/7] Rip off the Travis platform auto-detection logic --- alabaster/__init__.py | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/alabaster/__init__.py b/alabaster/__init__.py index 2efe0ff..45937ab 100644 --- a/alabaster/__init__.py +++ b/alabaster/__init__.py @@ -1,10 +1,5 @@ import os -try: - import requests -except ImportError: - pass - from alabaster import _version as version @@ -34,26 +29,6 @@ def set_up_travis_context(context): travis_slug = github_slug if travis_button_enabled else travis_button travis_tld = context["theme_travis_tld"].strip('.').lower() - if travis_button_enabled and travis_tld == "auto": - try: - travis_api_response = requests.get( - "https://api.travis-ci.com/repo/{}".format( - travis_slug.replace("/", "%2F") - ), - headers={ - "Travis-API-Version": "3", - "User-Agent": "Sphinx-Alabaster-Theme/{version} " - "(+https://github.com/bitprophet/alabaster)".format( - version=version.__version__ - ), - }, - ) - is_travis_com_repo = 200 <= travis_api_response.status_code < 300 - travis_tld = "com" if is_travis_com_repo else "org" - except NameError: - travis_tld = "com" - elif travis_tld != "com": - travis_tld = "org" 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( From 8c27091f16480959317edd3a537072843777525a Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Thu, 20 Dec 2018 13:54:12 +0100 Subject: [PATCH 6/7] Add notes about `travis_tld` theme option to docs --- docs/customization.rst | 3 +++ 1 file changed, 3 insertions(+) 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 --------------------------- From fefcf2cdf7c427e46527077bdee161847a6dd74e Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Thu, 20 Dec 2018 14:51:07 +0100 Subject: [PATCH 7/7] Change single quotes to double quotes --- alabaster/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alabaster/__init__.py b/alabaster/__init__.py index 45937ab..a24405d 100644 --- a/alabaster/__init__.py +++ b/alabaster/__init__.py @@ -28,7 +28,7 @@ def set_up_travis_context(context): travis_slug = github_slug if travis_button_enabled else travis_button - travis_tld = context["theme_travis_tld"].strip('.').lower() + 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(