The mechanism at work here is Flask’s own Blueprint mechanism. The BlueprintPlugin mixin allows plugins to define their own full fledged endpoints for whatever purpose,īe it a more sophisticated API than what is possible via the SimpleApiPlugin or a custom web frontend. Plugin identifier being the plugin’s identifier and path being the path as defined in the asset dictionary.Īssets of the types js, css and less will be automatically bundled by OctoPrint usingĪ dictionary describing the static assets to publish for the plugin BlueprintPlugin class ugin. The assets will be made available by OctoPrint under the URL /plugin//static/, with Type, the files being represented as relative paths from the asset folder as defined via get_asset_folder().ĭef get_assets ( self ): return dict ( js =, clientjs =, css =, less = ) The expected format to be returned is a dictionary mapping one or more of these keys to a list of files of that LESS files with additional styles, will be embedded into delivered pages when running in LESS mode. JavaScript files containing additional parts for the JS Client Library (since 1.3.10) cssĬSS files with additional styles, will be embedded into delivered pages when not running in LESS mode. JavaScript files, such as additional view models jsclient Imported at the appropriate places to be available: js The following asset types are recognized and automatically The absolute path to the folder where the plugin stores its static assets get_assets ( ) ĭefines the static assets the plugin offers. Your plugin stores its assets at some other place than the static sub folder in the plugin base directory. get_asset_folder ( ) ĭefines the folder where the plugin stores its static assets as defined in get_assets(). The AssetPlugin mixin allows plugins to define additional static assets such as JavaScript or CSS files toīe automatically embedded into the pages delivered by the server to be used within the client sided part ofĪ typical usage of the AssetPlugin functionality is to embed a custom view model to be used by templates injectedĪssetPlugin is a RestartNeedingPlugin. OctoPrintPlugin, which also provide attributes of interest to plugin developers. Please note that all plugin mixins inherit from Plugin and This will result in the following messages to be generated: On_after_startup method will be ordered first by bundle status, then by plugin identifier: plugin_d, plugin_a, plugin_b, plugin_c. StartupPlugin.on_after_startup for which all of the plugins return None. Now, the execution order of the on_after_startup method will be determined based on another sorting context, The execution order of the on_startup method will hence be plugin_b, plugin_c, plugin_d, plugin_a. Put after the other two, with plugin_d coming before plugin_a since it comes bundled with OctoPrint. Plugin_a and plugin_d don’t define a sort key and hence will be Will order both plugins based first on their bundling status and then on their plugin identifier. OctoPrint will detect that plugin_b and plugin_c define a order number, and since it’s identical for both ( 1) info ( "PluginD started up" ) _plugin_implementation_ = PluginD () info ( "PluginD starting up" ) def on_after_startup ( self, * args, ** kwargs ): self. StartupPlugin ): def on_startup ( self, * args, ** kwargs ): self. # in this example this is bundled with OctoPrint import ugin class PluginD ( octoprint. Merged into one big asset map (differing between javascripts and stylesheets of various types) for use during Implementations are collected and then all assets they return via their get_assets methods are retrieved and The following snippet taken from OctoPrint’s code for example shows how all AssetPlugin Using mixins always follows the pattern of retrieving the matching implementations from the plugin subsystem, thenĬalling the specific mixin’s methods as defined and necessary. OctoPrint’s plugin coreĬollects those from the plugins and offers methods to access them based on the mixin type, which get used at multiple Implement one or multiple mixins using the _plugin_implementation_ control property. Which are to be subclassed and extended to add functionality to OctoPrint. Plugin mixins are the heart of OctoPrint’s plugin system.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |