Merge pull request #1 from Codixer/cleanup

Cleanup
This commit is contained in:
Ellie M 2022-04-06 00:34:33 -07:00 committed by GitHub
commit ca365b8177
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 4548 additions and 2498 deletions

BIN
.DS_Store vendored

Binary file not shown.

View file

@ -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

4
.gitignore vendored
View file

@ -9,4 +9,6 @@ users.html
oldusers.html
web/_js/minified.js
allCharacters.txt
combined.js
combined.js
*.DS_Store
.vscode/

View file

@ -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
<h4><b>WE ONLY ACCEPT NEW CONTRIBUTIONS ON REDDIT</b></h4>
**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).

View file

@ -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.")

38
tools/subreddit-format.py Normal file
View file

@ -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")

View file

@ -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")

BIN
web/.DS_Store vendored

Binary file not shown.

View file

@ -168,6 +168,10 @@ header > a:hover {
color: #FFAA00;
}
header h1 {
font-size: 24px;
}
#logo {
padding: 5px;
/*background-color: #FFF;*/

View file

@ -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);

View file

@ -141,7 +141,7 @@ function initOverlap(){
if(args){
id = args.split("id=")[1];
if(id){
id = parseInt(id.split("&")[0]);
id = id.split("&")[0];
}
}

View file

@ -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){

View file

@ -24,12 +24,12 @@
<html>
<head>
<meta charset="UTF-8">
<title>The /r/place Atlas</title>
<title>The 2022 /r/place Atlas</title>
<meta name="description" content="An Atlas of Reddit's /r/place, with information to each artwork of the canvas.">
<meta name="author" content="Roland Rytz">
<meta name="keywords" content="reddit, /r/place, april">
<meta name="application-name" content="/r/place Atlas">
<meta name="application-name" content="2022 /r/place Atlas">
<meta name="robots" content="index, follow">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1">
@ -41,7 +41,7 @@
<header class="aboutHeader">
<a href="./">
<img id="logo" src="./_img/logo-100x100.png" height="50" width="50" alt="">
<h1>The /r/place Atlas</h1>
<h1>The 2022 /r/place Atlas</h1>
</a>
<!--nav>
<a id="viewLink" href="./" class="current">View</a>
@ -72,7 +72,7 @@ <h2>My Bitcoin Address</h2>
<img src="https://api.netlify.com/api/v1/badges/1e7291ce-0680-45ed-9843-47a32a992bbb/deploy-status" alt="Deploys by Netlify" />
</a>
<br>
<h2 id="abouth2">The /r/place Atlas</h2>
<h2 id="abouth2">The 2022 /r/place Atlas</h2>
<p>This is an Atlas aiming to chart all the artworks created during the <a href="https://www.reddit.com/r/place/">/r/place</a> April's fools event on <a href="https://www.reddit.com/" target="_blank">Reddit</a> in 2022.</p>
<p>The original code was developed by <a href="/" target="_blank" rel="author">Roland Rytz</a> (<a href="mailto:roland.rytz@gmail.com" target="_blank">mail</a>, <a href="https://reddit.com/user/draemmli/" target="_blank">reddit</a>) and is available under the free <a href="https://www.gnu.org/licenses/agpl-3.0.en.html" target="_blank">AGPL license</a> on <a target="_blank" href="https://github.com/RolandR/place-atlas">GitHub</a>.</p>
<br>

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -24,8 +24,8 @@
<html>
<head>
<meta charset="UTF-8">
<title>The /r/place Atlas</title>
<meta name="description" content="An interactive map of Reddit's /r/place, with information to each artwork of the canvas.">
<title>The 2022 /r/place Atlas</title>
<meta name="description" content="An interactive map of Reddit's 2022 /r/place, with information to each artwork of the canvas.">
<meta name="author" content="Roland Rytz (2022 by Stefano#7366)">
<meta name="keywords" content="reddit, /r/place 2022">
<meta name="application-name" content="The /r/place Atlas 2022">
@ -42,7 +42,7 @@
{
"@context": "http://schema.org",
"@type": "WebSite",
"name": "The /r/place Atlas",
"name": "The 2022 /r/place Atlas",
"url": "http://place-atlas.stefanocoding.me/",
"author": {
"@type": "Person",