From 94408fd2dd3407666ba5c8f279eb4dcf6e75b2a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 23 Jan 2023 16:47:26 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Fix=20outdated=20jinja=20&=20fla?= =?UTF-8?q?sk=20doc=20links?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #4655 --- THIRDPARTYLICENSES.md | 2 +- docs/plugins/gettingstarted.rst | 11 +++-------- src/octoprint/plugin/types.py | 22 +++++++++++----------- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/THIRDPARTYLICENSES.md b/THIRDPARTYLICENSES.md index 4074c7de3..0222b3f5c 100644 --- a/THIRDPARTYLICENSES.md +++ b/THIRDPARTYLICENSES.md @@ -44,7 +44,7 @@ * [emoji](https://github.com/carpedm20/emoji/): BSD * [feedparser](https://github.com/kurtmckee/feedparser): BSD * [filetype](https://h2non.github.io/filetype.py/): MIT - * [Flask](http://flask.pocoo.org/): BSD + * [Flask](https://flask.palletsprojects.com/): BSD * [Flask-Assets](http://github.com/miracle2k/flask-assets): BSD * [Flask-Babel](http://github.com/mitsuhiko/flask-babel): BSD * [Flask-Login](https://github.com/maxcountryman/flask-login): MIT diff --git a/docs/plugins/gettingstarted.rst b/docs/plugins/gettingstarted.rst index e0c635965..d36deb99f 100644 --- a/docs/plugins/gettingstarted.rst +++ b/docs/plugins/gettingstarted.rst @@ -473,7 +473,7 @@ Also adjust your plugin's ``templates/helloworld_navbar.jinja2`` like this: OctoPrint injects the template variables that your plugin defines prefixed with ``plugin__`` into the template renderer, so your ``url`` got turned into ``plugin_helloworld_url`` which you can now use as a simple -`Jinja2 Variable `_ in your plugin's template. +`Jinja2 Variable `_ in your plugin's template. Restart OctoPrint and shift-reload the page in your browser (to make sure you really get a fresh copy). The link should still work and point to the URL we defined as default. @@ -1041,10 +1041,9 @@ might show what's possible with a few lines of code already. Finally, just take .. seealso:: - `Jinja Template Designer Documentation `_ + `Jinja Template Designer Documentation `_ Jinja's Template Designer Documentation describes the syntax and semantics of the template language used - by OctoPrint's frontend. Linked here are the docs for Jinja 2.8.1, which OctoPrint still - relies on for backwards compatibility reasons [#f3]_. + by OctoPrint's frontend. .. rubric:: Footnotes @@ -1057,7 +1056,3 @@ might show what's possible with a few lines of code already. Finally, just take .. [#f2] Refer to the `LESS documentation `_ on how to do that. If you are developing your plugin under Windows you might also want to give `WinLESS `_ a look which will run in the background and keep your CSS files up to date with your various project's LESS files automatically. -.. [#f3] Please always consult the Jinja documentation at `jinja.octoprint.org `_ instead of - the current stable documentation available at Jinja's project page. The reason for that is that for backwards - compatibility reasons OctoPrint currently sadly has to rely on an older version of Jinja. The documentation - available at `jinja.octoprint.org `_ matches that older version. diff --git a/src/octoprint/plugin/types.py b/src/octoprint/plugin/types.py index 80d412f87..f98be4141 100644 --- a/src/octoprint/plugin/types.py +++ b/src/octoprint/plugin/types.py @@ -600,7 +600,7 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin): OctoPrint will query whether your mixin implementation will handle a provided request by calling :meth:`~octoprint.plugin.UiPlugin.will_handle_ui` with the Flask - `Request `_ object as + `Request `_ object as parameter. If you plugin returns `True` here, OctoPrint will next call :meth:`~octoprint.plugin.UiPlugin.on_ui_render` with a few parameters like - again - the Flask Request object and the render keyword arguments as @@ -676,7 +676,7 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin): ``UiPlugin.will_handle_ui``. Arguments: - request (flask.Request): A Flask `Request `_ + request (flask.Request): A Flask `Request `_ object. Returns: @@ -761,12 +761,12 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin): now (datetime.datetime): The datetime instance representing "now" for this request, in case your plugin implementation needs this information. - request (flask.Request): A Flask `Request `_ object. + request (flask.Request): A Flask `Request `_ object. render_kwargs (dict): The (cached) render keyword arguments that would usually be provided to the core UI render function. Returns: - flask.Response: Should return a Flask `Response `_ + flask.Response: Should return a Flask `Response `_ object that can be served to the requesting client directly. May be created with ``flask.make_response`` combined with something like ``flask.render_template``. @@ -1173,7 +1173,7 @@ class SimpleApiPlugin(OctoPrintPlugin): """ Utilizing the ``SimpleApiPlugin`` mixin plugins may implement a simple API based around one GET resource and one resource accepting JSON commands POSTed to it. This is the easy alternative for plugin's which don't need the - full power of a `Flask Blueprint `_ that the :class:`BlueprintPlugin` + full power of a `Flask Blueprint `_ that the :class:`BlueprintPlugin` mixin offers. Use this mixin if all you need to do is return some kind of dynamic data to your plugin from the backend @@ -1298,7 +1298,7 @@ class SimpleApiPlugin(OctoPrintPlugin): def on_api_get(self, request): """ Called by OctoPrint upon a GET request to ``/api/plugin/``. ``request`` will contain the - received `Flask request object `_ which you may evaluate + received `Flask request object `_ which you may evaluate for additional arguments supplied with the request. If your plugin returns nothing here, OctoPrint will return an empty response with return code ``204 No content`` @@ -1317,7 +1317,7 @@ class BlueprintPlugin(OctoPrintPlugin, RestartNeedingPlugin): The ``BlueprintPlugin`` mixin allows plugins to define their own full fledged endpoints for whatever purpose, be it a more sophisticated API than what is possible via the :class:`SimpleApiPlugin` or a custom web frontend. - The mechanism at work here is `Flask's `_ own `Blueprint mechanism `_. + The mechanism at work here is `Flask's `_ own `Blueprint mechanism `_. The mixin automatically creates a blueprint for you that will be registered under ``/plugin//``. All you need to do is decorate all of your view functions with the :func:`route` decorator, @@ -1389,8 +1389,8 @@ class BlueprintPlugin(OctoPrintPlugin, RestartNeedingPlugin): A decorator to mark view methods in your BlueprintPlugin subclass. Works just the same as Flask's own ``route`` decorator available on blueprints. - See `the documentation for flask.Blueprint.route `_ - and `the documentation for flask.Flask.route `_ for more + See `the documentation for flask.Blueprint.route `_ + and `the documentation for flask.Flask.route `_ for more information. """ @@ -1413,8 +1413,8 @@ class BlueprintPlugin(OctoPrintPlugin, RestartNeedingPlugin): A decorator to mark errorhandlings methods in your BlueprintPlugin subclass. Works just the same as Flask's own ``errorhandler`` decorator available on blueprints. - See `the documentation for flask.Blueprint.errorhandler `_ - and `the documentation for flask.Flask.errorhandler `_ for more + See `the documentation for flask.Blueprint.errorhandler `_ + and `the documentation for flask.Flask.errorhandler `_ for more information. .. versionadded:: 1.3.0