Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Automatically upload your sheet code!

1653065061

Edited 1654536216
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hey all! I've got a new release today, but unlike usual, it's not code for an API script or a character sheet. Instead, this is a tool for all us code authors on Roll20. Roll20 Autouploader Back when the sheet sandbox was first released, I had asked Kenton why the sheet sandbox couldn't simply monitor a directory and automatically update the sandbox when the html, css, or translation.json files changed. Back then, this wasn't possible as browsers don't generally have live access to the file system of a user's computer. That changes today with the release of v1.0 of the Roll20 API and Sheet Autouploader ! You can also find the source code on github . v1.21Alpha of the autouploader also works on API scripts! What is it? The autouploader is an extension for Chromium browsers (except Brave) that will monitor a file directory of your choosing and will update the sheet sandbox when sheet code files (html, css, or translation.json) in that directory change. It will also provide some basic feedback on issues with your CSS or translation.json files that cause them to be thrown out by the Roll20 parser. Here's a video of it in action on a demo project . How does it work? The autouploader replaces the default Roll20 sheetsandbox tools with the script's own upload status dialog. This dialog provides a button to select a directory to watch as well as a variety of status indicators for how the extension is working. Once you select a directory to watch, the extension looks in that directory and selects the html, css, and translation.json file contained in it to watch. About once a second, the extension will poll these files to see if the last modified date is more recent than the last modified date of the file that was uploaded. If the file was modified more recently, it is uploaded and the sheet sandbox is updated. If there are multiple files of a given file type (e.g. two html files), the extension will select the last one that it finds. In addition to uploading the sheet code, the extension also provides some more detailed feedback on your code and how the Roll20 code sanitizer will react to it. CSS file contents are checked for all the various disallowed characters and words that will cause the sanitizer to throw out the CSS. Translation files are checked to make sure they are valid JSON. While the code is uploaded regardless, the upload interface will give you a descriptive warning of what's wrong and the color of the status box for the problematic file will turn yellow so that you know what file has a problem, and what that problem is. This will hopefully reduce the amount of time that we spend trying to figure out why our code changes aren't being applied only to realize that it's because we gave an element the class medieval  and the sanitizer threw out the CSS because it found eval  in the code. The actual method of updating the sheet sandbox uses the same R20 sheet upload code under the hood, in fact the extension is just automating the act of supplying the file to the R20 sandbox interface, so this should remain fully compatible with the R20 sheet sandbox unless R20 changes the fundamental nature of how file uploads work in the sheet sandbox. Data Privacy Am I just looking to amass a huge library of custom sheet code to pull apart and use!? The answer is, no I'm not. The extension has no persistent memory and won't remember what you did with it once you close the browser tab your sheet sandbox is in. The only place that any data is uploaded to is the Roll20 sheet sandbox, and the extension only provides Roll20 with the same data that they receive when you manually upload code to the sheet sandbox. The extension does see everything that is in the directory that you select for it to monitor and future versions may allow the extension to dig deeper into the folder structure contained within the directory. However, the extension is incapable of seeing any information about the folder structure that the monitored directory is contained in. Extending into the future This first release of the extension is just a well developed proof of concept. There are several features that I'd like to bring to the extension in the future. In no particular order: The ability to auto upload API script code as well ( in Alpha Testing ) The ability to monitor the API sandbox state from the game page More detailed descriptions of the CSS sanitizer errors Known Issues The extension does not work on all chromium browsers (e.g. Brave). This is because it relies on a newer browser API that some chromium browsers have disabled or may not have been updated to have. Browsers that are known to work at the time of writing are Chrome and Edge. The extension can't be adapted to work with Firefox or any other non-chromium browser as chromium browsers are the only ones with the File System Access API. Like this project? Want to support the creation of cool tools like this? Support me on the Kurohyou Studios Patreon !
1653065612
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Fantastic achievement! Direct integration with the editor or development system of your choice. Since I don't have any experience with sheet creation, I am looking forward in particular to the eventual addition of the API feature.
1653070692

Edited 1653070733
vÍnce
Pro
Sheet Author
I would have been happy with just clicking a single button to update all the sheet files(html, css, translate) at once... lol I've been using this for a week or so while working on a sheet and this is a REAL time-saver.  Great work as always Scott! 
1653086222
GiGs
Pro
Sheet Author
API Scripter
Tis is a great concept. I use firefox, so can't test it, but it looks great. and those planned additions look amazing.
1653090760
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
How do you envision this working? The ability to monitor the API sandbox state from the game page
1653108711
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
keithcurtis said: How do you envision this working? The ability to monitor the API sandbox state from the game page It depends on what exactly I find is possible. At a minimum, I'd like to add some sort of animation to indicate whether the API sandbox is up or down, similar to how Aaron's API Heartbeat script works. I'd probably look at putting this as a tag on the extension's icon in the extension tray to make it as unobtrusive as possible. Some additional things I'd like to look into are reporting the error that caused an API shutdown (likely in an extension popup from the extension's icon) and stealing Oosh's API console forwarding. While this feature would have some benefit for us coders, it'd be helpful for all API users.
1653110378
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Yes indeed. I have become dependent on API Heartbeat, but it makes it nearly impossible to edit the macro bar while the API is running. (updating the icon causes the macro bar to lose focus).
1653231568
Andreas J.
Forum Champion
Sheet Author
Translator
This is big :D
1653235170
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
vÍnce said: I would have been happy with just clicking a single button to update all the sheet files(html, css, translate) at once... lol I've been using this for a week or so while working on a sheet and this is a REAL time-saver.  Great work as always Scott!  This is what could be done in Firefox.
1653250069
GiGs
Pro
Sheet Author
API Scripter
Scott C. said: vÍnce said: I would have been happy with just clicking a single button to update all the sheet files(html, css, translate) at once... lol I've been using this for a week or so while working on a sheet and this is a REAL time-saver.  Great work as always Scott!  This is what could be done in Firefox. As a firefox user, I wouldn't mind seeing that :) A question: one thing that happens when I'm doing a lot of work in ythe sandbox, is that after a while, the sheet I have active stops updating. I don't know if it's a sandbox issue, a character corruption issue, or a firefox isue. But this happens in pretty much every long session where I load changes a lot. The only fix I've found is to open a different character (or a new one) and work on that one, and things start working properly again. It's a nuisance, the sandbox is still great to use, but I'm now wondering if other people see this, and if so, does it affect this extension?
1653253787
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
GiGs said: Scott C. said: vÍnce said: I would have been happy with just clicking a single button to update all the sheet files(html, css, translate) at once... lol I've been using this for a week or so while working on a sheet and this is a REAL time-saver.  Great work as always Scott!  This is what could be done in Firefox. As a firefox user, I wouldn't mind seeing that :) A question: one thing that happens when I'm doing a lot of work in ythe sandbox, is that after a while, the sheet I have active stops updating. I don't know if it's a sandbox issue, a character corruption issue, or a firefox isue. But this happens in pretty much every long session where I load changes a lot. The only fix I've found is to open a different character (or a new one) and work on that one, and things start working properly again. It's a nuisance, the sandbox is still great to use, but I'm now wondering if other people see this, and if so, does it affect this extension? I've had the code update freeze and the sheet becomes nonresponsive during manual updates, . Usually just reuploading the code fixes it for me. The only similar bug that I've run into is that if you use any of the Roll20 Jquery listeners, they don't reactivate properly after you reload code.
1653278677
GiGs
Pro
Sheet Author
API Scripter
Scott, a question about monitoring folders. Does this monitor a single folder, or does it associate each sandbox (you can have up to 15) with a different folder?
1653278855
GiGs
Pro
Sheet Author
API Scripter
Scott C. said: I've had the code update freeze and the sheet becomes nonresponsive during manual updates, . Usually just reuploading the code fixes it for me. The only similar bug that I've run into is that if you use any of the Roll20 Jquery listeners, they don't reactivate properly after you reload code. If this happens with any frequency, it's a good idea to put a warning: "if the sheet becomes unresponsive, do this and it'll work again." With a note that this isn't a problem with the extension, it's just a glitch with the sandbox. Otherwise people might think there's an issue with the extension.
1653284628

Edited 1653284717
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
GiGs said: Scott, a question about monitoring folders. Does this monitor a single folder, or does it associate each sandbox (you can have up to 15) with a different folder? It monitors a directory that you specify each time. The File System Access API features can only be activated from a user interaction (e.g. clicking on a button). This is a security feature of the API to prevent websites from tricking users into sharing information erroneously. And, the directory and file objects aren't serializable as far as I know. Unfortunately, together these mean that it's not possible to just set the directory once and use it over and over again across browser opening/closing. However, the monitoring is done on a per tab basis, so if you had multiple sandboxes open for some reason they each be able to monitor a separate folder. GiGs said: Scott C. said: I've had the code update freeze and the sheet becomes nonresponsive during manual updates, . Usually just reuploading the code fixes it for me. The only similar bug that I've run into is that if you use any of the Roll20 Jquery listeners, they don't reactivate properly after you reload code. If this happens with any frequency, it's a good idea to put a warning: "if the sheet becomes unresponsive, do this and it'll work again." With a note that this isn't a problem with the extension, it's just a glitch with the sandbox. Otherwise people might think there's an issue with the extension. Hmm, probably a good idea. Wonder if there's a way for the extension to detect the freeze and automatically reload.
1653284923

Edited 1653284939
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Did some work on some of the planned features. Pause/resume and reload all files is coming once I finalize the icons to be used:
1653285585

Edited 1653285605
vÍnce
Pro
Sheet Author
I also experienced the sandbox not auto-updating occasionally while making edits in vscode. I found changing/re-selecting the folder seemed to act like a refresh.  I like the refresh option though.  Seems like a more intuitive approach.
1653333133
Richard W.
Pro
Sheet Author
API Scripter
Love it, great work!
1653600033

Edited 1653618280
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Ok, think I have the interface pretty good for the next update. Here's what it's going to look like: Here's what's being shown there: No more "robot eye", as Medieve called it on discord. Now, if the extension crashes, the background color of the "monitoring ..." area will simply change to yellow a few seconds after the crash happens and the log will be updated that the crash occurred. This may also happen if you are having connection issues, and the log entry will note that possibility. If it is a connection issue, the extension should self-correct. Icon buttons instead of text. These just save space. File selection! The extension will now support multiple files of a given type as well as searching the translations  folder for language specific translation JSONs. The gif only demonstrates swapping the translation files, but all three file types will work this way. There's also some features that I now know are possible, although I haven't put them in my dev code yet. Ability to "rewind" to a previous code state and return to "live" code Ability to download a previous code state Decided to can these last two features as I'm not sure they add much value and had some technical limitations I wasn't happy with. Once I get this update goes live, I'll start working on the API side of the extension.
1653619394

Edited 1653619526
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
V1.01 code is up on the github for testing. Assuming no major issues are found with it, I'll send it to publish on the chrome store next week. Change log v1.01 Extension now allows selecting from multiple files in a folder and supports switching to language specific translation files in a translations subfolder Removed the robot eye that showed the extension was functioning. Added error detection functionality that changes the color of the "monitoring" field if the extension crashes or the internet connection is lost. The update log will also get an entry if an error is detected.
1654291540
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
I've been working on getting the API autoupload working. Still need to finish several UI bits, but here's what it looks like right now
1654291845
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Aieeee!!! it looks so cool.
1654348955
Andreas J.
Forum Champion
Sheet Author
Translator
With these latest updates, maybe I'll finally give a try at creating API Scripts...
1654535439

Edited 1654536082
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
v1.21 Alpha This is the first version to have API sync capabilities. The API sync can monitor multiple directories, and will even look for files several levels deep within a given directory. It will also select from multiple versions of a script's code using the script's script.json file so that you can use a file structure similar to the API repo. This initial version of the API upload does not allow for switching between different versions of an API script, and will simply take whatever version is listed as active in the script.json. Here's the API sync in action: Check it out by grabbing the code from the repo.  I'm planning to do an extended alpha/beta test of the API upload functionality before releasing this update on the google web store because it has many more moving parts than the sheet upload functionality that I want to make sure work correctly. Changelog v1.21Alpha Updated readme to reflect the features of the API upload Fixed a fragile section of the code that could cause a crash on page load. v1.2alpha Alpha release of API code auto upload
1656261374
Richard
Pro
Sheet Author
This is amazing! It's working well for me for character sheet uploads. Thank you for your efforts!