Peter Justin 7 years ago
parent
commit
030efb9247
5 changed files with 65 additions and 39 deletions
  1. 1 10
      flaskbb/app.py
  2. 2 2
      flaskbb/cli/main.py
  3. 2 0
      flaskbb/plugins/models.py
  4. 60 26
      flaskbb/plugins/spec.py
  5. 0 1
      flaskbb/utils/translations.py

+ 1 - 10
flaskbb/app.py

@@ -411,13 +411,4 @@ def load_plugins(app):
         removed = 0
         if app.config["REMOVE_DEAD_PLUGINS"]:
             removed = remove_zombie_plugins_from_db()
-
-    app.logger.debug(
-        "Plugins Found: {}".format(app.pluggy.list_name_plugin())
-    )
-    app.logger.debug(
-        "Disabled Plugins: {}".format(app.pluggy.list_disabled_plugins())
-    )
-    app.logger.debug(
-        "Removed Plugins: {}".format(removed)
-    )
+            app.logger.info("Removed Plugins: {}".format(removed))

+ 2 - 2
flaskbb/cli/main.py

@@ -38,7 +38,6 @@ from flaskbb.utils.populate import (create_test_data, create_welcome_forum,
 from flaskbb.utils.translations import compile_translations
 
 
-
 class FlaskBBGroup(FlaskGroup):
     def __init__(self, *args, **kwargs):
         super(FlaskBBGroup, self).__init__(*args, **kwargs)
@@ -53,7 +52,8 @@ class FlaskBBGroup(FlaskGroup):
             app.pluggy.hook.flaskbb_cli(cli=self, app=app)
             self._loaded_flaskbb_plugins = True
         except Exception as exc:
-            click.echo(click.style("Error while loading CLI Plugins", fg='red'))
+            click.echo(click.style("Error while loading CLI Plugins",
+                                   fg='red'))
             click.echo(click.style(traceback.format_exc(), fg='red'))
 
     def get_command(self, ctx, name):

+ 2 - 0
flaskbb/plugins/models.py

@@ -57,10 +57,12 @@ class PluginRegistry(CRUDMixin, db.Model):
 
     @property
     def settings(self):
+        """Returns a dict with contains all the settings in a plugin."""
         return {kv.key: kv.value for kv in itervalues(self.values)}
 
     @property
     def info(self):
+        """Returns some information about the plugin."""
         return current_app.pluggy.list_plugin_metadata().get(self.name, {})
 
     @property

+ 60 - 26
flaskbb/plugins/spec.py

@@ -14,70 +14,104 @@ from pluggy import HookspecMarker
 spec = HookspecMarker('flaskbb')
 
 
+# Setup Hooks
+
 @spec
 def flaskbb_extensions(app):
-    """
-    Hook for initializing any plugin loaded extensions
-    """
+    """Hook for initializing any plugin loaded extensions."""
 
 
 @spec
 def flaskbb_load_translations():
-    """
-    Hook for registering translation folders.
-    """
+    """Hook for registering translation folders."""
 
 
 @spec
 def flaskbb_load_migrations():
-    """
-    Hook for registering additional migrations
-    """
+    """Hook for registering additional migrations."""
 
 
 @spec
 def flaskbb_load_blueprints(app):
-    """
-    Hook for registering blueprints
-    """
+    """Hook for registering blueprints."""
 
 
 @spec
 def flaskbb_request_processors(app):
-    """
-    Hook for registering pre/post request processors
-    """
+    """Hook for registering pre/post request processors."""
 
 
 @spec
 def flaskbb_errorhandlers(app):
-    """
-    Hook for registering error handlers
-    """
+    """Hook for registering error handlers."""
 
 
 @spec
 def flaskbb_jinja_directives(app):
+    """Hook for registering jinja filters, context processors, etc."""
+
+
+@spec
+def flaskbb_additional_setup(app, pluggy):
+    """Hook for any additional setup a plugin wants to do after all other
+    application setup has finished.
     """
-    Hook for registering jinja filters, context processors, etc
+
+
+@spec
+def flaskbb_cli(cli):
+    """Hook for registering CLI commands."""
+
+
+# Template Hooks
+
+@spec
+def flaskbb_tpl_before_navigation():
+    """Hook for registering additional navigation items.
+
+    in :file:`templates/layout.html`.
     """
 
 
 @spec
-def flaskbb_additional_setup(app, pluggy):
+def flaskbb_tpl_after_navigation():
+    """Hook for registering additional navigation items.
+
+    in :file:`templates/layout.html`.
     """
-    Hook for any additional setup a plugin wants to do after all other application
-    setup has finished
+
+
+@spec
+def flaskbb_tpl_before_registration_form():
+    """This hook is emitted in the Registration form **before** the first
+    input field but after the hidden CSRF token field.
+
+    in :file:`templates/auth/register.html`.
     """
 
 
 @spec
-def flaskbb_cli(cli):
+def flaskbb_tpl_after_registration_form():
+    """This hook is emitted in the Registration form **after** the last
+    input field but before the submit field.
+
+    in :file:`templates/auth/register.html`.
     """
-    Hook for registering CLI commands
+
+
+@spec
+def flaskbb_tpl_before_update_user_details():
+    """This event is emitted in the Change User Details form **before** an
+    input field is rendered.
+
+    in :file:`templates/user/change_user_details.html`.
     """
 
 
 @spec
-def flaskbb_tpl_before_navigation():
-    """Hook for registering additional navigation items."""
+def flaskbb_tpl_after_update_user_details():
+    """This hook is emitted in the Change User Details form **after** the last
+    input field has been rendered but before the submit field.
+
+    in :file:`templates/user/change_user_details.html`.
+    """

+ 0 - 1
flaskbb/utils/translations.py

@@ -26,7 +26,6 @@ class FlaskBBDomain(Domain):
         with self.app.app_context():
             self.plugin_translations = \
                 self.app.pluggy.hook.flaskbb_load_translations()
-            print(self.plugin_translations)
 
     def get_translations(self):
         """Returns the correct gettext translations that should be used for