Added .editorconfig

Use tab instead of spaces
This commit is contained in:
mxdanger 2022-05-04 14:37:47 -07:00
parent 8dc6914f4b
commit d90c269179
4 changed files with 206 additions and 197 deletions

9
.editorconfig Normal file
View File

@ -0,0 +1,9 @@
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = tab
indent_size = tab
tab_size = 4

View File

@ -1,6 +1,6 @@
[build] [build]
publish = "dist/" publish = "dist/"
command = "FILE=tools/ci/build-prod.sh; rm -rf dist/; if [ -f $FILE ]; then bash $FILE; else cp -r web/ dist/; fi" command = "FILE=tools/ci/build-prod.sh; rm -rf dist/; if [ -f $FILE ]; then bash $FILE; else cp -r web/ dist/; fi"
[build.environment] [build.environment]
PYTHON_VERSION = "3.8" PYTHON_VERSION = "3.8"

View File

@ -14,187 +14,187 @@
*/ */
function createInfoBlock(entry, isPreview) { function createInfoBlock(entry, isPreview) {
function createLabel(name, value, parent) { function createLabel(name, value, parent) {
const nameElement = document.createElement("span"); const nameElement = document.createElement("span");
nameElement.className = "fw-bold"; nameElement.className = "fw-bold";
nameElement.textContent = name; nameElement.textContent = name;
const valueElement = document.createElement("span"); const valueElement = document.createElement("span");
valueElement.textContent = value; valueElement.textContent = value;
parent.appendChild(nameElement); parent.appendChild(nameElement);
parent.appendChild(valueElement); parent.appendChild(valueElement);
return parent; return parent;
} }
function createInfoListItem(name, value) { function createInfoListItem(name, value) {
const entryInfoListElement = document.createElement("li"); const entryInfoListElement = document.createElement("li");
entryInfoListElement.className = "list-group-item"; entryInfoListElement.className = "list-group-item";
createLabel(name, value, entryInfoListElement); createLabel(name, value, entryInfoListElement);
return entryInfoListElement; return entryInfoListElement;
} }
const element = document.createElement("div"); const element = document.createElement("div");
element.className = "card mb-2 overflow-hidden shadow"; element.className = "card mb-2 overflow-hidden shadow";
const headerElement = document.createElement("h4"); const headerElement = document.createElement("h4");
headerElement.className = "card-header"; headerElement.className = "card-header";
const linkElement = document.createElement("a"); const linkElement = document.createElement("a");
linkElement.className = "text-decoration-none d-flex justify-content-between text-body"; linkElement.className = "text-decoration-none d-flex justify-content-between text-body";
if (isPreview) linkElement.href = "#"; if (isPreview) linkElement.href = "#";
else { else {
let targetPeriod = formatPeriod(currentPeriod, currentPeriod, currentVariation) let targetPeriod = formatPeriod(currentPeriod, currentPeriod, currentVariation)
linkElement.href = "#" + entry.id linkElement.href = "#" + entry.id
if (targetPeriod && targetPeriod != defaultPeriod) linkElement.href += "/" + targetPeriod if (targetPeriod && targetPeriod != defaultPeriod) linkElement.href += "/" + targetPeriod
}; };
const linkNameElement = document.createElement("span"); const linkNameElement = document.createElement("span");
linkNameElement.className = "flex-grow-1 text-break"; linkNameElement.className = "flex-grow-1 text-break";
linkNameElement.textContent = entry.name; linkNameElement.textContent = entry.name;
headerElement.appendChild(linkElement); headerElement.appendChild(linkElement);
linkElement.appendChild(linkNameElement); linkElement.appendChild(linkNameElement);
linkElement.insertAdjacentHTML("beforeend", '<i class="bi bi-link-45deg align-self-center link-primary" aria-hidden="true"></i>');// '<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" class="bi bi-link-45deg ms-1 align-self-center flex-shrink-0" viewBox="0 0 16 16"><path d="M4.715 6.542 3.343 7.914a3 3 0 1 0 4.243 4.243l1.828-1.829A3 3 0 0 0 8.586 5.5L8 6.086a1.002 1.002 0 0 0-.154.199 2 2 0 0 1 .861 3.337L6.88 11.45a2 2 0 1 1-2.83-2.83l.793-.792a4.018 4.018 0 0 1-.128-1.287z"/><path d="M6.586 4.672A3 3 0 0 0 7.414 9.5l.775-.776a2 2 0 0 1-.896-3.346L9.12 3.55a2 2 0 1 1 2.83 2.83l-.793.792c.112.42.155.855.128 1.287l1.372-1.372a3 3 0 1 0-4.243-4.243L6.586 4.672z"/></svg>'); linkElement.insertAdjacentHTML("beforeend", '<i class="bi bi-link-45deg align-self-center link-primary" aria-hidden="true"></i>');// '<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" class="bi bi-link-45deg ms-1 align-self-center flex-shrink-0" viewBox="0 0 16 16"><path d="M4.715 6.542 3.343 7.914a3 3 0 1 0 4.243 4.243l1.828-1.829A3 3 0 0 0 8.586 5.5L8 6.086a1.002 1.002 0 0 0-.154.199 2 2 0 0 1 .861 3.337L6.88 11.45a2 2 0 1 1-2.83-2.83l.793-.792a4.018 4.018 0 0 1-.128-1.287z"/><path d="M6.586 4.672A3 3 0 0 0 7.414 9.5l.775-.776a2 2 0 0 1-.896-3.346L9.12 3.55a2 2 0 1 1 2.83 2.83l-.793.792c.112.42.155.855.128 1.287l1.372-1.372a3 3 0 1 0-4.243-4.243L6.586 4.672z"/></svg>');
element.appendChild(headerElement); element.appendChild(headerElement);
const bodyElement = document.createElement("div"); const bodyElement = document.createElement("div");
bodyElement.className = "card-body d-flex flex-column gap-3"; bodyElement.className = "card-body d-flex flex-column gap-3";
element.appendChild(bodyElement); element.appendChild(bodyElement);
if (entry.description) { if (entry.description) {
const descElement = document.createElement("div"); const descElement = document.createElement("div");
descElement.id = "objectDescription"; descElement.id = "objectDescription";
let formattedDesc = entry.description.replace(/\n{2}/g, '</p><p>'); let formattedDesc = entry.description.replace(/\n{2}/g, '</p><p>');
formattedDesc = formattedDesc.replace(/\n/g, '<br>'); formattedDesc = formattedDesc.replace(/\n/g, '<br>');
descElement.innerHTML = '<p>' + formattedDesc + '</p>'; descElement.innerHTML = '<p>' + formattedDesc + '</p>';
bodyElement.appendChild(descElement); bodyElement.appendChild(descElement);
} }
const linkListElement = document.createElement("div"); const linkListElement = document.createElement("div");
linkListElement.className = "d-flex flex-column gap-2"; linkListElement.className = "d-flex flex-column gap-2";
bodyElement.appendChild(linkListElement); bodyElement.appendChild(linkListElement);
const listElement = document.createElement("ul"); const listElement = document.createElement("ul");
listElement.className = "list-group list-group-flush"; listElement.className = "list-group list-group-flush";
element.appendChild(listElement); element.appendChild(listElement);
if (entry.diff) { if (entry.diff) {
let diffElement = createInfoListItem("Diff: ", entry.diff); let diffElement = createInfoListItem("Diff: ", entry.diff);
if (entry.diff == "add") { if (entry.diff == "add") {
diffElement.className = "list-group-item list-group-item-success"; diffElement.className = "list-group-item list-group-item-success";
} else if (entry.diff == "edit") { } else if (entry.diff == "edit") {
diffElement.className = "list-group-item list-group-item-warning"; diffElement.className = "list-group-item list-group-item-warning";
} else if (entry.diff == "delete") { } else if (entry.diff == "delete") {
diffElement.className = "list-group-item list-group-item-danger"; diffElement.className = "list-group-item list-group-item-danger";
} }
listElement.appendChild(diffElement); listElement.appendChild(diffElement);
} }
if (!isPreview) { if (!isPreview) {
const [x, y] = entry.center; const [x, y] = entry.center;
listElement.appendChild(createInfoListItem("Position: ", `${Math.floor(x)}, ${Math.floor(y)}`)); listElement.appendChild(createInfoListItem("Position: ", `${Math.floor(x)}, ${Math.floor(y)}`));
if(entry.path){ if(entry.path){
const area = calcPolygonArea(entry.path); const area = calcPolygonArea(entry.path);
listElement.appendChild(createInfoListItem("Area: ", `${area} pixels`)); listElement.appendChild(createInfoListItem("Area: ", `${area} pixels`));
} }
} }
if (!(entry.links.subreddit === undefined || entry.links.subreddit.length == 0)) { if (!(entry.links.subreddit === undefined || entry.links.subreddit.length == 0)) {
const subredditGroupElement = document.createElement("div"); const subredditGroupElement = document.createElement("div");
subredditGroupElement.className = "btn-group-vertical"; subredditGroupElement.className = "btn-group-vertical";
linkListElement.appendChild(subredditGroupElement); linkListElement.appendChild(subredditGroupElement);
entry.links.subreddit.forEach(subreddit => { entry.links.subreddit.forEach(subreddit => {
if (subreddit) { if (subreddit) {
subreddit = "r/" + subreddit; subreddit = "r/" + subreddit;
const subredditLinkElement = document.createElement("a"); const subredditLinkElement = document.createElement("a");
subredditLinkElement.className = "btn btn-primary text-truncate"; subredditLinkElement.className = "btn btn-primary text-truncate";
subredditLinkElement.target = "_blank"; subredditLinkElement.target = "_blank";
subredditLinkElement.rel = "noopener noreferrer"; subredditLinkElement.rel = "noopener noreferrer";
subredditLinkElement.href = "https://reddit.com/" + subreddit; subredditLinkElement.href = "https://reddit.com/" + subreddit;
subredditLinkElement.innerHTML = `<i class="bi bi-reddit" aria-hidden="true"></i> ${subreddit}`; subredditLinkElement.innerHTML = `<i class="bi bi-reddit" aria-hidden="true"></i> ${subreddit}`;
subredditGroupElement.appendChild(subredditLinkElement); subredditGroupElement.appendChild(subredditLinkElement);
} }
}); });
}; };
if (!(entry.links.website === undefined || entry.links.website.length == 0)) { if (!(entry.links.website === undefined || entry.links.website.length == 0)) {
const websiteGroupElement = document.createElement("div"); const websiteGroupElement = document.createElement("div");
websiteGroupElement.className = "btn-group-vertical"; websiteGroupElement.className = "btn-group-vertical";
linkListElement.appendChild(websiteGroupElement); linkListElement.appendChild(websiteGroupElement);
entry.links.website.forEach(link => { entry.links.website.forEach(link => {
if (link) { if (link) {
const websiteLinkElement = document.createElement("a"); const websiteLinkElement = document.createElement("a");
websiteLinkElement.className = "btn btn-primary text-truncate" websiteLinkElement.className = "btn btn-primary text-truncate"
websiteLinkElement.target = "_blank"; websiteLinkElement.target = "_blank";
websiteLinkElement.rel = "noopener noreferrer"; websiteLinkElement.rel = "noopener noreferrer";
websiteLinkElement.href = link; websiteLinkElement.href = link;
try { try {
const urlObject = new URL(link) const urlObject = new URL(link)
websiteLinkElement.innerHTML = `<i class="bi bi-globe" aria-hidden="true"></i> ${urlObject.hostname.replace(/^www./, "")}`; websiteLinkElement.innerHTML = `<i class="bi bi-globe" aria-hidden="true"></i> ${urlObject.hostname.replace(/^www./, "")}`;
} catch (e) { } catch (e) {
websiteLinkElement.innerHTML = `<i class="bi bi-globe" aria-hidden="true"></i> Website`; websiteLinkElement.innerHTML = `<i class="bi bi-globe" aria-hidden="true"></i> Website`;
} }
websiteGroupElement.appendChild(websiteLinkElement); websiteGroupElement.appendChild(websiteLinkElement);
} }
}); });
} }
if (!(entry.links.discord === undefined || entry.links.discord.length == 0)) { if (!(entry.links.discord === undefined || entry.links.discord.length == 0)) {
const discordGroupElement = document.createElement("div"); const discordGroupElement = document.createElement("div");
discordGroupElement.className = "btn-group-vertical"; discordGroupElement.className = "btn-group-vertical";
linkListElement.appendChild(discordGroupElement); linkListElement.appendChild(discordGroupElement);
entry.links.discord.forEach(link => { entry.links.discord.forEach(link => {
if (link) { if (link) {
const discordLinkElement = document.createElement("a"); const discordLinkElement = document.createElement("a");
discordLinkElement.className = "btn btn-primary text-truncate" discordLinkElement.className = "btn btn-primary text-truncate"
discordLinkElement.target = "_blank"; discordLinkElement.target = "_blank";
discordLinkElement.rel = "noopener noreferrer"; discordLinkElement.rel = "noopener noreferrer";
discordLinkElement.href = "https://discord.gg/" + link; discordLinkElement.href = "https://discord.gg/" + link;
discordLinkElement.innerHTML = `<i class="bi bi-discord" aria-hidden="true"></i> ${link}`; discordLinkElement.innerHTML = `<i class="bi bi-discord" aria-hidden="true"></i> ${link}`;
discordGroupElement.appendChild(discordLinkElement); discordGroupElement.appendChild(discordLinkElement);
} }
}); });
} }
if (!(entry.links.wiki === undefined || entry.links.wiki.length == 0)) { if (!(entry.links.wiki === undefined || entry.links.wiki.length == 0)) {
const wikiGroupElement = document.createElement("div"); const wikiGroupElement = document.createElement("div");
wikiGroupElement.className = "btn-group-vertical"; wikiGroupElement.className = "btn-group-vertical";
linkListElement.appendChild(wikiGroupElement); linkListElement.appendChild(wikiGroupElement);
entry.links.wiki.forEach(link => { entry.links.wiki.forEach(link => {
if (link) { if (link) {
const wikiLinkElement = document.createElement("a"); const wikiLinkElement = document.createElement("a");
wikiLinkElement.className = "btn btn-primary text-truncate" wikiLinkElement.className = "btn btn-primary text-truncate"
wikiLinkElement.target = "_blank"; wikiLinkElement.target = "_blank";
wikiLinkElement.rel = "noopener noreferrer"; wikiLinkElement.rel = "noopener noreferrer";
wikiLinkElement.href = "https://place-wiki.stefanocoding.me/wiki/" + link.replace(/ /g, '_'); wikiLinkElement.href = "https://place-wiki.stefanocoding.me/wiki/" + link.replace(/ /g, '_');
wikiLinkElement.innerHTML = `<i class="bi bi-book" aria-hidden="true"></i> Wiki Article`; wikiLinkElement.innerHTML = `<i class="bi bi-book" aria-hidden="true"></i> Wiki Article`;
wikiGroupElement.appendChild(wikiLinkElement); wikiGroupElement.appendChild(wikiLinkElement);
} }
}); });
} }
const idElement = document.createElement("div"); const idElement = document.createElement("div");
idElement.className = "py-1"; idElement.className = "py-1";
createLabel("ID: ", entry.id, idElement); createLabel("ID: ", entry.id, idElement);
const idElementContainer = document.createElement("div"); const idElementContainer = document.createElement("div");
idElementContainer.className = "card-footer d-flex justify-content-between align-items-center"; idElementContainer.className = "card-footer d-flex justify-content-between align-items-center";
idElementContainer.appendChild(idElement); idElementContainer.appendChild(idElement);
element.appendChild(idElementContainer); element.appendChild(idElementContainer);
if (!isPreview && (!entry.diff || entry.diff !== "delete")) { if (!isPreview && (!entry.diff || entry.diff !== "delete")) {
const editElement = document.createElement("a"); const editElement = document.createElement("a");
editElement.textContent = "Edit"; editElement.textContent = "Edit";
editElement.className = "btn btn-sm btn-outline-primary"; editElement.className = "btn btn-sm btn-outline-primary";
editElement.href = "./?mode=draw&id=" + entry.id editElement.href = "./?mode=draw&id=" + entry.id
editElement.title = "Edit " + entry.name; editElement.title = "Edit " + entry.name;
idElementContainer.appendChild(editElement); idElementContainer.appendChild(editElement);
} }
if (!bodyElement.hasChildNodes()) bodyElement.remove(); if (!bodyElement.hasChildNodes()) bodyElement.remove();
if (!linkListElement.hasChildNodes()) linkListElement.remove(); if (!linkListElement.hasChildNodes()) linkListElement.remove();
if (!listElement.hasChildNodes()) listElement.remove(); if (!listElement.hasChildNodes()) listElement.remove();
return element; return element;
} }

View File

@ -1,35 +1,35 @@
{ {
"background_color": "#111111", "background_color": "#111111",
"display": "minimal-ui", "display": "minimal-ui",
"scope": "/", "scope": "/",
"start_url": "/", "start_url": "/",
"name": "r/place atlas", "name": "r/place atlas",
"short_name": "placeAtlas2", "short_name": "placeAtlas2",
"description": "The atlas for the r/place event from 2022", "description": "The atlas for the r/place event from 2022",
"icons": [ "icons": [
{ {
"src": "_img/pwa/logo-round-192x192.png", "src": "_img/pwa/logo-round-192x192.png",
"sizes": "192x192", "sizes": "192x192",
"type": "image/png", "type": "image/png",
"purpose": "any" "purpose": "any"
}, },
{ {
"src": "_img/pwa/logo-maskable-192x192.png", "src": "_img/pwa/logo-maskable-192x192.png",
"sizes": "192x192", "sizes": "192x192",
"type": "image/png", "type": "image/png",
"purpose": "maskable" "purpose": "maskable"
}, },
{ {
"src": "_img/pwa/logo-round-512x512.png", "src": "_img/pwa/logo-round-512x512.png",
"sizes": "512x512", "sizes": "512x512",
"type": "image/png", "type": "image/png",
"purpose": "any" "purpose": "any"
}, },
{ {
"src": "_img/pwa/logo-maskable-512x512.png", "src": "_img/pwa/logo-maskable-512x512.png",
"sizes": "512x512", "sizes": "512x512",
"type": "image/png", "type": "image/png",
"purpose": "maskable" "purpose": "maskable"
} }
] ]
} }