| _docs | ||
| accounts | ||
| api | ||
| apiclone | ||
| assets | ||
| files/uploads | ||
| galleries | ||
| internalapi | ||
| lib | ||
| news | ||
| notifications | ||
| projects | ||
| projectsAPI | ||
| siteapi | ||
| static | ||
| templates | ||
| uploads | ||
| userprofiles | ||
| .gitignore | ||
| jinxer.py | ||
| LICENSE | ||
| manage.py | ||
| README.md | ||
| requirements.sh | ||
| upgrade.sh | ||
APIClone
Work in progress recreation of the main Scratch API, projects API, assets API and uploads API
Requirements
APIClone requires the following to be installed:
- Python. Only versions 3.12 and 3.13 were tested, but any version from 3.8 to the latest should work in theory.
- Django. Only versions 4.2 and 5.1 were tested, but any version from 4.0 to the latest one should work in theory.
- django-cors-headers. For Arch Linux users, there's an AUR package: python-django-cors-headers
- Pillow. Used for the
uploadssubdomain.
Optional:
- PyMemcache. You can disable by deleting the
CACHESdictionary from settings.py - Memcached (Windows version). Required by PyMemcache, useless without it.
- Varnish. Varnish isn't actually used by APIClone itself, but it rather wraps around Django and caches everything, effectively avoiding hundreds of possible gateway timeouts while using APIClone on certain lower-end hardware, such as a 2010 laptop, or can be used to just lower the tension on the server.
On Arch Linux, you can run requirements.sh to automatically install every mandatory and optional dependencies. For other distros or operating systems, just use dark magic.
Usage with Scratch-WWW
-
Clone APIClone and Scratch-WWW:
git clone https://codeberg.org/heathercat123/apiclone.git git clone --depth=1 --single-branch --branch develop https://github.com/scratchfoundation/scratch-www.git cd apicloneYou can also use the chipmunk mirror by replacing
codeberg.orgbycode.chipmunk.landif you really want to. -
Optional: Start Memcached:
- On systemd-based Linux distros (which is most of them):
sudo systemctl start memcached. - On other Linux distros: Read your distribution's manual.
- On Windows: Execute memcached.exe
- On systemd-based Linux distros (which is most of them):
-
Create superuser (admin/ST account):
python manage.py createsuperuserYour username has to be lowercase. -
Optional: Collect static files: ```python manage.py collectstatic`` This will create the
static_proddirectory for production environments. -
Start APIClone:
python manage.py runserver 8080Tip: If you don't want to use Varnish but you have already built Scratch-WWW configured to the Varnish port, you may want to replace8080by6081. -
Switch to another terminal window.
-
Optional: Start Varnish:
- On systemd-based Linux distros:
sudo systemctl start varnish. - On other Linux distros: Read your distrobition's manual (again!).
- On systemd-based Linux distros:
-
Install Scratch-WWW's dependencies and translations:
cd scratch-www npm install npm run translate -
Start Scratch-WWW:
API_HOST=http://localhost:6081/api \ ASSET_HOST=http://localhost:6081/assets \ BACKPACK_HOST=http://localhost:6081/backpack \ PROJECT_HOST=http://localhost:6081/projectshost \ STATIC_HOST=http://localhost:6081/uploads \ FALLBACK=http://localhost:6081 \ npm startReplace 6081 by 8080 if not using Varnish.
-
Log in using the superuser created before.
-
Select Users, then click on your username.
-
Scroll down and set Full username to the same username as before, but with whatever casing your heart desires (so it doesn't have to be lowercase).
You can now open http://localhost:8333 in a web browser (without /admin!) and enjoy Scratch-WWW with APIClone. Note that many elements of the website are hard-coded whereas they should be modifiable by the user, such as the home page's "What's Happening" box. Quite a few pages and API endpoints are also missing. Both of these are either currently being worked on or this project may randomly have gotten abandoned. I love life.
Standalone usage
TODO: Write this section.
It's basically like with WWW but without the WWW part and you have to set SCRATCHR2_ONLY in /apiclone/local_settings.py.