Merge pull request #1425 from Hans5958/live-love-life

Various "minor" changes
This commit is contained in:
Stefano 2023-04-03 12:02:40 +02:00 committed by GitHub
commit 63dd4f67e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
54 changed files with 11497 additions and 3116 deletions

View file

@ -25,16 +25,6 @@
"security"
]
},
{
"login": "imskyyc",
"name": "imskyyc",
"avatar_url": "https://avatars.githubusercontent.com/u/48039776?v=4",
"profile": "https://www.imskyyc.xyz/",
"contributions": [
"financial",
"ideas"
]
},
{
"login": "ab-gh",
"name": "ash",
@ -109,5 +99,6 @@
"repoType": "github",
"repoHost": "https://github.com",
"projectName": "atlas",
"projectOwner": "placeAtlas"
"projectOwner": "placeAtlas",
"badgeTemplate": "[![All Contributors](https://img.shields.io/badge/all_contributors-<%= contributors.length %>-orange.svg?style=flat)](#contributors)"
}

13
.github/ISSUE_TEMPLATE/1-bug-report.yml vendored Normal file
View file

@ -0,0 +1,13 @@
name: Bug report
description: Create a report to help us improve
labels: ["bug"]
body:
- type: textarea
id: description
attributes:
label: Describe the bug
description: A clear and concise description of what the bug is.
placeholder: Tell us what you see!
value: "A bug happened!"
validations:
required: true

View file

@ -0,0 +1,12 @@
name: Feature request
description: Suggest an idea for this project
labels: ["enhancement"]
body:
- type: textarea
id: description
attributes:
label: Describe the solution
description: A clear and concise description of what you want to happen.
placeholder: Tell us what you want!
validations:
required: true

21
.github/ISSUE_TEMPLATE/3-edit-json.yml vendored Normal file
View file

@ -0,0 +1,21 @@
name: Entry edit submission
description: Edit an existing entry after using the website
labels: ["entry update"]
body:
- type: markdown
attributes:
value: |
Make sure you have prepared your JSON data that you get after editing. If you haven't, [CONTRIBUTING.md](https://github.com/placeAtlas/atlas/blob/master/CONTRIBUTING.md) has a guide for editing an existing entry.
- type: textarea
id: description
attributes:
label: Summary of changes
description: A summary of what is being updated/changed.
- type: textarea
id: json
attributes:
label: Entry data
description: Upon editing, please copy the exported JSON-formatted data. This will be automatically formatted into code, so no need for backticks.
render: json
validations:
required: true

View file

@ -0,0 +1,12 @@
name: Edit request
description: Request for edits of the Atlas data
labels: ["entry update"]
body:
- type: textarea
id: description
attributes:
label: Describe the changes
description: A clear and concise description of what you want to happen.
placeholder: Tell us what you want!
validations:
required: true

7
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View file

@ -0,0 +1,7 @@
contact_links:
- name: Discord server ↪
url: https://discord.gg/pJkm23b2nA
about: Discuss or get help on the Discord server
- name: Subreddit ↪
url: https://reddit.com/r/placeAtlas2
about: Discuss or get help on the subreddit

View file

@ -1,16 +0,0 @@
---
name: Update request
about: Change/Add additional info to an existing entry on this/main repo
title: 'Update request: [title]'
labels: entry update
assignees: ''
---
- Summary of changes:
- Paste inside codeblock here:
```
```

View file

@ -1,23 +1,36 @@
name: Qodana
on:
workflow_dispatch:
pull_request:
pull_request_target:
branches:
- master
paths:
- "**.js"
- "**.sh"
- "**.py"
push:
branches:
- master
paths:
- "**.js"
- "**.sh"
- "**.py"
jobs:
qodana:
name: Qodana
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 'Qodana Scan'
- name: Check using Qodana
uses: JetBrains/qodana-action@main
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
- uses: github/codeql-action/upload-sarif@v2
- name: Upload results
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json
env:

View file

@ -7,12 +7,11 @@ on:
paths:
- web/atlas.json
jobs:
Validate-JSON:
validate:
name: Validate JSON
runs-on: ubuntu-latest
steps:
- name: Check out repository code
- name: Checkout code
uses: actions/checkout@v3
- name: Validate JSON
run: |
chmod +x ${{ github.workspace }}/tools/validate_json.py
python3 ${{ github.workspace }}/tools/validate_json.py ${{ github.workspace }}/web/atlas.json
run: python3 tools/ci/validate_json.py web/atlas.json

16
.gitignore vendored
View file

@ -1,29 +1,21 @@
# Secrets
**/**/credentials
credentials
praw
# Temporary files
temp_atlas.json
manual_atlas.json
manual_atlas.txt
temp.json
temp.js
temp-atlas.json
temp-atlas-manual.*
temp.*
temp-read-ids.txt
allCharacters.txt
combined.js
# Excluded files
users.html
oldusers.html
web/_js/minified.js
*.DS_Store
.vscode/
web/atlas-before-ids-migration.json
tools/read-ids-temp.txt
# Build files
node_modules/
/package-lock.json
/yarn.lock
dist*/

5
.parcelrc Normal file
View file

@ -0,0 +1,5 @@
{
"extends": "@parcel/config-default",
"resolvers": ["parcel-resolver-ignore", "..."],
"namers": ["parcel-namer-rewrite", "..."]
}

View file

@ -1,43 +1,111 @@
# Contributing
This project is open source. You may contribute to the project by submitting a Pull Request on the GitHub repo or send your submissions through Reddit. Other than than, you cau use Discord or Reddit for help.
This project is open source, and contributions are welcome. In fact, the Atlas relies on user contributions.
## Map Contributions
You may contribute to the project by submitting a Pull Request on the GitHub repo or sending your submissions through [Reddit](https://www.reddit.com/r/placeAtlas2). Other than than, you cau use [Discord](https://discord.gg/pJkm23b2nA) or [Reddit](https://www.reddit.com/r/placeAtlas2) for help.
**WE ONLY ACCEPT NEW CONTRIBUTIONS ON REDDIT!**
## New Atlas entries
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.
> **Warning**: **WE ONLY ACCEPT NEW ENTRIES ON REDDIT!**
### Reddit
To contribute to the map, we require a certain format for artwork region and labels. This can be generated on [the drawing mode](https://place-atlas.stefanocoding.me?mode=draw) on the website.
1. Follow the instructions on the [contributing page](https://place-atlas.stefanocoding.me/index.html?mode=draw), then post it to Reddit by clicking "Post Direct to Reddit".
2. Flair your post with the "New Entry" tag.
3. A moderator will accept your contribution shortly.
To add a new entry, go to [the drawing mode](https://place-atlas.stefanocoding.me?mode=draw) and draw a shape/polygon around the region you'd like to describe. You can use the <kbd>Undo</kbd>, <kbd>Redo</kbd>, and <kbd>Reset</kbd> buttons to help you creating a good polygon. Make sure that the lines you're drawing don't form a [self-intersecting polygon](https://upload.wikimedia.org/wikipedia/commons/thumb/0/0f/Complex_polygon.svg/288px-Complex_polygon.svg.png).
<!--
Multiple periods can be added to represent the changing state of the artwork on different times. You can set the start and end period, as well as chosing the appropriate canvas variations. You can also copy the polygon from one period to the other, duplicating a period to be edited later, as well as deleting a period (if there is more than one). An alert is also shown if there are errors for assistance.
### GitHub
When you're happy with the shape you've drawn, press <kbd>Finish</kbd>. You will now be able to enter some information about the highlighted region:
1. Create a fork of our repo.
2. Enter your data into the `web/atlas.json` file, with the correct format and ID number.
3. Create a Pull Request.
- **Name**: A short, descriptive name.
- **Description**: A short description that will also be understood by somebody not familiar with the topic. Usually, the first sentence on Wikipedia is a good example.
- **Links**: Some links that's either most relevant to the topic, or that was responsible for creating the artwork.
- **Website**: If you're describing a project, the project's main website would be suitable here.
- **Subreddit**: Format it like `r/subreddit`.
- **Discord**: Write the invite code, that the invite link without the `discord.gg/` part.
- **Wiki**: The page title of [The r/place Wiki](https://place-wiki.stefanocoding.me/).
-->
All fields but the name are optional. For example, a country flag doesn't necessarily need a description.
## Map Edits
Once you've entered all the information, you'll be presented with a pop-up window containing some [JSON](https://en.wikipedia.org/wiki/JSON)-formatted data. You can press the <kbd>Post Direct to Reddit</kbd> button, or copy the entire JSON text and [create a new text post on the subreddit](https://www.reddit.com/r/placeAtlas2/submit). Remember to flair your post with <kbd>New Entry</kvd>.
### Reddit
## Edits to Atlas entries
1. Click "Edit" on a entry and follow the instructions there, then post it to Reddit by clicking "Post Direct to Reddit".
2. Flair your post with the "Edit Entry" tag.
3. A moderator will accept your contribution shortly.
Other than adding new ones, you can edit existing atlas entries.
### Using the web interface
### GitHub
You can use the website to edit single entries easily. On the website, click <kbd>Edit</kbd> on an entry box. Afterwards, you can follow the same instructions as [when creating a new entry](#new-atlas-entries). Upon submitting, please label it as <kbd>Edit Entry</kbd> instead.
1. Create a fork of our repo.
2. Enter your data into the `web/atlas.json` file, with the correct format and ID number.
3. Create a Pull Request against the `cleanup` branch.
## Cleaning Contributions
As an alternative, you can also submit an issue on GitHub using [this form](https://github.com/placeAtlas/atlas/issues/new?assignees=&labels=entry+update&template=edit-entry.yml).
If you spot a duplicate, please PR against the `cleanup` branch. To help find duplicates, [use the Overlap mode](https://place-atlas.stefanocoding.me?mode=overlap).
### Manually
Edits are also welcome on this repository through GitHub. You may use GitHub for bulk or large-scale changes, such as removing duplicates.
`web/atlas.json` is where the Atlas data is located, in which you can edit on GitHub. Below is an example of an entry. The example has been expanded, but please save it in the way so each line is an entry which is minified.
```json5
{
"id": "tu203o",
"name": "An entry",
"description": "This is an entry, it is remarkable.",
"links": {
"subreddit": ["placeAtlas2", "subreddit1", "subreddit2"],
"discord": ["pJkm23b2nA"],
"website": ["https://example.com"],
"wiki": ["An_Entry", "An_Entry_2"]
},
"path": {
// 109-166: Default canvas variation (r/place), period 109 to 166.
// T:0-1: "The Final Clean" canvas variation, period 0 (The Final Clean) to 1 (Unofficial Corrections).
"109-166, T:0-1": [
[1527, 1712],
[1625, 1712],
[1625, 1682],
// ...
]
},
"center": {
"109-166, T:0-1": [1639, 1754]
}
}
```
Upon creating a fork of this repository and pushing the changes, create a Pull Request against the `cleanup` branch. A member will merge the pull request if it is adequate.
To help find duplicates, [use the Overlap mode](https://place-atlas.stefanocoding.me?mode=overlap).
## Development
Other than contributing to the Atlas data, code contributions are also accepted. Here are some information regarding some aspects on the repository.
### Web interface
This website is built using classic HTML 5 (no JS frameworks such as Vue, React, etc are used). Bootstrap 5 is used as a CSS framework.
Opening the HTML file on your browser is adequate enough to edit. If it doesn't work, you can try running a local HTTP server.
```sh
# Run it inside the web/ folder.
cd web
# Choose one of the following.
# Python 2
python -m SimpleHTTPServer 8000
# Python 3
python -m http.server 8000
# Node.js (http-server)
npx http-server
# Node.js (serve)
npx serve
```
### Tools
The `tools` folder have various scripts for the maintainance of the project, such as...
- Adding submitted entries from the subreddit
- Formatting/tidying up the data
- Building the site for production
The tools are built using either Node.js and/or Python (3).

View file

@ -5,67 +5,32 @@
[![Discord](https://img.shields.io/discord/960791635342524496?color=%235865F2&logo=discord&logoColor=white)](https://discord.gg/pJkm23b2nA)
[![Subreddit subscribers](https://img.shields.io/reddit/subreddit-subscribers/placeAtlas2?color=%23FF4500&label=r%2FplaceAtlas2&logo=reddit&logoColor=white)](https://www.reddit.com/r/placeAtlas2/)
[![Website](https://img.shields.io/static/v1?label=website&message=place-atlas.stefanocoding.me&color=blue)](https://place-atlas.stefanocoding.me/)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
# The 2022 r/place Atlas
The 2022 r/place Atlas is a project aiming to catalog all the artworks created during Reddit's 2022 r/place event.
The 2022 r/place Atlas is a project aiming to chart all the artworks created during the r/place April Fools event on Reddit in 2022. It is made with information to each artwork of the canvas provided by the community.
This project was established by Roland Rytz for the event in 2017, and further developed by Place Atlas team and contributors.
This project was established by Roland Rytz for the event in 2017, and further developed and maintained by the Place Atlas team and contributors.
This project is licensed under the GNU Affero General Public License v3.0.
This project is licensed under the [GNU Affero General Public License v3.0](LICENSE).
You can check out the website by clicking [here](https://place-atlas.stefanocoding.me/).
If you don't know GitHub and wanted to submit new entries or request changes to existing ones, please visit [r/placeAtlas2](https://www.reddit.com/r/placeAtlas2/).
You can check out the website by visiting [place-atlas.stefanocoding.me](https://place-atlas.stefanocoding.me/). If you want to keep distance from GitHub, you may visit [r/placeAtlas2](https://www.reddit.com/r/placeAtlas2/).
## Contributing
This project is open source. You may contribute to the project by submitting a Pull Request on the GitHub repo or send your submissions through Reddit. Other than than, you cau use Discord or Reddit for help.
This project is open source, and contributions are welcome. In fact, the Atlas relies on user contributions.
### Map Contributions
Please read [CONTRIBUTING.md](CONTRIBUTING.md) to learn how to submit a new entry, edit existing entries, or contribute to the development of the codebase.
**WE ONLY ACCEPT NEW CONTRIBUTIONS ON REDDIT!**
[The r/placeAlas2 subreddit](https://reddit.com/r/placeAtlas2/) and [the Discord server](https://discord.gg/pJkm23b2nA) is also the place to submit all bug reports, feature requests, or questions.
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.
## Contributors
#### Reddit
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-6-orange.svg?style=flat)](#contributors)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
1. Follow the instructions on the [contributing page](https://place-atlas.stefanocoding.me/index.html?mode=draw), then post it to Reddit by clicking "Post Direct to Reddit".
2. Flair your post with the "New Entry" tag.
3. A moderator will accept your contribution shortly.
<!--
#### GitHub
1. Create a fork of our repo.
2. Enter your data into the `web/_js/atlas.js` file, with the correct format and ID number.
3. Create a Pull Request.
-->
### Map Edits
#### Reddit
1. Click "Edit" on a entry and follow the instructions there, then post it to Reddit by clicking "Post Direct to Reddit".
2. Flair your post with the "Edit Entry" tag.
3. A moderator will accept your contribution shortly.
#### GitHub
1. Create a fork of our repo.
2. Enter your data into the `web/atlas.json` file, with the correct format and ID number.
3. Create a Pull Request against the `cleanup` branch.
### Cleaning Contributions
If you spot a duplicate, please PR against the `cleanup` branch. To help find duplicates, [use the Overlap mode](https://place-atlas.stefanocoding.me?mode=overlap).
## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key))):
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
@ -73,12 +38,12 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<table>
<tbody>
<tr>
<td align="center"><a href="https://stefanocoding.me"><img src="https://avatars.githubusercontent.com/u/25939526?v=4?s=100" width="100px;" alt="Stefano"/><br /><sub><b>Stefano</b></sub></a><br /><a href="#business-Codixer" title="Business development">💼</a> <a href="https://github.com/placeAtlas/atlas/commits?author=Codixer" title="Code">💻</a> <a href="#content-Codixer" title="Content">🖋</a> <a href="#data-Codixer" title="Data">🔣</a> <a href="#design-Codixer" title="Design">🎨</a> <a href="#fundingFinding-Codixer" title="Funding Finding">🔍</a> <a href="#infra-Codixer" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-Codixer" title="Maintenance">🚧</a> <a href="#projectManagement-Codixer" title="Project Management">📆</a> <a href="#question-Codixer" title="Answering Questions">💬</a> <a href="#security-Codixer" title="Security">🛡️</a></td>
<td align="center"><a href="https://github.com/ab-gh"><img src="https://avatars.githubusercontent.com/u/18347932?v=4?s=100" width="100px;" alt="ash"/><br /><sub><b>ash</b></sub></a><br /><a href="#business-ab-gh" title="Business development">💼</a> <a href="#content-ab-gh" title="Content">🖋</a> <a href="#data-ab-gh" title="Data">🔣</a> <a href="#projectManagement-ab-gh" title="Project Management">📆</a> <a href="https://github.com/placeAtlas/atlas/pulls?q=is%3Apr+reviewed-by%3Aab-gh" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="https://linktr.ee/aeywoo"><img src="https://avatars.githubusercontent.com/u/65846594?v=4?s=100" width="100px;" alt="Aeywoo"/><br /><sub><b>Aeywoo</b></sub></a><br /><a href="#business-Aeywoo" title="Business development">💼</a> <a href="https://github.com/placeAtlas/atlas/issues?q=author%3AAeywoo" title="Bug reports">🐛</a> <a href="#blog-Aeywoo" title="Blogposts">📝</a> <a href="#content-Aeywoo" title="Content">🖋</a> <a href="#maintenance-Aeywoo" title="Maintenance">🚧</a> <a href="#research-Aeywoo" title="Research">🔬</a></td>
<td align="center"><a href="https://www.linkedin.com/in/chenghanngan/"><img src="https://avatars.githubusercontent.com/u/6516839?v=4?s=100" width="100px;" alt="Cheng Hann Gan"/><br /><sub><b>Cheng Hann Gan</b></sub></a><br /><a href="#data-AnonymousRandomPerson" title="Data">🔣</a> <a href="#content-AnonymousRandomPerson" title="Content">🖋</a> <a href="#research-AnonymousRandomPerson" title="Research">🔬</a> <a href="https://github.com/placeAtlas/atlas/commits?author=AnonymousRandomPerson" title="Code">💻</a> <a href="https://github.com/placeAtlas/atlas/pulls?q=is%3Apr+reviewed-by%3AAnonymousRandomPerson" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="https://github.com/mxdanger"><img src="https://avatars.githubusercontent.com/u/32040254?v=4?s=100" width="100px;" alt="mxdanger"/><br /><sub><b>mxdanger</b></sub></a><br /><a href="https://github.com/placeAtlas/atlas/commits?author=mxdanger" title="Code">💻</a> <a href="#a11y-mxdanger" title="Accessibility">️️️️♿️</a> <a href="https://github.com/placeAtlas/atlas/issues?q=author%3Amxdanger" title="Bug reports">🐛</a> <a href="#design-mxdanger" title="Design">🎨</a> <a href="#ideas-mxdanger" title="Ideas, Planning, & Feedback">🤔</a> <a href="#infra-mxdanger" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-mxdanger" title="Maintenance">🚧</a> <a href="#tool-mxdanger" title="Tools">🔧</a> <a href="#userTesting-mxdanger" title="User Testing">📓</a></td>
<td align="center"><a href="https://github.com/artillect"><img src="https://avatars.githubusercontent.com/u/8906201?v=4?s=100" width="100px;" alt="Riley"/><br /><sub><b>Riley</b></sub></a><br /><a href="#data-artillect" title="Data">🔣</a> <a href="#design-artillect" title="Design">🎨</a> <a href="https://github.com/placeAtlas/atlas/commits?author=artillect" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://stefanocoding.me"><img src="https://avatars.githubusercontent.com/u/25939526?v=4?s=100" width="100px;" alt="Stefano"/><br /><sub><b>Stefano</b></sub></a><br /><a href="#business-Codixer" title="Business development">💼</a> <a href="https://github.com/placeAtlas/atlas/commits?author=Codixer" title="Code">💻</a> <a href="#content-Codixer" title="Content">🖋</a> <a href="#data-Codixer" title="Data">🔣</a> <a href="#design-Codixer" title="Design">🎨</a> <a href="#fundingFinding-Codixer" title="Funding Finding">🔍</a> <a href="#infra-Codixer" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-Codixer" title="Maintenance">🚧</a> <a href="#projectManagement-Codixer" title="Project Management">📆</a> <a href="#question-Codixer" title="Answering Questions">💬</a> <a href="#security-Codixer" title="Security">🛡️</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ab-gh"><img src="https://avatars.githubusercontent.com/u/18347932?v=4?s=100" width="100px;" alt="ash"/><br /><sub><b>ash</b></sub></a><br /><a href="#business-ab-gh" title="Business development">💼</a> <a href="#content-ab-gh" title="Content">🖋</a> <a href="#data-ab-gh" title="Data">🔣</a> <a href="#projectManagement-ab-gh" title="Project Management">📆</a> <a href="https://github.com/placeAtlas/atlas/pulls?q=is%3Apr+reviewed-by%3Aab-gh" title="Reviewed Pull Requests">👀</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://linktr.ee/aeywoo"><img src="https://avatars.githubusercontent.com/u/65846594?v=4?s=100" width="100px;" alt="Aeywoo"/><br /><sub><b>Aeywoo</b></sub></a><br /><a href="#business-Aeywoo" title="Business development">💼</a> <a href="https://github.com/placeAtlas/atlas/issues?q=author%3AAeywoo" title="Bug reports">🐛</a> <a href="#blog-Aeywoo" title="Blogposts">📝</a> <a href="#content-Aeywoo" title="Content">🖋</a> <a href="#maintenance-Aeywoo" title="Maintenance">🚧</a> <a href="#research-Aeywoo" title="Research">🔬</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://www.linkedin.com/in/chenghanngan/"><img src="https://avatars.githubusercontent.com/u/6516839?v=4?s=100" width="100px;" alt="Cheng Hann Gan"/><br /><sub><b>Cheng Hann Gan</b></sub></a><br /><a href="#data-AnonymousRandomPerson" title="Data">🔣</a> <a href="#content-AnonymousRandomPerson" title="Content">🖋</a> <a href="#research-AnonymousRandomPerson" title="Research">🔬</a> <a href="https://github.com/placeAtlas/atlas/commits?author=AnonymousRandomPerson" title="Code">💻</a> <a href="https://github.com/placeAtlas/atlas/pulls?q=is%3Apr+reviewed-by%3AAnonymousRandomPerson" title="Reviewed Pull Requests">👀</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/mxdanger"><img src="https://avatars.githubusercontent.com/u/32040254?v=4?s=100" width="100px;" alt="mxdanger"/><br /><sub><b>mxdanger</b></sub></a><br /><a href="https://github.com/placeAtlas/atlas/commits?author=mxdanger" title="Code">💻</a> <a href="#a11y-mxdanger" title="Accessibility">️️️️♿️</a> <a href="https://github.com/placeAtlas/atlas/issues?q=author%3Amxdanger" title="Bug reports">🐛</a> <a href="#design-mxdanger" title="Design">🎨</a> <a href="#ideas-mxdanger" title="Ideas, Planning, & Feedback">🤔</a> <a href="#infra-mxdanger" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-mxdanger" title="Maintenance">🚧</a> <a href="#tool-mxdanger" title="Tools">🔧</a> <a href="#userTesting-mxdanger" title="User Testing">📓</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/artillect"><img src="https://avatars.githubusercontent.com/u/8906201?v=4?s=100" width="100px;" alt="Riley"/><br /><sub><b>Riley</b></sub></a><br /><a href="#data-artillect" title="Data">🔣</a> <a href="#design-artillect" title="Design">🎨</a> <a href="https://github.com/placeAtlas/atlas/commits?author=artillect" title="Documentation">📖</a></td>
</tr>
</tbody>
</table>
@ -88,4 +53,4 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. This section only includes GitHub contributions. Other credits are shown on [the About page](https://place-atlas.stefanocoding.me/about).

9067
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,36 @@
{
"devDependencies": {
"all-contributors-cli": "^6.23.1"
}
}
"devDependencies": {
"@fullhuman/postcss-purgecss": "^4.1.3",
"@parcel/packager-raw-url": "^2.5.0",
"@parcel/transformer-jsonld": "^2.5.0",
"@parcel/transformer-webmanifest": "^2.5.0",
"parcel": "^2.5.0",
"parcel-namer-rewrite": "^2.0.0-rc.2",
"parcel-resolver-ignore": "^2.1.3",
"postcss": "^8.4.12",
"all-contributors-cli": "^6.23.1"
},
"parcel-namer-rewrite": {
"rules": {
"^(icon-.+)\\.(svg|png|gif|jpg|jpeg)": "_img/pwa/$1.$2",
"^(screenshot-.+)\\.(svg|png|gif|jpg|jpeg)": "_img/pwa/$1.$2",
"(.*)\\.(svg|png|gif|jpg|jpeg)": "_img/$1.$2",
"(.*)\\.(css|woff2?)": "_css/$1{.hash}.$2",
"(.*)\\.(js)": "_js/$1{.hash}.$2"
}
},
"parcelIgnore": [
"sw.js"
],
"browserslist": [
">= 0.5%",
"last 2 major versions",
"not dead",
"Chrome >= 60",
"Firefox >= 60",
"Firefox ESR",
"iOS >= 12",
"Safari >= 12",
"not Explorer <= 11"
]
}

14
postcss.config.js Normal file
View file

@ -0,0 +1,14 @@
const plugins = [];
if (process.env.NODE_ENV === "production") {
plugins["@fullhuman/postcss-purgecss"] = {
content: [
'./dist-temp/*.{html,js,svg}',
'./dist-temp/**/*.{html,js,svg}'
]
}
}
module.exports = {
plugins
};

View file

@ -243,14 +243,14 @@ def convert_subreddit_to_website(entry: dict):
elif not "website" in entry["links"] or len(entry["website"]) == 0:
if not "website" in entry["links"]:
entry["links"]["website"] = []
entry["website"].append(entry["links"]["subreddit"][i])
entry["links"]["website"].append(entry["links"]["subreddit"][i])
entry["links"]["subreddit"][i] = ""
elif re.match(CSTW_REGEX["user"], entry["links"]["subreddit"][i]):
if not "website" in entry["links"] or len(entry["website"]) == 0:
username = re.match(CSTW_REGEX["user"], entry["links"]["subreddit"][i]).group(1)
if not "website" in entry["links"]:
entry["links"]["website"] = []
entry["website"].append("https://www.reddit.com/user/" + username)
entry["links"]["website"].append("https://www.reddit.com/user/" + username)
entry["links"]["subreddit"][i] = ""
return entry

View file

@ -1,5 +0,0 @@
{
"extends": "@parcel/config-default",
"resolvers": ["parcel-resolver-ignore", "..."],
"namers": ["parcel-namer-rewrite", "..."]
}

View file

@ -6,22 +6,16 @@ rm -rf dist
rm -rf .parcel-cache
cp -r web/ dist-temp/
cp tools/ci/postcss.config.js ./
cp tools/ci/package.json ./
cp tools/ci/.parcelrc ./
npm i
python tools/ci/cdn-to-local.py
npx parcel build dist-temp/index.html dist-temp/**.html --dist-dir "dist" --no-source-maps --no-content-hash
rm -rf dist-temp
rm -rf postcss.config.js
rm -rf .parcelrc
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/pwabuilder-sw-register.js dist/
cp web/pwabuilder-sw.js dist/
cp web/sw.js dist/

View file

@ -1,36 +0,0 @@
{
"devDependencies": {
"@fullhuman/postcss-purgecss": "^4.1.3",
"@parcel/packager-raw-url": "^2.5.0",
"@parcel/transformer-jsonld": "^2.5.0",
"@parcel/transformer-webmanifest": "^2.5.0",
"parcel": "^2.5.0",
"parcel-namer-rewrite": "^2.0.0-rc.2",
"parcel-resolver-ignore": "^2.1.3",
"postcss": "^8.4.12"
},
"parcel-namer-rewrite": {
"rules": {
"^(icon-.+)\\.(svg|png|gif|jpg|jpeg)": "_img/pwa/$1.$2",
"^(screenshot-.+)\\.(svg|png|gif|jpg|jpeg)": "_img/pwa/$1.$2",
"(.*)\\.(svg|png|gif|jpg|jpeg)": "_img/$1.$2",
"(.*)\\.(css|woff2?)": "_css/$1{.hash}.$2",
"(.*)\\.(js)": "_js/$1{.hash}.$2"
}
},
"parcelIgnore": [
"pwabuilder-sw-register.js",
"pwabuilder-sw.js"
],
"browserslist": [
">= 0.5%",
"last 2 major versions",
"not dead",
"Chrome >= 60",
"Firefox >= 60",
"Firefox ESR",
"iOS >= 12",
"Safari >= 12",
"not Explorer <= 11"
]
}

View file

@ -1,21 +0,0 @@
const purgecss = require("@fullhuman/postcss-purgecss");
const plugins = [];
if (process.env.NODE_ENV === "production") {
plugins.push(
purgecss({
content: [
'./dist-temp/*.html',
'./dist-temp/**/*.html',
'./dist-temp/**/*.js',
'./dist-temp/*.svg',
'./dist-temp/**/*.svg'
]
})
);
}
module.exports = {
plugins: plugins
};

View file

@ -3,7 +3,7 @@
import sys
import json
path = "./../web/atlas.json"
path = "./../../web/atlas.json"
# path override as 1st param: validate_json.py path_to_file.json
if (len(sys.argv) > 1):

View file

@ -1,661 +0,0 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.

View file

@ -1,16 +1,16 @@
import json
import os
import formatter
from aformatter import format_all_entries, per_line_entries
import scale_back
from scale_back import ScaleConfig
merge_source_file = 'temp_atlas.json'
merge_source_file = 'temp-atlas.json'
with open(merge_source_file, 'r', encoding='UTF-8') as f1:
out_json = json.loads(f1.read())
formatter.format_all_entries(out_json)
format_all_entries.format_all_entries(out_json)
base_image_path = os.path.join('..', 'web', '_img', 'canvas', 'place30')
ScaleConfig.image1 = os.path.join(base_image_path, '159.png')
@ -60,10 +60,10 @@
print('Writing...')
with open('../web/atlas.json', 'w', encoding='utf-8') as atlas_file:
atlas_file.write(formatter.per_line_entries(atlas_json))
atlas_file.write(per_line_entries(atlas_json))
with open('../data/read-ids.txt', 'a', encoding='utf-8') as read_ids_file:
with open('read-ids-temp.txt', 'r+', encoding='utf-8') as read_ids_temp_file:
with open('temp-read-ids.txt', 'r+', encoding='utf-8') as read_ids_temp_file:
read_ids_file.writelines(read_ids_temp_file.readlines())
read_ids_temp_file.truncate(0)

View file

@ -44,13 +44,13 @@ def migrate_atlas_format(entry: dict):
time_key = '%d-%d, T' % time_range
new_entry = {
**new_entry,
"center": {
time_key: center
},
"path": {
time_key: path
}
**new_entry,
"center": {
time_key: center
},
"path": {
time_key: path
}
}
del entry['center']

View file

@ -1,6 +1,25 @@
# Script to retroactively fix flairs
# Only touches things flaired "New entry" that either fail JSON parsing or are already in the atlas
# Otherwise, it leaves them untouched
"""
Script to retroactively fix flairs
Only touches things flaired "New entry" that either fail JSON parsing or are already in the Atlas
Otherwise, it leaves them untouched
Setting up authentication:
1. Head to https://www.reddit.com/prefs/apps
2. Click "are you a developer? create an app..." on the button
3. Enter the name and description
4. Select "script" for the type
5. Enter "redirect uri" as "http://localhost:8080"
6. Create file "credentials" with the format below
[id] <- Under "personal use script"
[secret]
[username] <- For flair access, must be a mod, Don't do this... │
[password] <- ...if you don't know what you are doing. │
Running:
1. Run the script
"""
import praw
import json
@ -42,7 +61,7 @@ def set_flair(submission, flair):
total_all_flairs = 0
rejected_count = 0
processed_count = 0
#for submission in reddit.subreddit('placeAtlas2').new(limit=1000):
for submission in reddit.subreddit('placeAtlas2').new(limit=1000):
#for submission in reddit.subreddit('placeAtlas2').search('flair:"New Entry"',limit=1000,syntax='lucene', sort="top"):
#for submission in reddit.subreddit('placeAtlas2').search('flair:"New Entry"',limit=1000,syntax='lucene', sort="comments"):
#for submission in reddit.subreddit('placeAtlas2').search('flair:"New Entry"',limit=1000,syntax='lucene', sort="hot"):
@ -64,8 +83,8 @@ def set_flair(submission, flair):
Running Script
1. Input the next ID to use
2. Manually resolve errors in manual_atlas.json
3. Copy temp_atlas.json entries into web/_js/atlas.js
2. Manually resolve errors in temp-atlas-manual.json
3. Copy temp-atlas.json entries into web/_js/atlas.js
4. Pull Request
"""

View file

@ -1,25 +1,25 @@
"""
Auth setup
Setting up authentication:
1. Head to https://www.reddit.com/prefs/apps
2. Click "create another app"
3. Give it a name and description
4. Select "script"
5. Redirect to http://localhost:8080
2. Click "are you a developer? create an app..." on the button
3. Enter the name and description
4. Select "script" for the type
5. Enter "redirect uri" as "http://localhost:8080"
6. Create file "credentials" with the format below
[ID] <- Under "personal use script"
[Secret]
[Username] <- Must be a mod, don't do this if you │
[Password] <- don't know what you are doing. │
7. Run Script
[id] <- Under "personal use script"
[secret]
[username] <- For flair access, must be a mod, Don't do this... │
[password] <- ...if you don't know what you are doing. │
Running Script
1. Input the next ID to use
2. Manually resolve errors in manual_atlas.json
3 a. Use merge_out.py, or...
b. a. Copy temp_atlas.json entries into web/_js/atlas.js (mind the edits!)
b. Copy read-ids-temp.txt IDs into data/read-ids.txt
Running:
1. Run the script
2. Input the next ID to use
3. Manually resolve errors in temp-atlas-manual.json
4 a. Use merge_out.py, or...
b. a. Copy temp-atlas.json entries into web/_js/atlas.js (mind the edits!)
b. Copy temp-read-ids.txt IDs into data/read-ids.txt
5. Create a pull request
"""
@ -28,9 +28,9 @@
import time
import re
import traceback
from formatter import format_all, validate
from aformatter import format_all, validate
with open('temp_atlas.json', 'w', encoding='utf-8') as OUT_FILE, open('read-ids-temp.txt', 'w') as READ_IDS_FILE, open('manual_atlas.txt', 'w', encoding='utf-8') as FAIL_FILE:
with open('temp-atlas.json', 'w', encoding='utf-8') as OUT_FILE, open('temp-read-ids.txt', 'w') as READ_IDS_FILE, open('temp-atlas-manual.txt', 'w', encoding='utf-8') as FAIL_FILE:
OUT_FILE_LINES = ['[\n', ']\n']
@ -111,7 +111,7 @@ def set_flair(submission, flair):
assert submission_json["id"] == 0, "Edit invalid because ID is tampered, it must be 0!"
submission_json_dummy = {"id": f'zzz{submission.id}'}
submission_json_dummy = {"id": submission.id}
for key in submission_json:
if not key in submission_json_dummy:
@ -148,4 +148,4 @@ def set_flair(submission, flair):
OUT_FILE.writelines(OUT_FILE_LINES)
print(f"\n\nTotal all flairs: {total_all_flairs}\nSuccess: {successcount}/{totalcount}\nFail: {failcount}/{totalcount}\nPlease check manual_atlas.txt for failed entries to manually resolve.")
print(f"\n\nTotal all flairs: {total_all_flairs}\nSuccess: {successcount}/{totalcount}\nFail: {failcount}/{totalcount}\nPlease check temp-atlas-manual.txt for failed entries to manually resolve.")

1
tools/requirements.txt Normal file
View file

@ -0,0 +1 @@
praw

View file

@ -1,23 +1,14 @@
<!--
========================================================================
The 2022 r/place Atlas
An atlas of Reddit's 2022 r/place, with information to each
artwork of the canvas provided by the community.
Copyright (c) 2017 Roland Rytz <roland@draemm.li>
Copyright (c) 2022 Place Atlas contributors
Licensed under the GNU Affero General Public License Version 3
https://place-atlas.stefanocoding.me/license.txt
========================================================================
Licensed under AGPL-3.0 (https://place-atlas.stefanocoding.me/license.txt)
-->
<!--
This shrinks the atlas by making it arrays instead of objects, but
This shrinks the Atlas by making it arrays instead of objects, but
the difference in size is only about 100k, so it's probably not
worth the effort

View file

@ -1,17 +1,9 @@
/*
========================================================================
The 2022 r/place Atlas
An atlas of Reddit's 2022 r/place, with information to each
artwork of the canvas provided by the community.
Copyright (c) 2017 Roland Rytz <roland@draemm.li>
Copyright (c) 2022 Place Atlas contributors
Licensed under the GNU Affero General Public License Version 3
https://place-atlas.stefanocoding.me/license.txt
========================================================================
*/
/*!
* The 2022 r/place Atlas
* Copyright (c) 2017 Roland Rytz <roland@draemm.li>
* Copyright (c) 2022 Place Atlas contributors
* Licensed under AGPL-3.0 (https://place-atlas.stefanocoding.me/license.txt)
*/
/* purgecss start ignore */

View file

@ -1,17 +1,9 @@
/*
========================================================================
The 2022 r/place Atlas
An atlas of Reddit's 2022 r/place, with information to each
artwork of the canvas provided by the community.
Copyright (c) 2017 Roland Rytz <roland@draemm.li>
Copyright (c) 2022 Place Atlas contributors
Licensed under the GNU Affero General Public License Version 3
https://place-atlas.stefanocoding.me/license.txt
========================================================================
*/
/*!
* The 2022 r/place Atlas
* Copyright (c) 2017 Roland Rytz <roland@draemm.li>
* Copyright (c) 2022 Place Atlas contributors
* Licensed under AGPL-3.0 (https://place-atlas.stefanocoding.me/license.txt)
*/
const redditWrapperEl = document.querySelector('#reddit-contributors-wrapper')
fetch('all-authors.txt')

View file

@ -1,17 +1,30 @@
/*
========================================================================
The 2022 /r/place Atlas
// This script only applies to this instance of the Atlas.
// Please also check code indicated with "@instance-only" outside this file.
// TODO: Avoid having instance-only code inside the main scripts to make updating easier.
An atlas of Reddit's 2022 /r/place, with information to each
artwork of the canvas provided by the community.
const prodDomain = "place-atlas.stefanocoding.me"
window.prodDomain = prodDomain
Copyright (c) 2017 Roland Rytz <roland@draemm.li>
Copyright (c) 2022 Place Atlas contributors
const instanceId = "2022"
window.instanceId = instanceId
Licensed under the GNU Affero General Public License Version 3
https://place-atlas.stefanocoding.me/license.txt
========================================================================
*/
const instanceSubreddit = "placeAtlas2"
window.instanceSubreddit = instanceSubreddit
const pageTitle = "The 2022 r/place Atlas"
window.pageTitle = pageTitle
const canvasSize = {
x: 2000,
y: 2000
}
window.canvasSize = canvasSize
const canvasCenter = {
x: canvasSize.x/2,
y: canvasSize.y/2
}
window.canvasCenter = canvasCenter
const variationsConfig = {
default: {
@ -19,6 +32,11 @@ const variationsConfig = {
code: "",
default: 164,
drawablePeriods: [1, 164],
drawableRegions: [
[[1, 55], [0, 0, 1000, 1000]],
[[56, 108], [0, 0, 2000, 1000]],
[[109, 164], [0, 0, 2000, 2000]]
],
expansions: [56, 109],
versions: [
{ "timestamp": 1648818000, "url": ["./_img/canvas/place30ex/start.png"] },
@ -225,269 +243,17 @@ const variationsConfig = {
// icon: '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 192 192" aria-hidden="true"><path d="M-.07,0V192H191.93V38h-38V117.2l-28.5,28.8h-29.6l-24.89,25.2v-25.2H38.93V38h115V0H-.07Z"/><path d="M72.56,73.7l-7.64,7.64,7.87,7.87-7.87,7.87,7.64,7.64,7.87-7.87,7.87,7.87,7.63-7.64-7.87-7.87,7.87-7.87-7.63-7.64-7.87,7.87-7.87-7.87Z"/><path d="M137.39,73.7l-7.87,7.87-7.87-7.87-7.63,7.63,7.87,7.87-7.87,7.87,7.64,7.64,7.87-7.87,7.87,7.87,7.64-7.64-7.87-7.87,7.87-7.87-7.64-7.64Z"/></svg>'
// }
}
window.variationsConfig = variationsConfig
const codeReference = {}
const imageCache = {}
console.info(`%cThe 2022 r/place Atlas
%cCopyright (c) 2017 Roland Rytz <roland@draemm.li>
Copyright (c) 2022 Place Atlas contributors
Licensed under AGPL-3.0 (https://place-atlas.stefanocoding.me/license.txt)
const variantsEl = document.getElementById("variants")
https://place-atlas.stefanocoding.me/
https://discord.gg/pJkm23b2nA
https://reddit.com/r/placeatlas2
https://github.com/placeAtlas/atlas
for (const variation in variationsConfig) {
codeReference[variationsConfig[variation].code] = variation
const optionEl = document.createElement('option')
optionEl.value = variation
optionEl.textContent = variationsConfig[variation].name
variantsEl.appendChild(optionEl)
}
const timelineSlider = document.getElementById("timeControlsSlider")
const timelineList = document.getElementById("timeControlsList")
const tooltip = document.getElementById("timeControlsTooltip")
const image = document.getElementById("image")
let abortController = new AbortController()
let currentUpdateIndex = 0
let updateTimeout = setTimeout(null, 0)
let tooltipDelayHide = setTimeout(null, 0)
let currentVariation = "default"
const defaultPeriod = variationsConfig[currentVariation].default
const defaultVariation = currentVariation
let currentPeriod = defaultPeriod
window.currentPeriod = currentPeriod
window.currentVariation = currentVariation
// SETUP
timelineSlider.max = variationsConfig[currentVariation].versions.length - 1
timelineSlider.value = currentPeriod
timelineList.children[0].value = defaultPeriod
timelineSlider.addEventListener("input", (e) => timelineParser(e.target.value))
timelineSlider.addEventListener("wheel", function (e) {
if (e.deltaY < 0) {
this.valueAsNumber += 1;
timelineParser(this.value)
} else {
this.value -= 1;
timelineParser(this.value)
}
e.stopPropagation();
}, { passive: true })
function timelineParser(value) {
updateTooltip(parseInt(value), currentVariation)
clearTimeout(updateTimeout)
updateTimeout = setTimeout(() => {
updateTime(parseInt(timelineSlider.value), currentVariation)
setTimeout(() => {
if (timelineSlider.value != currentPeriod && abortController.signal.aborted) {
updateTime(parseInt(timelineSlider.value), currentVariation)
}
}, 50)
}, 25)
}
variantsEl.addEventListener("input", (event) => {
updateTime(-1, event.target.value)
})
const dispatchTimeUpdateEvent = (period = timelineSlider.value, atlas = atlas) => {
const timeUpdateEvent = new CustomEvent('timeupdate', {
detail: {
period: period,
atlas: atlas
}
})
document.dispatchEvent(timeUpdateEvent)
}
async function updateBackground(newPeriod = currentPeriod, newVariation = currentVariation) {
abortController.abort()
abortController = new AbortController()
currentUpdateIndex++
const myUpdateIndex = currentUpdateIndex
const variationConfig = variationsConfig[newVariation]
variantsEl.value = currentVariation
if (variationConfig.icon) {
variantsEl.previousElementSibling.innerHTML = variationConfig.icon
variantsEl.previousElementSibling.classList.remove('d-none')
variantsEl.parentElement.classList.add('input-group')
} else {
variantsEl.previousElementSibling.innerHTML = ""
variantsEl.previousElementSibling.classList.add('d-none')
variantsEl.parentElement.classList.remove('input-group')
}
const configObject = variationConfig.versions[currentPeriod]
if (typeof configObject.url === "string") {
if (imageCache[configObject.url] === undefined) {
const fetchResult = await fetch(configObject.url, {
signal: abortController.signal
})
if (currentUpdateIndex !== myUpdateIndex) {
return [configObject, newPeriod, newVariation]
}
const imageBlob = await fetchResult.blob()
imageCache[configObject.url] = URL.createObjectURL(imageBlob)
}
image.src = imageCache[configObject.url]
} else {
const canvas = document.createElement('canvas')
const context = canvas.getContext('2d')
context.canvas.width = 2000
context.canvas.height = 2000
await Promise.all(configObject.url.map(async url => {
if (imageCache[url] === undefined) {
const fetchResult = await fetch(url, {
signal: abortController.signal
})
if (currentUpdateIndex !== myUpdateIndex) {
return
}
const imageBlob = await fetchResult.blob()
imageCache[url] = URL.createObjectURL(imageBlob)
}
}))
for await (const url of configObject.url) {
const imageLayer = new Image()
await new Promise(resolve => {
imageLayer.onload = () => {
context.drawImage(imageLayer, 0, 0)
resolve()
}
imageLayer.src = imageCache[url]
})
}
if (currentUpdateIndex !== myUpdateIndex) return [configObject, newPeriod, newVariation]
const blob = await new Promise(resolve => canvas.toBlob(resolve))
image.src = URL.createObjectURL(blob)
}
}
async function updateTime(newPeriod = currentPeriod, newVariation = currentVariation, forcePeriod = false) {
document.body.dataset.canvasLoading = ""
if (!variationsConfig[newVariation]) newVariation = defaultVariation
const variationConfig = variationsConfig[newVariation]
if (newPeriod < 0) newPeriod = 0
else if (newPeriod > variationConfig.versions.length - 1) newPeriod = variationConfig.versions.length - 1
currentPeriod = newPeriod
if (currentVariation !== newVariation) {
currentVariation = newVariation
timelineSlider.max = variationConfig.versions.length - 1
if (!forcePeriod) {
currentPeriod = variationConfig.default
newPeriod = currentPeriod
}
if (variationConfig.versions.length === 1) bottomBar.classList.add('no-time-slider')
else bottomBar.classList.remove('no-time-slider')
}
timelineSlider.value = currentPeriod
updateTooltip(newPeriod, newVariation)
await updateBackground(newPeriod, newVariation)
atlas = []
for (const atlasIndex in atlasAll) {
let chosenIndex
const validPeriods2 = Object.keys(atlasAll[atlasIndex].path)
for (const i in validPeriods2) {
const validPeriods = validPeriods2[i].split(', ')
for (const j in validPeriods) {
const [start, end, variation] = parsePeriod(validPeriods[j])
if (isOnPeriod(start, end, variation, newPeriod, newVariation)) {
chosenIndex = i
break
}
}
if (chosenIndex !== undefined) break
}
if (chosenIndex === undefined) continue
const pathChosen = Object.values(atlasAll[atlasIndex].path)[chosenIndex]
const centerChosen = Object.values(atlasAll[atlasIndex].center)[chosenIndex]
if (pathChosen === undefined) continue
atlas.push({
...atlasAll[atlasIndex],
path: pathChosen,
center: centerChosen,
})
}
dispatchTimeUpdateEvent(newPeriod, atlas)
delete document.body.dataset.canvasLoading
tooltip.dataset.forceVisible = ""
clearTimeout(tooltipDelayHide)
tooltipDelayHide = setTimeout(() => {
delete tooltip.dataset.forceVisible
}, 1000)
}
function updateTooltip(newPeriod, newVariation) {
const configObject = variationsConfig[newVariation].versions[newPeriod]
// If timestap is a number return a UTC formatted date otherwise use exact timestap label
if (typeof configObject.timestamp === "number") tooltip.querySelector('div').textContent = new Date(configObject.timestamp * 1000).toUTCString()
else tooltip.querySelector('div').textContent = configObject.timestamp
// Clamps position of tooltip to prevent from going off screen
const timelineSliderRect = timelineSlider.getBoundingClientRect()
let min = -timelineSliderRect.left + 12
let max = (window.innerWidth - tooltip.offsetWidth) - timelineSliderRect.left + 4
tooltip.style.left = Math.min(Math.max((timelineSlider.offsetWidth) * (timelineSlider.value) / (timelineSlider.max) - tooltip.offsetWidth / 2, min), max) + "px"
}
tooltip.parentElement.addEventListener('mouseenter', () => updateTooltip(parseInt(timelineSlider.value), currentVariation))
window.addEventListener('resize', () => updateTooltip(parseInt(timelineSlider.value), currentVariation))
function isOnPeriod(start, end, variation, currentPeriod, currentVariation) {
if (start > end) [start, end] = [end, start]
return currentPeriod >= start && currentPeriod <= end && variation === currentVariation
}
function parsePeriod(periodString) {
let variation = defaultVariation
periodString = periodString + ""
if (periodString.split(':').length > 1) {
const split = periodString.split(':')
variation = codeReference[split[0]]
periodString = split[1]
}
if (periodString.search('-') + 1) {
let [start, end] = periodString.split('-').map(i => parseInt(i))
if (start > end) [start, end] = [end, start]
return [start, end, variation]
} else if (codeReference[periodString]) {
variation = codeReference[periodString]
const defaultPeriod = variationsConfig[variation].default
return [defaultPeriod, defaultPeriod, variation]
} else {
const periodNew = parseInt(periodString)
return [periodNew, periodNew, variation]
}
}
function formatPeriod(start, end, variation) {
let periodString, variationString
variationString = variationsConfig[variation].code
if (start > end) [start, end] = [end, start]
if (start === end) {
if (start === variationsConfig[variation].default && variation !== defaultVariation) {
periodString = ""
}
else periodString = start
}
else periodString = start + "-" + end
if (periodString && variationString) return variationsConfig[variation].code + ":" + periodString
if (variationString) return variationString
return periodString
}
To get the image of the canvas, use downloadCanvas().
`, 'font-size: 150%; line-height: 150%', '')

View file

@ -3,7 +3,7 @@ function updateFavicon(colorScheme) {
const favicon = document.head.querySelector('.js-site-favicon[type="image/svg+xml"]')
const faviconFallback = document.head.querySelector('.js-site-favicon[type="image/png"]')
if (favicon && faviconFallback) {
if (colorScheme || colorScheme == 'dark') {
if (colorScheme || colorScheme === 'dark') {
favicon.href = '_img/favicon-dark.svg'
faviconFallback.href = '_img/favicon-dark.png'
} else {

View file

@ -35,7 +35,7 @@ function pointIsInPolygon(point, polygon) {
const xi = polygon[i][0], yi = polygon[i][1];
const xj = polygon[j][0], yj = polygon[j][1];
const intersect = ((yi > y) != (yj > y))
const intersect = ((yi > y) !== (yj > y))
&& (x < (xj - xi) * (y - yi) / (yj - yi) + xi);
if (intersect) inside = !inside;
}

View file

@ -1,17 +1,9 @@
/*
========================================================================
The 2022 r/place Atlas
An atlas of Reddit's 2022 r/place, with information to each
artwork of the canvas provided by the community.
Copyright (c) 2017 Roland Rytz <roland@draemm.li>
Copyright (c) 2022 Place Atlas contributors
Licensed under the GNU Affero General Public License Version 3
https://place-atlas.stefanocoding.me/license.txt
========================================================================
*/
/*!
* The 2022 r/place Atlas
* Copyright (c) 2017 Roland Rytz <roland@draemm.li>
* Copyright (c) 2022 Place Atlas contributors
* Licensed under AGPL-3.0 (https://place-atlas.stefanocoding.me/license.txt)
*/
window.addEventListener("error", function (e) {
console.error(e)
@ -23,12 +15,12 @@ window.addEventListener("error", function (e) {
})
function getPositionOfEntry(entry) {
let startX = 2000, startY = 2000
let startX = canvasSize.x, startY = canvasSize.y
for (const [x, y] of entry.path) {
startX = Math.min(x, startX)
startY = Math.min(y, startY)
}
if (startX === 2000 || startY === 2000) return null
if (startX === canvasSize.x || startY === canvasSize.y) return null
return [parseInt(startX), parseInt(startY)]
}
@ -37,7 +29,7 @@ const areaMap = new Map()
// Modified from https://stackoverflow.com/a/33670691
function calcPolygonArea(vertices) {
const hit = areaMap.get(vertices)
if (hit != null) {
if (hit !== null) {
return hit
}
@ -45,8 +37,8 @@ function calcPolygonArea(vertices) {
for (let i = 0, l = vertices.length; i < l; i++) {
const addX = vertices[i][0]
const addY = vertices[i == vertices.length - 1 ? 0 : i + 1][1]
const subX = vertices[i == vertices.length - 1 ? 0 : i + 1][0]
const addY = vertices[i === vertices.length - 1 ? 0 : i + 1][1]
const subX = vertices[i === vertices.length - 1 ? 0 : i + 1][0]
const subY = vertices[i][1]
total += (addX * addY * 0.5)

View file

@ -1,17 +1,10 @@
/*
========================================================================
The 2022 r/place Atlas
/*!
* The 2022 r/place Atlas
* Copyright (c) 2017 Roland Rytz <roland@draemm.li>
* Copyright (c) 2022 Place Atlas contributors
* Licensed under AGPL-3.0 (https://place-atlas.stefanocoding.me/license.txt)
*/
An atlas of Reddit's 2022 r/place, with information to each
artwork of the canvas provided by the community.
Copyright (c) 2017 Roland Rytz <roland@draemm.li>
Copyright (c) 2022 Place Atlas contributors
Licensed under the GNU Affero General Public License Version 3
https://place-atlas.stefanocoding.me/license.txt
========================================================================
*/
const finishButton = document.getElementById("finishButton")
const resetButton = document.getElementById("resetButton")
const undoButton = document.getElementById("undoButton")
@ -31,6 +24,8 @@ const periodsAdd = document.getElementById('periodsAdd')
const exportButton = document.getElementById("exportButton")
const cancelButton = document.getElementById("cancelButton")
const exportDirectPostButton = document.getElementById("exportDirectPost")
let exportDirectPostTooltip = null
const exportModalElement = document.getElementById("exportModal")
const exportModal = new bootstrap.Modal(exportModalElement)
@ -46,9 +41,9 @@ 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 = 0
let entryId = undefined
let path = []
let center = [1000, 1000]
let center = [canvasCenter.x, canvasCenter.y]
let websiteGroupElements = []
let subredditGroupElements = []
@ -68,17 +63,34 @@ const periodClipboard = {
"path": null
}
;[...document.querySelectorAll("#objectInfo textarea")].forEach(el => {
el.addEventListener("input", function () {
this.style.height = "auto"
this.style.height = (this.scrollHeight) + "px"
})
const drawBackButton = document.createElement("a")
drawBackButton.className = "btn btn-outline-primary"
drawBackButton.id = "drawBackButton"
drawBackButton.textContent = "Exit Draw Mode"
const baseInputAddon = document.createElement("span")
baseInputAddon.className = "input-group-text"
const baseInputGroup = document.createElement("div")
baseInputGroup.className = "input-group"
const baseInputField = document.createElement("input")
baseInputField.className = "form-control"
baseInputField.spellcheck = false
baseInputField.type = "text"
;[...document.querySelectorAll("#objectInfo textarea")].forEach(el => {
el.addEventListener("input", function () {
this.style.height = "auto"
this.style.height = (this.scrollHeight) + "px"
})
})
window.initDraw = initDraw
function initDraw() {
// Adds exit draw button and removes list button
showListButton.insertAdjacentHTML("afterend", '<button class="btn btn-outline-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasDraw" aria-controls="offcanvasDraw">Menu</button><a id="drawBackButton" class="btn btn-outline-primary" href="./">Exit Draw Mode</a>')
showListButton.insertAdjacentHTML("afterend", '<button class="btn btn-outline-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasDraw" aria-controls="offcanvasDraw">Menu</button>')
showListButton.parentElement.appendChild(drawBackButton)
showListButton.remove()
// Opens draw menu
@ -114,8 +126,8 @@ function initDraw() {
})
function getCanvasCoords(x, y) {
x = x - container.offsetLeft
y = y - container.offsetTop
x -= container.offsetLeft
y -= container.offsetTop
const pos = [
~~((x - (container.clientWidth / 2 - innerContainer.clientWidth / 2 + zoomOrigin[0])) / zoom) + 0.5,
@ -170,9 +182,9 @@ function initDraw() {
})
window.addEventListener("keyup", function (e) {
if (e.key == "z" && e.ctrlKey) {
if (e.key === "z" && e.ctrlKey) {
undo()
} else if (e.key == "y" && e.ctrlKey) {
} else if (e.key === "y" && e.ctrlKey) {
redo()
} else if (e.key === "Shift") {
if (e.code === "ShiftRight") {
@ -234,7 +246,7 @@ function initDraw() {
objectInfoForm.addEventListener('submit', function (e) {
e.preventDefault()
// Allows for html form validation with preview button
if (e.submitter && e.submitter.value == "Preview") {
if (e.submitter && e.submitter.value === "Preview") {
preview()
} else {
exportJson()
@ -248,7 +260,7 @@ function initDraw() {
function generateExportObject() {
const exportObject = {
id: entryId,
id: entryId ?? 0,
name: nameField.value,
description: descriptionField.value,
links: {},
@ -290,18 +302,38 @@ function initDraw() {
function exportJson() {
const exportObject = generateExportObject()
let jsonString = JSON.stringify(exportObject, null, "\t")
jsonString = jsonString.split("\n")
jsonString = jsonString.join("\n ")
jsonString = " " + jsonString
exportArea.value = jsonString
let directPostUrl = "https://www.reddit.com/r/placeAtlas2/submit?selftext=true&title=New%20Submission&text=" + encodeURIComponent(exportArea.value)
if (jsonString.length > 7493) {
directPostUrl = "https://www.reddit.com/r/placeAtlas2/submit?selftext=true&title=New%20Submission&text=" + encodeURIComponent(" " + JSON.stringify(exportObject))
}
document.getElementById("exportDirectPost").href = directPostUrl
let prettyJsonString = JSON.stringify(exportObject, null, "\t")
prettyJsonString = " " + prettyJsonString.split("\n").join("\n ")
exportArea.value = prettyJsonString
let directPostJsonString = prettyJsonString
let directPostUrl = `https://www.reddit.com/r/${instanceSubreddit}/submit?selftext=true&title=`
if (exportObject.id === 0) directPostUrl += `✨%20${encodeURIComponent(exportObject.name)}`
else directPostUrl += `✏%20${encodeURIComponent(exportObject.name)}`
directPostUrl += "&text="
if (entryId == 0) document.getElementById("redditFlair").textContent = "New Entry"
if (directPostJsonString.length + directPostJsonString > 7579) {
directPostJsonString = encodeURIComponent(" " + JSON.stringify(exportObject))
}
if (exportArea.value > 40000) {
exportArea.value = " " + JSON.stringify(exportObject)
}
directPostUrl += directPostJsonString
if (directPostUrl.length > 7579) {
// exportDirectPostButton.classList.add("disabled")
// exportDirectPostButton.ariaDisabled = true
exportDirectPostButton.dataset.bsToggle = "tooltip"
exportDirectPostButton.dataset.bsTitle = "This may not work due to the length of the entry. If needed, please copy manually."
if (!exportDirectPostTooltip) exportDirectPostTooltip = new bootstrap.Tooltip(exportDirectPostButton)
} else {
// exportDirectPostButton.classList.remove("disabled")
// exportDirectPostButton.ariaDisabled = false
exportDirectPostButton.dataset.bsTitle = ""
}
exportDirectPostButton.href = directPostUrl
if (exportObject.id === 0) document.getElementById("redditFlair").textContent = "New Entry"
else document.getElementById("redditFlair").textContent = "Edit Entry"
exportModal.show()
@ -349,7 +381,7 @@ function initDraw() {
function reset() {
// Requires button to be pressed twice to confirm reset
if (resetButton.textContent == "Confirm Reset") {
if (resetButton.textContent = "Confirm Reset") {
resetButton.textContent = "Reset"
resetButton.className = "btn btn-secondary"
@ -470,14 +502,14 @@ function initDraw() {
function updateHovering(e, tapped) {
if (!dragging && (!fixed || tapped)) {
const pos = [
(e.clientX - (container.clientWidth / 2 - innerContainer.clientWidth / 2 + zoomOrigin[0] + container.offsetLeft)) / zoom
, (e.clientY - (container.clientHeight / 2 - innerContainer.clientHeight / 2 + zoomOrigin[1] + container.offsetTop)) / zoom
(e.clientX - (container.clientWidth / 2 - innerContainer.clientWidth / 2 + zoomOrigin[0] + container.offsetLeft)) / zoom,
(e.clientY - (container.clientHeight / 2 - innerContainer.clientHeight / 2 + zoomOrigin[1] + container.offsetTop)) / zoom
]
const coords_p = document.getElementById("coords_p")
// Displays coordinates as zero instead of NaN
if (isNaN(pos[0]) == true) {
if (isNaN(pos[0]) === true) {
coords_p.textContent = "0, 0"
} else {
coords_p.textContent = Math.ceil(pos[0]) + ", " + Math.ceil(pos[1])
@ -495,20 +527,20 @@ function initDraw() {
function addFieldButton(inputButton, inputGroup, array, index, name) {
if (inputButton.title == "Remove " + name) {
if (inputButton.title === "Remove " + name) {
removeFieldButton(inputGroup, array, index)
return
}
inputButton.className = "btn btn-outline-secondary"
inputButton.title = "Remove " + name
inputButton.innerHTML = '<i class="bi bi-trash-fill" aria-hidden="true"></i>'
if (name == "website") {
if (name === "website") {
addWebsiteFields(null, array.length, array)
} else if (name == "subreddit") {
} else if (name === "subreddit") {
addSubredditFields(null, array.length, array)
} else if (name == "Discord invite") {
} else if (name === "Discord invite") {
addDiscordFields(null, array.length, array)
} else if (name == "wiki page") {
} else if (name === "wiki page") {
addWikiFields(null, array.length, array)
}
}
@ -519,14 +551,11 @@ function initDraw() {
}
function addWebsiteFields(link, index, array) {
const inputGroup = document.createElement("div")
inputGroup.className = "input-group"
const inputGroup = baseInputGroup.cloneNode()
websiteGroup.appendChild(inputGroup)
const inputField = document.createElement("input")
const inputField = baseInputField.cloneNode()
inputField.type = "url"
inputField.name = "url"
inputField.className = "form-control"
inputField.id = "websiteField" + index
inputField.placeholder = "https://example.com"
inputField.pattern = "https?://.*"
@ -539,7 +568,7 @@ function initDraw() {
const inputButton = document.createElement("button")
inputButton.type = "button"
// If button is the last in the array give it the add button
if (array.length == index + 1) {
if (array.length === index + 1) {
inputButton.className = "btn btn-secondary"
inputButton.title = "Add website"
inputButton.innerHTML = '<i class="bi bi-plus-lg" aria-hidden="true"></i>'
@ -554,26 +583,21 @@ function initDraw() {
}
function addSubredditFields(link, index, array) {
const inputGroup = document.createElement("div")
inputGroup.className = "input-group"
const inputGroup = baseInputGroup.cloneNode()
subredditGroup.appendChild(inputGroup)
const inputAddon = document.createElement("span")
inputAddon.className = "input-group-text"
const inputAddon = baseInputAddon.cloneNode()
inputAddon.id = "subredditField" + index + "-addon"
inputAddon.textContent = "reddit.com/"
inputGroup.appendChild(inputAddon)
const inputField = document.createElement("input")
inputField.type = "text"
inputField.className = "form-control"
const inputField = baseInputField.cloneNode()
inputField.id = "subredditField" + index
inputField.placeholder = "r/example"
inputField.pattern = "^r\/[A-Za-z0-9][A-Za-z0-9_]{1,20}$"
inputField.title = "Subreddit in format of r/example"
inputField.minLength = "4"
inputField.maxLength = "23"
inputField.spellcheck = false
inputField.setAttribute("aria-labelledby", "subredditLabel")
inputField.setAttribute("aria-describedby", "subredditField" + index + "-addon")
if (link) {
@ -587,7 +611,7 @@ function initDraw() {
const inputButton = document.createElement("button")
inputButton.type = "button"
// If button is the last in the array give it the add button
if (array.length == index + 1) {
if (array.length === index + 1) {
inputButton.className = "btn btn-secondary"
inputButton.title = "Add subreddit"
inputButton.innerHTML = '<i class="bi bi-plus-lg" aria-hidden="true"></i>'
@ -612,22 +636,17 @@ function initDraw() {
}
function addDiscordFields(link, index, array) {
const inputGroup = document.createElement("div")
inputGroup.className = "input-group"
const inputGroup = baseInputGroup.cloneNode()
discordGroup.appendChild(inputGroup)
const inputAddon = document.createElement("span")
inputAddon.className = "input-group-text"
const inputAddon = baseInputAddon.cloneNode()
inputAddon.id = "discordField" + index + "-addon"
inputAddon.textContent = "discord.gg/"
inputGroup.appendChild(inputAddon)
const inputField = document.createElement("input")
inputField.type = "text"
inputField.className = "form-control"
const inputField = baseInputField.cloneNode()
inputField.id = "discordField" + index
inputField.placeholder = "pJkm23b2nA"
inputField.spellcheck = false
inputField.setAttribute("aria-labelledby", "discordLabel")
inputField.setAttribute("aria-describedby", "discordField" + index + "-addon")
inputField.value = link
@ -637,7 +656,7 @@ function initDraw() {
const inputButton = document.createElement("button")
inputButton.type = "button"
// If button is the last in the array give it the add button
if (array.length == index + 1) {
if (array.length === index + 1) {
inputButton.className = "btn btn-secondary"
inputButton.title = "Add Discord invite"
inputButton.innerHTML = '<i class="bi bi-plus-lg" aria-hidden="true"></i>'
@ -662,16 +681,12 @@ function initDraw() {
}
function addWikiFields(link, index, array) {
const inputGroup = document.createElement("div")
inputGroup.className = "input-group"
const inputGroup = baseInputGroup.cloneNode()
wikiGroup.appendChild(inputGroup)
const inputField = document.createElement("input")
inputField.type = "text"
inputField.className = "form-control"
const inputField = baseInputField.cloneNode()
inputField.id = "wikiField" + index
inputField.placeholder = "Page title"
inputField.spellcheck = false
inputField.setAttribute("aria-labelledby", "wikiLabel")
inputField.value = link
inputGroup.appendChild(inputField)
@ -680,7 +695,7 @@ function initDraw() {
const inputButton = document.createElement("button")
inputButton.type = "button"
// If button is the last in the array give it the add button
if (array.length == index + 1) {
if (array.length === index + 1) {
inputButton.className = "btn btn-secondary"
inputButton.title = "Add wiki page"
inputButton.innerHTML = '<i class="bi bi-plus-lg" aria-hidden="true"></i>'
@ -694,7 +709,7 @@ function initDraw() {
inputGroup.appendChild(inputButton)
}
if (params.has('id')) {
if (params.has('id') && getEntry(params.get('id'))) {
entryId = params.get('id')
const entry = getEntry(entryId)
@ -740,7 +755,7 @@ function initDraw() {
} else {
document.getElementById("offcanvasDrawLabel").textContent = "New Entry"
pathWithPeriods.push([defaultPeriod, []])
pathWithPeriods.push([formatPeriod(currentPeriod, currentPeriod, currentVariation), []])
// Builds multi-input list
addWebsiteFields("", 0, [0])
@ -753,17 +768,7 @@ function initDraw() {
zoom = 4
zoomOrigin = [
innerContainer.clientWidth / 2 - center[0] * zoom,// + container.offsetLeft
innerContainer.clientHeight / 2 - center[1] * zoom// + container.offsetTop
]
scaleZoomOrigin = [
2000 / 2 - center[0],// + container.offsetLeft
2000 / 2 - center[1]// + container.offsetTop
]
applyView()
setView(center[0], center[1])
document.addEventListener('timeupdate', () => {
renderBackground()
@ -771,10 +776,16 @@ function initDraw() {
})
periodsAdd.addEventListener('click', () => {
pathWithPeriods.push([defaultPeriod, []])
pathWithPeriods.push([formatPeriod(currentPeriod, currentPeriod, currentVariation), []])
initPeriodGroups()
})
drawBackButton.href = "./" + formatHash(entryId, currentPeriod, currentPeriod, currentVariation)
document.addEventListener('timeupdate', (event) => {
drawBackButton.href = "./" + formatHash(entryId, event.detail.period, event.detail.period, event.detail.variation)
})
}
function calculateCenter(path) {
@ -845,18 +856,18 @@ function initPeriodGroups() {
startPeriodEl.max = variationsConfig[variation].drawablePeriods[1]
endPeriodEl.max = variationsConfig[variation].drawablePeriods[1]
startPeriodEl.value = start
if (startPeriodEl.value == startPeriodEl.min) startPeriodLeftEl.disabled = true
if (startPeriodEl.value == startPeriodEl.max) startPeriodRightEl.disabled = true
if (startPeriodEl.value === startPeriodEl.min) startPeriodLeftEl.disabled = true
if (startPeriodEl.value === startPeriodEl.max) startPeriodRightEl.disabled = true
endPeriodEl.value = end
if (endPeriodEl.value == endPeriodEl.min) endPeriodLeftEl.disabled = true
if (endPeriodEl.value == endPeriodEl.max) endPeriodRightEl.disabled = true
if (endPeriodEl.value === endPeriodEl.min) endPeriodLeftEl.disabled = true
if (endPeriodEl.value === endPeriodEl.max) endPeriodRightEl.disabled = true
// Adds tick marks to assit in preventing overlap
startPeriodListEl.innerHTML = '<option value="' + (end - 1) + '"></option>'
endPeriodListEl.innerHTML = '<option value="' + (start + 1) + '"></option>'
// Removes slider controls if no timeline range exists
if (startPeriodEl.max == 0) periodGroupEl.classList.add('no-time-slider')
if (startPeriodEl.max === 0) periodGroupEl.classList.add('no-time-slider')
else periodGroupEl.classList.remove('no-time-slider')
// If one period disable delete
@ -865,6 +876,7 @@ function initPeriodGroups() {
startPeriodEl.addEventListener('input', () => {
if (path.length >= 3) {
periodCenter = calculateCenter(path)
// @instance-only
if ((periodCenter[1] > 1000) && (startPeriodEl.valueAsNumber <= variationsConfig[variation].expansions[1])) {
// Second expansion
startPeriodEl.value = variationsConfig[variation].expansions[1];
@ -888,30 +900,29 @@ function initPeriodGroups() {
// Set zoom view
periodCenter = calculateCenter(path)
zoomOrigin = [innerContainer.clientWidth / 2 - periodCenter[0] * zoom, innerContainer.clientHeight / 2 - periodCenter[1] * zoom]
scaleZoomOrigin = [2000 / 2 - periodCenter[0], 2000 / 2 - periodCenter[1]]
applyView()
setView(periodCenter[0], periodCenter[1], setZoomByPath(path))
})
function startPeriodUpdate(value) {
endPeriodListEl.innerHTML = '<option value="' + (parseInt(value) + 1) + '"></option>'
// Update time only when value changes
if (startPeriodEl.value != timelineSlider.value) {
if (startPeriodEl.value !== timelineSlider.value) {
timelineSlider.value = value
updateTime(parseInt(value), variation)
}
// Set start incremental button disabled states
if (startPeriodEl.value == startPeriodEl.min) {
if (startPeriodEl.value === startPeriodEl.min) {
startPeriodLeftEl.disabled = true
startPeriodRightEl.disabled = false
} else if (startPeriodEl.value == startPeriodEl.max) {
} else if (startPeriodEl.value === startPeriodEl.max) {
startPeriodLeftEl.disabled = false
startPeriodRightEl.disabled = true
} else {
if (path.length >= 3) {
periodCenter = calculateCenter(path)
// @instance-only
if ((periodCenter[1] > 1000) && (startPeriodEl.valueAsNumber <= variationsConfig[variation].expansions[1])) {
// Second expansion
startPeriodLeftEl.disabled = true
@ -932,6 +943,7 @@ function initPeriodGroups() {
endPeriodEl.addEventListener('input', () => {
if (path.length >= 3) {
periodCenter = calculateCenter(path)
// @instance-only
if ((periodCenter[1] > 1000) && (endPeriodEl.valueAsNumber <= variationsConfig[variation].expansions[1])) {
// Second expansion
endPeriodEl.value = variationsConfig[variation].expansions[1];
@ -955,29 +967,28 @@ function initPeriodGroups() {
// Set zoom view
periodCenter = calculateCenter(path)
zoomOrigin = [innerContainer.clientWidth / 2 - periodCenter[0] * zoom, innerContainer.clientHeight / 2 - periodCenter[1] * zoom]
scaleZoomOrigin = [2000 / 2 - periodCenter[0], 2000 / 2 - periodCenter[1]]
applyView()
setView(periodCenter[0], periodCenter[1], setZoomByPath(path))
})
function endPeriodUpdate(value) {
startPeriodListEl.innerHTML = '<option value="' + (parseInt(value) + 1) + '"></option>'
// Update time only when value changes
if (endPeriodEl.value != timelineSlider.value) {
if (endPeriodEl.value !== timelineSlider.value) {
timelineSlider.value = value
updateTime(parseInt(value), variation)
}
// Set end incremental button disabled states
if (endPeriodEl.value == endPeriodEl.min) {
if (endPeriodEl.value === endPeriodEl.min) {
endPeriodLeftEl.disabled = true
endPeriodRightEl.disabled = false
} else if (endPeriodEl.value == endPeriodEl.max) {
} else if (endPeriodEl.value === endPeriodEl.max) {
endPeriodLeftEl.disabled = false
endPeriodRightEl.disabled = true
} else {
if (path.length >= 3) {
periodCenter = calculateCenter(path)
// @instance-only
if (periodCenter && (periodCenter[1] > 1000) && (endPeriodEl.valueAsNumber <= variationsConfig[variation].expansions[1])) {
// Second expansion
endPeriodLeftEl.disabled = true
@ -1014,7 +1025,7 @@ function initPeriodGroups() {
startPeriodEl.value = newVariationConfig.default
endPeriodEl.value = newVariationConfig.default
periodVariationEl.previousElementSibling.innerHTML = newVariationConfig.icon
if (startPeriodEl.max == 0) periodGroupEl.classList.add('no-time-slider')
if (startPeriodEl.max === 0) periodGroupEl.classList.add('no-time-slider')
else periodGroupEl.classList.remove('no-time-slider')
pathWithPeriods[index][0] = `${newVariationConfig.code}:${newVariationConfig.default}`
updateTime(newVariationConfig.default, newVariation)
@ -1154,10 +1165,11 @@ function updatePeriodGroups() {
else periodDeleteEl.disabled = false
// Set start incremental button disabled states
if (startPeriodEl.value == startPeriodEl.min) {
// @instance-only
if (startPeriodEl.value === startPeriodEl.min) {
startPeriodLeftEl.disabled = true
startPeriodRightEl.disabled = false
} else if (startPeriodEl.value == startPeriodEl.max) {
} else if (startPeriodEl.value === startPeriodEl.max) {
startPeriodLeftEl.disabled = false
startPeriodRightEl.disabled = true
} else {
@ -1177,10 +1189,11 @@ function updatePeriodGroups() {
}
// Set end incremental button disabled states
if (endPeriodEl.value == endPeriodEl.min) {
// @instance-only
if (endPeriodEl.value === endPeriodEl.min) {
endPeriodLeftEl.disabled = true
endPeriodRightEl.disabled = false
} else if (endPeriodEl.value == endPeriodEl.max) {
} else if (endPeriodEl.value === endPeriodEl.max) {
endPeriodLeftEl.disabled = false
endPeriodRightEl.disabled = true
} else {
@ -1240,7 +1253,7 @@ function updatePath(newPath, newUndoHistory) {
path = newPath || path
if (path.length > 3) center = calculateCenter(path)
render(path)
undoButton.disabled = path.length == 0; // Maybe make it undo the cancel action in the future
undoButton.disabled = path.length === 0; // Maybe make it undo the cancel action in the future
undoHistory = newUndoHistory || []
redoButton.disabled = (!undoHistory.length)

View file

@ -1,17 +1,17 @@
/*
========================================================================
The 2022 r/place Atlas
/*!
* The 2022 r/place Atlas
* Copyright (c) 2017 Roland Rytz <roland@draemm.li>
* Copyright (c) 2022 Place Atlas contributors
* Licensed under AGPL-3.0 (https://place-atlas.stefanocoding.me/license.txt)
*/
An atlas of Reddit's 2022 r/place, with information to each
artwork of the canvas provided by the community.
const baseLinkElement = document.createElement("a")
baseLinkElement.className = "btn btn-primary text-truncate"
baseLinkElement.target = "_blank"
baseLinkElement.rel = "noopener noreferrer"
Copyright (c) 2017 Roland Rytz <roland@draemm.li>
Copyright (c) 2022 Place Atlas contributors
Licensed under the GNU Affero General Public License Version 3
https://place-atlas.stefanocoding.me/license.txt
========================================================================
*/
const baseGroupElement = document.createElement("div")
baseGroupElement.className = "btn-group-vertical"
function createLabel(name, value, parent) {
const nameElement = document.createElement("span")
@ -42,9 +42,12 @@ function createInfoBlock(entry, isPreview) {
linkElement.className = "text-decoration-none d-flex justify-content-between text-body"
if (isPreview) linkElement.href = "#"
else {
const targetPeriod = formatPeriod(currentPeriod, currentPeriod, currentVariation)
linkElement.href = "#" + entry.id
if (targetPeriod && targetPeriod != defaultPeriod) linkElement.href += "/" + targetPeriod
linkElement.href = formatHash(entry.id)
linkElement.addEventListener('click', e => {
e.preventDefault()
location.hash = formatHash(entry.id)
window.dispatchEvent(new HashChangeEvent("hashchange"))
})
}
const linkNameElement = document.createElement("span")
linkNameElement.className = "flex-grow-1 text-break"
@ -78,19 +81,19 @@ function createInfoBlock(entry, isPreview) {
if (entry.diff) {
const diffElement = createInfoListItem("Diff: ", entry.diff)
if (entry.diff == "add") {
if (entry.diff === "add") {
diffElement.className = "list-group-item list-group-item-success"
} else if (entry.diff == "edit") {
} else if (entry.diff === "edit") {
diffElement.className = "list-group-item list-group-item-warning"
} else if (entry.diff == "delete") {
} else if (entry.diff === "delete") {
diffElement.className = "list-group-item list-group-item-danger"
}
listElement.appendChild(diffElement)
}
// Enetry data submitted to preview does not include center or path
// Entry data submitted to preview does not include center or path
if (!isPreview) {
const [x, y] = entry.center
const [x, y] = entry?.center
listElement.appendChild(createInfoListItem("Position: ", `${Math.floor(x)}, ${Math.floor(y)}`))
if (entry.path) {
@ -99,18 +102,14 @@ function createInfoBlock(entry, isPreview) {
}
}
if (!(entry.links.subreddit === undefined || entry.links.subreddit.length == 0)) {
const subredditGroupElement = document.createElement("div")
subredditGroupElement.className = "btn-group-vertical"
if (entry.links.subreddit?.length) {
const subredditGroupElement = baseGroupElement.cloneNode()
linkListElement.appendChild(subredditGroupElement)
entry.links.subreddit.forEach(subreddit => {
if (subreddit) {
subreddit = "r/" + subreddit
const subredditLinkElement = document.createElement("a")
subredditLinkElement.className = "btn btn-primary text-truncate"
subredditLinkElement.target = "_blank"
subredditLinkElement.rel = "noopener noreferrer"
const subredditLinkElement = baseLinkElement.cloneNode()
subredditLinkElement.href = "https://reddit.com/" + subreddit
subredditLinkElement.innerHTML = `<i class="bi bi-reddit" aria-hidden="true"></i> ${subreddit}`
subredditGroupElement.appendChild(subredditLinkElement)
@ -118,17 +117,13 @@ function createInfoBlock(entry, isPreview) {
})
}
if (!(entry.links.website === undefined || entry.links.website.length == 0)) {
const websiteGroupElement = document.createElement("div")
websiteGroupElement.className = "btn-group-vertical"
if (entry.links.website?.length) {
const websiteGroupElement = baseGroupElement.cloneNode()
linkListElement.appendChild(websiteGroupElement)
entry.links.website.forEach(link => {
if (link) {
const websiteLinkElement = document.createElement("a")
websiteLinkElement.className = "btn btn-primary text-truncate"
websiteLinkElement.target = "_blank"
websiteLinkElement.rel = "noopener noreferrer"
const websiteLinkElement = baseLinkElement.cloneNode()
websiteLinkElement.href = link
try {
const urlObject = new URL(link)
@ -141,17 +136,13 @@ function createInfoBlock(entry, isPreview) {
})
}
if (!(entry.links.discord === undefined || entry.links.discord.length == 0)) {
const discordGroupElement = document.createElement("div")
discordGroupElement.className = "btn-group-vertical"
if (entry.links.discord?.length) {
const discordGroupElement = baseGroupElement.cloneNode()
linkListElement.appendChild(discordGroupElement)
entry.links.discord.forEach(link => {
if (link) {
const discordLinkElement = document.createElement("a")
discordLinkElement.className = "btn btn-primary text-truncate"
discordLinkElement.target = "_blank"
discordLinkElement.rel = "noopener noreferrer"
const discordLinkElement = baseLinkElement.cloneNode()
discordLinkElement.href = "https://discord.gg/" + link
discordLinkElement.innerHTML = `<i class="bi bi-discord" aria-hidden="true"></i> ${link}`
discordGroupElement.appendChild(discordLinkElement)
@ -159,17 +150,13 @@ function createInfoBlock(entry, isPreview) {
})
}
if (!(entry.links.wiki === undefined || entry.links.wiki.length == 0)) {
const wikiGroupElement = document.createElement("div")
wikiGroupElement.className = "btn-group-vertical"
if (entry.links.wiki?.length) {
const wikiGroupElement = baseGroupElement.cloneNode()
linkListElement.appendChild(wikiGroupElement)
entry.links.wiki.forEach(link => {
if (link) {
const wikiLinkElement = document.createElement("a")
wikiLinkElement.className = "btn btn-primary text-truncate"
wikiLinkElement.target = "_blank"
wikiLinkElement.rel = "noopener noreferrer"
const wikiLinkElement = baseLinkElement.cloneNode()
wikiLinkElement.href = "https://place-wiki.stefanocoding.me/wiki/" + link.replace(/ /g, '_')
wikiLinkElement.innerHTML = `<i class="bi bi-book" aria-hidden="true"></i> Wiki Article`
wikiGroupElement.appendChild(wikiLinkElement)
@ -191,7 +178,7 @@ function createInfoBlock(entry, isPreview) {
const editElement = document.createElement("a")
editElement.textContent = "Edit"
editElement.className = "btn btn-sm btn-outline-primary"
editElement.href = "./?mode=draw&id=" + entry.id
editElement.href = "./?mode=draw&id=" + entry.id + formatHash(undefined)
editElement.title = "Edit " + entry.name
idElementContainer.appendChild(editElement)
}

View file

@ -1,25 +1,21 @@
/*
========================================================================
The 2022 r/place Atlas
An atlas of Reddit's 2022 r/place, with information to each
artwork of the canvas provided by the community.
Copyright (c) 2017 Roland Rytz <roland@draemm.li>
Copyright (c) 2022 Place Atlas contributors
Licensed under the GNU Affero General Public License Version 3
https://place-atlas.stefanocoding.me/license.txt
========================================================================
*/
const prodDomain = "place-atlas.stefanocoding.me"
/*!
* The 2022 r/place Atlas
* Copyright (c) 2017 Roland Rytz <roland@draemm.li>
* Copyright (c) 2022 Place Atlas contributors
* Licensed under AGPL-3.0 (https://place-atlas.stefanocoding.me/license.txt)
*/
const innerContainer = document.getElementById("innerContainer")
const container = document.getElementById("container")
const canvas = document.getElementById("highlightCanvas")
const canvasImage = document.getElementById('image')
const context = canvas.getContext("2d")
canvas.width = canvasSize.x
canvas.height = canvasSize.y
canvasImage.width = canvasSize.x
canvasImage.height = canvasSize.y
let zoom = 1
if (window.devicePixelRatio) {
@ -37,24 +33,36 @@ let lastPosition = [0, 0]
const viewportSize = [0, 0]
// TODO Probably merge both functions
function applyView() {
//console.log(zoomOrigin, scaleZoomOrigin)
//console.log(scaleZoomOrigin[0])
scaleZoomOrigin[0] = Math.max(-1000, Math.min(1000, scaleZoomOrigin[0]))
scaleZoomOrigin[1] = Math.max(-1000, Math.min(1000, scaleZoomOrigin[1]))
scaleZoomOrigin[0] = Math.max(-canvasCenter.x, Math.min(canvasCenter.x, scaleZoomOrigin[0]))
scaleZoomOrigin[1] = Math.max(-canvasCenter.y, Math.min(canvasCenter.y, scaleZoomOrigin[1]))
zoomOrigin = [scaleZoomOrigin[0] * zoom, scaleZoomOrigin[1] * zoom]
innerContainer.style.height = (~~(zoom * 2000)) + "px"
innerContainer.style.width = (~~(zoom * 2000)) + "px"
innerContainer.style.height = (~~(zoom * canvasSize.x)) + "px"
innerContainer.style.width = (~~(zoom * canvasSize.y)) + "px"
innerContainer.style.left = ~~(container.clientWidth / 2 - innerContainer.clientWidth / 2 + zoomOrigin[0] + container.offsetLeft) + "px"
innerContainer.style.top = ~~(container.clientHeight / 2 - innerContainer.clientHeight / 2 + zoomOrigin[1] + container.offsetTop) + "px"
}
function setView(x, y, zoomN = zoom) {
zoom = zoomN
scaleZoomOrigin = [
canvasCenter.x - x,
canvasCenter.y - y
]
applyView()
}
let atlas = null
window.atlas = atlas
let atlasAll = null
@ -66,7 +74,7 @@ init()
async function init() {
// For Reviewing Reddit Changes
//let resp = await fetch("../tools/temp_atlas.json")
//let resp = await fetch("../tools/temp-atlas.json")
const resp = await fetch("./atlas.json")
atlas = await resp.json()
atlas.sort(function (a, b) {
@ -140,7 +148,7 @@ async function init() {
}
} else if (mode.startsWith("diff")) {
try {
const liveResp = await fetch("https://place-atlas.stefanocoding.me/atlas.json")
const liveResp = await fetch(`https://${prodDomain}/atlas.json`)
let liveJson = await liveResp.json()
liveJson = updateAtlasAll(liveJson)
@ -173,7 +181,7 @@ async function init() {
if (mode.includes("only")) {
atlasAll = atlasAll.filter(function (entry) {
return typeof entry.diff == "string"
return typeof entry.diff === "string"
})
}
@ -195,7 +203,7 @@ async function init() {
document.getElementById("loading").classList.add("d-none")
document.getElementById("zoomInButton").addEventListener("click", function (e) {
document.getElementById("zoomInButton").addEventListener("click", function () {
/*if(zoomAnimationFrame){
window.cancelAnimationFrame(zoomAnimationFrame)
@ -219,7 +227,7 @@ async function init() {
})
document.getElementById("zoomOutButton").addEventListener("click", function (e) {
document.getElementById("zoomOutButton").addEventListener("click", function () {
/*if(zoomAnimationFrame){
window.cancelAnimationFrame(zoomAnimationFrame)
@ -236,13 +244,13 @@ async function init() {
initialPinchZoom = zoom
lastPosition = [x, y]
zoom = zoom / 2
zoom /= 2
zoom = Math.max(minZoom, Math.min(maxZoom, zoom))
applyZoom(x, y, zoom)
})
document.getElementById("zoomResetButton").addEventListener("click", function (e) {
document.getElementById("zoomResetButton").addEventListener("click", function () {
zoom = 1
zoomOrigin = [0, 0]
scaleZoomOrigin = [0, 0]
@ -267,14 +275,8 @@ async function init() {
lastPosition = [x, y]
if (e.ctrlKey) {
zoom = zoom / 2
} else {
zoom = zoom * 2
}
if (e.ctrlKey) zoom /= 2
else zoom *= 2
zoom = Math.max(minZoom, Math.min(maxZoom, zoom))
applyZoom(x, y, zoom)
@ -344,7 +346,7 @@ async function init() {
container.addEventListener("touchstart", function (e) {
if (e.touches.length == 2) {
if (e.touches.length === 2) {
e.preventDefault()
}
@ -359,11 +361,11 @@ async function init() {
function touchstart(e) {
if (e.touches.length == 1) {
if (e.touches.length === 1) {
mousedown(e.touches[0].clientX, e.touches[0].clientY)
} else if (e.touches.length == 2) {
} else if (e.touches.length === 2) {
initialPinchDistance = Math.sqrt(
Math.pow(e.touches[0].clientX - e.touches[1].clientX, 2)
@ -394,7 +396,7 @@ async function init() {
})
window.addEventListener("touchmove", function (e) {
if (e.touches.length == 2 || e.scale > 1) {
if (e.touches.length === 2 || e.scale > 1) {
e.preventDefault()
}
@ -430,11 +432,11 @@ async function init() {
updateLines()
if (e.touches.length == 1) {
if (e.touches.length === 1) {
mousemove(e.touches[0].clientX, e.touches[0].clientY)
} else if (e.touches.length == 2) {
} else if (e.touches.length === 2) {
const newPinchDistance = Math.sqrt(
Math.pow(e.touches[0].clientX - e.touches[1].clientX, 2)
@ -473,7 +475,7 @@ async function init() {
window.addEventListener("mouseup", function (e) {
if (hovered.length > 0) {
container.style.cursor = "pointer"
} else if (drawing == true) {
} else if (drawing === true) {
container.style.cursor = "crosshair"
} else {
container.style.cursor = "default"
@ -493,11 +495,11 @@ async function init() {
function touchend(e) {
if (e.touches.length == 0) {
if (e.touches.length === 0) {
mouseup()
} else if (e.touches.length == 1) {
} else if (e.touches.length === 1) {
initialPinchZoom = zoom
lastPosition = [e.touches[0].clientX, e.touches[0].clientY]
}

View file

@ -1,23 +1,15 @@
/*
========================================================================
The 2022 r/place Atlas
An atlas of Reddit's 2022 r/place, with information to each
artwork of the canvas provided by the community.
Copyright (c) 2017 Roland Rytz <roland@draemm.li>
Copyright (c) 2022 Place Atlas contributors
Licensed under the GNU Affero General Public License Version 3
https://place-atlas.stefanocoding.me/license.txt
========================================================================
*/
/*!
* The 2022 r/place Atlas
* Copyright (c) 2017 Roland Rytz <roland@draemm.li>
* Copyright (c) 2022 Place Atlas contributors
* Licensed under AGPL-3.0 (https://place-atlas.stefanocoding.me/license.txt)
*/
function initOverlap() {
window.renderBackground = renderBackground
const hovered = []
// const hovered = []
buildObjectsList(null, null)
renderBackground(atlas)
@ -69,12 +61,12 @@ function initOverlap() {
let blank = 0
for (let i = 0; i < pixels.length; i += 4) {
if (pixels[i] == 255) {
if (pixels[i] === 255) {
blank++
}
}
const blankPercentage = (blank / (2000 * 2000)) * 100
const blankPercentage = (blank / (canvasSize.x * canvasSize.y)) * 100
console.info(blank + " blank pixels, which are " + blankPercentage.toPrecision(4) + "% of the canvas (" + (100 - blankPercentage).toPrecision(4) + "% mapped)")
}

View file

@ -1,17 +1,9 @@
/*
========================================================================
The 2022 r/place Atlas
An atlas of Reddit's 2022 r/place, with information to each
artwork of the canvas provided by the community.
Copyright (c) 2017 Roland Rytz <roland@draemm.li>
Copyright (c) 2022 Place Atlas contributors
Licensed under the GNU Affero General Public License Version 3
https://place-atlas.stefanocoding.me/license.txt
========================================================================
*/
/*!
* The 2022 r/place Atlas
* Copyright (c) 2017 Roland Rytz <roland@draemm.li>
* Copyright (c) 2022 Place Atlas contributors
* Licensed under AGPL-3.0 (https://place-atlas.stefanocoding.me/license.txt)
*/
let areasSum = 0
const areas = []
@ -122,12 +114,12 @@ let linesDistance = 1
for (let i = 0; i <= Math.ceil((mostCounts / linesDistance) / 5) * 5; i++) {
ctx.beginPath()
ctx.moveTo(
50
, ~~(el.height - 50 - i * (linesDistance / mostCounts) * (el.height - 100)) + 0.5
50,
~~(el.height - 50 - i * (linesDistance / mostCounts) * (el.height - 100)) + 0.5
)
ctx.lineTo(
el.width - 25
, ~~(el.height - 50 - i * (linesDistance / mostCounts) * (el.height - 100)) + 0.5
el.width - 25,
~~(el.height - 50 - i * (linesDistance / mostCounts) * (el.height - 100)) + 0.5
)
ctx.stroke()
}
@ -138,19 +130,19 @@ linesDistance = 5
for (let i = 0; i <= Math.ceil(mostCounts / linesDistance); i++) {
ctx.beginPath()
ctx.moveTo(
50
, ~~(el.height - 50 - i * (linesDistance / mostCounts) * (el.height - 100)) + 0.5
50,
~~(el.height - 50 - i * (linesDistance / mostCounts) * (el.height - 100)) + 0.5
)
ctx.lineTo(
el.width - 25
, ~~(el.height - 50 - i * (linesDistance / mostCounts) * (el.height - 100)) + 0.5
el.width - 25,
~~(el.height - 50 - i * (linesDistance / mostCounts) * (el.height - 100)) + 0.5
)
ctx.stroke()
ctx.fillText(
i * linesDistance
, 40
, ~~(el.height - 50 - i * (linesDistance / mostCounts) * (el.height - 100)) + 0.5
i * linesDistance,
40,
~~(el.height - 50 - i * (linesDistance / mostCounts) * (el.height - 100)) + 0.5
)
}
@ -162,9 +154,9 @@ ctx.font = "10px sans"
let a = 0
for (let i = 0; i <= counts.length; i++) {
if (i % skip == 0) {
if (i % skip === 0) {
let y = 0
if (a % 2 == 0) {
if (a % 2 === 0) {
y = ~~(el.height - 30) + 0.5
} else {
y = ~~(el.height - 45) + 0.5
@ -172,19 +164,19 @@ for (let i = 0; i <= counts.length; i++) {
a++
ctx.beginPath()
ctx.moveTo(
~~(((i) / steps) * (el.width - 125) + 75) + 0.5
, ~~(el.height - 50) + 0.5
~~(((i) / steps) * (el.width - 125) + 75) + 0.5,
~~(el.height - 50) + 0.5
)
ctx.lineTo(
~~(((i) / steps) * (el.width - 125) + 75) + 0.5
, y
~~(((i) / steps) * (el.width - 125) + 75) + 0.5,
y
)
ctx.stroke()
ctx.fillText(
(i) * (max / steps)
, ~~(((i) / steps) * (el.width - 125) + 75) - 0.5
, y + 5
(i) * (max / steps),
~~(((i) / steps) * (el.width - 125) + 75) - 0.5,
y + 5
)
}
}
@ -193,17 +185,17 @@ ctx.fillStyle = "#FF0000"
ctx.strokeStyle = "#CC0000"
for (let i = 0; i < counts.length; i++) {
if (i % 2 == 0) {
if (i % 2 === 0) {
ctx.fillStyle = "#FF0000"
} else {
ctx.fillStyle = "#DD0000"
}
ctx.fillRect(
~~((i / steps) * (el.width - 125) + 75)
, el.height - 50
, Math.ceil(1 / steps * (el.width - 125))
, ~~(-(counts[i] / mostCounts) * (el.height - 100))
~~((i / steps) * (el.width - 125) + 75),
el.height - 50,
Math.ceil(1 / steps * (el.width - 125)),
~~(-(counts[i] / mostCounts) * (el.height - 100))
)
/*ctx.beginPath()
@ -245,30 +237,10 @@ for (let i = 0; i < topCount; i++) {
console.info(outstring)
atlas.sort(function (a, b) {
if (a.center[0] < b.center[0]) {
return -1
}
if (a.center[0] > b.center[0]) {
return 1
}
// a must be equal to b
return 0
})
atlas.sort((a, b) => a.center[0] - b.center[0])
console.info("Median x: " + atlas[~~(atlas.length / 2)].center[0])
atlas.sort(function (a, b) {
if (a.center[1] < b.center[1]) {
return -1
}
if (a.center[1] > b.center[1]) {
return 1
}
// a must be equal to b
return 0
})
atlas.sort((a, b) => a.center[1] - b.center[1])
console.info("Median y: " + atlas[~~(atlas.length / 2)].center[1])

287
web/_js/main/time.js Normal file
View file

@ -0,0 +1,287 @@
/*!
* The 2022 r/place Atlas
* Copyright (c) 2017 Roland Rytz <roland@draemm.li>
* Copyright (c) 2022 Place Atlas contributors
* Licensed under AGPL-3.0 (https://place-atlas.stefanocoding.me/license.txt)
*/
const codeReference = {}
let canvasUrl = ""
const variantsEl = document.getElementById("variants")
for (const variation in variationsConfig) {
codeReference[variationsConfig[variation].code] = variation
const optionEl = document.createElement('option')
optionEl.value = variation
optionEl.textContent = variationsConfig[variation].name
variantsEl.appendChild(optionEl)
}
const timelineSlider = document.getElementById("timeControlsSlider")
const timelineList = document.getElementById("timeControlsList")
const tooltip = document.getElementById("timeControlsTooltip")
const image = document.getElementById("image")
let abortController = new AbortController()
let currentUpdateIndex = 0
let updateTimeout = setTimeout(null, 0)
let tooltipDelayHide = setTimeout(null, 0)
let currentVariation = "default"
const defaultPeriod = variationsConfig[currentVariation].default
const defaultVariation = currentVariation
let currentPeriod = defaultPeriod
window.currentPeriod = currentPeriod
window.currentVariation = currentVariation
// SETUP
if (variationsConfig[currentVariation].versions.length === 1) bottomBar.classList.add('no-time-slider')
timelineSlider.max = variationsConfig[currentVariation].versions.length - 1
timelineSlider.value = currentPeriod
timelineList.children[0].value = defaultPeriod
timelineSlider.addEventListener("input", (e) => timelineParser(e.target.value))
timelineSlider.addEventListener("wheel", function (e) {
if (e.deltaY < 0) {
this.valueAsNumber += 1;
timelineParser(this.value)
} else {
this.value -= 1;
timelineParser(this.value)
}
e.stopPropagation();
}, { passive: true })
function timelineParser(value) {
updateTooltip(parseInt(value), currentVariation)
clearTimeout(updateTimeout)
updateTimeout = setTimeout(() => {
updateTime(parseInt(timelineSlider.value), currentVariation)
setTimeout(() => {
if (timelineSlider.value !== currentPeriod && abortController.signal.aborted) {
updateTime(parseInt(timelineSlider.value), currentVariation)
}
}, 50)
}, 25)
}
variantsEl.addEventListener("input", (event) => {
updateTime(-1, event.target.value)
})
const dispatchTimeUpdateEvent = (period = currentPeriod, variation = currentVariation, atlas = atlas) => {
const timeUpdateEvent = new CustomEvent('timeupdate', {
detail: {
period: period,
variation: variation,
periodString: formatPeriod(period, period, variation),
atlas: atlas
}
})
document.dispatchEvent(timeUpdateEvent)
}
async function updateBackground(newPeriod = currentPeriod, newVariation = currentVariation) {
abortController.abort()
abortController = new AbortController()
currentUpdateIndex++
const myUpdateIndex = currentUpdateIndex
const variationConfig = variationsConfig[newVariation]
variantsEl.value = currentVariation
if (variationConfig.icon) {
variantsEl.previousElementSibling.innerHTML = variationConfig.icon
variantsEl.previousElementSibling.classList.remove('d-none')
variantsEl.parentElement.classList.add('input-group')
} else {
variantsEl.previousElementSibling.innerHTML = ""
variantsEl.previousElementSibling.classList.add('d-none')
variantsEl.parentElement.classList.remove('input-group')
}
const configObject = variationConfig.versions[currentPeriod]
let layerUrls = []
if (typeof configObject.url === "string") {
layerUrls.push(configObject.url)
} else {
layerUrls.push(...configObject.url)
}
const canvas = document.createElement('canvas')
const context = canvas.getContext('2d')
context.canvas.width = canvasSize.x
context.canvas.height = canvasSize.y
for await (const url of layerUrls) {
const imageLayer = new Image()
await new Promise(resolve => {
imageLayer.onload = () => {
context.drawImage(imageLayer, 0, 0)
resolve()
}
imageLayer.src = url
})
}
if (currentUpdateIndex !== myUpdateIndex) return [configObject, newPeriod, newVariation]
const blob = await new Promise(resolve => canvas.toBlob(resolve))
canvasUrl = URL.createObjectURL(blob)
image.src = canvasUrl
}
async function updateTime(newPeriod = currentPeriod, newVariation = currentVariation, forceLoad = false) {
document.body.dataset.canvasLoading = ""
const oldPeriod = currentPeriod
const oldVariation = currentVariation
if (!variationsConfig[newVariation]) newVariation = defaultVariation
const variationConfig = variationsConfig[newVariation]
if (newPeriod < 0) newPeriod = 0
else if (newPeriod > variationConfig.versions.length - 1) newPeriod = variationConfig.versions.length - 1
currentPeriod = newPeriod
currentVariation = newVariation
if (oldVariation !== newVariation) {
timelineSlider.max = variationConfig.versions.length - 1
if (!forceLoad) {
currentPeriod = variationConfig.default
newPeriod = currentPeriod
}
if (variationConfig.versions.length === 1) bottomBar.classList.add('no-time-slider')
else bottomBar.classList.remove('no-time-slider')
}
timelineSlider.value = currentPeriod
updateTooltip(newPeriod, newVariation)
await updateBackground(newPeriod, newVariation)
atlas = []
for (const atlasIndex in atlasAll) {
let chosenIndex
const validPeriods2 = Object.keys(atlasAll[atlasIndex].path)
for (const i in validPeriods2) {
const validPeriods = validPeriods2[i].split(', ')
for (const j in validPeriods) {
const [start, end, variation] = parsePeriod(validPeriods[j])
if (isOnPeriod(start, end, variation, newPeriod, newVariation)) {
chosenIndex = i
break
}
}
if (chosenIndex !== undefined) break
}
if (chosenIndex === undefined) continue
const pathChosen = Object.values(atlasAll[atlasIndex].path)[chosenIndex]
const centerChosen = Object.values(atlasAll[atlasIndex].center)[chosenIndex]
if (pathChosen === undefined) continue
atlas.push({
...atlasAll[atlasIndex],
path: pathChosen,
center: centerChosen,
})
}
dispatchTimeUpdateEvent(newPeriod, newVariation, atlas)
delete document.body.dataset.canvasLoading
tooltip.dataset.forceVisible = ""
clearTimeout(tooltipDelayHide)
tooltipDelayHide = setTimeout(() => {
delete tooltip.dataset.forceVisible
}, 1000)
}
function updateTooltip(period, variation) {
const configObject = variationsConfig[variation].versions[period]
// If timestap is a number return a UTC formatted date otherwise use exact timestap label
if (typeof configObject.timestamp === "number") tooltip.querySelector('div').textContent = new Date(configObject.timestamp * 1000).toUTCString()
else tooltip.querySelector('div').textContent = configObject.timestamp
// Clamps position of tooltip to prevent from going off screen
const timelineSliderRect = timelineSlider.getBoundingClientRect()
let min = -timelineSliderRect.left + 12
let max = (window.innerWidth - tooltip.offsetWidth) - timelineSliderRect.left + 4
tooltip.style.left = Math.min(Math.max((timelineSlider.offsetWidth) * (timelineSlider.value) / (timelineSlider.max) - tooltip.offsetWidth / 2, min), max) + "px"
}
tooltip.parentElement.addEventListener('mouseenter', () => updateTooltip(parseInt(timelineSlider.value), currentVariation))
window.addEventListener('resize', () => updateTooltip(parseInt(timelineSlider.value), currentVariation))
function isOnPeriod(start, end, variation, currentPeriod, currentVariation) {
if (start > end) [start, end] = [end, start]
return currentPeriod >= start && currentPeriod <= end && variation === currentVariation
}
function parsePeriod(periodString) {
let variation = defaultVariation
periodString = periodString + ""
if (periodString.split(':').length > 1) {
const split = periodString.split(':')
variation = codeReference[split[0]]
periodString = split[1]
}
if (periodString.search('-') + 1) {
let [start, end] = periodString.split('-').map(i => parseInt(i))
if (start > end) [start, end] = [end, start]
return [start, end, variation]
} else if (codeReference[periodString]) {
variation = codeReference[periodString]
const defaultPeriod = variationsConfig[variation].default
return [defaultPeriod, defaultPeriod, variation]
} else {
const periodNew = parseInt(periodString)
return [periodNew, periodNew, variation]
}
}
function formatPeriod(start, end, variation) {
start ??= currentPeriod
end ??= currentPeriod
variation ??= currentVariation
let periodString, variationString
variationString = variationsConfig[variation].code
if (start > end) [start, end] = [end, start]
if (start === end) {
if (start === variationsConfig[variation].default && variation !== defaultVariation) {
periodString = ""
}
else periodString = start
}
else periodString = start + "-" + end
if (periodString && variationString) return variationsConfig[variation].code + ":" + periodString
if (variationString) return variationString
return periodString
}
function formatHash(id, start, end, variation) {
start ??= currentPeriod
end ??= currentPeriod
variation ??= currentVariation
const result = [id]
const targetPeriod = formatPeriod(start, end, variation)
if (targetPeriod && targetPeriod !== defaultPeriod) result.push(targetPeriod)
if (!result.some(el => el || el === 0)) return ''
return '#' + result.join('/')
}
function downloadCanvas() {
const linkEl = document.createElement("a")
linkEl.download = "canvas.png"
linkEl.href = canvasUrl
linkEl.classList.add("d-none")
document.body.appendChild(linkEl)
linkEl.click()
document.body.removeChild(linkEl)
}

View file

@ -1,17 +1,9 @@
/*
========================================================================
The 2022 /r/place Atlas
An atlas of Reddit's 2022 /r/place, with information to each
artwork of the canvas provided by the community.
Copyright (c) 2017 Roland Rytz <roland@draemm.li>
Copyright (c) 2022 Place Atlas contributors
Licensed under the GNU Affero General Public License Version 3
https://place-atlas.stefanocoding.me/license.txt
========================================================================
*/
/*!
* The 2022 r/place Atlas
* Copyright (c) 2017 Roland Rytz <roland@draemm.li>
* Copyright (c) 2022 Place Atlas contributors
* Licensed under AGPL-3.0 (https://place-atlas.stefanocoding.me/license.txt)
*/
const linesCanvas = document.getElementById("linesCanvas")
const linesContext = linesCanvas.getContext("2d")
@ -21,8 +13,8 @@ let previousZoomOrigin = [0, 0]
let previousScaleZoomOrigin = [0, 0]
const backgroundCanvas = document.createElement("canvas")
backgroundCanvas.width = 2000
backgroundCanvas.height = 2000
backgroundCanvas.width = canvasSize.x
backgroundCanvas.height = canvasSize.y
const backgroundContext = backgroundCanvas.getContext("2d")
const wrapper = document.getElementById("wrapper")
@ -45,6 +37,12 @@ const entriesList = document.getElementById("entriesList")
let entriesListShown = false
const drawButton = document.getElementById("drawLink")
const objectEditNav = document.createElement("a")
objectEditNav.className = "btn btn-outline-primary"
objectEditNav.id = "objectEditNav"
objectEditNav.textContent = "Edit"
let sortedAtlas
const entriesLimit = 50
@ -86,7 +84,7 @@ filterInput.addEventListener("input", function () {
})
document.getElementById("sort").addEventListener("input", function () {
if (this.value != "relevant") {
if (this.value !== "relevant") {
defaultSort = this.value
}
resetEntriesList(filterInput.value.toLowerCase(), this.value)
@ -114,7 +112,7 @@ offcanvasDraw.addEventListener('hidden.bs.offcanvas', function () {
applyView()
})
offcanvasList.addEventListener('show.bs.offcanvas', function (e) {
offcanvasList.addEventListener('show.bs.offcanvas', function () {
wrapper.classList.remove('listHidden')
wrapper.classList.add('listTransitioning')
applyView()
@ -159,10 +157,12 @@ function clearObjectsList() {
updateLines()
fixed = false
render()
objectEditNav.remove()
document.title = pageTitle
}
function toggleFixed(e, tapped) {
if (!fixed && hovered.length == 0) {
if (!fixed && hovered.length === 0) {
entriesList.classList.remove("disableHover")
return 0
}
@ -185,23 +185,6 @@ objectsContainer.addEventListener("scroll", function () {
})
window.addEventListener("resize", function (e) {
//console.log(document.documentElement.clientWidth, document.documentElement.clientHeight)
// Legacy code
let viewportWidth = document.documentElement.clientWidth
if (document.documentElement.clientWidth > 2000 && viewportWidth <= 2000) {
entriesListShown = true
wrapper.classList.remove("listHidden")
}
if (document.documentElement.clientWidth < 2000 && viewportWidth >= 2000) {
entriesListShown = false
wrapper.classList.add("listHidden")
}
updateHovering(e)
viewportWidth = document.documentElement.clientWidth
applyView()
render()
@ -221,24 +204,24 @@ function updateLines() {
for (let i = 0; i < hovered.length; i++) {
const element = hovered[i].element
if (element.getBoundingClientRect().left != 0) {
if (element.getBoundingClientRect().left !== 0) {
linesContext.beginPath()
// Align line based on which side the card is on
if ((element.getBoundingClientRect().left + element.clientWidth / 2) < (document.documentElement.clientWidth / 2)) {
linesContext.moveTo(
element.getBoundingClientRect().left + document.documentElement.scrollLeft + element.clientWidth - 5
, element.getBoundingClientRect().top + document.documentElement.scrollTop + 20
element.getBoundingClientRect().left + document.documentElement.scrollLeft + element.clientWidth - 5,
element.getBoundingClientRect().top + document.documentElement.scrollTop + 20
)
} else {
linesContext.moveTo(
element.getBoundingClientRect().left + document.documentElement.scrollLeft + 5
, element.getBoundingClientRect().top + document.documentElement.scrollTop + 20
element.getBoundingClientRect().left + document.documentElement.scrollLeft + 5,
element.getBoundingClientRect().top + document.documentElement.scrollTop + 20
)
}
linesContext.lineTo(
~~(hovered[i].center[0] * zoom) + innerContainer.offsetLeft
, ~~(hovered[i].center[1] * zoom) + innerContainer.offsetTop
~~(hovered[i].center[0] * zoom) + innerContainer.offsetLeft,
~~(hovered[i].center[1] * zoom) + innerContainer.offsetTop
)
linesContext.stroke()
}
@ -251,24 +234,24 @@ function updateLines() {
for (let i = 0; i < hovered.length; i++) {
const element = hovered[i].element
if (element.getBoundingClientRect().left != 0) {
if (element.getBoundingClientRect().left !== 0) {
linesContext.beginPath()
// Align line based on which side the card is on
if ((element.getBoundingClientRect().left + element.clientWidth / 2) < (document.documentElement.clientWidth / 2)) {
linesContext.moveTo(
element.getBoundingClientRect().left + document.documentElement.scrollLeft + element.clientWidth - 5
, element.getBoundingClientRect().top + document.documentElement.scrollTop + 20
element.getBoundingClientRect().left + document.documentElement.scrollLeft + element.clientWidth - 5,
element.getBoundingClientRect().top + document.documentElement.scrollTop + 20
)
} else {
linesContext.moveTo(
element.getBoundingClientRect().left + document.documentElement.scrollLeft + 5
, element.getBoundingClientRect().top + document.documentElement.scrollTop + 20
element.getBoundingClientRect().left + document.documentElement.scrollLeft + 5,
element.getBoundingClientRect().top + document.documentElement.scrollTop + 20
)
}
linesContext.lineTo(
~~(hovered[i].center[0] * zoom) + innerContainer.offsetLeft
, ~~(hovered[i].center[1] * zoom) + innerContainer.offsetTop
~~(hovered[i].center[0] * zoom) + innerContainer.offsetLeft,
~~(hovered[i].center[1] * zoom) + innerContainer.offsetTop
)
linesContext.stroke()
}
@ -341,12 +324,12 @@ function buildObjectsList(filter = null, sort = null) {
}
if (filter) {
sortedAtlas = atlas.filter(function (value) {
sortedAtlas = atlas.filter(entry => {
return (
value.name.toLowerCase().indexOf(filter) !== -1
|| value.description.toLowerCase().indexOf(filter) !== -1
|| value.subreddit && value.subreddit.toLowerCase().indexOf(filter) !== -1
|| value.id === filter
entry.name.toLowerCase().includes(filter.toLowerCase())
|| entry.description.toLowerCase().includes(filter.toLowerCase())
|| Object.values(entry.links).flat().some(str => str.toLowerCase().includes(filter))
|| entry.id === filter
)
})
document.getElementById("atlasSize").innerHTML = "Found " + sortedAtlas.length + " entries."
@ -372,73 +355,35 @@ function buildObjectsList(filter = null, sort = null) {
switch (sort) {
case "shuffle":
sortFunction = null
if (entriesOffset == 0) {
if (entriesOffset === 0) {
shuffle()
}
break
case "alphaAsc":
sortFunction = function (a, b) {
return a.name.toLowerCase().localeCompare(b.name.toLowerCase())
}
sortFunction = (a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase())
break
case "alphaDesc":
sortFunction = function (a, b) {
return b.name.toLowerCase().localeCompare(a.name.toLowerCase())
}
sortFunction = (a, b) => b.name.toLowerCase().localeCompare(a.name.toLowerCase())
break
case "newest":
sortFunction = function (a, b) {
if (a.id > b.id) {
return -1
}
if (a.id < b.id) {
return 1
}
// a must be equal to b
return 0
}
sortFunction = (a, b) => b.id.length - a.id.length || b.id.localeCompare(a.id)
break
case "oldest":
sortFunction = function (a, b) {
if (a.id < b.id) {
return -1
}
if (a.id > b.id) {
return 1
}
// a must be equal to b
return 0
}
sortFunction = (a, b) => a.id.length - b.id.length || a.id.localeCompare(b.id)
break
case "area":
sortFunction = function (a, b) {
return calcPolygonArea(b.path) - calcPolygonArea(a.path)
}
sortFunction = (a, b) => calcPolygonArea(b.path) - calcPolygonArea(a.path)
break
case "relevant":
sortFunction = function (a, b) {
if (a.name.toLowerCase().indexOf(filter) !== -1 && b.name.toLowerCase().indexOf(filter) !== -1) {
if (a.name.toLowerCase().indexOf(filter) < b.name.toLowerCase().indexOf(filter)) {
return -1
}
else if (a.name.toLowerCase().indexOf(filter) > b.name.toLowerCase().indexOf(filter)) {
return 1
} else {
return a.name.toLowerCase().localeCompare(b.name.toLowerCase())
}
} else if (a.name.toLowerCase().indexOf(filter) !== -1) {
sortFunction = (a, b) => {
if (a.name.toLowerCase().includes(filter) && b.name.toLowerCase().includes(filter)) {
return a.name.toLowerCase().indexOf(filter) - b.name.toLowerCase().indexOf(filter) || a.name.toLowerCase().localeCompare(b.name.toLowerCase())
} else if (a.name.toLowerCase().includes(filter)) {
return -1
} else if (b.name.toLowerCase().indexOf(filter) !== -1) {
} else if (b.name.toLowerCase().includes(filter)) {
return 1
} else {
if (a.description.toLowerCase().indexOf(filter) < b.description.toLowerCase().indexOf(filter)) {
return -1
}
else if (a.description.toLowerCase().indexOf(filter) > b.description.toLowerCase().indexOf(filter)) {
return 1
} else {
return a.name.toLowerCase().localeCompare(b.name.toLowerCase())
}
return a.description.toLowerCase().indexOf(filter) - b.description.toLowerCase().indexOf(filter) || a.name.toLowerCase().localeCompare(b.name.toLowerCase())
}
}
break
@ -458,7 +403,7 @@ function buildObjectsList(filter = null, sort = null) {
element.entry = sortedAtlas[i]
element.addEventListener("mouseenter", function (e) {
element.addEventListener("mouseenter", function () {
if (!fixed && !dragging) {
objectsContainer.replaceChildren()
@ -466,21 +411,8 @@ function buildObjectsList(filter = null, sort = null) {
previousScaleZoomOrigin = [scaleZoomOrigin[0], scaleZoomOrigin[1]]
applyView()
setView(this.entry.center[0], this.entry.center[1], setZoomByPath(entry.path))
zoomOrigin = [
innerContainer.clientWidth / 2 - this.entry.center[0] * zoom// + container.offsetLeft
, innerContainer.clientHeight / 2 - this.entry.center[1] * zoom// + container.offsetTop
]
scaleZoomOrigin = [
2000 / 2 - this.entry.center[0]
, 2000 / 2 - this.entry.center[1]
]
//console.log(zoomOrigin)
applyView()
hovered = [this.entry]
render()
hovered[0].element = this
@ -496,50 +428,11 @@ function buildObjectsList(filter = null, sort = null) {
previousScaleZoomOrigin = [scaleZoomOrigin[0], scaleZoomOrigin[1]]
applyView()
}
// Legacy code
/*if (document.documentElement.clientWidth < 500) {
objectsContainer.replaceChildren()
entriesListShown = false
bsOffcanvasList.hide()
wrapper.classList.add("listHidden")
zoom = 4
renderBackground(atlas)
applyView()
updateHovering(e)
zoomOrigin = [
innerContainer.clientWidth / 2 - this.entry.center[0] * zoom// + container.offsetLeft
, innerContainer.clientHeight / 2 - this.entry.center[1] * zoom// + container.offsetTop
]
scaleZoomOrigin = [
2000 / 2 - this.entry.center[0]
, 2000 / 2 - this.entry.center[1]
]
previousZoomOrigin = [zoomOrigin[0], zoomOrigin[1]]
previousScaleZoomOrigin = [scaleZoomOrigin[0], scaleZoomOrigin[1]]
fixed = true
hovered = [this.entry]
hovered[0].element = this
applyView()
render()
updateLines()
}*/
})
element.addEventListener("mouseleave", function () {
if (!fixed && !dragging) {
zoomOrigin = [previousScaleZoomOrigin[0] * zoom, previousScaleZoomOrigin[1] * zoom]
scaleZoomOrigin = [previousScaleZoomOrigin[0], previousScaleZoomOrigin[1]]
applyView()
setView(previousScaleZoomOrigin[0], previousScaleZoomOrigin[1])
hovered = []
updateLines()
render()
@ -685,73 +578,73 @@ async function render() {
function updateHovering(e, tapped) {
if (!dragging && (!fixed || tapped)) {
const pos = [
(e.clientX - (container.clientWidth / 2 - innerContainer.clientWidth / 2 + zoomOrigin[0] + container.offsetLeft)) / zoom
, (e.clientY - (container.clientHeight / 2 - innerContainer.clientHeight / 2 + zoomOrigin[1] + container.offsetTop)) / zoom
]
const coords_p = document.getElementById("coords_p")
if (dragging || (fixed && !tapped)) return
// Displays coordinates as zero instead of NaN
if (isNaN(pos[0]) == true) {
coords_p.textContent = "0, 0"
} else {
coords_p.textContent = Math.ceil(pos[0]) + ", " + Math.ceil(pos[1])
}
const pos = [
(e.clientX - (container.clientWidth / 2 - innerContainer.clientWidth / 2 + zoomOrigin[0] + container.offsetLeft)) / zoom,
(e.clientY - (container.clientHeight / 2 - innerContainer.clientHeight / 2 + zoomOrigin[1] + container.offsetTop)) / zoom
]
const coords_p = document.getElementById("coords_p")
if (pos[0] <= 2200 && pos[0] >= -100 && pos[0] <= 2200 && pos[0] >= -100) {
const newHovered = []
for (let i = 0; i < atlas.length; i++) {
if (pointIsInPolygon(pos, atlas[i].path)) {
newHovered.push(atlas[i])
}
}
// Displays coordinates as zero instead of NaN
if (isNaN(pos[0]) === true) {
coords_p.textContent = "0, 0"
} else {
coords_p.textContent = Math.ceil(pos[0]) + ", " + Math.ceil(pos[1])
}
let changed = false
if (!(pos[0] <= 2200 && pos[0] >= -100 && pos[0] <= 2200 && pos[0] >= -100)) return
if (hovered.length == newHovered.length) {
for (let i = 0; i < hovered.length; i++) {
if (hovered[i].id != newHovered[i].id) {
changed = true
break
}
}
} else {
changed = true
}
if (changed) {
hovered = newHovered.sort(function (a, b) {
return calcPolygonArea(a.path) - calcPolygonArea(b.path)
})
objectsContainer.replaceChildren()
for (const i in hovered) {
const element = createInfoBlock(hovered[i])
objectsContainer.appendChild(element)
hovered[i].element = element
}
if (hovered.length > 0) {
document.getElementById("timeControlsSlider").blur()
closeObjectsListButton.classList.remove("d-none")
if ((objectsContainer.scrollHeight > objectsContainer.clientHeight) && !tapped) {
objectsListOverflowNotice.classList.remove("d-none")
} else {
objectsListOverflowNotice.classList.add("d-none")
}
} else {
closeObjectsListButton.classList.add("d-none")
objectsListOverflowNotice.classList.add("d-none")
entriesList.classList.remove("disableHover")
}
render()
}
const newHovered = []
for (let i = 0; i < atlas.length; i++) {
if (pointIsInPolygon(pos, atlas[i].path)) {
newHovered.push(atlas[i])
}
}
let changed = false
if (hovered.length === newHovered.length) {
for (let i = 0; i < hovered.length; i++) {
if (hovered[i].id !== newHovered[i].id) {
changed = true
break
}
}
} else {
changed = true
}
if (!changed) return
hovered = newHovered.sort(function (a, b) {
return calcPolygonArea(a.path) - calcPolygonArea(b.path)
})
objectsContainer.replaceChildren()
for (const i in hovered) {
const element = createInfoBlock(hovered[i])
objectsContainer.appendChild(element)
hovered[i].element = element
}
if (hovered.length > 0) {
document.getElementById("timeControlsSlider").blur()
closeObjectsListButton.classList.remove("d-none")
if ((objectsContainer.scrollHeight > objectsContainer.clientHeight) && !tapped) {
objectsListOverflowNotice.classList.remove("d-none")
} else {
objectsListOverflowNotice.classList.add("d-none")
}
} else {
closeObjectsListButton.classList.add("d-none")
objectsListOverflowNotice.classList.add("d-none")
entriesList.classList.remove("disableHover")
}
render()
}
window.addEventListener("hashchange", highlightEntryFromUrl)
@ -759,79 +652,81 @@ window.addEventListener("hashchange", highlightEntryFromUrl)
function highlightEntryFromUrl() {
const hash = window.location.hash.substring(1); //Remove hash prefix
const [id, period] = hash.split('/')
let [id, period] = hash.split('/')
// Handle zzz and 0.. prefix
let newId = id.replace(/^zzz([a-z0-9]{7})$/g, "$1").replace(/^0+/, '')
if (id !== newId) history.replaceState({}, "", `./#${[newId, period].filter(e => e).join('/')}`)
id = newId
let targetPeriod, targetVariation
if (period) {
const [, targetPeriod, targetVariation] = parsePeriod(period)
updateTime(targetPeriod, targetVariation, true)
[, targetPeriod, targetVariation] = parsePeriod(period)
} else {
updateTime(defaultPeriod, defaultVariation, true)
targetPeriod = defaultPeriod
targetVariation = defaultVariation
}
updateTime(targetPeriod, targetVariation, true)
if (id) {
if (!id) return
const entries = atlas.filter(function (e) {
return e.id === id
})
const entries = atlas.filter(function (e) {
return e.id === id
})
if (entries.length === 1) {
const entry = entries[0]
if (entries.length !== 1) return
const entry = entries[0]
document.title = entry.name + " on the 2022 r/place Atlas"
document.title = entry.name + " on " + pageTitle
if ((!entry.diff || entry.diff !== "delete")) {
if (document.getElementById("objectEditNav")) {
document.getElementById("objectEditNav").href = "./?mode=draw&id=" + id
document.getElementById("objectEditNav").title = "Edit " + entry.name
} else {
const objectEditNav = document.createElement("a")
objectEditNav.className = "btn btn-outline-primary"
objectEditNav.id = "objectEditNav"
objectEditNav.innerText = "Edit"
objectEditNav.href = "./?mode=draw&id=" + id
objectEditNav.title = "Edit " + entry.name
showListButton.parentElement.appendChild(objectEditNav)
}
} else if (entry.diff == "delete" && document.getElementById("objectEditNav")) {
document.getElementById("objectEditNav").remove()
}
const infoElement = createInfoBlock(entry)
objectsContainer.replaceChildren()
objectsContainer.appendChild(infoElement)
//console.log(entry.center[0])
//console.log(entry.center[1])
zoom = 4
renderBackground(atlas)
applyView()
zoomOrigin = [
innerContainer.clientWidth / 2 - entry.center[0] * zoom// + container.offsetLeft
, innerContainer.clientHeight / 2 - entry.center[1] * zoom// + container.offsetTop
]
scaleZoomOrigin = [
2000 / 2 - entry.center[0]// + container.offsetLeft
, 2000 / 2 - entry.center[1]// + container.offsetTop
]
//console.log(zoomOrigin)
closeObjectsListButton.classList.remove("d-none")
entriesList.classList.add("disableHover")
applyView()
hovered = [entry]
render()
hovered[0].element = infoElement
updateLines()
fixed = true
if ((!entry.diff || entry.diff !== "delete")) {
objectEditNav.href = "./?mode=draw&id=" + id
objectEditNav.title = "Edit " + entry.name
if (!objectEditNav.isConnected) {
showListButton.parentElement.appendChild(objectEditNav)
}
} else if (entry.diff === "delete" && document.getElementById("objectEditNav")) {
objectEditNav.remove()
}
const infoElement = createInfoBlock(entry)
objectsContainer.replaceChildren()
objectsContainer.appendChild(infoElement)
renderBackground(atlas)
applyView()
setView(entry.center[0], entry.center[1], setZoomByPath(entry.path))
closeObjectsListButton.classList.remove("d-none")
entriesList.classList.add("disableHover")
hovered = [entry]
render()
hovered[0].element = infoElement
updateLines()
fixed = true
}
function setZoomByPath(path) {
let boundingBox = [canvasSize.x, 0, canvasSize.y, 0]
path?.forEach(([x, y]) => {
boundingBox[0] = Math.min(boundingBox[0], x)
boundingBox[1] = Math.max(boundingBox[1], x)
boundingBox[2] = Math.min(boundingBox[2], y)
boundingBox[3] = Math.max(boundingBox[3], y)
})
const boundingBoxSize = [boundingBox[1] - boundingBox[0], boundingBox[3] - boundingBox[2]]
const clientSize = [
Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0),
Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0)
]
zoom = Math.min(clientSize[0] / boundingBoxSize[0], clientSize[1] / boundingBoxSize[1])
zoom = Math.min(4, zoom/2)
}
function initView() {
@ -840,7 +735,7 @@ function initView() {
renderBackground(atlas)
render()
document.addEventListener('timeupdate', (event) => {
document.addEventListener('timeupdate', () => {
sortedAtlas = atlas.concat()
resetEntriesList(null, null)
})
@ -866,12 +761,12 @@ function initExplore() {
function updateHovering(e, tapped) {
if (!dragging && (!fixed || tapped)) {
const pos = [
(e.clientX - (container.clientWidth / 2 - innerContainer.clientWidth / 2 + zoomOrigin[0] + container.offsetLeft)) / zoom
, (e.clientY - (container.clientHeight / 2 - innerContainer.clientHeight / 2 + zoomOrigin[1] + container.offsetTop)) / zoom
(e.clientX - (container.clientWidth / 2 - innerContainer.clientWidth / 2 + zoomOrigin[0] + container.offsetLeft)) / zoom,
(e.clientY - (container.clientHeight / 2 - innerContainer.clientHeight / 2 + zoomOrigin[1] + container.offsetTop)) / zoom
]
const coords_p = document.getElementById("coords_p")
// Displays coordinates as zero instead of NaN
if (isNaN(pos[0]) == true) {
if (isNaN(pos[0]) === true) {
coords_p.textContent = "0, 0"
} else {
coords_p.textContent = Math.ceil(pos[0]) + ", " + Math.ceil(pos[1])
@ -895,21 +790,27 @@ function initGlobal() {
updateHovering(e)
}
})
document.addEventListener('timeupdate', (event) => {
let hashData = window.location.hash.substring(1).split('/')
const targetHash = formatHash(hashData[0], event.detail.period, event.detail.period, event.detail.variation)
if (location.hash !== targetHash) history.replaceState({}, "", `./${targetHash}`)
})
}
function initViewGlobal() {
container.addEventListener("mousedown", function (e) {
lastPos = [
e.clientX
, e.clientY
e.clientX,
e.clientY
]
})
container.addEventListener("touchstart", function (e) {
if (e.touches.length == 1) {
if (e.touches.length === 1) {
lastPos = [
e.touches[0].clientX
, e.touches[0].clientY
e.touches[0].clientX,
e.touches[0].clientY
]
}
}, { passive: true })
@ -925,23 +826,26 @@ function initViewGlobal() {
//console.log(e)
//console.log(e.changedTouches[0].clientX)
if (e.changedTouches.length == 1) {
e = e.changedTouches[0]
//console.log(lastPos[0] - e.clientX)
if (Math.abs(lastPos[0] - e.clientX) + Math.abs(lastPos[1] - e.clientY) <= 4) {
//console.log("Foo!!")
dragging = false
fixed = false
setTimeout(
function () {
updateHovering(e, true)
}
, 10)
}
}
if (e.changedTouches.length !== 1) return
e = e.changedTouches[0]
//console.log(lastPos[0] - e.clientX)
if (Math.abs(lastPos[0] - e.clientX) + Math.abs(lastPos[1] - e.clientY) > 4)
//console.log("Foo!!")
dragging = false
fixed = false
setTimeout(function () {
updateHovering(e, true)
}, 10)
})
if (window.location.hash) { // both "/" and just "/#" will be an empty hash string
highlightEntryFromUrl()
}
document.addEventListener('timeupdate', (event) => {
drawButton.href = "./?mode=draw" + formatHash(undefined, event.detail.period, event.detail.period, event.detail.variation)
})
}

View file

@ -1,16 +1,8 @@
<!--
========================================================================
The 2022 r/place Atlas
An atlas of Reddit's 2022 r/place, with information to each
artwork of the canvas provided by the community.
Copyright (c) 2017 Roland Rytz <roland@draemm.li>
Copyright (c) 2022 Place Atlas contributors
Licensed under the GNU Affero General Public License Version 3
https://place-atlas.stefanocoding.me/license.txt
========================================================================
Licensed under AGPL-3.0 (https://place-atlas.stefanocoding.me/license.txt)
-->
<!DOCTYPE html>
@ -82,15 +74,15 @@ <h1 class="display-5 fw-bold mb-4">The 2022 r/place Atlas</h1>
<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 Fools event on Reddit in 2022. It is made with information to each artwork of the canvas provided by the community.</p>
<p>The original code was developed by <a href="https://draemm.li/various/place-atlas/">Roland Rytz</a> <a href="mailto:roland.rytz@gmail.com"><i aria-label="Mail" class="bi bi-envelope"></i></a> <a href="https://reddit.com/user/draemmli/"><i aria-label="Reddit" class="bi bi-reddit"></i></a> and is available under the free <a href="https://www.gnu.org/licenses/agpl-3.0.en.html">AGPL license</a> on <a href="https://github.com/RolandR/place-atlas">GitHub</a>.</p>
<hr>
<p>The currently maintained version of the website is managed by Stefano Haagmans and is obtainable under the same license within a <a href="https://github.com/placeAtlas/atlas">GitHub fork</a>. Initial images are provided by <a href="https://place.thatguyalex.com/">Alex Tsernoh</a>.</p>
<p>The currently maintained version of the website is managed by <a href="https://github.com/placeAtlas">the Place Atlas team</a>, led by Stefano Haagmans and is obtainable under the same license within a <a href="https://github.com/placeAtlas/atlas">GitHub fork</a>. Initial images are provided by <a href="https://place.thatguyalex.com/">Alex Tsernoh</a>.</p>
<p>Maintaining and updating the website takes work, but I enjoy doing it for free and giving this to people. But if you would like to support me, or the people who helped me with contributions to this project. You're free to support us though <a href="https://paypal.me/placeAtlas/5">PayPal</a>, <a href="https://www.patreon.com/placeAtlas">Patreon</a>, or <a href="https://ko-fi.com/placeatlas">Ko-Fi</a>.</p>
<p>To maintain the same tradition, I will also be offering stickers to anyone donating more then 20$ (Due to the size increase). But, you're not forced to do anything! This only shows appreciation to us and the people who've worked on this project</p>
<p>Roland Rytz worked on the Atlas full-time (and more!) for over two weeks during the 2017 r/place event. If you'd like to support Roland, you can do so by <a href="https://paypal.me/draemmli">PayPal</a>. If you donate more than 10(€/$/CHF/mBTC), He'll (hopefully) send you a nice sticker of the 2017 Place canvas!</p>
<h2>Contributing</h2>
<p>The Atlas relies on user contributions.</p>
<p>To contribute a label for an artwork, please read <a href="https://www.reddit.com/r/placeAtlas2/comments/tu203o/how_to_contribute/">this post on Reddit</a> to learn how to submit a new entry. Alternatively, contributions can be made directly on <a href="https://github.com/placeAtlas/atlas/blob/master/CONTRIBUTING.md">GitHub</a>.</p>
<p>The <a href="https://reddit.com/r/placeAtlas2/">r/placeAtlas2</a> subreddit is also the place to submit all bug reports, feature requests or questions.</p>
<p>This project is open source, and contributions are welcome. In fact, the Atlas relies on user contributions.</p>
<p>To contribute a label for an artwork, please read <a href="https://github.com/placeAtlas/atlas/blob/master/CONTRIBUTING.md">this guide</a> to learn how to submit a new entry, edit existing entries, or contribute to the development of the codebase.</p>
<p><a href="https://reddit.com/r/placeAtlas2/">The r/placeAtlas2 subreddit</a> and <a href="https://discord.gg/pJkm23b2nA">the Discord server</a> is also the place to submit all bug reports, feature requests, or questions.</p>
<div id="credits">
<h2>Credit</h2>
@ -198,7 +190,7 @@ <h3>Reddit Contributors</h3>
<div class="position-sticky" style="top: 5rem;">
<div class="p-4 mb-3 bg-secondary bg-opacity-10 rounded">
<h4>Contact?</h4>
<p>If you're press, a influencer or anything media connected, or you would like to use the atlas in one. Please contact us beforehand through:</p>
<p>If you're press, a influencer or anything media connected, or you would like to use the Atlas in one. Please contact us beforehand through:</p>
<ul>
<li><a href="mailto:press@stefanocoding.me">press@stefanocoding.me</a></li>
</ul>
@ -219,7 +211,7 @@ <h4>Sponsor this project</h4>
<div class="p-4">
<h4>Deployment</h4>
<p>This site is powered by Netlify.</p>
<a class="d-flex flex-wrap justify-content-left gap-2" href="https://www.netlify.com" target="_blank" rel="noopener">
<a class="d-flex flex-wrap align-items-center justify-content-left gap-2" href="https://www.netlify.com" target="_blank" rel="noopener">
<img src="https://www.netlify.com/img/global/badges/netlify-color-bg.svg" alt="Deploys by Netlify" />
<img src="https://api.netlify.com/api/v1/badges/1e7291ce-0680-45ed-9843-47a32a992bbb/deploy-status" type="image/svg+xml" alt="Netlify status" />
</a>

File diff suppressed because it is too large Load diff

View file

@ -1,16 +1,8 @@
<!--
========================================================================
The 2022 r/place Atlas
An atlas of Reddit's 2022 r/place, with information to each
artwork of the canvas provided by the community.
Copyright (c) 2017 Roland Rytz <roland@draemm.li>
Copyright (c) 2022 Place Atlas contributors
Licensed under the GNU Affero General Public License Version 3
https://place-atlas.stefanocoding.me/license.txt
========================================================================
Licensed under AGPL-3.0 (https://place-atlas.stefanocoding.me/license.txt)
-->
<!DOCTYPE html>
@ -49,7 +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">
<script type="module" src="./pwabuilder-sw-register.js"></script>
<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">
{
@ -169,9 +161,8 @@ <h4 class="mb-3">Hang on…</h4>
</div>
<canvas id="linesCanvas"></canvas>
<div id="innerContainer">
<canvas id="highlightCanvas" width="2000" height="2000"></canvas>
<img id="image" width="2000" height="2000" alt="" />
<canvas id="highlightCanvas"></canvas>
<img id="image" alt="" />
</div>
</div>
<div class="offcanvas offcanvas-start bg-body" data-bs-scroll="true" data-bs-backdrop="false" tabindex="-1" id="offcanvasList" aria-labelledby="offcanvasListLabel">
@ -296,7 +287,7 @@ <h5 class="px-2">Timeline</h5>
<button type="button" class="btn btn-primary d-block mx-auto" id="periodsAdd">Add Period</button>
</div>
<div id="hint">
<p class="text-center">Please read <a href="https://www.reddit.com/r/placeAtlas2/comments/tu203o/how_to_contribute/" target="_blank" rel="noopener noreferrer">this Reddit post</a> for instructions.</p>
<p class="text-center">Please read <a href="https://github.com/placeAtlas/atlas/blob/master/CONTRIBUTING.md" target="_blank" rel="noopener noreferrer">this guide</a> for instructions.</p>
<hr>
<p>You can suggest new entries to the Atlas for art that isn't mapped yet, or update entries by editing it.</p>
<p>Click anywhere on the image to start drawing a shape. Switch between periods by adding a period, and/or seek through the timeline.</p>
@ -355,7 +346,7 @@ <h5 class="modal-title" id="exportModalLabel">Export Entry</h5>
<div class="modal-body d-flex flex-column">
<p>Use the Post Direct to Reddit button or manually copy the text below and submit it as a new text post to <a href="https://www.reddit.com/r/placeAtlas2/" target="_blank" rel="noopener noreferrer">r/placeAtlas2</a> on Reddit.</p>
<p>Don't forget to flair it with the <span class="badge rounded-pill bg-primary"><i class="bi bi-tag" aria-hidden="true"></i> <span id="redditFlair">New Entry</span></span> tag.</p>
<p>We will then check it and add it to the atlas.</p>
<p>We will then check it and add it to the Atlas.</p>
<textarea class="form-control flex-grow-1" cols="40" rows="20" id="exportString" title="Raw JSON string" readonly></textarea>
</div>
<div class="modal-footer">
@ -446,16 +437,18 @@ <h5 class="modal-title" id="donateModalLabel">Donation Links</h5>
</template>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
<script src="./_js/time.js"></script>
<script src="./_js/infoblock.js"></script>
<script src="./_js/pointInPolygon.js"></script>
<script src="./_js/atlas.js"></script>
<script src="./_js/view.js"></script>
<script src="./_js/overlap.js"></script>
<script src="./_js/polylabel.js"></script>
<script src="./_js/draw.js"></script>
<script src="./_js/main.js"></script>
<!-- <script src="./_js/stats.js"></script>
<script src="./_js/lib/pointInPolygon.js"></script>
<script src="./_js/lib/polylabel.js"></script>
<script src="./_js/config.js"></script>
<script src="./_js/main/time.js"></script>
<script src="./_js/main/infoblock.js"></script>
<script src="./_js/main/atlas.js"></script>
<script src="./_js/main/view.js"></script>
<script src="./_js/main/overlap.js"></script>
<script src="./_js/main/draw.js"></script>
<script src="./_js/main/main.js"></script>
<!-- <script src="./_js/main/stats.js"></script>
<script src="./_js/minified.js"></script> -->
<pwa-update swpath="./sw.js"></pwa-update>
</body>
</html>

View file

@ -1,51 +1,65 @@
{
"background_color": "#ff8800",
"display": "standalone",
"scope": "/",
"start_url": "/",
"name": "The r/place Atlas",
"short_name": "r/placeAtlas2",
"description": "The atlas for the r/place event of 2022 hosted on Reddit.",
"icons": [{
"src": "./_img/pwa/logo-round-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "any"
},
{
"src": "./_img/pwa/logo-maskable-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "./_img/pwa/logo-round-512x512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any"
},
{
"src": "./_img/pwa/logo-maskable-512x512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
],
"screenshots": [{
"src": "./_img/pwa/screenshot-1.png",
"sizes": "750x1334",
"type": "image/png"
},
{
"src": "./_img/pwa/screenshot-2.png",
"sizes": "1280x800",
"type": "image/png"
},
{
"src": "./_img/pwa/screenshot-3.png",
"sizes": "750x1334",
"type": "image/png"
}
],
"theme_color": "#ff8800"
"background_color": "#ff8800",
"display": "standalone",
"scope": "/",
"start_url": "/",
"name": "The r/place Atlas",
"short_name": "r/placeAtlas2",
"description": "The atlas for the r/place event of 2022 hosted on Reddit.",
"icons": [
{
"src": "./_img/pwa/logo-round-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "any"
},
{
"src": "./_img/pwa/logo-maskable-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "./_img/pwa/logo-round-512x512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any"
},
{
"src": "./_img/pwa/logo-maskable-512x512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
],
"screenshots": [
{
"src": "./_img/pwa/screenshot-1.png",
"sizes": "750x1334",
"type": "image/png"
},
{
"src": "./_img/pwa/screenshot-2.png",
"sizes": "1280x800",
"type": "image/png"
},
{
"src": "./_img/pwa/screenshot-3.png",
"sizes": "750x1334",
"type": "image/png"
}
],
"theme_color": "#ff8800",
"lang": "en",
"dir": "ltr",
"orientation": "any",
"display_override": [
"minimal-ui",
"standalone",
"browser",
"window-controls-overlay"
],
"categories": [
"navigation"
]
}

View file

@ -1,4 +0,0 @@
import 'https://cdn.jsdelivr.net/npm/@pwabuilder/pwaupdate';
const el = document.createElement('pwa-update');
document.body.appendChild(el);

View file

@ -1,26 +0,0 @@
// This is the "Offline copy of assets" service worker
const CACHE = "pwabuilder-offline";
const QUEUE_NAME = "bgSyncQueue";
importScripts('https://storage.googleapis.com/workbox-cdn/releases/5.1.2/workbox-sw.js');
self.addEventListener("message", (event) => {
if (event.data && event.data.type === "SKIP_WAITING") {
self.skipWaiting();
}
});
const bgSyncPlugin = new workbox.backgroundSync.BackgroundSyncPlugin(QUEUE_NAME, {
maxRetentionTime: 24 * 60 // Retry for max of 24 Hours (specified in minutes)
});
workbox.routing.registerRoute(
new RegExp('/*'),
new workbox.strategies.StaleWhileRevalidate({
cacheName: CACHE,
plugins: [
bgSyncPlugin
]
})
);

37
web/sw.js Normal file
View file

@ -0,0 +1,37 @@
// This is the "Offline copy of assets" service worker
importScripts('https://cdn.jsdelivr.net/npm/workbox-sw@6.5.4/build/workbox-sw.js');
self.addEventListener("message", (event) => {
if (event.data && event.data.type === "SKIP_WAITING") {
self.skipWaiting();
}
});
workbox.routing.registerRoute(
({ url }) => {!url.pathname.startsWith('/_img/canvas/')},
new workbox.strategies.NetworkFirst({
cacheName: "main",
plugins: [
new workbox.backgroundSync.BackgroundSyncPlugin(
"main-queue", {
maxRetentionTime: 24 * 60 // 24 hours (in minutes)
}
)
]
})
);
workbox.routing.registerRoute(
({ url }) => url.pathname.startsWith('/_img/canvas/'),
new workbox.strategies.CacheFirst({
cacheName: "canvas",
plugins: [
new workbox.backgroundSync.BackgroundSyncPlugin(
"canvas-queue", {
maxRetentionTime: 4 * 7 * 24 * 60 // 4 weeks (in minutes)
}
)
]
})
);