Merge branch 'master' of https://github.com/placeAtlas/atlas into cleanup

This commit is contained in:
AnonymousRandomPerson 2023-07-08 12:24:45 -04:00
commit fa9867fc56
12 changed files with 83 additions and 39 deletions

3
.github/CODEOWNERS vendored
View File

@ -1 +1,2 @@
web/atlas.json @placeAtlas/archival-team
web/atlas.json @placeAtlas/archival-team
data/patches @placeAtlas/archival-team

View File

@ -1,6 +1,11 @@
[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"
ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF web/ .parcelrc netlify.toml package-lock.json package.json postcss.config.js"
[build.environment]
PYTHON_VERSION = "3.8"
PYTHON_VERSION = "3.8"
[context.deploy-preview]
command = "FILE=tools/ci/build-preview.sh; rm -rf dist/; if [ -f $FILE ]; then bash $FILE; else cp -r web/ dist/; fi"
ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF data/patches/ web/ .parcelrc netlify.toml package-lock.json package.json postcss.config.js"

View File

@ -7,6 +7,7 @@ import json
import math
import traceback
import tqdm
import os
END_NORMAL_IMAGE = "164"
END_WHITEOUT_IMAGE = "166"
@ -420,4 +421,7 @@ def go(path):
if __name__ == '__main__':
go("../web/atlas.json")
while not os.path.exists('README.md'):
os.chdir('..')
go("web/atlas.json")

22
tools/ci/build-preview.sh Normal file
View File

@ -0,0 +1,22 @@
# This command should be run on CI/Netlify enviroment!
# If you really wanted to run it, run it on the root.
rm -rf dist-temp
rm -rf dist
rm -rf .parcel-cache
cp -r web/ dist-temp/
npm i
python tools/ci/cdn_to_local.py
python tools/ci/merge_out.py # On previews, attempt to merge patches
npx parcel build dist-temp/index.html dist-temp/**.html --dist-dir "dist" --no-source-maps --no-content-hash
rm -rf dist-temp
cp -r web/_img/ dist/
cp web/atlas.json dist/
cp web/*.txt dist/
cp web/_headers dist/
cp web/favicon.ico dist/
cp web/sw.js dist/

View File

@ -6,16 +6,20 @@ from jsonschema import validate, RefResolver
from pathlib import Path, PurePosixPath
import os
instance_path = "../../web/atlas.json"
if len(sys.argv) == 1:
while not os.path.exists('README.md'):
os.chdir('..')
instance_path = "web/atlas.json"
# path override as 1st param: validate_json.py path_to_file.json
if (len(sys.argv) > 1):
if len(sys.argv) > 1:
instance_path = sys.argv[1]
schema_path = "../schema/atlas.json"
schema_path = "tools/schema/atlas.json"
# schema override as 2nd param: validate_json.py [...] path_to_schema.json
if (len(sys.argv) > 2):
if len(sys.argv) > 2:
schema_path = sys.argv[2]
relative_path = "file:" + str(PurePosixPath(Path(os.getcwd(), schema_path)))

View File

@ -3,7 +3,10 @@ import os
import secrets
from pathlib import Path
patches_dir = "../data/patches/"
while not os.path.exists('README.md'):
os.chdir('..')
patches_dir = "data/patches/"
Path(patches_dir).mkdir(parents=True, exist_ok=True)
entry = None

View File

@ -9,13 +9,16 @@ out_ids = []
atlas_ids = {}
authors = []
with open('../web/all-authors.txt', 'r', encoding='utf-8') as authors_file:
while not os.path.exists('README.md'):
os.chdir('..')
with open('web/all-authors.txt', 'r', encoding='utf-8') as authors_file:
authors = authors_file.read().strip().split()
with open('../data/read-ids.txt', 'r', encoding='utf-8') as ids_file:
with open('data/read-ids.txt', 'r', encoding='utf-8') as ids_file:
out_ids = ids_file.read().strip().split()
with open('../web/atlas.json', 'r', encoding='utf-8') as atlas_file:
with open('web/atlas.json', 'r', encoding='utf-8') as atlas_file:
atlas_data = json.loads(atlas_file.read())
last_id = 0
@ -26,13 +29,13 @@ for i, entry in enumerate(atlas_data):
if id.isnumeric() and int(id) > last_id and int(id) - last_id < 100:
last_id = int(id)
patches_dir = "../data/patches/"
permanent_patch_file = "temp-atlas.json"
patches_dir = "data/patches/"
permanent_patch_file = "tools/temp-atlas.json"
if not os.path.exists(patches_dir):
print("Patches folder not found. Exiting.")
exit()
base_image_path = os.path.join('..', 'web', '_img', 'canvas', 'place30')
base_image_path = os.path.join('web', '_img', 'canvas', 'place30')
ScaleConfig.image1 = os.path.join(base_image_path, '159.png')
filenames = os.listdir(patches_dir)
@ -111,13 +114,13 @@ for filename in filenames:
traceback.print_exc()
print('Writing...')
with open('../web/atlas.json', 'w', encoding='utf-8') as atlas_file:
with open('web/atlas.json', 'w', encoding='utf-8') as atlas_file:
per_line_entries(atlas_data, atlas_file)
with open('../data/read-ids.txt', 'w', encoding='utf-8') as ids_file:
with open('data/read-ids.txt', 'w', encoding='utf-8') as ids_file:
ids_file.write("\n".join(out_ids) + "\n")
with open('../web/all-authors.txt', 'w', encoding='utf-8') as authors_file:
with open('web/all-authors.txt', 'w', encoding='utf-8') as authors_file:
authors_file.write("\n".join(authors) + "\n")
print('All done.')

View File

@ -34,8 +34,12 @@ from pathlib import Path
import humanize
from datetime import datetime
import secrets
import os
patches_dir = "../data/patches/"
while not os.path.exists('README.md'):
os.chdir('..')
patches_dir = "data/patches/"
Path(patches_dir).mkdir(parents=True, exist_ok=True)
def set_flair(submission, flair):
@ -69,7 +73,7 @@ print("Running...")
existing_ids = []
with open('../data/read-ids.txt', 'r') as edit_ids_file:
with open('data/read-ids.txt', 'r') as edit_ids_file:
for id in [x.strip() for x in edit_ids_file.readlines()]:
existing_ids.append(id)

View File

@ -21,7 +21,7 @@
"description": "The ID of the entry. The value is a placeholder for new entries."
}
],
"description": "The ID of the entry. Usually, this is a number (string or number) this is the post ID of the new entry submission."
"description": "The ID of the entry. Usually, this is a number (preferably number, or string), or the post ID of the new entry submission."
},
"name": {
"type": "string",

View File

@ -1,9 +1,6 @@
/*
Access-Control-Allow-Origin: *
/_img/place/*.png
cache-control: public, max-age=604800
/_img/canvas/*/*.png
cache-control: public, max-age=604800

View File

@ -43,7 +43,7 @@ const exportArea = document.getElementById("exportString")
const subredditPattern = /^(?:(?:(?:(?:(?:https?:\/\/)?(?:(?:www|old|new|np)\.)?)?reddit\.com)?\/)?[rR]\/)?([A-Za-z0-9][A-Za-z0-9_]{1,20})(?:\/[^" ]*)*$/
const discordPattern = /^(?:(?:https?:\/\/)?(?:www\.)?(?:(?:discord)?\.?gg|discord(?:app)?\.com\/invite)\/)?([^\s/]+?)(?=\b)$/
let entryId = undefined
let entry
let path = []
let center = [canvasCenter.x, canvasCenter.y]
@ -273,7 +273,7 @@ function initDraw() {
function generateExportObject() {
const exportObject = {
id: entryId ?? -1,
id: -1,
name: nameField.value,
description: descriptionField.value,
links: {},
@ -285,7 +285,7 @@ function initDraw() {
if (!isNaN(Number(exportObject.id))) exportObject.id = Number(exportObject.id)
}
const pathWithPeriodsTemp = JSON.parse(JSON.stringify(pathWithPeriods))
const pathWithPeriodsTemp = structuredClone(pathWithPeriods)
for (let i = pathWithPeriodsTemp.length - 1; i > 0; i--) {
for (let j = 0; j < i; j++) {
@ -336,8 +336,8 @@ function initDraw() {
let redditPostJsonString = " " + prettyJsonString.split("\n").join("\n ")
let redditPostUrl = `https://www.reddit.com/r/${instanceSubreddit}/submit?selftext=true&title=`
if (exportObject.id === 0) redditPostUrl += `✨%20${encodeURIComponent(exportObject.name)}`
else redditPostUrl += `✏%20${encodeURIComponent(exportObject.name)}`
if (exportObject.id === 0) redditPostUrl += `✨%20${encodeURIComponent(exportObject.name ?? entry.name)}`
else redditPostUrl += `✏%20${encodeURIComponent(exportObject.name ?? entry.name)}`
redditPostUrl += "&text="
if (encodeURIComponent(redditPostJsonString).length > 7579 - redditPostUrl.length) {
@ -364,7 +364,7 @@ function initDraw() {
// GitHub
let githubPostJsonString = prettyJsonString
let githubPostUrl = `${instanceRepo}/new/cleanup/data/patches?filename=gh-${[...Array(4)].map(() => Math.floor(Math.random() * 16).toString(16)).join('')}-${slugify(exportObject.name)}.json&value=`
let githubPostUrl = `${instanceRepo}/new/cleanup/data/patches?filename=gh-${[...Array(4)].map(() => Math.floor(Math.random() * 16).toString(16)).join('')}-${slugify(exportObject.name ?? entry.name)}.json&value=`
if (encodeURIComponent(githubPostJsonString).length > 8192 - githubPostUrl.length) {
githubPostJsonString = miniJsonString
@ -565,14 +565,12 @@ function initDraw() {
}
const getEntry = id => {
if (!id) return
const entries = atlasAll.filter(entry => entry.id.toString() === id.toString())
if (entries.length === 1) return entries[0]
return {}
return
}
const params = new URLSearchParams(document.location.search)
function addFieldButton(inputButton, inputGroup, array, index, name) {
if (inputButton.title === "Remove " + name) {
removeFieldButton(inputGroup, array, index)
@ -756,9 +754,11 @@ function initDraw() {
inputGroup.appendChild(inputButton)
}
if (params.has('id') && getEntry(params.get('id'))) {
entryId = params.get('id')
const entry = getEntry(entryId)
const params = new URLSearchParams(document.location.search)
const entryId = params.get('id')
entry = getEntry(entryId)
if (entry) {
nameField.value = entry.name
descriptionField.value = entry.description
@ -827,10 +827,10 @@ function initDraw() {
initPeriodGroups()
})
drawBackButton.href = "./" + formatHash(entryId, currentPeriod, currentPeriod, currentVariation)
drawBackButton.href = "./" + formatHash(entry?.id, currentPeriod, currentPeriod, currentVariation)
document.addEventListener('timeupdate', event => {
drawBackButton.href = "./" + formatHash(entryId, event.detail.period, event.detail.period, event.detail.variation)
drawBackButton.href = "./" + formatHash(entry?.id, event.detail.period, event.detail.period, event.detail.variation)
})
}

View File

@ -41,6 +41,7 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-dark-5@1.1.3/dist/css/bootstrap-dark.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css">
<link rel="manifest" href="./manifest.webmanifest">
<link rel="me" href="https://enshittification.social/@Codixer">
<script type="module" src="https://cdn.jsdelivr.net/npm/@pwabuilder/pwaupdate/dist/pwa-update.js"></script>
<script src="./_js/favicon.js" defer></script>
<script type="application/ld+json">
@ -457,4 +458,4 @@
<script src="./_js/minified.js"></script> -->
<pwa-update swpath="./sw.js"></pwa-update>
</body>
</html>
</html>