diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index dfd09336..00000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.github/workflows/github-actions.yml b/.github/workflows/validate-json.yml similarity index 79% rename from .github/workflows/github-actions.yml rename to .github/workflows/validate-json.yml index 9928c584..55331c5c 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/validate-json.yml @@ -1,5 +1,11 @@ name: Validate JSON -on: [push, pull_request] +on: + push: + paths: + - web/atlas.json + pull_request: + paths: + - web/atlas.json jobs: Validate-JSON: runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 554adea0..f1754b75 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,6 @@ users.html oldusers.html web/_js/minified.js allCharacters.txt -combined.js \ No newline at end of file +combined.js +*.DS_Store +.vscode/ \ No newline at end of file diff --git a/README.md b/README.md index 4e24b5f8..872a1ace 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# The Place Atlas +# The 2022 Place Atlas The /r/place Atlas is a project aiming to catalog all the artworks created during Reddit's 2022 /r/place event. This project was created by Roland Rytz and is licensed under the GNU Affero General Public License v3.0. @@ -12,7 +12,7 @@ If you don't know GitHub and wanted to submit new entries or request changes to ### Map Contributions -

WE ONLY ACCEPT NEW CONTRIBUTIONS ON REDDIT

+**WE ONLY ACCEPT NEW CONTRIBUTIONS ON REDDIT!** To contribute to the map, we require a certain format for artwork region and labels. This can be generated on the [contributing page](https://place-atlas.stefanocoding.me/index.html?mode=draw) on the website. @@ -40,4 +40,4 @@ To contribute to the map, we require a certain format for artwork region and lab ### Cleaning Contributions -If you spot a duplicate, please PR against `/cleanup`. To help find duplicates, run the code locally, changing line 92 of `main.js` to `overlap`. +If you spot a duplicate, please PR against `/cleanup`. To help find duplicates, append `?mode=overlap` to the url: [`https://place-atlas.stefanocoding.me?mode=overlap`](https://place-atlas.stefanocoding.me?mode=overlap). diff --git a/tools/redditcrawl.py b/tools/redditcrawl.py index a8317d0e..ee22378e 100755 --- a/tools/redditcrawl.py +++ b/tools/redditcrawl.py @@ -2,6 +2,7 @@ import praw import json import time +import re outfile = open('temp_atlas.json', 'w', encoding='utf-8') failfile = open('manual_atlas.json', 'w', encoding='utf-8') @@ -14,8 +15,9 @@ failcount = 0 successcount = 0 +totalcount = 0 -jsonfile = open("../web/atlas.json", "r") +jsonfile = open("../web/atlas.json", "r", encoding='utf-8') existing = json.load(jsonfile) existing_ids = [] @@ -51,7 +53,13 @@ break if(submission.link_flair_text == "New Entry"): text = submission.selftext - text = text.replace("\\", "") + #Old backslash filter: + #text = text.replace("\\", "") + #New one: One \\ escapes a backslash in python's parser + # Two escape it again in the regex parser, so \\\\ is \ + # Then anything but " or n is replaced with the first capture group (anything but " or n) + # Test in repl: re.sub("\\\\([^\"n])", "\\1", "\\t < removed slash, t stays and > stays \\n \\\"") + re.sub("\\\\([^\"n])", "\\1", text) try: text = text.replace("\"id\": 0,", "\"id\": 0,\n\t\t\"submitted_by\": \""+submission.author.name+"\",") except AttributeError: @@ -66,10 +74,11 @@ text = "\n".join(lines) try: outfile.write(json.dumps(json.loads(text))+",\n") + successcount += 1 except json.JSONDecodeError: failfile.write(text+",\n") failcount += 1 print("written "+submission.id+" submitted "+str(round(time.time()-submission.created_utc))+" seconds ago") - successcount += 1 + totalcount += 1 -print(f"\n\nSuccess: {successcount}\nFail: {failcount}\nPlease check manual_atlas.txt for failed entries to manually resolve.") +print(f"\n\nSuccess: {successcount}/{totalcount}\nFail: {failcount}/{totalcount}\nPlease check manual_atlas.txt for failed entries to manually resolve.") diff --git a/tools/subreddit-format.py b/tools/subreddit-format.py new file mode 100644 index 00000000..41ca2744 --- /dev/null +++ b/tools/subreddit-format.py @@ -0,0 +1,38 @@ +#!/usr/bin/python + +import re +pattern1 = re.compile(r'"subreddit": "\/r\/(.+?)/?"') +pattern2 = re.compile(r'"subreddit": "r\/(.+?)/?"') +pattern3 = re.compile(r'"subreddit": "\/?r(?!\/)(.+?)/?"') +pattern4 = re.compile(r'"subreddit": "(?:(?:https:\/\/)?www.)?reddit.com\/r\/(.+?)(/[^"]*)*"') +pattern5 = re.compile(r'"subreddit": "\[(?:(?:https:\/\/)?www.)?reddit.com\/r\/(.+?)(/[^"]*)*\]\((?:(?:https:\/\/)?www.)?reddit.com\/r\/(.+?)(/[^"]*)*\)"') + +def go(path): + + with open(path, "r+", encoding='UTF-8') as f1: + contents = f1.read() + + for match in pattern5.finditer(contents): + contents = contents.replace(match.group(0), '"subreddit": "r/' + match.group(2) + '"', 1) + + for match in pattern4.finditer(contents): + contents = contents.replace(match.group(0), '"subreddit": "r/' + match.group(1) + '"', 1) + + for match in pattern1.finditer(contents): + contents = contents.replace(match.group(0), '"subreddit": "r/' + match.group(1) + '"', 1) + + for match in pattern2.finditer(contents): + contents = contents.replace(match.group(0), '"subreddit": "r/' + match.group(1) + '"', 1) + + for match in pattern3.finditer(contents): + contents = contents.replace(match.group(0), '"subreddit": "r/' + match.group(1) + '"', 1) + + # # r/... to /r/.. (comment if not needed) + for match in pattern2.finditer(contents): + contents = contents.replace(match.group(0), '"subreddit": "/r/' + match.group(1) + '"', 1) + + with open(path, "w", encoding='UTF-8') as f2: + f2.write(contents) + +go("../web/atlas.json") +go("../web/atlas-before-ids-migration.json") \ No newline at end of file diff --git a/tools/validate_json.py b/tools/validate_json.py index 64e5b7c8..aa8ba5a2 100644 --- a/tools/validate_json.py +++ b/tools/validate_json.py @@ -9,6 +9,6 @@ if (len(sys.argv) > 1): path = sys.argv[1] -json.load(open(path)) +json.load(open(path, "r", encoding='utf-8')) print("JSON is valid") \ No newline at end of file diff --git a/web/.DS_Store b/web/.DS_Store deleted file mode 100644 index deae35fa..00000000 Binary files a/web/.DS_Store and /dev/null differ diff --git a/web/_css/style.css b/web/_css/style.css index d970c265..9c6eefde 100644 --- a/web/_css/style.css +++ b/web/_css/style.css @@ -168,6 +168,10 @@ header > a:hover { color: #FFAA00; } +header h1 { + font-size: 24px; +} + #logo { padding: 5px; /*background-color: #FFF;*/ diff --git a/web/_js/infoblock.js b/web/_js/infoblock.js index 524ef993..edbaccb1 100644 --- a/web/_js/infoblock.js +++ b/web/_js/infoblock.js @@ -4,7 +4,7 @@ function createInfoBlock(entry) { let headerElement = document.createElement("h2"); let linkElement = document.createElement("a"); - linkElement.href = "?" + entry.id; + linkElement.href = "?id=" + entry.id; linkElement.innerText = entry.name; headerElement.appendChild(linkElement); diff --git a/web/_js/overlap.js b/web/_js/overlap.js index 61937518..4d4aa6a1 100644 --- a/web/_js/overlap.js +++ b/web/_js/overlap.js @@ -141,7 +141,7 @@ function initOverlap(){ if(args){ id = args.split("id=")[1]; if(id){ - id = parseInt(id.split("&")[0]); + id = id.split("&")[0]; } } diff --git a/web/_js/view.js b/web/_js/view.js index 701cbfb5..51c107e0 100644 --- a/web/_js/view.js +++ b/web/_js/view.js @@ -267,7 +267,7 @@ function initView(){ if(args){ id = args.split("id=")[1]; if(id){ - id = parseInt(id.split("&")[0]); + id = id.split("&")[0]; } } @@ -280,7 +280,7 @@ function initView(){ if (entry.length === 1){ entry = entry[0]; - document.title = entry.name + " on the /r/place Atlas"; + document.title = entry.name + " on the 2022 /r/place Atlas"; var infoElement = createInfoBlock(entry); objectsContainer.innerHTML = ""; @@ -703,6 +703,8 @@ function initView(){ }); container.addEventListener("touchend", function(e){ + e.preventDefault() + //console.log(e); //console.log(e.changedTouches[0].clientX); if(e.changedTouches.length == 1){ diff --git a/web/about.html b/web/about.html index f7e0f276..23e97adc 100644 --- a/web/about.html +++ b/web/about.html @@ -24,12 +24,12 @@ - The /r/place Atlas + The 2022 /r/place Atlas - + @@ -41,7 +41,7 @@
-

The /r/place Atlas

+

The 2022 /r/place Atlas