index.rst 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. .. _plugins:
  2. Plugins
  3. =======
  4. .. module:: flaskbb.plugins
  5. FlaskBB provides a full featured plugin system. This system allows you to
  6. easily extend or modify FlaskBB without touching any FlaskBB code. Under the
  7. hood it uses the `pluggy plugin system`_ which does most of the heavy lifting
  8. for us. A list of available plugins can be found at the `GitHub Wiki`_. A
  9. proper index for FlaskBB Plugins and Themes still have to be built.
  10. If you are interested in creating new plugins, checkout out the
  11. :ref:`Developing new Plugins <plugin_development>` page.
  12. .. _`pluggy plugin system`: https://pluggy.readthedocs.io/en/latest/
  13. .. _`GitHub Wiki`: https://github.com/sh4nks/flaskbb/wiki
  14. Management
  15. ----------
  16. Before plugins can be used in FlaskBB, they have to be downloaded, installed
  17. and activated.
  18. Plugins can be very minimalistic with nothing to install at all (just enabling
  19. and disabling) to be very complex where you have to `run migrations <./plugins.html#database>`_ and add
  20. some `additional settings <./plugins.html#install>`_.
  21. Download
  22. ~~~~~~~~
  23. Downloading a Plugin is as easy as::
  24. $ pip install flaskbb-plugin-MYPLUGIN
  25. if the plugin has been uploaded to PyPI. If you haven't uploaded your plugin
  26. to PyPI or are in the middle of developing one, you can just::
  27. $ pip install -e .
  28. in your plugin's package directory to install it.
  29. Remove
  30. ~~~~~~
  31. Removing a plugin is a little bit more tricky. By default, FlaskBB does not
  32. remove the settings of a plugin by itself because this could lead to some
  33. unwanted dataloss.
  34. `Disable`_ and `Uninstall`_ the plugin first before continuing.
  35. After taking care of this and you are confident that you won't need the
  36. plugin anymore you can finally remove it::
  37. $ pip uninstall flaskbb-plugin-MYPLUGIN
  38. There is a setting in FlaskBB which lets you control the deletion of settings
  39. of a plugin. If ``REMOVE_DEAD_PLUGINS`` is set to ``True``, all not available
  40. plugins (not available on the filesystem) are constantly removed. Only change
  41. this if you know what you are doing.
  42. Install
  43. ~~~~~~~
  44. In our context, by installing a plugin, we mean, to install the settings
  45. and apply the migrations. Personal Note: I can't think of a better name and
  46. I am open for suggestions.
  47. The plugin can be installed via the Admin Panel (in tab 'Plugins') or by
  48. running::
  49. flaskbb plugins install <plugin_name>
  50. Make sure to to apply the migrations of the plugin as well (**if any**, check the plugins docs)::
  51. flaskbb db upgrade <plugin_name>@head
  52. Uninstall
  53. ~~~~~~~~~
  54. Removing a plugin involves two steps. The first one is to check if the plugin
  55. has applied any migrations on FlaskBB and if so you can
  56. undo them via::
  57. $ flaskbb db downgrade <plugin_name>@base
  58. The second step is to wipe the settings from FlaskBB which can be done in the
  59. Admin Panel or by running::
  60. $ flaskbb plugins uninstall <plugin_name>
  61. Disable
  62. ~~~~~~~
  63. Disabling a plugin has the benefit of keeping all the data of the plugin but
  64. not using the functionality it provides. A plugin can either be deactivated
  65. via the Admin Panel or by running::
  66. flaskbb plugins disable <plugin_name>
  67. .. important:: Restart the server.
  68. You must restart the wsgi/in-built server in order to make the changes
  69. effect your forum.
  70. Enable
  71. ~~~~~~
  72. All plugins are activated by default. To activate a deactivated plugin you
  73. either have to activate it via the Admin Panel again or by running the
  74. activation command::
  75. flaskbb plugins enable <plugin_name>
  76. Database
  77. --------
  78. Upgrading, downgrading and generating database revisions is all handled
  79. via alembic. We make use of alembic's branching feature to manage seperate
  80. migrations for the plugins. Each plugin will have it's own branch in alembic
  81. where migrations can be managed. Following commands are used for generaring,
  82. upgrading and downgrading your plugins database migrations:
  83. * (Auto-)Generating revisions
  84. ``flaskbb db revision --branch <plugin_name> "<YOUR_MESSAGE>"``
  85. Replace <YOUR_MESSAGE> with something like "initial migration" if it's
  86. the first migration or with just a few words that will describe the
  87. changes of the revision.
  88. * Applying revisions
  89. ``flaskbb db upgrade <plugin_name>@head``
  90. If you want to upgrade to specific revision, replace ``head`` with the
  91. revision id.
  92. * Downgrading revisions
  93. ``flaskbb db downgrade <plugin_name>@-1``
  94. If you just want to revert the latest revision, just use ``-1``.
  95. To downgrade all database migrations, use ``base``.