FriendsOfFlarum / upload

The file upload extension with insane intelligence for your Flarum forum.
https://discuss.flarum.org/d/4154
MIT License
177 stars 96 forks source link

Interfaces for templates. Allow non-bbcode templates. Add URL template #226

Closed clarkwinkelmann closed 4 years ago

clarkwinkelmann commented 4 years ago

Fixes #187

Our current implementation isn't really friendly with custom templates that don't rely on bbcode. You could register a fake bbcode that you're not actually using but it's not super pretty or obvious.

This PR introduces interfaces for custom templates, with a separate interface if you want Upload to register the bbcode.

The PR also adds a new "just-url" template which... just inserts the URL. That way the extension can be used with AutoImage, AutoVideo and probably other extensions out of the box without the need to write that super simple template.

Backward compatibility questions:

This was almost a backward-compatible change but unfortunately the use of the separate interface that AbstractTemplate doesn't implement means custom templates would lose their bbcode. We could work around that by keeping AbstractTemplate explicitly for backward support and make it implement both interfaces.

The use of the string return type on the interfaces is also a breaking change we could easily solve if we don't want it.

Do we know of anyone running custom templates on their forum? I'm thinking it's best to release this as a developer breaking change as very few forums probably use the features and it's a more future-proof syntax.