Skip to content

Commit

Permalink
🚧 More progress on migration
Browse files Browse the repository at this point in the history
- added lightbox plugin
- added custom site_url relative link postprocessor
- fixed some links
  • Loading branch information
foosel committed Jul 27, 2023
1 parent 7788cce commit 577fe15
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 12 deletions.
4 changes: 2 additions & 2 deletions docs/plugin-guide/concepts/lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ There are three sources of installed plugins that OctoPrint will check during st

Each plugin that OctoPrint finds it will first load, then enable. On enabling a plugin, OctoPrint will
register its declared [hook handlers][plugin-guide.concepts.hooks] and [helpers][plugin-guide.concepts.helpers], apply
any [settings overlays][plugin-guide.concepts.control-properties.settings-overlays],
any [settings overlays][plugin-guide.concepts.control-properties.plugin-settings-overlay],
[inject the required properties][plugin-guide.concepts.mixins.injected-properties] into its declared
[mixin implementation][plugin-guide.concepts.mixins] and register those as well.

Expand Down Expand Up @@ -42,5 +42,5 @@ that the Plugin Manager is not the only way to uninstall a plugin from the syste
manually through the command line, circumventing Plugin Manager completely.

<figure markdown>
![The lifecycle of OctoPrint plugins.](../images/plugin-guide/lifecycle/plugins_lifecycle.svg)
![The lifecycle of OctoPrint plugins.](site:images/plugin-guide/lifecycle/plugins_lifecycle.svg)
</figure>
22 changes: 18 additions & 4 deletions docs/plugin-guide/concepts/mixins.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,52 +247,66 @@ OctoPrint's connectivity checker, an instance of [`octoprint.util.ConnectivityCh

## Available plugin mixins {: #plugin-guide.concepts.mixins.available-plugin-mixins }

Please note that all plugin mixins inherit from
[`Plugin`][octoprint.plugin.core.Plugin] and
[`OctoPrintPlugin`][octoprint.plugin.types.OctoPrintPlugin],
which also provide attributes of interest to plugin developers.
Please note that all plugin mixins inherit from [`Plugin`][octoprint.plugin.core.Plugin] and
[`OctoPrintPlugin`][octoprint.plugin.types.OctoPrintPlugin], which also provide attributes of interest to plugin developers.

[`AssetPlugin`][octoprint.plugin.types.AssetPlugin]
: The AssetPlugin mixin allows plugins to define additional static assets such as
JavaScript or CSS files to be automatically embedded into the pages delivered by the
server to be used within the client sided part of the plugin.

[`BlueprintPlugin`][octoprint.plugin.types.BlueprintPlugin]
: 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
[`SimpleApiPlugin`][octoprint.plugin.SimpleApiPlugin] or a custom web frontend.

[`EnvironmentDetectionPlugin`][octoprint.plugin.types.EnvironmentDetectionPlugin]
: The `EnvironmentDetectionPlugin` mixin allows enrichting OctoPrint's environmental
information collections with additional data, and to react to successfully collected
environmental information.

[`EventHandlerPlugin`][octoprint.plugin.types.EventHandlerPlugin]
: The `EventHandlerPlugin` mixin allows OctoPrint plugins to react to any of [OctoPrint's events][dev-guide.events].
OctoPrint will call the `on_event` method for any event fired on its internal event bus, supplying the
event type and the associated payload.

[`ProgressPlugin`][octoprint.plugin.types.ProgressPlugin]
: Via the `ProgressPlugin` mixin plugins can let themselves be called upon progress in
print jobs or slicing jobs, limited to minimally 1% steps.

[`SettingsPlugin`][octoprint.plugin.types.SettingsPlugin]
: Including the `SettingsPlugin` mixin allows plugins to store and retrieve their own
settings within OctoPrint's configuration.

[`ShutdownPlugin`][octoprint.plugin.types.ShutdownPlugin]
: The `ShutdownPlugin` allows hooking into the shutdown of OctoPrint. It's usually
used in conjunction with the [`StartupPlugin`][octoprint.plugin.types.StartupPlugin]
mixin, to cleanly shut down additional services again that where started by the
[`StartupPlugin`][octoprint.plugin.types.StartupPlugin] part of the plugin.

[`SimpleApiPlugin`][octoprint.plugin.types.SimpleApiPlugin]
: Utilizing the `SimpleApiPlugin` mixin plugins may implement a simple API based around
one GET resource and one resource accepting JSON commands POSTed to it.

[`SlicerPlugin`][octoprint.plugin.types.SlicerPlugin]
: Via the `SlicerPlugin` mixin plugins can add support for slicing engines to be used by
OctoPrint.

[`StartupPlugin`][octoprint.plugin.types.StartupPlugin]
: The `StartupPlugin` allows hooking into the startup of OctoPrint. It can be used to
start up additional services on or just after the startup of the server.

[`TemplatePlugin`][octoprint.plugin.types.TemplatePlugin]
: Using the `TemplatePlugin` mixin plugins may inject their own components into the
OctoPrint web interface.

[`UiPlugin`][octoprint.plugin.types.UiPlugin]
: The `UiPlugin` mixin allows plugins to completely replace the UI served by OctoPrint.

[`WebcamProviderPlugin`][octoprint.plugin.types.WebcamProviderPlugin]
: The `WebcamProviderPlugin` can be used to provide one or more webcams visible on the
frontend and used for snapshots/timelapses.

[`WizardPlugin`][octoprint.plugin.types.WizardPlugin]
: The `WizardPlugin` mixin allows plugins to report to OctoPrint whether
the `wizard` templates they define via the
Expand Down
8 changes: 4 additions & 4 deletions docs/user-guide/features/safe-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ You can select "Restart OctoPrint in safe mode" from the "System" menu, if the "
OctoPrint" server command has been correctly configured.

<figure markdown>
!["Restart OctoPrint in safe mode" in the "System" menu](../../images/user-guide/features/safe_mode/systemmenu.png)
!["Restart OctoPrint in safe mode" in the "System" menu](site:images/user-guide/features/safe_mode/systemmenu.png)
<figcaption>"Restart OctoPrint in safe mode" in the "System" menu</figcaption>
</figure>

### Via the `server.startOnceInSafeMode` config flag

You can set the flag `server.startOnceInSafeMode` in [`config.yaml`](../configuration/config_yaml)
You can set the flag `server.startOnceInSafeMode` in [`config.yaml`][user-guide.configuration.config-yaml]
to `true` and restart. This will make OctoPrint start up in safe mode. The flag will clear
automatically.

Expand All @@ -56,7 +56,7 @@ To set this flag you have the following options:
startOnceInSafeMode: true
```
Please also refer to the [YAML primer](../configuration/yaml).
Please also refer to the [YAML primer][user-guide.configuration.yaml-primer].
### Via the `--safe` command line flag

Expand All @@ -81,7 +81,7 @@ When OctoPrint is running in safe mode the following changes to its normal opera
safe mode.

<figure markdown>
![Safe mode notification](../../images/user-guide/features/safe_mode/notification.png)
![Safe mode notification](site:images/user-guide/features/safe_mode/notification.png)
<figcaption>Safe mode notification</figcaption>
</figure>

Expand Down
31 changes: 31 additions & 0 deletions extensions/hooks/site_urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import logging
import urllib.parse
import re

import mkdocs.plugins

log = logging.getLogger("mkdocs")

SITE_URLS_REGEX = re.compile(r'(href|src)="site:([^"]+)"', re.IGNORECASE)


@mkdocs.plugins.event_priority(50)
def on_page_content(html, page, config, files):
site_url = config["site_url"]
path = urllib.parse.urlparse(site_url).path

if not path:
path = "/"
if not path.endswith("/"):
path += "/"

def _replace(match):
param = match.group(1)
url = match.group(2)
if url.startswith("/"):
url = url[1:]

log.info(f"Replacing site:{match.group(2)} with {path}{url}...")
return f'{param}="{path}{url}"'

return SITE_URLS_REGEX.sub(_replace, html)
14 changes: 13 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ theme:
- content.code.annotate
- navigation.indexes
- navigation.instant
- navigation.path
- navigation.prune
- navigation.tabs
- navigation.tabs.sticky
- navigation.top
- navigation.tracking
#- toc.integrate
- toc.follow
font:
code: JetBrains Mono
palette:
Expand All @@ -57,6 +60,8 @@ markdown_extensions:
- markdown_grid_tables
- md_in_html
- meta
- pymdownx.caret
- pymdownx.critic
- pymdownx.emoji:
emoji_index: !!python/name:materialx.emoji.twemoji
emoji_generator: !!python/name:materialx.emoji.to_svg
Expand All @@ -68,7 +73,9 @@ markdown_extensions:
- pymdownx.inlinehilite
- pymdownx.keys
- pymdownx.magiclink
- pymdownx.snippets
- pymdownx.mark
- pymdownx.snippets:
url_download: true
- pymdownx.superfences:
custom_fences:
- name: mermaid
Expand All @@ -78,11 +85,15 @@ markdown_extensions:
alternate_style: true
- pymdownx.tasklist:
custom_checkbox: true
- pymdownx.tilde
- tables
- toc:
permalink: "#"
- "extensions.markdown.version"

hooks:
- extensions/hooks/site_urls.py

nav:
- Home: index.md
- User Guide:
Expand Down Expand Up @@ -119,6 +130,7 @@ plugins:
- gen-files:
scripts:
- extensions/gen_ref_pages.py
- glightbox
- literate-nav:
nav_file: SUMMARY.md
- macros:
Expand Down
13 changes: 12 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ markdown-grid-tables = "^0.3.1"
class-doc = "^0.2.6"
mergedeep = "^1.3.4"
mike = "^1.1.2"
mkdocs-glightbox = "^0.3.4"

[tool.poetry.dev-dependencies]

Expand Down

0 comments on commit 577fe15

Please sign in to comment.