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..b818bfe4 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. diff --git a/tools/redditcrawl.py b/tools/redditcrawl.py index a8317d0e..6be23e56 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') @@ -15,7 +16,7 @@ failcount = 0 successcount = 0 -jsonfile = open("../web/atlas.json", "r") +jsonfile = open("../web/atlas.json", "r", encoding='utf-8') existing = json.load(jsonfile) existing_ids = [] @@ -51,7 +52,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: 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/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