mirror of https://github.com/placeAtlas/atlas.git
Merge pull request #1444 from Hans5958/live-love-life/6
Various "minor" changes (6)
This commit is contained in:
commit
3ae6005df6
|
@ -1 +1,2 @@
|
|||
web/atlas.json @placeAtlas/archival-team
|
||||
web/atlas.json @placeAtlas/archival-team
|
||||
data/patches @placeAtlas/archival-team
|
|
@ -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"
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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/
|
|
@ -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)))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.')
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue