mirror of
https://github.com/loot/loot.github.io.git
synced 2026-07-27 14:13:30 -07:00
Replace GitHub.js and tomlify-j0.4 dependencies
With the official GitHub JS client and @ltd/j-toml respectively. As part of this, turn the JS files into modules and load the dependencies from inside the modules.
This commit is contained in:
@@ -3,7 +3,7 @@ loot.github.io
|
||||
|
||||
This repository acts as the main LOOT team repository, and holds all the issues that aren't specific to the code or any one game. In addition to that, it also holds LOOT's static website.
|
||||
|
||||
The static website is a [Jekyll](https://jekyllrb.com/) site that uses [Material Design Lite](https://www.getmdl.io/) components and the [js-yaml](https://github.com/nodeca/js-yaml) and [Github.js](https://github.com/michael/github) libraries, which are provided by Google, Cloudflare and unpkg CDNs respectively.
|
||||
The static website is a [Jekyll](https://jekyllrb.com/) site that uses [Material Design Lite](https://www.getmdl.io/) components and the [js-yaml](https://github.com/nodeca/js-yaml), [Octokit.js](https://github.com/octokit/rest.js) and [j-toml](https://github.com/LongTengDao/j-toml) libraries, which are provided by Google, Cloudflare and Skypack CDNs.
|
||||
|
||||
The easiest way to build this site locally is using Docker:
|
||||
|
||||
|
||||
@@ -18,6 +18,4 @@ permalink: /convert-settings/
|
||||
|
||||
<p>Note that the download link that appears above after converting YAML does not work in Internet Explorer or Edge. Users of those browsers will need to copy the content of the TOML text box into a <code>settings.toml</code> file they create themselves, or use a different browser</code>.</p>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-yaml/4.1.0/js-yaml.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/tomlify-j0.4@3.0.0/tomlify.min.js"></script>
|
||||
<script src="/js/convert.js"></script>
|
||||
<script src="/js/convert.js" type="module"></script>
|
||||
|
||||
+1
-2
@@ -9,5 +9,4 @@ permalink: /credits/
|
||||
<div id="progress" class="mdl-spinner mdl-js-spinner mdl-spinner--single-color is-active"></div>
|
||||
</div>
|
||||
|
||||
<script src="https://unpkg.com/github-api@2.3.0/dist/GitHub.bundle.min.js"></script>
|
||||
<script src="/js/credits.js"></script>
|
||||
<script src="/js/credits.js" type="module"></script>
|
||||
|
||||
+6
-11
@@ -1,4 +1,6 @@
|
||||
'use strict';
|
||||
import { load } from 'https://cdnjs.cloudflare.com/ajax/libs/js-yaml/4.1.0/js-yaml.mjs';
|
||||
import TOML from 'https://cdn.skypack.dev/-/@ltd/j-toml@v1.33.3-g895G5Q2ba82bha6HlB9/dist=es2019,mode=imports/optimized/@ltd/j-toml.js';
|
||||
|
||||
function upgradeOldYaml(yaml) {
|
||||
if (yaml['Debug Verbosity'] && !yaml.enableDebugLogging) {
|
||||
@@ -37,20 +39,13 @@ function upgradeOldYaml(yaml) {
|
||||
|
||||
function yamlToToml(evt) {
|
||||
try {
|
||||
const settings = upgradeOldYaml(jsyaml.load(evt.target.value));
|
||||
const settings = upgradeOldYaml(load(evt.target.value));
|
||||
|
||||
const options = {
|
||||
space: 2,
|
||||
replace: function(key, value) {
|
||||
if (typeof value === 'number') {
|
||||
/* Settings only use integers, no floats. */
|
||||
return Math.round(value).toString();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
indent: 2,
|
||||
newline: '\n'
|
||||
}
|
||||
const toml = tomlify.toToml(settings, options);
|
||||
const toml = TOML.stringify(settings, options);
|
||||
|
||||
document.getElementById('output').value = toml;
|
||||
|
||||
|
||||
+24
-9
@@ -1,4 +1,6 @@
|
||||
'use strict';
|
||||
import { Octokit } from "https://cdn.skypack.dev/pin/@octokit/rest@v19.0.4-xPNRCbtf1MpCCpqHe5lx/mode=imports,min/optimized/@octokit/rest.js";
|
||||
import { throttling } from "https://cdn.skypack.dev/pin/@octokit/plugin-throttling@v4.2.0-q2ZrzGw3H4mnkheWbYZl/mode=imports,min/optimized/@octokit/plugin-throttling.js";
|
||||
|
||||
function addToList(listElement, person) {
|
||||
const a = document.createElement('a');
|
||||
@@ -45,12 +47,12 @@ function sortContributors(a,b) {
|
||||
}
|
||||
|
||||
function getStats(contributor) {
|
||||
const isAnon = contributor.author.type === 'Anonymous';
|
||||
const isAnon = contributor.type === 'Anonymous';
|
||||
return {
|
||||
contributions: contributor.total,
|
||||
name: isAnon ? contributor.author.name : contributor.author.login,
|
||||
avatar_url: isAnon ? undefined : contributor.author.avatar_url,
|
||||
html_url: isAnon ? 'mailto:' + contributor.author.email : contributor.author.html_url
|
||||
contributions: contributor.contributions,
|
||||
name: isAnon ? contributor.name : contributor.login,
|
||||
avatar_url: isAnon ? undefined : contributor.avatar_url,
|
||||
html_url: isAnon ? 'mailto:' + contributor.email : contributor.html_url
|
||||
};
|
||||
}
|
||||
|
||||
@@ -81,13 +83,26 @@ function getContributorsStats(contributors) {
|
||||
}
|
||||
|
||||
async function getContributors() {
|
||||
const github = new GitHub();
|
||||
const ThrottledOctokit = Octokit.plugin(throttling);
|
||||
|
||||
const reposResponse = await github.getOrganization('loot').getRepos();
|
||||
const octokit = new ThrottledOctokit({
|
||||
throttle: {
|
||||
onAbuseLimit: () => true,
|
||||
onRateLimit: () => true
|
||||
}
|
||||
});
|
||||
|
||||
const promises = reposResponse.data
|
||||
const repos = await octokit.paginate(octokit.rest.repos.listForOrg, {
|
||||
org: 'loot'
|
||||
});
|
||||
|
||||
const promises = repos
|
||||
.filter(repo => !repo.fork)
|
||||
.map(repo => github.getRepo('loot', repo.name).getContributors());
|
||||
.map(repo => octokit.paginate(octokit.rest.repos.listContributors, {
|
||||
owner: 'loot',
|
||||
repo: repo.name,
|
||||
anon: true
|
||||
}));
|
||||
|
||||
return Promise.all(promises).then(results => results.flat());
|
||||
}
|
||||
|
||||
+24
-7
@@ -1,4 +1,7 @@
|
||||
'use strict';
|
||||
import { Octokit } from 'https://cdn.skypack.dev/pin/@octokit/rest@v19.0.4-xPNRCbtf1MpCCpqHe5lx/mode=imports,min/optimized/@octokit/rest.js';
|
||||
import { throttling } from 'https://cdn.skypack.dev/pin/@octokit/plugin-throttling@v4.2.0-q2ZrzGw3H4mnkheWbYZl/mode=imports,min/optimized/@octokit/plugin-throttling.js';
|
||||
import { dump, load } from 'https://cdnjs.cloudflare.com/ajax/libs/js-yaml/4.1.0/js-yaml.mjs';
|
||||
|
||||
// Globals
|
||||
///////////////////
|
||||
@@ -76,13 +79,27 @@ function onSearchInit(evt) {
|
||||
console.log("Loading masterlist...");
|
||||
progress.classList.remove('hidden');
|
||||
|
||||
var repo = (new GitHub())
|
||||
.getRepo('loot', gameButton.getAttribute('data-selected'))
|
||||
.getContents(undefined, 'masterlist.yaml', true)
|
||||
.then(readMasterlist)
|
||||
.catch(function() {
|
||||
document.getElementById('progress').classList.add('hidden');
|
||||
});
|
||||
const ThrottledOctokit = Octokit.plugin(throttling);
|
||||
|
||||
const octokit = new ThrottledOctokit({
|
||||
throttle: {
|
||||
onAbuseLimit: () => true,
|
||||
onRateLimit: () => true
|
||||
}
|
||||
});
|
||||
|
||||
octokit.rest.repos.getContent({
|
||||
owner: 'loot',
|
||||
repo: gameButton.getAttribute('data-selected'),
|
||||
path: 'masterlist.yaml',
|
||||
mediaType: {
|
||||
format: 'raw'
|
||||
}
|
||||
})
|
||||
.then(readMasterlist)
|
||||
.catch(function() {
|
||||
document.getElementById('progress').classList.add('hidden');
|
||||
});
|
||||
}
|
||||
|
||||
function onGameSelect(evt) {
|
||||
|
||||
+1
-3
@@ -24,6 +24,4 @@ permalink: /search/
|
||||
<div id="progress" class="mdl-spinner mdl-js-spinner mdl-spinner--single-color is-active hidden"></div>
|
||||
<div id="results" class="mdl-shadow--2dp"></div>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-yaml/4.1.0/js-yaml.min.js"></script>
|
||||
<script src="https://unpkg.com/github-api@2.3.0/dist/GitHub.bundle.min.js"></script>
|
||||
<script src="/js/search.js"></script>
|
||||
<script src="/js/search.js" type="module"></script>
|
||||
|
||||
Reference in New Issue
Block a user