From d90c2691794d1da4f0f6f0026b3d8373ebc72961 Mon Sep 17 00:00:00 2001 From: mxdanger <32040254+mxdanger@users.noreply.github.com> Date: Wed, 4 May 2022 14:37:47 -0700 Subject: [PATCH] Added .editorconfig Use tab instead of spaces --- .editorconfig | 9 ++ netlify.toml | 6 +- web/_js/infoblock.js | 322 +++++++++++++++++++-------------------- web/manifest.webmanifest | 66 ++++---- 4 files changed, 206 insertions(+), 197 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..e1f1dac0 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +# Editor configuration, see https://editorconfig.org + +root = true + +[*] +charset = utf-8 +indent_style = tab +indent_size = tab +tab_size = 4 \ No newline at end of file diff --git a/netlify.toml b/netlify.toml index d6a78873..f4d5a066 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,6 +1,6 @@ [build] - publish = "dist/" - command = "FILE=tools/ci/build-prod.sh; rm -rf dist/; if [ -f $FILE ]; then bash $FILE; else cp -r web/ dist/; fi" + publish = "dist/" + command = "FILE=tools/ci/build-prod.sh; rm -rf dist/; if [ -f $FILE ]; then bash $FILE; else cp -r web/ dist/; fi" [build.environment] - PYTHON_VERSION = "3.8" \ No newline at end of file + PYTHON_VERSION = "3.8" \ No newline at end of file diff --git a/web/_js/infoblock.js b/web/_js/infoblock.js index b41afeb3..179d6309 100644 --- a/web/_js/infoblock.js +++ b/web/_js/infoblock.js @@ -14,187 +14,187 @@ */ function createInfoBlock(entry, isPreview) { - function createLabel(name, value, parent) { - const nameElement = document.createElement("span"); - nameElement.className = "fw-bold"; - nameElement.textContent = name; - const valueElement = document.createElement("span"); - valueElement.textContent = value; - parent.appendChild(nameElement); - parent.appendChild(valueElement); - return parent; - } - function createInfoListItem(name, value) { - const entryInfoListElement = document.createElement("li"); - entryInfoListElement.className = "list-group-item"; - createLabel(name, value, entryInfoListElement); - return entryInfoListElement; - } + function createLabel(name, value, parent) { + const nameElement = document.createElement("span"); + nameElement.className = "fw-bold"; + nameElement.textContent = name; + const valueElement = document.createElement("span"); + valueElement.textContent = value; + parent.appendChild(nameElement); + parent.appendChild(valueElement); + return parent; + } + function createInfoListItem(name, value) { + const entryInfoListElement = document.createElement("li"); + entryInfoListElement.className = "list-group-item"; + createLabel(name, value, entryInfoListElement); + return entryInfoListElement; + } - const element = document.createElement("div"); - element.className = "card mb-2 overflow-hidden shadow"; + const element = document.createElement("div"); + element.className = "card mb-2 overflow-hidden shadow"; - const headerElement = document.createElement("h4"); - headerElement.className = "card-header"; + const headerElement = document.createElement("h4"); + headerElement.className = "card-header"; - const linkElement = document.createElement("a"); - linkElement.className = "text-decoration-none d-flex justify-content-between text-body"; - if (isPreview) linkElement.href = "#"; - else { - let targetPeriod = formatPeriod(currentPeriod, currentPeriod, currentVariation) - linkElement.href = "#" + entry.id - if (targetPeriod && targetPeriod != defaultPeriod) linkElement.href += "/" + targetPeriod - }; - const linkNameElement = document.createElement("span"); - linkNameElement.className = "flex-grow-1 text-break"; - linkNameElement.textContent = entry.name; - headerElement.appendChild(linkElement); - linkElement.appendChild(linkNameElement); - linkElement.insertAdjacentHTML("beforeend", '');// ''); - element.appendChild(headerElement); - - const bodyElement = document.createElement("div"); - bodyElement.className = "card-body d-flex flex-column gap-3"; - element.appendChild(bodyElement); + const linkElement = document.createElement("a"); + linkElement.className = "text-decoration-none d-flex justify-content-between text-body"; + if (isPreview) linkElement.href = "#"; + else { + let targetPeriod = formatPeriod(currentPeriod, currentPeriod, currentVariation) + linkElement.href = "#" + entry.id + if (targetPeriod && targetPeriod != defaultPeriod) linkElement.href += "/" + targetPeriod + }; + const linkNameElement = document.createElement("span"); + linkNameElement.className = "flex-grow-1 text-break"; + linkNameElement.textContent = entry.name; + headerElement.appendChild(linkElement); + linkElement.appendChild(linkNameElement); + linkElement.insertAdjacentHTML("beforeend", '');// ''); + element.appendChild(headerElement); + + const bodyElement = document.createElement("div"); + bodyElement.className = "card-body d-flex flex-column gap-3"; + element.appendChild(bodyElement); - if (entry.description) { - const descElement = document.createElement("div"); - descElement.id = "objectDescription"; - let formattedDesc = entry.description.replace(/\n{2}/g, '

'); - formattedDesc = formattedDesc.replace(/\n/g, '
'); - descElement.innerHTML = '

' + formattedDesc + '

'; - bodyElement.appendChild(descElement); - } + if (entry.description) { + const descElement = document.createElement("div"); + descElement.id = "objectDescription"; + let formattedDesc = entry.description.replace(/\n{2}/g, '

'); + formattedDesc = formattedDesc.replace(/\n/g, '
'); + descElement.innerHTML = '

' + formattedDesc + '

'; + bodyElement.appendChild(descElement); + } - const linkListElement = document.createElement("div"); - linkListElement.className = "d-flex flex-column gap-2"; - bodyElement.appendChild(linkListElement); + const linkListElement = document.createElement("div"); + linkListElement.className = "d-flex flex-column gap-2"; + bodyElement.appendChild(linkListElement); - const listElement = document.createElement("ul"); - listElement.className = "list-group list-group-flush"; - element.appendChild(listElement); + const listElement = document.createElement("ul"); + listElement.className = "list-group list-group-flush"; + element.appendChild(listElement); - if (entry.diff) { - let diffElement = createInfoListItem("Diff: ", entry.diff); - if (entry.diff == "add") { - diffElement.className = "list-group-item list-group-item-success"; - } else if (entry.diff == "edit") { - diffElement.className = "list-group-item list-group-item-warning"; - } else if (entry.diff == "delete") { - diffElement.className = "list-group-item list-group-item-danger"; - } - listElement.appendChild(diffElement); - } + if (entry.diff) { + let diffElement = createInfoListItem("Diff: ", entry.diff); + if (entry.diff == "add") { + diffElement.className = "list-group-item list-group-item-success"; + } else if (entry.diff == "edit") { + diffElement.className = "list-group-item list-group-item-warning"; + } else if (entry.diff == "delete") { + diffElement.className = "list-group-item list-group-item-danger"; + } + listElement.appendChild(diffElement); + } - if (!isPreview) { - const [x, y] = entry.center; - listElement.appendChild(createInfoListItem("Position: ", `${Math.floor(x)}, ${Math.floor(y)}`)); - - if(entry.path){ - const area = calcPolygonArea(entry.path); - listElement.appendChild(createInfoListItem("Area: ", `${area} pixels`)); - } - } + if (!isPreview) { + const [x, y] = entry.center; + listElement.appendChild(createInfoListItem("Position: ", `${Math.floor(x)}, ${Math.floor(y)}`)); + + if(entry.path){ + const area = calcPolygonArea(entry.path); + listElement.appendChild(createInfoListItem("Area: ", `${area} pixels`)); + } + } - if (!(entry.links.subreddit === undefined || entry.links.subreddit.length == 0)) { - const subredditGroupElement = document.createElement("div"); - subredditGroupElement.className = "btn-group-vertical"; - linkListElement.appendChild(subredditGroupElement); + if (!(entry.links.subreddit === undefined || entry.links.subreddit.length == 0)) { + const subredditGroupElement = document.createElement("div"); + subredditGroupElement.className = "btn-group-vertical"; + linkListElement.appendChild(subredditGroupElement); - entry.links.subreddit.forEach(subreddit => { - if (subreddit) { - subreddit = "r/" + subreddit; - const subredditLinkElement = document.createElement("a"); - subredditLinkElement.className = "btn btn-primary text-truncate"; - subredditLinkElement.target = "_blank"; - subredditLinkElement.rel = "noopener noreferrer"; - subredditLinkElement.href = "https://reddit.com/" + subreddit; - subredditLinkElement.innerHTML = ` ${subreddit}`; - subredditGroupElement.appendChild(subredditLinkElement); - } - }); - }; + entry.links.subreddit.forEach(subreddit => { + if (subreddit) { + subreddit = "r/" + subreddit; + const subredditLinkElement = document.createElement("a"); + subredditLinkElement.className = "btn btn-primary text-truncate"; + subredditLinkElement.target = "_blank"; + subredditLinkElement.rel = "noopener noreferrer"; + subredditLinkElement.href = "https://reddit.com/" + subreddit; + subredditLinkElement.innerHTML = ` ${subreddit}`; + subredditGroupElement.appendChild(subredditLinkElement); + } + }); + }; - if (!(entry.links.website === undefined || entry.links.website.length == 0)) { - const websiteGroupElement = document.createElement("div"); - websiteGroupElement.className = "btn-group-vertical"; - linkListElement.appendChild(websiteGroupElement); + if (!(entry.links.website === undefined || entry.links.website.length == 0)) { + const websiteGroupElement = document.createElement("div"); + websiteGroupElement.className = "btn-group-vertical"; + linkListElement.appendChild(websiteGroupElement); - entry.links.website.forEach(link => { - if (link) { - const websiteLinkElement = document.createElement("a"); - websiteLinkElement.className = "btn btn-primary text-truncate" - websiteLinkElement.target = "_blank"; - websiteLinkElement.rel = "noopener noreferrer"; - websiteLinkElement.href = link; - try { - const urlObject = new URL(link) - websiteLinkElement.innerHTML = ` ${urlObject.hostname.replace(/^www./, "")}`; - } catch (e) { - websiteLinkElement.innerHTML = ` Website`; - } - websiteGroupElement.appendChild(websiteLinkElement); - } - }); - } + entry.links.website.forEach(link => { + if (link) { + const websiteLinkElement = document.createElement("a"); + websiteLinkElement.className = "btn btn-primary text-truncate" + websiteLinkElement.target = "_blank"; + websiteLinkElement.rel = "noopener noreferrer"; + websiteLinkElement.href = link; + try { + const urlObject = new URL(link) + websiteLinkElement.innerHTML = ` ${urlObject.hostname.replace(/^www./, "")}`; + } catch (e) { + websiteLinkElement.innerHTML = ` Website`; + } + websiteGroupElement.appendChild(websiteLinkElement); + } + }); + } - if (!(entry.links.discord === undefined || entry.links.discord.length == 0)) { - const discordGroupElement = document.createElement("div"); - discordGroupElement.className = "btn-group-vertical"; - linkListElement.appendChild(discordGroupElement); + if (!(entry.links.discord === undefined || entry.links.discord.length == 0)) { + const discordGroupElement = document.createElement("div"); + discordGroupElement.className = "btn-group-vertical"; + linkListElement.appendChild(discordGroupElement); - entry.links.discord.forEach(link => { - if (link) { - const discordLinkElement = document.createElement("a"); - discordLinkElement.className = "btn btn-primary text-truncate" - discordLinkElement.target = "_blank"; - discordLinkElement.rel = "noopener noreferrer"; - discordLinkElement.href = "https://discord.gg/" + link; - discordLinkElement.innerHTML = ` ${link}`; - discordGroupElement.appendChild(discordLinkElement); - } - }); - } + entry.links.discord.forEach(link => { + if (link) { + const discordLinkElement = document.createElement("a"); + discordLinkElement.className = "btn btn-primary text-truncate" + discordLinkElement.target = "_blank"; + discordLinkElement.rel = "noopener noreferrer"; + discordLinkElement.href = "https://discord.gg/" + link; + discordLinkElement.innerHTML = ` ${link}`; + discordGroupElement.appendChild(discordLinkElement); + } + }); + } - if (!(entry.links.wiki === undefined || entry.links.wiki.length == 0)) { - const wikiGroupElement = document.createElement("div"); - wikiGroupElement.className = "btn-group-vertical"; - linkListElement.appendChild(wikiGroupElement); + if (!(entry.links.wiki === undefined || entry.links.wiki.length == 0)) { + const wikiGroupElement = document.createElement("div"); + wikiGroupElement.className = "btn-group-vertical"; + linkListElement.appendChild(wikiGroupElement); - entry.links.wiki.forEach(link => { - if (link) { - const wikiLinkElement = document.createElement("a"); - wikiLinkElement.className = "btn btn-primary text-truncate" - wikiLinkElement.target = "_blank"; - wikiLinkElement.rel = "noopener noreferrer"; - wikiLinkElement.href = "https://place-wiki.stefanocoding.me/wiki/" + link.replace(/ /g, '_'); - wikiLinkElement.innerHTML = ` Wiki Article`; - wikiGroupElement.appendChild(wikiLinkElement); - } - }); - } + entry.links.wiki.forEach(link => { + if (link) { + const wikiLinkElement = document.createElement("a"); + wikiLinkElement.className = "btn btn-primary text-truncate" + wikiLinkElement.target = "_blank"; + wikiLinkElement.rel = "noopener noreferrer"; + wikiLinkElement.href = "https://place-wiki.stefanocoding.me/wiki/" + link.replace(/ /g, '_'); + wikiLinkElement.innerHTML = ` Wiki Article`; + wikiGroupElement.appendChild(wikiLinkElement); + } + }); + } - const idElement = document.createElement("div"); - idElement.className = "py-1"; - createLabel("ID: ", entry.id, idElement); + const idElement = document.createElement("div"); + idElement.className = "py-1"; + createLabel("ID: ", entry.id, idElement); - const idElementContainer = document.createElement("div"); - idElementContainer.className = "card-footer d-flex justify-content-between align-items-center"; - idElementContainer.appendChild(idElement); - element.appendChild(idElementContainer); + const idElementContainer = document.createElement("div"); + idElementContainer.className = "card-footer d-flex justify-content-between align-items-center"; + idElementContainer.appendChild(idElement); + element.appendChild(idElementContainer); - if (!isPreview && (!entry.diff || entry.diff !== "delete")) { - const editElement = document.createElement("a"); - editElement.textContent = "Edit"; - editElement.className = "btn btn-sm btn-outline-primary"; - editElement.href = "./?mode=draw&id=" + entry.id - editElement.title = "Edit " + entry.name; - idElementContainer.appendChild(editElement); - } + if (!isPreview && (!entry.diff || entry.diff !== "delete")) { + const editElement = document.createElement("a"); + editElement.textContent = "Edit"; + editElement.className = "btn btn-sm btn-outline-primary"; + editElement.href = "./?mode=draw&id=" + entry.id + editElement.title = "Edit " + entry.name; + idElementContainer.appendChild(editElement); + } - if (!bodyElement.hasChildNodes()) bodyElement.remove(); - if (!linkListElement.hasChildNodes()) linkListElement.remove(); - if (!listElement.hasChildNodes()) listElement.remove(); + if (!bodyElement.hasChildNodes()) bodyElement.remove(); + if (!linkListElement.hasChildNodes()) linkListElement.remove(); + if (!listElement.hasChildNodes()) listElement.remove(); return element; } \ No newline at end of file diff --git a/web/manifest.webmanifest b/web/manifest.webmanifest index 5983edfb..594c169c 100644 --- a/web/manifest.webmanifest +++ b/web/manifest.webmanifest @@ -1,35 +1,35 @@ { - "background_color": "#111111", - "display": "minimal-ui", - "scope": "/", - "start_url": "/", - "name": "r/place atlas", - "short_name": "placeAtlas2", - "description": "The atlas for the r/place event from 2022", - "icons": [ - { - "src": "_img/pwa/logo-round-192x192.png", - "sizes": "192x192", - "type": "image/png", - "purpose": "any" - }, - { - "src": "_img/pwa/logo-maskable-192x192.png", - "sizes": "192x192", - "type": "image/png", - "purpose": "maskable" - }, - { - "src": "_img/pwa/logo-round-512x512.png", - "sizes": "512x512", - "type": "image/png", - "purpose": "any" - }, - { - "src": "_img/pwa/logo-maskable-512x512.png", - "sizes": "512x512", - "type": "image/png", - "purpose": "maskable" - } - ] + "background_color": "#111111", + "display": "minimal-ui", + "scope": "/", + "start_url": "/", + "name": "r/place atlas", + "short_name": "placeAtlas2", + "description": "The atlas for the r/place event from 2022", + "icons": [ + { + "src": "_img/pwa/logo-round-192x192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "any" + }, + { + "src": "_img/pwa/logo-maskable-192x192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "_img/pwa/logo-round-512x512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "any" + }, + { + "src": "_img/pwa/logo-maskable-512x512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] }