full system zip export and import works. check readme

This commit is contained in:
cube
2026-03-30 16:18:29 +01:00
parent f8efe51891
commit 9483193ebb
2 changed files with 42 additions and 24 deletions

View File

@@ -10,6 +10,14 @@ the blinkies and stamps stuff is literally just because i want an easy way to up
make sure blinkies are actually blinkie-sized, and stamps are likewise stamp-sized. too much variation in size will make the layout weird. there's not validation because its designed just to make uploading the images not require ftp + manual code as i had been doing before.
## export / import
there are currently various ways to export and import data for use within myriad. individual member exports and imports deal only with the fields (though icons, stamps, and blinkies can be exported to a zip folder). they're designed to be used with an active database for whatever purpose the user requires.
the other option is to export the entire system to json or zip file. **importing an entire system is best used on a completely empty database, as it deals with inserting id fields**. a full system import is useful for when an update is released that requires the database to be re-initialised, you can quickly restore information and images you had before.
both are a little janky as they've just been implemented rather quickly to cover the base requirement of being able to migrate the database in some form. **don't rely on them, be sure to keep your own backups**.
# dev set up (windows)
- after cloning, run `py -3 -m venv .venv` in the root directory and then `.venv\Scripts\activate`
@@ -29,7 +37,7 @@ it is recommended to run waitress in a tmux window for easier management
create new tmux window
`tmux new -s myriad`
```tmux new -s myriad```
detach from tmux window
@@ -37,61 +45,67 @@ detach from tmux window
attach to existing tmux window
`tmux attach -t myriad`
```tmux attach -t myriad```
## installing
clone the repo and set up virtual env
`git clone https://tea.cubes.link/cube/myriad.git`
```
git clone https://tea.cubes.link/cube/myriad.git
`cd myriad`
cd myriad
`python3 -m venv venv`
python3 -m venv venv
`source venv/bin/activate`
source venv/bin/activate
```
install necessary packages in the virtual env
`pip install flask`
```
pip install flask
`pip install waitress`
pip install waitress
```
make sure all directories exist
`mkdir instance`
```
mkdir instance
`mkdir myriad/static/icons`
mkdir myriad/static/icons
`mkdir myriad/static/blinkies`
mkdir myriad/static/blinkies
`mkdir myriad/static/stamps`
mkdir myriad/static/stamps
`mkdir myriad/static/tmp`
mkdir myriad/static/tmp
```
copy sample from readme and paste into the following
`sudo nano instance/config.py`
```sudo nano instance/config.py```
in a window where you can copy the output, (or in python itself) generate a secret key and copy it to the clipboard
`python -c 'import secrets; print(secrets.token_hex())'`
```python -c 'import secrets; print(secrets.token_hex())'```
add a new line to config.py and paste in the key
`SECRET_KEY = '(paste generated key here)'`
```SECRET_KEY = '(paste generated key here)'```
initialize the database
`flask --app myriad init-db`
```flask --app myriad init-db```
start running the site
`waitress-serve --port=80 --call 'myriad:create_app'`
```waitress-serve --port=80 --call 'myriad:create_app'```
after running and setting up first user stop waitress (CTRL+C), then edit the config to disable user registration for security
`sudo nano instance/config.py`
```sudo nano instance/config.py```
`REGISTRATION = False`
@@ -99,12 +113,12 @@ once you have disabled registration you will need to go to /auth/login in order
## updating
**WARNING: Before updating ALWAYS use administration settings to back up your entire system to a downloadable zip file**
stop waitress (CTRL+C) and use `git pull` to pull changes
start waitress again to reload
if it is a database changing update, use backup features, re-init db, then re-import from backup
# config

View File

@@ -276,9 +276,7 @@ def import_member(member):
homepage = member["homepage-pin"]
user_id = 0
db.execute("INSERT INTO member (id,created,user_id, member_name,subtitle, bio,public,theme,homepage) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",(mid, date_created, user_id, name, subtitle, description,privacy, theme, homepage))
db.commit()
main_icon_id = ""
groups = member["groups"]
for group in groups:
@@ -309,6 +307,9 @@ def import_member(member):
for icon in icons:
db.execute("INSERT INTO icons (member_id, icon_location) VALUES (?, ?)",(mid, icon))
db.commit()
if icon == member["main-icon"]:
last = db.execute('SELECT last_insert_rowid()').fetchone()
main_icon_id = last[0]
blinkies = member["blinkies"]
for blinkie in blinkies:
@@ -320,6 +321,9 @@ def import_member(member):
db.execute("INSERT INTO stamps (member_id, stamp_location) VALUES (?, ?)",(mid, stamp))
db.commit()
db.execute("INSERT INTO member (id,created,user_id, member_name,subtitle, bio,public,theme,homepage,main_icon) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",(mid, date_created, user_id, name, subtitle, description,privacy, theme, homepage, main_icon_id))
db.commit()
@bp.route("/admin", methods=("GET", "POST"))