regebro / hovercraft

Make dynamic impressive presentations from text files!
https://hovercraft.readthedocs.org
MIT License
1.49k stars 208 forks source link

Local directives #144

Closed vorpalvorpal closed 7 years ago

vorpalvorpal commented 7 years ago

I have created a simple plugin system which allows the creation of local reST directives without having to edit anything in docutils. I have created an audio and video directive as well as improved the image directive. I am in the process of creating a mutationObserver directive and am thinking about the design of one to work with d3.js/vega.

As well as these general purpose ones, I think local directives will be useful for individuals who have something specific to their presentation that they need to do repeatedly (like put some particular effect over an image or text...)

Documentation of how to make a directive is in local_directives.README.rst. Documentation of media directives is in local_directives/media/README.rst

regebro commented 7 years ago

You have inadvertently added a lot of files to the git repo that shouldn't be there, which makes it hard to review. Fix that and I'll look at it. An audio and video command would definitely be cool, but I'm not sure we need a plugin system to do that, but if it isn't too complex I guess it's fine.

vorpalvorpal commented 7 years ago

No worries. I'll put together a new pull request that is just for the media directives without the plugin stuff (and maybe even without a whole heap of merge files this time... Sorry.). I'll probably have time to do it next week some time.

The reason I wanted some plugin architecture is that to do the media directives as part of hovercraft's core i needed to edit hovercraft's xsl, js and css. That's fine for core functionality like video/audio, but I also have other extensions to reST that would probably be useful to other people that I would like to share, but which doesn't make sense as part of hovercraft's core. And even for new directives that are really specific to my own presentations and so don't make sense to be shared, if they aren't implemented as plug-ins I have to re-edit hovercrafts css, js and xsl each time hovercraft is updated.

Anyway, I'll do some research into how plug-ins can be implemented as python modules and see if I can figure something out. I'm not sure that it needs to be for anything other than reST directives, however. Impress.js is currently in the process of implementing a plug-in architecture and when they finish that, changes to how the presentation itself runs should presumably be addressed through that. Otherwise it might become unclear weather a change should be implemented as a impress.js plug-in or a hovercraft plug-in. It might even make sense for things like the newly implemented header/footer or even the presentation console to be pushed upstream as plugins depending on what impress.js comes up with...

Another aim I had with putting local directives in self-contained folders was allowing simple re-use with minimal modification by other projects. While I was banging my head against the table trying to figure out how on earth to write custom directives, I found quite a few people who wanted to do the same thing. I thought that having all the moving parts in a single folder would make it easier for people outside of hovercraft to figure out what is going on without having to figure out what hovercraft is doing.

vorpalvorpal commented 7 years ago

Just to check I am on the right track, am I right in thinking that (assuming you are sold on the idea of plugins at all...) you would like them to be actively loaded by the user. Something along the lines of "pip3 install \n hovercraft --add-plugin "

regebro commented 7 years ago

Yeah, I think that would be best. Perhaps a configuration option in the presentation?