I'm trying to create a plugin for Sketch that creates a folder and a file inside it on a specific location.
Since the sketch plugins are written with JavaScript I've been searching how to create a folder and/or a file with JavaScript, and then think about the path, but i'm stuck, i couldn't find the answer so i decided to open a thread myself.
The question is: How can i create a folder/file with JavaScript? and how i can choose where i put it?
Any feedback is welcome I'm new to posting here and a noob with programming so feel free to redirect me to documentation and/or tutorials that may be useful for my issue.
The simple answer is you can't. Imagine if any old website could create files and folders on your disk whenever it liked. The security implications would be horrendous.
This can be done with the user's permission.
AppSandbox provides this functionality for you:
https://github.com/bomberstudios/sketch-sandbox/blob/master/sandbox.js
The user is prompted to grant permission to do this the first time they run your plug-in. Every time after, it simply writes the file without interruption.
Related
I'm working on a Quizz with Html/JS on Github and which will be dedicated to my comrades.
I would like to be able to read everyone’s answers so I thought about creating a text or csv file with their answers that would be saved in a specific directory of the github project.
But I’m a beginner and I don’t know if that’s possible, i’ve seen tracks that use PHP or NodeJs with FileSaver.js, but I haven’t managed any of them because i would like it to be automatic, not to ask the user to download his answers.
If some people knwo how to do it or explain me why it’s impossible and how to do it otherwise it’ll be cool.
Thanks ! ;)
Unless you want to make every person using the quiz a contributor to your Github project (which will require that they sign up for Github accounts and tell you their account name so you can manually grant them permission) and then use the API to read the CSV file, modify it, then commit the change (and resolve any merge conflicts caused by race conditions): This is not possible (and if you are willing to do that, then it is among the most complex approach that you could take).
If you want to store and aggregate data submitted by visitors to a website then write some server-side code (using whatever language and frameworks you like, PHP and Node.js are both options) and use a web hosting service designed to support them. Github Pages is designed only for static pages and doesn't support any form of server-side programming.
Once you store the data in a file, just use git commands to commit and push it.
I'm trying to find something that can run my javascript project so that I can send it as a finished project?
I've tried googling for results, which wasn't helpful.
I also found a few youtube videos. They didn't have much of what I wanted.
I have a friend who doesn't have javascript and I want to send him over my finished project. Either as a file or an application, but I'd like it to be sent over so he can see it without the use of javascript and seeing the code.
If they have a browser they have JavaScript. Package up your code as an HTML file that loads the JavaScript.
If this is a Node application then you may need to look at packaging it up differently. Installing Node isn't difficult, and it's available for pretty much anything that can compute.
For a more ambitious packaging you can use something like Electron to make a distributable application. This is a larger investment of time, but it's the easiest for the user to use.
Hey so i started using Electron becouse of HTML/CSS/JS possibilites.
I have expirience mostly with PHP and some little with JS.
Was searching how to hide files of Electron (becouse .asar file can be unpacked) and its just stupid to put my MySQL server info in .js file and let users see that info..
Is there any way to hide atleast 1 .js file where i would put all necessery stuff like mysql connection and mysql managing?
I googled a lot about that some people say that Node.JS can to that but i cant find anywhere how to exacly do it?
Tried to switch to CEFSharp but cant realise how to interact between C# and Webpage (used webserver for template and php stuff but like how to tell C# that variable of A is A and use that C# variable for something)..
Hope somebody will help me, maybe its dumb question for some expirienced developers but i mostly work in PHP and i wanna learn new stuff..
Thanks!
Long story in short - no. In deep down, any code you ship in client to users should be considered to be revealed, just matter of how hard will it be. Instead of shipping important credential and obfuscate to not able to read it, application should be designed to be safe even if user reads whole code in client.
I'm not really any sort of expert on Electron. I'll assume that you will either create a login or a config file. In the first case you can use the database to determine if access is allowed. If you don't want to setup a login script then you can use a config.json file that is not part of the build file. There are a few node packages you can use - I believe one is "electron-storage" to help with the access to the database. Hope this helps.
Johnf
I have written a script in PHP that connects to my FTP server and downloads the latest backup of all the websites I have created.
I have written this script in PHP (using ftp_get and all those lovely functions!), but I have also created a nice looking dashboard in HTML, which uses AJAX to not only execute the PHP code but to output all the "echo"'s into a textarea so I know which ones were successfully downloaded and which ones failed.
My problem is that I am not the only employee, there are quite a few of us who could execute this script, so on the dashboard I want there to be a way of choosing where these backsup are saved without having to edit a hardcoded destination in the PHP. At the moment, it's hardcoded to save to my desktop, but if someone else were to use it on their computer, it won't work.
I have tried searching for this, but no one has asked exactly the question I needed answering.
If the answers could be using HTML, JavaScript/jQuery or PHP, that would be handy.
Thank you in advance.
------------EDIT------------
Not sure people are understanding my problem, so I will try and explain it differently :)
I have a backup tool that will connect to an FTP server, go through each project folder and download the latest backup of that site. In total, there are at least 20 files to be downloaded.
Multiple people will be using this tool, depending who is around to backup the files.
Bob might want to save it directly to his desktop: C:/Users/Bob/Desktop.
Barbara might want to save it in C:/Users/Barbara/Backup Folder/2017/
Jimmy wants to save it in C:/Users/Jimmy/Projects/Project_name/Backup-01-01-2017
And I might want to save it onto an external HDD.
I want the tool to have a function that will allow the user to specify a location on their HDD where these files will all be saved.
I hope this is clearer.
Many thanks.
Recently I have been trying to create a chat project which makes a ringing noise once you receive a message. My problem is that I cannot find a ringing noise that will be available for the project anywhere. Google drive does not work, the javascript can't process it. For some reason if I link sound from wikipedia it does work. Is there a way to upload a ringing sound which will be available to link to through javascript?
Thanks!
P.S. I'm sorry about how long this question is, congratulations if you read it & managed to understand what I'm saying :)
It creates a bit of overhead but you can use something like this to have an easy access to your audio:
http://www.createjs.com/soundjs
In a theoretical sense you would have your assets (be it soundfiles or images or what ever) loaded to the webserver you serve your page from. Normaly you will have an assets folder on there. You can then access these files by using the path to that folder on your server in your code.
HTML5 should provide functions for sound playback and such as well. Might as well start there