Files
Bubberstation/code/modules/asset_cache
LemonInTheDark 0c4af38f41 [MDB IGNORE] TGUI library, plus polish (#65326)
* Prevents potentially infinite length books from being written and stored. I'm not sure if this is an actual issue, but I have a funny feeling it may become one someday

* Moves the paper defines to their own file

* It's become clear to me that I am stupid

* git add --all

* Makes book info into a datum to allow for easy passing around

* Converts the library scanner to tgui, lays the groundwork for tgui visitor consoles

* Makes the db request for book info sort
Adds the frontend for the visitor's console
Adds a hash to prevent duplicate db requests
Adds a prams changed var to help facilitate a better search button
Makes the page number code accept text as input

* Makes the ui index at 1 even tho we index at 0 internally

* Begins the conversion process for the library console.

Changes the library console to override the visitor, to utalize for the archive access portion of the ui
Makes scanner into a weakref, I'm coming for you handheld scanner
Renames some vars to make things clearer

* Converts the remaining refs of the old console typepath over, adds a circuit board for consoles because pain

* Changes how bookshelves load in books
Instead of loading them in lazyally, we load them during init
This lets us track what books are stored in which areas

Somewhat jutting off of this, adds map config for designating something as "part of the library"
This will be useful later

* Renames the random poster, adds a spritesheet for bibles. Both will be useful in a moment

* Ok. This is a bit of a mess.
Converts the library console to tgui.
This comes with a few minor behavior changes:
You can now select what type of poster you want to print, instead of just printing a random one
It's now possible to heed the console's emag warning
The console's inventory page will fill at roundstart with the books in your area/if you're in a library, any
areas designated as "library like" in the map config
You can see what type of bible the chaplin has selected?

"Fixes":
You can no longer just dump books into the scanner forever

Implementation details:
Any input that makes a db request will now A: freeze up any other db inputs until it's finished, and B: Start a
1 second timer before any new db requests can be made
Of note, I'm handling html encoding in a very targeted way.
All book_data datums need to have html encoded values. get_title/author/content exist so a defaulting and tgui
appropriate version can be loaded in. This somewhat matches with the trusted var on set_title, it exists to
prevent double html encoding.

While we're here

Input/DB (Book data should be html encoded)
Inside book datum (Book data should be html encoded)
Sending to tgui (Book data should be decoded during extraction with the get_() procs)
Sending anywhere else (Book data should be html encoded, otherwise it's an xss vuln)

Uhhhh tgui stuff?
I'm using a custom theme for emag visuals, I'll get into that more later
The visitor and book management console share the same data/act pipeline, which is why they're parented/subtyped
They also share a page selection component, which is why the visitor's console imports it.

Uhhhhh
Oh right, fuck.
Ok so the page selection component is kinda cursed, the left and right controls are fine
But I'm trying to get a << < [page/max] > >> setup going, and that means resetting the center input past change
so the default value can be used
This ends up being slightly hacky. I'm sorry.

Oh also, I implemented a custom tab setup for this ui. I have no idea why it was literally like 5 months ago.
I think it looks pretty nice, but if you want me to nuke it I can. Sorry for any headache around this.

More tgui stuff next

* Scanner/visitor cleanup, some other odds and ends

* Adds in a dark red and black theme for library computers to be triggered by an emag.
Things of note: I'm overriding some lists that get passed into buttons and one other thing using set, since the
list is alreadt generated by that step in the process? I think?
I've added dimness control to the dimmer component, since well, it was dimming already dark uis.
I also made and added a rather large background svg. I've got no experience with this sort of thing, and all the
compression methods I found for this ended up being busts. I know this isn't acceptable as an end product, but I
don't know how to get it there.

Somewhat on that note, this ui might not be worth the size for the amount of use it gets. I'm fine with nuking
it if that's the case, I bring this up because I have a very poor understanding of the logistics of something
like this, so I have a feeling I've fucked up somewhere

* Forgot these, just a scss file for library computers, barely used but I think it's worthwhile

* Missed this eariler. As a part of the uploading tab, I'm displaying the contents of books. I'm loading in that
context as raw html so paper -> book books look close to right. Means I need more html tags then our current
sanitize provides. I don't think any of these will cause issues, and there's also a good chance I'm missing
some. Will come up with a list later

* Updates the rest of the maps to use the new management typepath

* Fixes the default bible name being Default Bible Name, I am sorry

* Turns out I had the scaling wrong for bible names, lead to weird stacking because the bible icon doesn't scale, so I lowered its sizing

* Yeets unneeded exports (Thank you jlsnow)

Haha wouldn't it be funny if I didn't know how components worked

Co-authored-by: Jeremiah <42397676+jlsnow301@users.noreply.github.com>

* Resets the maps to master

* Fixes oversights from merge commit, changes maps

* Removes needless Flex's from the scanner

* Gives the library console the ability to parse markdown. Expands the list of acceptable html elements a bit

* Adds audio cues for printing and inserting/removing from the scanner, makes the scanner nicer to use in general

* Uses a compressed version of the background. It's still huge, but smaller at least

* Adds the printing audio to the book binder

* Cleans up tram

* curse you tram

* AHHHHHHHH

* MY LIFE IS TRUE PAIN

* Adds a path conversion statement to make people's lives easier

* Apply's style's suggestions

thx style

Co-authored-by: Aleksej Komarov <stylemistake@gmail.com>

* Compresses the background svg

* Further js cleanup

* We no longer render markdown in the ui, since any source of markdown is converted to html anyway

* More ui changes

Makes the tab/main screen logic use Flex rather then manuel offsets
Makes modals better fit the size of their contents
Readjusts the width of some inputs
Properly uses the header prop for a table
Makes the buttons in the upload panel look nicer
Restructures the print tab a bit

* Increase a modal's size

* Fixes computers with no keyboard overlay showing their screen even when the power is out

* Moves some data and logic onto the library subsystem. Kyler's review

Fixes harddels held by the library scanner. Makes the scanner's buffer
actually do something

* Makes book icon randomization a proc rather then just copypasta'd code

* Removes the kilo library edit, the soul was removed

* Damn you san (Fixes mapconflicts)

* Pain

Co-authored-by: Jeremiah <42397676+jlsnow301@users.noreply.github.com>
Co-authored-by: Aleksej Komarov <stylemistake@gmail.com>
2022-03-30 19:56:53 -07:00
..
2022-02-06 22:04:06 +02:00

Asset cache system

Framework for managing browser assets (javascript,css,images,etc)

This manages getting the asset to the client without doing unneeded re-sends, as well as utilizing any configured cdns.

There are two frameworks for using this system:

Asset datum:

Make a datum in asset_list_items.dm with your browser assets for your thing.

Checkout asset_list.dm for the helper subclasses

The simple subclass will most likely be of use for most cases.

Call get_asset_datum() with the type of the datum you created to get your asset cache datum

Call .send(client|usr) on that datum to send the asset to the client. Depending on the asset transport this may or may not block.

Call .get_url_mappings() to get an associated list with the urls your assets can be found at.

Manual backend:

See the documentation for /datum/asset_transport for the backend api the asset datums utilize.

The global variable SSassets.transport contains the currently configured transport.

Notes:

Because byond browse() calls use non-blocking queues, if your code uses output() (which bypasses all of these queues) to invoke javascript functions you will need to first have the javascript announce to the server it has loaded before trying to invoke js functions.

To make your code work with any CDNs configured by the server, you must make sure assets are referenced from the url returned by get_url_mappings() or by asset_transport's get_asset_url(). (TGUI also has helpers for this.) If this can not be easily done, you can bypass the cdn using legacy assets, see the simple asset datum for details.

CSS files that use url() can be made to use the CDN without needing to rewrite all url() calls in code by using the namespaced helper datum. See the documentation for /datum/asset/simple/namespaced for details.