Commit Graph

2842 Commits

Author SHA1 Message Date
Cohee
e0d0e1dd66
Merge pull request #1502 from valadaptive/status-cleanup
Clean up getStatus code
2023-12-10 15:49:37 +02:00
Cohee
6be1c6ff10
Merge pull request #1504 from valadaptive/store-compiled-templates
Cache compiled Handlebars templates
2023-12-10 15:32:52 +02:00
Cohee
5f1683f43a More input padding and stricter sanitation 2023-12-10 15:07:39 +02:00
Cohee
36438394a2
Merge pull request #1505 from valadaptive/no-random-comparator
Implement random sort with a shuffle
2023-12-10 15:06:27 +02:00
valadaptive
0fce475a95 Implement random sort with a shuffle
Sorting with a random comparator doesn't actually shuffle an array.
Depending on the sorting algorithm used, there will be a bias to the
shuffle (see https://bost.ocks.org/mike/shuffle/compare.html).
If you open that link in Firefox, the bias will be especially bad.
Instead of implementing "random" character sort using a random sort
comparator, use the shuffle function instead.
2023-12-09 22:52:38 -05:00
valadaptive
c48bc8a76e Cache compiled Handlebars templates
Since we already have a template cache, it makes sense to store the
templates in it *after* compiling them, to avoid the overhead of
re-compiling them every time we call renderTemplate.

I've also changed the cache from an object to a Map--it's more
semantically correct, and avoids weird edge cases like a template named
"hasOwnProperty" or some other function that exists as an object
property.
2023-12-09 21:29:36 -05:00
valadaptive
a23be7d785 Clean up CSS for API "connect" buttons
Instead of identifying each connect button by ID, we can just use the
.api_button class. The .menu_button class *would* override it due to CSS
cascade rules (specifically, declarations later in the stylesheet apply
over ones that appear earlier), but the `.menu_button.api_button`
selector has a higher *specificity* and hence works.
2023-12-09 18:52:14 -05:00
valadaptive
babb127aee Move NovelAI status functions over to the rest
Have all the get(...)Status and event handler registrations in the same
areas, rather than having the NovelAI ones far away. I want to
eventually move all the API-specific stuff into separate modules, but
this will make things cleaner for the time being.
2023-12-09 18:41:51 -05:00
valadaptive
0ea0399ed1 Separate getStatus into Kobold/textgen versions
This adds a bit of duplicate code for the time being, but ultimately
makes the code less confusing because we only need to include the bits
that are relevant to the specific API in each function. We can also
remove API parameters that are useless depending on the endpoint.
2023-12-09 18:39:19 -05:00
Cohee
a8224c16de Fix order of middleware application
Previously: CSRF => auth => whitelist
Now: auth => whitelist => CSRF
2023-12-09 19:56:26 +02:00
Cohee
2d7811fa46
Merge pull request #1499 from LenAnderson/qr-execute-from-any-preset
Allow /run for quick replies from any preset
2023-12-09 19:49:03 +02:00
LenAnderson
d00861d913 allow /run for quick replies from other presets
/run otherPresetName.quickReplyLabel
2023-12-09 17:20:15 +00:00
Cohee
e79f6d82da
Merge pull request #1498 from artisticMink/bulkedit-delete-optimization
Only refresh character list after all deletions have been processed.
2023-12-09 18:07:44 +02:00
Cohee
b915b89ca9 Fix ESLint 2023-12-09 16:09:10 +02:00
Cohee
04c83eae71 Use null coalescing operator 2023-12-09 16:07:55 +02:00
Cohee
ad9130b538 Single doc mode: edit on click 2023-12-09 16:01:43 +02:00
artisticMink
dfd41a110a Prevent 'no such file or directory' error when mass deleting characters 2023-12-09 14:36:37 +01:00
artisticMink
4692450975 Enable getPastCharacterChats to work with specific character ids 2023-12-09 14:36:15 +01:00
artisticMink
ba3966e148 Only refresh character list after all deletions have been processed. 2023-12-09 14:31:18 +01:00
Cohee
44ac2ca4e6 Avoid returning 401 as API response code 2023-12-09 15:11:35 +02:00
Cohee
6f610204d6
Merge pull request #1488 from LenAnderson/add-index-argument-to-setvar-/-setglobalvar
Add index argument to setvar / setglobalvar
2023-12-08 00:40:14 +02:00
Cohee
2607e787ff Put comment command on hold 2023-12-08 00:38:13 +02:00
Cohee
e2f886d796 Revert pipe caching 2023-12-08 00:33:27 +02:00
Cohee
32ac8d3b2c
Merge pull request #1492 from valadaptive/backgrounds-endpoint
Move backgrounds endpoints into their own module
2023-12-07 23:27:18 +02:00
Cohee
7f7ad6f523 Merge branch 'staging' into backgrounds-endpoint 2023-12-07 23:16:33 +02:00
Cohee
404b1562e5
Merge pull request #1491 from valadaptive/stats-endpoint
Move stats endpoints into their own module
2023-12-07 23:11:12 +02:00
valadaptive
c0a7472fe9 Move background file instead of copying+deleting 2023-12-07 15:28:04 -05:00
valadaptive
e7dce9b107 Remove response_dw_bg 2023-12-07 15:24:05 -05:00
valadaptive
32c86c1e95 Move backgrounds endpoints into separate file 2023-12-07 15:24:05 -05:00
valadaptive
2367f4f38f Rename backgrounds API endpoints 2023-12-07 15:17:19 -05:00
LenAnderson
65f2cc1952 add a comment slash commend /#
for commenting longer ST scripts
2023-12-07 18:29:28 +00:00
LenAnderson
d52b5fb947 pass prev pipeResult through if result undefined 2023-12-07 18:28:58 +00:00
LenAnderson
5a719d635a use isArray instead of instanceof 2023-12-07 18:27:11 +00:00
LenAnderson
7bfed3fca1 /addvar on array to push 2023-12-07 18:12:05 +00:00
Cohee
c84b6a5101 Add WI inclusion groups 2023-12-07 20:06:06 +02:00
valadaptive
eb1d4aed4d Move stats helpers into stats endpoint 2023-12-07 13:04:54 -05:00
valadaptive
afe0dfe913 Move stats endpoints into separate file 2023-12-07 13:00:34 -05:00
valadaptive
26ebb417f4 Rename stats API endpoints 2023-12-07 13:00:34 -05:00
valadaptive
d6f5e63d85 Move (re)creation of stats to its own function 2023-12-07 13:00:34 -05:00
Cohee
e804f27368 Convert value to string for echo. Fix return value 2023-12-07 19:37:55 +02:00
LenAnderson
2ee57afe2a add helpString for index in setvar 2023-12-07 16:51:45 +00:00
LenAnderson
db6f782e0f add index to /setvar and /setglobalvar 2023-12-07 16:48:24 +00:00
Cohee
b1f68d886c Fix WI field access for UID = 0 2023-12-07 18:45:34 +02:00
Cohee
72adb4c8aa Fix window.ai streaming 2023-12-07 17:42:06 +02:00
Cohee
990f958f4f #1484 Consolidate chat name template 2023-12-07 16:59:53 +02:00
Cohee
2417ae9d87 #1484 Display version on close chat 2023-12-07 16:57:47 +02:00
Cohee
bb1c278899
Merge pull request #1487 from LenAnderson/st-object-vars
Better handling of array / object variables
2023-12-07 16:48:09 +02:00
Cohee
785be22e51 Merge branch 'staging' into st-object-vars 2023-12-07 16:46:02 +02:00
Cohee
e9a49b7997
Merge pull request #1485 from LenAnderson/qr-expand-editor
Add expand button to QR textareas
2023-12-07 15:31:01 +02:00
Cohee
b506a17260 Fix expand after drag 2023-12-07 15:29:40 +02:00