Skip to content

Commit

Permalink
Gist-raw-links: Always provide newest version url. Fixes #18
Browse files Browse the repository at this point in the history
  • Loading branch information
Mottie committed May 20, 2017
1 parent a54ba4e commit c2c1a75
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions gist-raw-links.user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name Gist Raw Links
// @version 0.1.2
// @version 0.1.3
// @description Add a button that contains a list of gist raw file links
// @license MIT
// @author Rob Garrison
Expand Down Expand Up @@ -56,6 +56,21 @@
}
}

function addList(link, files) {
let url,
html = "";
Object.keys(files).forEach(file => {
// remove version sha from raw_url to always point at
// the latest version of the file - see #18
url = files[file].raw_url.replace(/raw\/\w+\//, "raw/");
html += `
<a class="dropdown-item ghrl-file" href="${url}">
${file}
</a>`;
});
$(".ghrl-files", link.parentNode).innerHTML = html;
}

function loadFileList(link) {
let url,
el = closest(".dropdown", link);
Expand All @@ -81,17 +96,6 @@
}
}

function addList(link, files) {
let html = "";
Object.keys(files).forEach(file => {
html += `
<a class="dropdown-item ghrl-file" href="${files[file].raw_url}">
${file}
</a>`;
});
$(".ghrl-files", link.parentNode).innerHTML = html;
}

function removeBackdrop(event) {
event.preventDefault();
const el = $(".modal-backdrop");
Expand Down

0 comments on commit c2c1a75

Please sign in to comment.