Facepunch / garrysmod-requests

Feature requests for Garry's Mod
83 stars 24 forks source link

Allow uploading .html, .css and .js files on workshop #1156

Open azephiris opened 6 years ago

azephiris commented 6 years ago

As said on the forums, some servers and non-workshop addons like Starfall use resource.AddFile to send the JS Ace Editor / HUD GUIs to clients.

I don't see any security flaw as we can already open any URLs in a HTML panel, and allowing these files extensions would be benefic with the upcoming Chromium update.

yogwoggf commented 1 week ago

@robotboy655 Will this ever be addressed? I don't see why .html, .css and .js are still not allowed in the AddonWhitelist. This hampers my ability to create snappy and modern user interfaces with DHTML.

garryspins commented 1 week ago

snappy and modern user interfaces are perfectly possible with vgui, in fact its exceptional at it and you don't need the workshop for this, SetHTML can take any string you like! Try webdl to /data/

Plus writing entire UI's using DHTML is questionable considering chromium isn't merged.

yogwoggf commented 1 week ago

snappy and modern user interfaces are perfectly possible with vgui, in fact its exceptional at it and you don't need the workshop for this, SetHTML can take any string you like! Try webdl to /data/

Plus writing entire UI's using DHTML is questionable considering chromium isn't merged.

Thank you for your rebuttal. I'm working on an unorthodox addon (one that primarily relies on chromium branch + binary modules), so this isn't necessarily going to the workshop. My issue is that I distribute the addon side of things using the GMA format since it provides easier deployment on users' installations and compresses well.

Therefore, I'm able to write entire UIs in DHTML (and my users will also see it identically). So, sure that makes my addon specifically fall into an unusual category--but this request is so simple and has been requested for years. I don't think that it'd hurt to fix this properly. (Plus, modern chromium has stuff like module scripts which are currently broken due to a MIME type mismatch because you need to use a different extension to package your addon)

garryspins commented 1 week ago

Then adding these to the wl sounds good to me!

BadgerCode commented 1 week ago

@robotboy655 Will this ever be addressed? I don't see why .html, .css and .js are still not allowed in the AddonWhitelist. This hampers my ability to create snappy and modern user interfaces with DHTML.

To workaround this myself, I did the following

  1. Store the HTML in a lua variable
  2. Use SetHTML to set the panel's HTML contents to that variable
  3. Split the HTML into 65K chunks to get around the size limit

Example

-- In your addon's initiation code
myHTMLChunks = {} -- Give it a unique name

-- HTML file 1.lua
table.insert(myHTMLChunks, [===[<!doctype html>
<html>

<head>
    <meta charset="UTF-8" />
...===])

-- HTML file 2.lua
table.insert(myHTMLChunks, [===...===])

-- Continue for as many HTML files as you need

-- After loading all of the HTML files
combinedHTML = table.concat(myHTMLChunks) -- Give it a unique name

-- When your UI needs to render
myPanel:SetHTML(combinedHTML)

I have a complete example on an older project of mine- https://github.com/BadgerCode/emojichat/tree/master

garryspins commented 1 week ago

You still dont get the benefits like autocomplete and syntax highlighting without copy/pasting it from a file of those types, much better to just do it with files

yogwoggf commented 3 days ago

@robotboy655 Any updates? Still waiting for an official response....