jamesvandyne/tanzawa

Plugin Support

Closed this issue ยท 5 comments

Add support for plugins. Plugins should be able to eventually allow you to modify the public and admin site (of their own pages) and the pubic facing pages. They should be able to store data (run migrations) from settings pages. They should be able to enabled / disabled via the admin pages.

In order to achieve this, Tanzawa should autodiscover plugins.py modules using from django.utils.module_loading import autodiscover_modules

The autodisocvered modules can then be listed in a page in the admin with a button to activate / deactivate.

Activation should add the application to installed apps and run migrations like below.

from collections import OrderedDict
from django.apps import apps
from django.conf import settings
from django.core import management

new_app_name = "my_new_app"

settings.INSTALLED_APPS += (new_app_name, )
apps.app_configs = OrderedDict()
apps.apps_ready = apps.models_ready = apps.loading = apps.ready = False
apps.clear_cache()
apps.populate(settings.INSTALLED_APPS)

management.call_command('makemigrations', new_app_name, interactive=False)

management.call_command('migrate', new_app_name, interactive=False)

source

The general flow should be:

  • django starts up
  • plugins app autodiscovers plugins and compares them against activated plugins
  • activated plugins will be added to installed apps / urls.py
  • migrations should only be run on activation or when activated and the system as a whole is running migrations
rmdes commented

Is there any core features that should instead be a plugin and activated on case by case basis ?

what would be an example of a tanzawa plugin ?

Syndication to Twitter/mastodon comes to mind

Syndication via Twitter/mastodon would be a great example of something that might work better as a plugin and is kind of a core feature.

Example plugins I'm thinking about are: A "now" page or a blogroll, or custom views for bookmarks?. More niche, something that could maybe import my activity from Strava, a plugin to provide a custom endpoint for me to post my electric usage to.

rmdes commented

Would be indeed great to be able to plug-in different data sources (Strava or even more self-hosted approach using open source tracking apps)

Custom endpoint for different usage is also neat!

Custom views : I'm thinking more for Photos, What if we could have a All Photo's views, aggregating all the content type photos ? That would be really neat!

Yes - I think custom photo views could be handled by a plugin. You could also group by exif data and such as well (as we do store it in the db as a python blob).

With the merge of #119, I've added support for plugins. Closing this issue.