Silex icon indicating copy to clipboard operation
Silex copied to clipboard

Silex Desktop Publish Files into same directory rather than JS and CSS Folders

Open MatthewReed303 opened this issue 2 years ago • 6 comments

Is there a way to tell Silex to publish all the files into one directory? My use case is a bit different to most and I'm building web interfaces for an Arduino ESP32 Microcontroller which uses flash memory but does not support directories, it is a flat-file system.

At the moment I have to copy every out of the js and css folder and paste it into the same directory as the .html file, I then edit the html file to use the directory for the js and css files. So every time I make a change in the editor and publish it, I have to repeat the process which becomes quite time consuming

MatthewReed303 avatar Jul 10 '22 10:07 MatthewReed303

Hi @MatthewReed303 Interesting use case, is it for a diy project? Yes there is a way, it takes a little bit of nodejs, do you have the basics of programming in node?

lexoyo avatar Jul 11 '22 18:07 lexoyo

Hi @lexoyo, Yes for a few wireless projects around the farm, but will expand on it in the future. It's pretty straightforward and just uses WebSocket for the data transfer. Have no experience in node.js in the process of learning a bit of JavaScript so can add node.js in there also if you put me in the right direction.

I have to also add this to the top of the JavaScript file when using the code tab in the editor $(document).ready(function() otherwise I get errors with linking to HTML elements. I can also add defer to the JavaScript source file in the HTML file to fix this issue.

MatthewReed303 avatar Jul 12 '22 09:07 MatthewReed303

Hi @MatthewReed303 Is this still needed? Should I give you some pointers?

lexoyo avatar Aug 19 '22 15:08 lexoyo

Hi @lexoyo, yes that would be great as I'm still have to manually move files etc So having option to output everything in the one directory would be great. Thanks

MatthewReed303 avatar Aug 20 '22 04:08 MatthewReed303

Hello

You will need to create a custom hosting provider to change the folders when publishing

  • Here is an example of a hosting provider https://github.com/lexoyo/silex-for-hosting-company/blob/master/custom-provider.js
  • In your case you will not need to override getVhosts, finalizePublication, and so on, instead override getJsFolder, getHtmlFolder getAssetsFolder and getCssFolder
  • Here is a list of everything you can override https://github.com/silexlabs/Silex/blob/99323822de956ec0c6e761570bffe2c02dfaaf0c/src/ts/server/types.ts#L10

In order to use this custom hosting provider, you need to host your instance of silex first https://github.com/silexlabs/Silex/wiki/How-to-Host-An-Instance-of-Silex

lexoyo avatar Aug 24 '22 13:08 lexoyo

Hi @MatthewReed303 Did you have a look at the links?

lexoyo avatar Sep 21 '22 08:09 lexoyo

Hi lexoyo, sorry I missed the reply. will take a look now. Thanks

MatthewReed303 avatar Sep 29 '22 04:09 MatthewReed303

👍 🙇

lexoyo avatar Sep 29 '22 06:09 lexoyo