Dash plotly set custom folder as my assets folder - plotly-dash

I've built a dash dashboard and customised the appearance using my own css. The structure of the app is below
I then dockerised and deployed the dashboard our linux servers. Unfortunately our linux servers have overwrriten the assets folder with it's own css.
In order the app to find it's own CSS, I need to specify my own assets folder in the dash app.
I've tried various syntax locally(below) but can't get it work
app = dash.Dash(__name__,static_folder='/new_assets/')
app = dash.Dash(__name__,assets_folder='/new_asssets/')
app = dash.Dash(__name__,assets_url_path='/new_asssets/')
Any advice on this would be greatly appreciated!

Turn out this was the right way to do it, but you need to specify the absolute path so I added this line to the top of my code and running the code from the dashboard directory.
import os
assets_path = os.getcwd() +'/src/new_assets'
app = dash.Dash(__name__,assets_folder=assets_path)

Related

Hugo FontAwesome import

Does anyone know the correct way to setup Hugo, using PostCSS to move fonts into public when building - but also be served locally in memory when running in local dev server?
I have tried postcss-url but that seems to only want to copy the files to a location, then the pathing doesn't work. Manually setting up a copy to public will get out of hand and then would't work for local dev.
Just to understand, what are you missing with the static files feature?

What is the correct way to display a HTML file downloaded and saved in the file system using codename one?

What is the correct way to display a HTML file downloaded and saved in the file system? I am able to download and save the html page in the .cn1 folder on Simulator but it doesn't display. I tested using the Page.html sample file found in the old Kitchen Sink demo.
Also, how can I use hardcoded paths like file:///storage/emulated/0/Folder/Page.html instead? I have tried but nothing appears in common folders in the phone e.g. the Android folder. Below is what I have done so far!
`Form fm_brw = new Form();`
`fm_brw.setLayout(new BorderLayout());`
`FileSystemStorage fs = FileSystemStorage.getInstance();`
`fs.mkdir(fs.getAppHomePath() + "SampleFolder");`
`Util.downloadUrlToFile("http://somesite.com/Page.html", fs.getAppHomePath() + "SampleFolder/Page.html", true);`
`BrowserComponent browser = new BrowserComponent();`
`browser.setURL(fs.getAppHomePath() + "SampleFolder/Page.html);`
`fm_brw.addComponent(BorderLayout.CENTER, browser);`
`fm_brw.show();`
You can't hardcode paths on phones as those differ even on the same phone for new installs to keep app isolation.
Your approach is correct but I'm assuming the html refers to images and other resources which are now unavailable so the process of downloading an HTML file for offline viewing is more complex as you would need to download all the resources then edit the HTML source to reference local files instead of server files.
#Shai Almog - Happy 2018 and please accept my apologies for the delayed reply. I figured out the reason for the webpage not diplaying... apparently, you have to add the "file://" when setting the url i.e. browser.setURL("file://"+str_homePath+str_filePath);
If this is not by your design then I can file an RFE.

How to manage eqFTP in Brackets to download files from server to pc

I am new to Brackets and I cannot find a solution to my problem.
I have a website and it has a CMS with lots of templates and css in different folders.
I need to modify all of them, one by one, changing styles, adding content and markups and so on.
I just started using Brackets and just installed eqFTP in it following the guide and set everything.
Now how can I download, using eqFTP, all templates and css from the server to my folder project in my pc so I can modify them and upload them all from brackets?
For example: if my templates are in public_html/templates and css are in public_html/styles/ how can I tell to eqFTP to download them in folder project?
dev here.
You should create new connection and then connect to your server, you'll see file tree and you want to right click on folder/file you need to download and choose 'Download'. For files you can actually use doubleclick which will download and open that file.
Hope this helps.

Air App will not read local text file using openAsync/readUTFBytes on user (non-admin) mode

I am running an Air App I did for the desktop, from the actual installed executable already deployed in the machine (Not from Flash Pro / Flex dev. environment). For some reason the app will not read a text file stored in the same application folder unless I run my app as administrator from the OS.
When I run the app as admin, or within the development environment it works fine. Maybe this is related to some security issue? I read the adobe air documentation, and this should work...
I am using openAsync/readUTFBytes on user as shown here:
var continueGamesConnection:FileStream();
var continueFile:File = new File(File.applicationDirectory.resolvePath("continueGames.txt").nativePath.toString());
continueGamesConnection.addEventListener(Event.COMPLETE, openSavedGames);
continueGamesConnection.openAsync(continueFile, FileMode.UPDATE);
function openSavedGames(event:Event):void
{
continueGamesConnection.removeEventListener(Event.COMPLETE, openSavedGames);
var content:URLVariables = new URLVariables();
var loadedContent:String = new String();
loadedContent = continueGamesConnection.readUTFBytes(continueGamesConnection.bytesAvailable);
content.decode(loadedContent);
variableX = content. variableX
//etc, etc.
continueGamesConnection.close();
}
By the way, I have also, tried using FileMode.READ, and others, and it still gives me the same problem. Only works if ran on admin mode or from the dev. environment.
It's very frustrating, I tried reading other posts without any luck... What solutions do people use for this kind of problem?
I have seen that you can set the app to run as admin somehow, and I guess that could work. However, this should work just fine, since it doesn't seem to violate any of the security APIs of Air. Seems like an overkill. But even so, how do I do that?
You help is greatly appreciated!
Typically for security reasons, applications do not have write permissions to the File.applicationDirectory.
It is recommended you use File.applicationStorageDirectory instead as that is the most appropriate place to save user data (such as a save game file).
Alternatively, you could also let the user browse to a directory with the FileReference class which may or not have permission.
Assuming that you are using a Windows SO, the problem that you have is about user access restrictions to folders C:\Program Files and C:\Program Files (x86) and there is nothing you can do from Flash or AIR to solve it. You could modify you security settings by right click on the folder or you should simply avoid using the app folder to store anything

How can I open PDF files inside a Mac node-webkit application?

I'm trying to add support for PDFs in my Mac node-webkit app. I tried using "PDF.js" but it requires the use of a web server so this won't help me.
I've already solved this issue for the PC version of the node-webkit app by installing "Adobe Acrobat Reader" and adding the "nppdf32.dll" file inside the plugins folder of the root directory of the PC application.
Now I'm trying to solve this issue for the Mac version. How can I open PDF files inside my Mac node-webkit application?
If you still want to try PDF.js, this is how I have gotten it working.
After downloading all the files, the main ones that do all the work are viewer.html and viewer.js. You can point to viewer.html from anywhere in your node-webkit app by doing something like:
$(".some-pdf").on("click", function(){
window.location.href = "path-to-pdfjs/viewer.html";
});
To determine which file it opens, there's a variable in view.js.
var DEFAULT_URL = 'pdfs/something.pdf';
Since you're using node-webkit, it won't have any issues accessing the file system.
I made it a little more dynamic, where the link can point to any specific pdf, by doing the following. In any file, the link adds a hash with the file name:
$(".some-pdf").on("click", function(){
window.location.href = "path-to-pdfjs/viewer.html#specific.pdf";
});
Then in viewer.js:
var DEFAULT_URL = 'pdfs/' + window.location.hash.replace("#", "");
Then it is a bit reusable through your app, if there are multiple pdf files involved.