yacscript 0.4.0__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {yacscript-0.4.0 → yacscript-0.5.0}/COPYING +12 -12
  2. {yacscript-0.4.0 → yacscript-0.5.0}/PKG-INFO +300 -267
  3. {yacscript-0.4.0 → yacscript-0.5.0}/README.md +299 -266
  4. yacscript-0.5.0/app/__init__.py +267 -0
  5. {yacscript-0.4.0 → yacscript-0.5.0}/app/app.py +933 -750
  6. {yacscript-0.4.0 → yacscript-0.5.0}/app/db.py +82 -82
  7. {yacscript-0.4.0 → yacscript-0.5.0}/app/definitions.py +77 -71
  8. {yacscript-0.4.0 → yacscript-0.5.0}/app/static/admin.js +116 -116
  9. {yacscript-0.4.0 → yacscript-0.5.0}/app/static/dialog.js +178 -178
  10. {yacscript-0.4.0 → yacscript-0.5.0}/app/static/handoff.js +14 -14
  11. {yacscript-0.4.0 → yacscript-0.5.0}/app/static/room.js +629 -629
  12. {yacscript-0.4.0 → yacscript-0.5.0}/app/static/style.css +302 -302
  13. {yacscript-0.4.0 → yacscript-0.5.0}/app/static/vendor/98.css +1 -1
  14. {yacscript-0.4.0 → yacscript-0.5.0}/app/static/vendor/socket.io.min.js +7 -7
  15. {yacscript-0.4.0 → yacscript-0.5.0}/app/templates/handoff.jinja +12 -12
  16. {yacscript-0.4.0 → yacscript-0.5.0}/app/templates/index.jinja +50 -50
  17. {yacscript-0.4.0 → yacscript-0.5.0}/app/templates/room.jinja +99 -99
  18. {yacscript-0.4.0 → yacscript-0.5.0}/pyproject.toml +30 -30
  19. yacscript-0.4.0/app/__init__.py +0 -151
  20. {yacscript-0.4.0 → yacscript-0.5.0}/app/static/file.mp3 +0 -0
  21. {yacscript-0.4.0 → yacscript-0.5.0}/app/static/icon.png +0 -0
  22. {yacscript-0.4.0 → yacscript-0.5.0}/app/static/join.mp3 +0 -0
  23. {yacscript-0.4.0 → yacscript-0.5.0}/app/static/leave.mp3 +0 -0
  24. {yacscript-0.4.0 → yacscript-0.5.0}/app/static/msg.mp3 +0 -0
  25. {yacscript-0.4.0 → yacscript-0.5.0}/app/static/send.mp3 +0 -0
  26. {yacscript-0.4.0 → yacscript-0.5.0}/app/static/tile.gif +0 -0
  27. {yacscript-0.4.0 → yacscript-0.5.0}/app/static/tile.jpg +0 -0
  28. {yacscript-0.4.0 → yacscript-0.5.0}/app/static/vendor/ms_sans_serif.woff +0 -0
  29. {yacscript-0.4.0 → yacscript-0.5.0}/app/static/vendor/ms_sans_serif.woff2 +0 -0
  30. {yacscript-0.4.0 → yacscript-0.5.0}/app/static/vendor/ms_sans_serif_bold.woff +0 -0
  31. {yacscript-0.4.0 → yacscript-0.5.0}/app/static/vendor/ms_sans_serif_bold.woff2 +0 -0
  32. {yacscript-0.4.0 → yacscript-0.5.0}/app/static/welcome.mp3 +0 -0
@@ -1,13 +1,13 @@
1
- DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2
- Version 2, December 2004
3
-
4
- Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
5
-
6
- Everyone is permitted to copy and distribute verbatim or modified
7
- copies of this license document, and changing it is allowed as long
8
- as the name is changed.
9
-
10
- DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
-
1
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2
+ Version 2, December 2004
3
+
4
+ Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
5
+
6
+ Everyone is permitted to copy and distribute verbatim or modified
7
+ copies of this license document, and changing it is allowed as long
8
+ as the name is changed.
9
+
10
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
+
13
13
  0. You just DO WHAT THE FUCK YOU WANT TO.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yacscript
3
- Version: 0.4.0
3
+ Version: 0.5.0
4
4
  Summary: yet another chatroom script.
5
5
  Author: Valine0x
6
6
  Author-email: Valine0x <me@valine0x.icu>
@@ -15,270 +15,303 @@ Requires-Dist: webargs>=8.7.0
15
15
  Requires-Python: >=3.13
16
16
  Description-Content-Type: text/markdown
17
17
 
18
- # YACS
19
- Yet Another Chatroom Script
20
-
21
- Inspired by [LE-CHAT-PHP](https://github.com/DanWin/le-chat-php)
22
-
23
- ![Splash Screen](docs/the-yacs.jpeg)
24
-
25
- ## Featuring
26
-
27
- - Multiple channels.
28
- - Admins.
29
- - Files and embedded images/videos.
30
- - BBCode.
31
- - CAPTCHA.
32
- - Vanilla HTML & CSS & JS.
33
- - No Cookies, it's bad for your teeth.
34
-
35
- ## Migrating from Older Versions (IMPORTANT)
36
-
37
- If you are upgrading from YACS 0.3.x or earlier, your existing database and resource files may not be compatible with the new release. Use the `migrate` command to fix things up **before** starting the server:
38
-
39
- ```bash
40
- # From venv
41
- (.venv) yacscript migrate --config config.toml
42
-
43
- # From source
44
- $ uv run yacscript migrate --config config.toml
45
- ```
46
-
47
- The `migrate` command will fix the database schema as well as the resource naming.
48
-
49
- It is safe to run `migrate` multiple times — if there is nothing to migrate, no changes will be made anyway.
50
-
51
- ## Try It Out Right Now!
52
-
53
- Join [The YACS Demo Server](https://chat.valine0x.icu) right now with passphrase **`the-yacs`** to see YACS in action!
54
-
55
- ## Deployment
56
-
57
- ### 1. Deploy with venv (Recommended)
58
-
59
- Create a venv with python version 3.13 or greater.
60
-
61
- ```bash
62
- $ python -m venv .venv
63
- ```
64
-
65
- ```bash
66
- # Activate venv in *nix shell (e.g. bash, zsh)
67
- $ source .venv/bin/activate
68
- ```
69
-
70
- ```pwsh
71
- # Activate venv in pwsh
72
- > . .venv\Scripts\Activate.ps1"
73
- ```
74
-
75
-
76
- Then, install the package inside venv.
77
-
78
- ```bash
79
- (.venv) pip install yacscript
80
- ```
81
-
82
- Create a configuration file and edit it to your liking.
83
-
84
- For reference, see the <a href="#configuration">configuration section</a>.
85
-
86
- ```bash
87
- (.venv) vi ./config.toml
88
- ```
89
-
90
- Finally, start the server within the venv:
91
-
92
- ```bash
93
- (.venv) yacscript start --config config.toml
94
- ```
95
-
96
- In addition to that, you might want to deploy the program as a daemon. Here's an example of a possible simple unit file for systemd.
97
-
98
- Assuming you have installed the venv as `/path/to/.venv`, for example `/opt/yacs/.venv`, making `/path/to/` means `/opt/yacs/` for the setup.
99
-
100
- ```ini
101
- [Unit]
102
- Description=YACS Service
103
- After=network.target
104
-
105
- [Service]
106
- Type=simple
107
- WorkingDirectory=/path/to
108
- Environment="PATH=/path/to/.venv/bin"
109
- ExecStart=/path/to/.venv/bin/yacscript start --config /path/to/config.toml
110
-
111
- [Install]
112
- WantedBy=multi-user.target
113
- ```
114
-
115
- ### 2. Deploy from source (with uv)
116
-
117
- Deploying from source gives you access to the latest features but may be unstable
118
-
119
- To deploy from source, first you need to install uv.
120
-
121
- ```bash
122
- # Install with pip.
123
- $ pip install uv
124
-
125
- # Install on macOS and Linux.
126
- $ curl -LsSf https://astral.sh/uv/install.sh | sh
127
-
128
- # Install on Windows.
129
- $ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
130
- ```
131
-
132
- Then, clone the repo.
133
-
134
- ```bash
135
- $ git clone https://github.com/valine-dev/yacs.git
136
- $ cd yacs
137
- ```
138
-
139
- Create a config file, and edit it to your liking.
140
-
141
- For reference, see the <a href="#configuration">configuration section</a>.
142
-
143
- ```bash
144
- $ vi ./config.toml
145
- ```
146
-
147
- Finally, run the server, dependencies and venv will be installed along the way.
148
-
149
- ```bash
150
- $ uv run yacscript start --config config.toml
151
- ```
152
-
153
- Additionally, it's also possible to make a daemon service out of deployment from source.
154
-
155
- An example unit file is shown as below.
156
-
157
- ```ini
158
- [Unit]
159
- Description=YACS Service
160
- After=network.target
161
-
162
- [Service]
163
- Type=simple
164
- WorkingDirectory=/path/to/yacs
165
- Environment="PATH=/path/to/yacs/.venv/bin"
166
- # Notice the difference to deploying from package!
167
- ExecStart=/path/to/uv run yacscript start --config /path/to/config.toml
168
-
169
- [Install]
170
- WantedBy=multi-user.target
171
- ```
172
-
173
- ## CLI Reference
174
-
175
- The `yacscript` command ships with the following subcommands:
176
-
177
- - `yacscript start --config config.toml` — Start the YACS server.
178
- - `yacscript gc --config config.toml` — Clean expired resources from disk.
179
- - `yacscript migrate --config config.toml` — Migrate your data from older versions.
180
-
181
- In which gc and migrate are mostly safe to run.
182
-
183
- ## User Manual
184
-
185
- Consult <a href="docs/manual.md">User Manual</a> for guidance.
186
-
187
- ## Configuration
188
-
189
- The program comes with a built in config, so you might want to only write fields that you need to deviates from default.
190
-
191
- All possible fields are shown below.
192
-
193
- ```toml
194
- [flask]
195
- # here you can configure built-in config values defined by flask
196
- DEBUG = false # DO NOT SET TO `true` WHEN EXPOSING TO PUBLIC!
197
-
198
- [app]
199
- # The app itself will only exposed through plain HTTP and it's strongly discorage to do so directly to public web. Use a reverse proxy with TLS in front of the app.
200
- ip = "0.0.0.0"
201
- port = 8080
202
-
203
- admin_phrase = "CHANGE_ME_ADMIN"
204
- # set user_phrase to empty will expose chatroom to the public
205
- user_phrase = "CHANGE_ME"
206
-
207
- log_level = "INFO"
208
- timeout = 5000 # in milisecond, use for heartbeat
209
-
210
- # Set to true only when the app is behind a reverse proxy!
211
- # Make sure X-Forwarded-For and X-Forwarded-Host are properly set!
212
- proxy_fix = false
213
-
214
- # For socketio connections
215
- # Do set a propper value in production enviroment
216
- cors_allowed_origins = "https://me.example"
217
-
218
-
219
- [custom]
220
- title = "The YACS"
221
- motd = "Hello!\nRule No.1"
222
-
223
- # These are the emotes that will rendered to the webpage
224
- emoticons = [
225
- "( ゚∀。)",
226
- "Insert Anything",
227
- "⭐"
228
- ]
229
-
230
-
231
- [res]
232
- path = "./resource" # Relative to project's root
233
- size_max = 1024 # In Megabytes
234
-
235
-
236
- [captcha]
237
- length = 4
238
- max_cache = 60
239
- expire = 120 # Expire time in seconds
240
-
241
- [captcha.options]
242
- # you don't want to have all of them turn on, it'll be confusing
243
- numbers = false
244
- lowercase = true
245
- uppercase = false
246
-
247
- [db]
248
- path = "./yacs.db"
249
- ```
250
-
251
- And, an example config could look like this.
252
-
253
- ```toml
254
- [flask]
255
- DEBUG = false
256
-
257
- [app]
258
- admin_phrase = "this-is-admin"
259
- user_phrase = "hello"
260
-
261
- [custom]
262
- title = "My YACS Server"
263
- motd = "Hello!\nRule No.1!"
264
- ```
265
-
266
- ## Acknowledgement
267
- YACS will not be possible without following existing projects.
268
-
269
- - [98.css](https://github.com/jdan/98.css)
270
- - [flask](https://github.com/pallets/flask/)
271
- - [bbcode](https://github.com/dcwatson/bbcode)
272
- - [webargs](https://github.com/marshmallow-code/webargs)
273
- - [captcha](https://github.com/lepture/captcha)
274
- - [flask-socketio](https://github.com/miguelgrinberg/flask-socketio)
275
-
276
-
277
- ## Loicense
278
- Oi mate! Got a loicense for that project Govna? Yes, and it is the best one!
279
-
280
- YACS is licensed under WTFPL with NO WARRANTY.
281
-
282
- <a href="http://www.wtfpl.net/"><img
283
- src="http://www.wtfpl.net/wp-content/uploads/2012/12/wtfpl-badge-4.png"
18
+ # YACS
19
+ Yet Another Chatroom Script
20
+
21
+ Inspired by [LE-CHAT-PHP](https://github.com/DanWin/le-chat-php)
22
+
23
+ ![Splash Screen](docs/the-yacs.jpeg)
24
+
25
+ ## Featuring
26
+
27
+ - Multiple channels.
28
+ - Admins.
29
+ - Files and embedded images/videos.
30
+ - BBCode.
31
+ - CAPTCHA.
32
+ - Vanilla HTML & CSS & JS.
33
+ - No Cookies, it's bad for your teeth.
34
+
35
+ ## Migrating from Older Versions (IMPORTANT)
36
+
37
+ **Migrating from 0.3.x**
38
+
39
+ If you are upgrading from YACS 0.3.x or earlier, your existing database and resource files may not be compatible with the new release. Use the `migrate` command to fix things up **before** starting the server:
40
+
41
+ ```bash
42
+ # From venv
43
+ (.venv) yacscript migrate --config config.toml
44
+
45
+ # From source
46
+ $ uv run yacscript migrate --config config.toml
47
+ ```
48
+
49
+ The `migrate` command will fix the database schema as well as the resource naming.
50
+
51
+ It is safe to run `migrate` multiple times — if there is nothing to migrate, no changes will be made anyway.
52
+
53
+ **Migrating from 0.4.0**
54
+
55
+ We're currently introducing a lot of breaking update since 0.5.0 regarding certain security issues. Manual interventions are minimal but required. Check lastest `README.md`, especially the <a href="#configuration">configuration section</a>.
56
+
57
+ - Inline attachments are now controlled by an allowlist of extensions. Other file types are sanitized.
58
+ - A strong admin passphrase is now required to start the server.
59
+ - `/auth` is now rate limited.
60
+ - `/room-preview` now requires explicit opt-in in config.
61
+
62
+ ## Try It Out Right Now!
63
+
64
+ Join [The YACS Demo Server](https://chat.valine0x.icu) right now with passphrase **`the-yacs`** to see YACS in action!
65
+
66
+ ## Deployment
67
+
68
+ ### 1. Deploy with venv (Recommended)
69
+
70
+ Create a venv with python version 3.13 or greater.
71
+
72
+ ```bash
73
+ $ python -m venv .venv
74
+ ```
75
+
76
+ ```bash
77
+ # Activate venv in *nix shell (e.g. bash, zsh)
78
+ $ source .venv/bin/activate
79
+ ```
80
+
81
+ ```pwsh
82
+ # Activate venv in pwsh
83
+ > . .venv\Scripts\Activate.ps1"
84
+ ```
85
+
86
+
87
+ Then, install the package inside venv.
88
+
89
+ ```bash
90
+ (.venv) pip install yacscript
91
+ ```
92
+
93
+ Create a configuration file and edit it to your liking.
94
+
95
+ For reference, see the <a href="#configuration">configuration section</a>.
96
+
97
+ ```bash
98
+ (.venv) vi ./config.toml
99
+ ```
100
+
101
+ Finally, start the server within the venv:
102
+
103
+ ```bash
104
+ (.venv) yacscript start --config config.toml
105
+ ```
106
+
107
+ In addition to that, you might want to deploy the program as a daemon. Here's an example of a possible simple unit file for systemd.
108
+
109
+ Assuming you have installed the venv as `/path/to/.venv`, for example `/opt/yacs/.venv`, making `/path/to/` means `/opt/yacs/` for the setup.
110
+
111
+ ```ini
112
+ [Unit]
113
+ Description=YACS Service
114
+ After=network.target
115
+
116
+ [Service]
117
+ Type=simple
118
+ WorkingDirectory=/path/to
119
+ Environment="PATH=/path/to/.venv/bin"
120
+ ExecStart=/path/to/.venv/bin/yacscript start --config /path/to/config.toml
121
+
122
+ [Install]
123
+ WantedBy=multi-user.target
124
+ ```
125
+
126
+ ### 2. Deploy from source (with uv)
127
+
128
+ Deploying from source gives you access to the latest features but may be unstable
129
+
130
+ To deploy from source, first you need to install uv.
131
+
132
+ ```bash
133
+ # Install with pip.
134
+ $ pip install uv
135
+
136
+ # Install on macOS and Linux.
137
+ $ curl -LsSf https://astral.sh/uv/install.sh | sh
138
+
139
+ # Install on Windows.
140
+ $ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
141
+ ```
142
+
143
+ Then, clone the repo.
144
+
145
+ ```bash
146
+ $ git clone https://github.com/valine-dev/yacs.git
147
+ $ cd yacs
148
+ ```
149
+
150
+ Create a config file, and edit it to your liking.
151
+
152
+ For reference, see the <a href="#configuration">configuration section</a>.
153
+
154
+ ```bash
155
+ $ vi ./config.toml
156
+ ```
157
+
158
+ Finally, run the server, dependencies and venv will be installed along the way.
159
+
160
+ ```bash
161
+ $ uv run yacscript start --config config.toml
162
+ ```
163
+
164
+ Additionally, it's also possible to make a daemon service out of deployment from source.
165
+
166
+ An example unit file is shown as below.
167
+
168
+ ```ini
169
+ [Unit]
170
+ Description=YACS Service
171
+ After=network.target
172
+
173
+ [Service]
174
+ Type=simple
175
+ WorkingDirectory=/path/to/yacs
176
+ Environment="PATH=/path/to/yacs/.venv/bin"
177
+ # Notice the difference to deploying from package!
178
+ ExecStart=/path/to/uv run yacscript start --config /path/to/config.toml
179
+
180
+ [Install]
181
+ WantedBy=multi-user.target
182
+ ```
183
+
184
+ ## CLI Reference
185
+
186
+ The `yacscript` command ships with the following subcommands:
187
+
188
+ - `yacscript start --config config.toml` — Start the YACS server.
189
+ - `yacscript gc --config config.toml` — Clean expired resources from disk.
190
+ - `yacscript migrate --config config.toml` — Migrate your data from older versions.
191
+
192
+ In which gc and migrate are mostly safe to run.
193
+
194
+ ## User Manual
195
+
196
+ Consult <a href="docs/manual.md">User Manual</a> for guidance.
197
+
198
+ ## Configuration
199
+
200
+ You should at least set a unique `app.admin_phrase` (at least 8 characters, not among some of the well-known placeholder) to start the server!
201
+
202
+ All possible fields are shown below.
203
+
204
+ ```toml
205
+ [flask]
206
+ # here you can configure built-in config values defined by flask
207
+ DEBUG = false # DO NOT SET TO `true` WHEN EXPOSING TO PUBLIC!
208
+
209
+ [app]
210
+ # The app itself will only exposed through plain HTTP and it's strongly discorage to do so directly to public web. Use a reverse proxy with TLS in front of the app.
211
+ ip = "0.0.0.0"
212
+ port = 8080
213
+
214
+ admin_phrase = "CHANGE_ME_ADMIN"
215
+ # admin_phrase must be at least 8 characters long and must not be a
216
+ # well-known/placeholder value ("admin", "password", "CHANGE_ME_ADMIN", ...).
217
+ # The server refuses to start otherwise.
218
+ # set user_phrase to empty will expose chatroom to the public
219
+ user_phrase = "CHANGE_ME"
220
+
221
+ log_level = "INFO"
222
+ timeout = 5000 # in milisecond, use for heartbeat
223
+
224
+ # Failed-login throttling, applied per IP and per nickname.
225
+ # The counters are kept in memory and reset when the process restarts.
226
+ auth_fail_limit = 20
227
+ auth_fail_window = 300 # in seconds
228
+
229
+ # Development only: lets /room-preview create an admin session without any
230
+ # credentials. NEVER enable this on a public server.
231
+ enable_room_preview = false
232
+
233
+ # Set to true only when the app is behind a reverse proxy!
234
+ # Make sure X-Forwarded-For and X-Forwarded-Host are properly set!
235
+ proxy_fix = false
236
+
237
+ # For socketio connections
238
+ # Do set a propper value in production enviroment
239
+ cors_allowed_origins = "https://me.example"
240
+
241
+
242
+ [custom]
243
+ title = "The YACS"
244
+ motd = "Hello!\nRule No.1"
245
+
246
+ # These are the emotes that will rendered to the webpage
247
+ emoticons = [
248
+ "( ゚∀。)",
249
+ "Insert Anything",
250
+ "⭐"
251
+ ]
252
+
253
+
254
+ [res]
255
+ path = "./resource" # Relative to project's root
256
+ size_max = 1024 # In Megabytes
257
+
258
+ # Per-user quota for files staged before they are attached to a message.
259
+ max_pending_files = 10
260
+ max_pending_mb = 0 # Total staged bytes per user, in Megabytes; 0 = 2 * size_max
261
+
262
+
263
+ [captcha]
264
+ length = 4
265
+ max_cache = 60
266
+ expire = 120 # Expire time in seconds
267
+
268
+ [captcha.options]
269
+ # you don't want to have all of them turn on, it'll be confusing
270
+ numbers = false
271
+ lowercase = true
272
+ uppercase = false
273
+
274
+ [reserved]
275
+ # Having regulars? Don't want your name get stolen? Reserve your name right now! It's free!
276
+ # A reserved nickname only accepts its own passphrase (or the admin phrase), so
277
+ # the shared user_phrase cannot be used to take it. Nicknames are case-sensitive.
278
+ "User01" = "their_passphrase"
279
+
280
+ [db]
281
+ path = "./yacs.db"
282
+ ```
283
+
284
+ And, an example config could look like this.
285
+
286
+ ```toml
287
+ [flask]
288
+ DEBUG = false
289
+
290
+ [app]
291
+ admin_phrase = "this-is-admin"
292
+ user_phrase = "hello"
293
+
294
+ [custom]
295
+ title = "My YACS Server"
296
+ motd = "Hello!\nRule No.1!"
297
+ ```
298
+
299
+ ## Acknowledgement
300
+ YACS will not be possible without following existing projects.
301
+
302
+ - [98.css](https://github.com/jdan/98.css)
303
+ - [flask](https://github.com/pallets/flask/)
304
+ - [bbcode](https://github.com/dcwatson/bbcode)
305
+ - [webargs](https://github.com/marshmallow-code/webargs)
306
+ - [captcha](https://github.com/lepture/captcha)
307
+ - [flask-socketio](https://github.com/miguelgrinberg/flask-socketio)
308
+
309
+
310
+ ## Loicense
311
+ Oi mate! Got a loicense for that project Govna? Yes, and it is the best one!
312
+
313
+ YACS is licensed under WTFPL with NO WARRANTY.
314
+
315
+ <a href="http://www.wtfpl.net/"><img
316
+ src="http://www.wtfpl.net/wp-content/uploads/2012/12/wtfpl-badge-4.png"
284
317
  width="80" height="15" alt="WTFPL" /></a>