thmsbfft / oryoki

Ōryōki [応量器] is an experimental web browser with a thin interface.
http://oryoki.io/
MIT License
484 stars 32 forks source link

Add a simple dotjs plugin system #6

Closed koddsson closed 8 years ago

koddsson commented 8 years ago

Hey hey 👋 I've no idea if you're accepting PRs to this project but I just saw it on HN and really like it.

Ever since the dotjs project got abandoned I've been looking for something similar. It works like dis:

Whenever a webpage is loaded we look for a file in ~/.js/<hostname>.js and if we find one we read it's contents and execute the javascript we find there on the page we just loaded.

I think the quote on the original dotjs project describes the functionality pretty well.

"I almost wish you could just stick JavaScript in ~/.js. Do you know what I'm saying?"

thmsbfft commented 8 years ago

Hey! 👋 I need to organize things a bit in the project first so I can accept PRs. Webpages plugins are on the todo list though so that'll come soon – super happy learning about dotjs :)

Since the implementation might be a little different I'd suggest to maybe store the plugins in Application Support/Oryoki? Possibly also adding a menu toggle to turn everything on/off.

koddsson commented 8 years ago

I need to organize things a bit in the project first so I can accept PRs.

Awesome! I'm in no rush to merge this since I can just use my current fork for now. If you need a hand you could label some issues and I might be able to pick some up when I have some spare time.

Since the implementation might be a little different I'd suggest to maybe store the plugins in Application Support/Oryoki?

I added a preference for plugin folder path in 6635d24 since I really like having my plugins at .js/ but it defaults to Application Support/Oryoki :grinning:

Possibly also adding a menu toggle to turn everything on/off.

I didn't do this yet but I probably will soon.

koddsson commented 8 years ago

Possibly also adding a menu toggle to turn everything on/off.

Ok I added this in a81bef4 but it's not persistant between reboots (just like show_title) but there's a preference property now that you can set so that it starts with plugins either enabled or disabled (just like show_title).

thmsbfft commented 8 years ago

Just checked out your branch. Trying to wrap my head around it. Node paths are a little tricky I guess, so just using ~/Library/Application Support/Oryoki/plugins doesn't work for me 😢

Q: why use ~/.js/ over Application Support? Easier to access from a terminal?

thmsbfft commented 8 years ago

Hey there – branched off dev to implement the dotjs-like plugin system (5fc5edd). I think your PR came in a little early, but the project is ready-ish now. I'll branch off dev for every feature and merge back up to master for releases.

Basically your code, with a few tweaks: A – if the path defined in preferences isn't set we look for plugins in Application Support/Web Plugins. I need to rewrite a bit the preference file so it accepts comments to explain that. B – we reload the page when toggling the web plugins. I also added Tools > Browse Web Plugins....

I'm looking at adding a couple default plugins now. What are some useful ones? Thinking of one that adds a way of playing youtube etc. in full window, so you can have video players floating on top of everything else.

✌️

thmsbfft commented 8 years ago

Hey! Web plugins are implemented in /dev as of 5645bc2 💥

Note: custom paths have to be absolute, so ~/.js would be /Users/YourUserName/.js

Looks okay to me, but let me know if you end up using it and find anything :)

I included hot-reloading the preference file so you can change the directory without relaunching the app. The menu toggle also reloads the current view when turning the plugins on/off. Plugins can be activated independently on each window.

koddsson commented 8 years ago

Hey! Web plugins are implemented in /dev as of 5645bc2 💥

✨✨✨ AWESOME ✨✨✨

Sorry for not being responsive about this PR but real life got in the way 😄