Custom file templates
By default, when you right-click in file explorer, then click new, you only have folder, but for files you have text file, HTML file and JPEG image (i suppose this one is here for... drawing ?).
It should be like on Linux, where the home directory contains a Templates folder, and any file you put in it will show up in the new file menu. This would allow to easily create other files, like JS files, or any ! And because its templates, you could put thing inside a template file, like the default "bug report" thing on this GitHub, and just create a filled file from a right-click !
AND, apps could even set a custom adanced templates, that opens the app and starts it in the folder you were, with a new file with the name you chosen ! This would be perfect for files that are not readable by an human (like the JPEG image), and could instead open it with the appropriate app to allow editing !
This is a good idea. It's also good for a start issue.
I would like to work on this issue @jelveh.
Great! Assigned π
Let me know if you need help with anything.
Well indeed I would need some guidance to get the project up and running on my machine.
Could you give this a try and let me know if it doesn't work? https://github.com/HeyPuter/puter?tab=readme-ov-file#-local-development
@jelveh I am able to run npm install and have all the packages but when I enter the command npm start The console does this:
[INFO::__dev-watcher] (10.578s) [puter.js:webpack-watch:out]
[INFO::__dev-watcher] (10.579s) [puter.js:webpack-watch:out] webpack 5.93.0 compiled with 1 warning in 2150 ms
[TICK::server-health] (10.872s) service checks
[TICK::server-health] (30.884s) service checks
[TICK::app-info] (31.389s) refresh app cache
[TICK::refresh_apps_cache] (46.417s) refresh associations cache
[TICK::server-health] (50.898s) service checks
...
[TICK::server-health] (291.089s) service checks
And keeps going for ever without starting the project
Are you using Windows? We're having some issues with Windows as non of the maintainers use Windows. I'd like to solve this though, let me loop in @KernelDeimos
Yes i am indeed using windows. Well let me know if I can be of any help solving this too.
If you find the issue/solution before we do please submit a PR. We're going to be discussing this issue more here as well βοΈ
@Koppeks
And keeps going for ever without starting the project
The repetition of "service checks" and cache message is typical of a post-boot state. Try https://localhost:4100 - is it working? If not, check for alarms, which are sticky at the bottom of the console output.
Edit: If you can post a screenshot of the backend console that might help
@KernelDeimos
After the command npm start this is the sequence I get
This [INFO::__dev-watcher] throws some of the first errors
More [INFO::__dev-watcher] errors
The project runs, but the https://localhost:4100 just prints a white screen and the api request all return 304 on the first get /? and 404 on the rest of the requests.
This is the screenshot of the sticky dev console
No alarms to be seen
Thanks for the screenshots! We're working on a fix right now. Should have a patch very soon βοΈ
The [INFO::__dev-watcher] logs are known to be a bit misleading right now. When the log is prefixed "err" it really means "came from the stderr stream". I plan to fix this.
Most of the issues so far are because we get C:\'s everywhere because node:path is "helping" (i.e. we're using it wrong in several places).
I think I fixed everything with this commit (had to commit on nj's spare laptop, it's the only Windows we have here)
@Koppeks see if it runs properly now. Also, let me know if you end up with a directory called C:\var\puter (ideally you won't but /var/puter kind of just keeps happening)
Amazing @KernelDeimos now it works like a charm! Now Puter for developers is up and running for windows too.
And yes there are multiple files been created at C:\var\puter
Good to know. If you set the environment variable NO_VAR_RUNTIME=1 Puter will use the database in volatile/runtime of the puter repository. Otherwise it will use C:\var\puter (or /var/puter on other OSes). I currently have no idea how or why the var alternative gets created automatically - I didn't actually write any code to have it do that... so it's quite a mystery. It's meant to be for production installations and Docker instances.
Feel free to report back about anything that's under-documented btw. I also plan to start recording more videos soon so that would also help me come up with good topics to cover.
Feel free to report back about anything that's under-documented btw.
Will do, I will start with the issue now.
I have started the issue yesterday and encounter some problems.
I have found that I need to use puter.fs.readdir() to manage folder and files, and all are async functions. In my case I should use the puter.fs.readdir() to search the template file of the user, but the UIContextMenu() and new_context_menu_item.js are not asynchronous functions.
Should I change the behavior of the functions to handle async await? Or there are other ways to search for directories I didn't see?
Sorry if this is a beginner question guys :smiling_face_with_tear:
Valid question. Here's one way to do it: every time the desktop is loaded you use puter.fs.readdir() to list template files and you put them in a global variable called window.file_templates and when the context menu is loaded you populate the New submenu with the values inside window.file_templates.
window.file_templates need to also be updated every time there is a change made to the templates directory's contents. For example, when a new file is added there or a file has been edited. But you could start with the previous paragraph and work your way to the more advanced stuff such as this paragraph.
Let me know if this helps.
The feature now its almost done, on service start I save all the custom template files and then on new_context_menu_item show them to the user.
I have encounter the following issues:
Dev Console warning alert
Also I cannot save any file at any place GrabaciΓ³n de pantalla desde 2024-07-19 18-16-55.webm
And just in case I am on Ubuntu 24.04 lts now, I know you guys fix windows for me to work on this issue, but I wanted to try Ubuntu :laughing: I don't know if the issues are related to Ubuntu now.
This is coming along nicely! I'm going to look into the dev console warning in a bit but as for saving the file, could you get a screenshot of your browser's dev console output? I suspect there should be an error printed there.
This is my browser's dev console after clicking the save button on the text editor
Uncaught in promise was the output after clicking save file on the text editor
Interesting, I need to see the code. Could you open a PR with your changes/branch?
@jelveh Its done let me know If I did something wrong or if I can help you with anything
Hey @Koppeks I saw that you closed the PR. Let me know if you need help with anything. I think that PR was pretty much ready to be merged π₯
I though the feature had to have more things π
. I feel like its missing a watcher when the files are added or deleted from the folder templates and the guy that send the idea sait the templates that had content should be used in the new created files from said template.
Also, I am taking extra long because I move back to windows π© , its all setup now
closed via #627 π