forked from jupyterhub/binderhub
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop using global variables in badge.js
Pathway towards making the functions more testable
- Loading branch information
Showing
2 changed files
with
19 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,16 @@ | ||
const BASE_URL = $("#base-url").data().url; | ||
const BADGE_BASE_URL = $('#badge-base-url').data().url; | ||
let badge_url; | ||
export function makeBadgeMarkup(badgeBaseUrl, baseUrl, url, syntax) { | ||
let badgeImageUrl; | ||
|
||
if (BADGE_BASE_URL) { | ||
badge_url = BADGE_BASE_URL + "badge_logo.svg"; | ||
} | ||
else { | ||
badge_url = window.location.origin + BASE_URL + "badge_logo.svg"; | ||
} | ||
if (badgeBaseUrl) { | ||
badgeImageUrl = badgeBaseUrl + "badge_logo.svg"; | ||
} else { | ||
badgeImageUrl = window.location.origin + baseUrl + "badge_logo.svg"; | ||
} | ||
|
||
export function markdownBadge(url) { | ||
// return markdown badge snippet | ||
return "[![Binder](" + badge_url + ")](" + url + ")"; | ||
} | ||
if (syntax === 'markdown') { | ||
return "[![Binder](" + badgeImageUrl + ")](" + url + ")"; | ||
} else if (syntax === 'rst') { | ||
return ".. image:: " + badgeImageUrl + "\n :target: " + url; | ||
|
||
export function rstBadge(url) { | ||
// return rst badge snippet | ||
return ".. image:: " + badge_url + "\n :target: " + url; | ||
} | ||
} |