Merge branch 'maintenance' into devel
This commit is contained in:
commit
bcea4839f6
37 files changed
+298
-70
No files matched your search
@@ -1,19 +1,18 @@
|
||||
name: "Issue Automation"
|
||||
on:
|
||||
issues:
|
||||
types: [opened, edited, closed, reopened]
|
||||
types: [opened, edited, closed, reopened, labeled, unlabeled]
|
||||
|
||||
jobs:
|
||||
issue-automation:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/github-script@v2
|
||||
- uses: actions/github-script@v5
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
let labels = [];
|
||||
let labels = context.payload.issue.labels.map(label => label.name);
|
||||
let setLabels = false;
|
||||
context.payload.issue.labels.forEach(label => { labels.push(label.name) });
|
||||
|
||||
switch (context.payload.action) {
|
||||
|
||||
@@ -55,7 +54,7 @@ jobs:
|
||||
}
|
||||
|
||||
if (setLabels) {
|
||||
github.issues.setLabels({
|
||||
github.rest.issues.setLabels({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
@@ -67,3 +66,91 @@ jobs:
|
||||
# if: github.event_name == 'issues' && (github.event.action == 'opened' || github.event.action == 'edited')
|
||||
# with:
|
||||
# repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- uses: actions/github-script@v5
|
||||
env:
|
||||
REMINDER: >
|
||||
Hi @${{ github.event.issue.user.login }}!
|
||||
|
||||
|
||||
It looks like you didn't upload a [system info bundle](https://community.octoprint.org/t/29887) as requested by the template.
|
||||
A bundle is required to further process your issue. It contains important logs and
|
||||
system information to be able to put your issue into context and give pointers as to
|
||||
what has happened.
|
||||
|
||||
|
||||
Please **edit your original post above** and upload **a bundle zip file**. Actually upload the file please and
|
||||
do not paste some link to a cloud provider, we want to have everything in one place here. Also do
|
||||
not unpack, repack or otherwise modify the bundle or its name, share it **exactly** like you get it from OctoPrint.
|
||||
|
||||
|
||||
Without the availability of a bundle, your issue will have to be closed.
|
||||
|
||||
|
||||
Thank you for your collaboration.
|
||||
THANKYOU: >
|
||||
Thank you @${{ github.event.issue.user.login }} for adding a bundle! Now this can actually get looked at.
|
||||
with:
|
||||
script: |
|
||||
const { REMINDER, THANKYOU } = process.env;
|
||||
const bundleRegex = /\[(octoprint-systeminfo-\d{14}\.zip)\]\(([^)]+)\)/g;
|
||||
const marker = "<!-- check_for_bundle -->";
|
||||
|
||||
const issueLabels = await github.rest.issues.listLabelsOnIssue({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number
|
||||
});
|
||||
let labels = issueLabels.data.map(label => label.name);
|
||||
|
||||
const comments = await github.rest.issues.listComments({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
})
|
||||
const comment = comments.data.find(c => c.user.login === "github-actions[bot]" && c.body.includes(marker));
|
||||
|
||||
if (!labels.includes("triage")) {
|
||||
console.log("No label, deleting comment if needed");
|
||||
if (comment) {
|
||||
await github.rest.issues.deleteComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
comment_id: comment.id,
|
||||
})
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const found = !!context.payload.issue.body.match(bundleRegex);
|
||||
|
||||
if (!found) {
|
||||
console.log("No bundle found, posting/updating reminder");
|
||||
const text = REMINDER + "\n" + marker;
|
||||
if (comment && comment.body !== text) {
|
||||
await github.rest.issues.updateComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
comment_id: comment.id,
|
||||
body: text
|
||||
});
|
||||
} else {
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
body: text
|
||||
});
|
||||
}
|
||||
} else if (found && comment) {
|
||||
console.log("Bundle found, saying thanks");
|
||||
const text = REMINDER.split("\n\n").map(line => `~~${line.trim()}~~`).join("\n\n") + "\n\n" + THANKYOU + "\n" + marker;
|
||||
if (comment.body !== text) {
|
||||
await github.rest.issues.updateComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
comment_id: comment.id,
|
||||
body: text
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -12,13 +12,18 @@ jobs:
|
||||
with:
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
|
||||
- uses: actions/github-script@v2
|
||||
- uses: actions/github-script@v5
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
let labels = [];
|
||||
// fetch a fresh set of labels, they might have changed earlier
|
||||
const issueLabels = await github.rest.issues.listLabelsOnIssue({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number
|
||||
});
|
||||
let labels = issueLabels.data.map(label => label.name);
|
||||
let setLabels = false;
|
||||
context.payload.pull_request.labels.forEach(label => { labels.push(label.name) });
|
||||
|
||||
let target = context.payload.pull_request.base.ref;
|
||||
if (["maintenance", "devel", "staging/maintenance", "staging/devel", "master"].includes(target)) {
|
||||
@@ -27,7 +32,7 @@ jobs:
|
||||
}
|
||||
|
||||
if (setLabels) {
|
||||
github.issues.setLabels({
|
||||
github.rest.issues.setLabels({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
|
||||
+3
-3
@@ -24,10 +24,10 @@ maintenance 1.8.0 3fe45661cd79c5137d9d4f5f4adb4d9519bc2084 pep440-dev
|
||||
fix/.* 1.8.0 3fe45661cd79c5137d9d4f5f4adb4d9519bc2084 pep440-dev
|
||||
improve/.* 1.8.0 3fe45661cd79c5137d9d4f5f4adb4d9519bc2084 pep440-dev
|
||||
|
||||
# staging/bugfix is the branch for preparation of the 1.6.1 bugfix release
|
||||
# staging/bugfix is the branch for preparation of the 1.7.2 bugfix release
|
||||
# so are any bug/... branches
|
||||
staging/bugfix 1.6.1 29484fb2926960279e62881d6ee073c374a2a5fe pep440-dev
|
||||
bug/.* 1.6.1 29484fb2926960279e62881d6ee073c374a2a5fe pep440-dev
|
||||
staging/bugfix 1.7.2 945825f03fbd2417a009dd33daf9f787aff60211 pep440-dev
|
||||
bug/.* 1.7.2 945825f03fbd2417a009dd33daf9f787aff60211 pep440-dev
|
||||
|
||||
# staging/maintenance is currently the branch for preparation of 1.7.0rc4
|
||||
# so is regressionfix/...
|
||||
|
||||
@@ -152,6 +152,8 @@ date of first contribution):
|
||||
* [Adam DeMuri](https://github.com/ademuri)
|
||||
* [Daniel Shenkle](https://github.com/DShenkle)
|
||||
* [Bryan Kenote](https://github.com/bryankenote)
|
||||
* [Quinn Damerell](https://github.com/QuinnDamerell)
|
||||
* [Sven Samoray](https://github.com/thelastWallE)
|
||||
|
||||
OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by
|
||||
[Daid Braam](https://github.com/daid). Parts of its communication layer and
|
||||
|
||||
@@ -226,6 +226,10 @@ For timelapse type ``zchange``.
|
||||
- 1
|
||||
- float
|
||||
- Size of retraction Z hop to detect and ignore for z-based snapshots
|
||||
* - ``minDelay``
|
||||
- 1
|
||||
- int
|
||||
- Snapshots will be rate limited against this interval, to prevent performance issues with vase mode/continuous z prints
|
||||
|
||||
.. _sec-api-timelapse-datamodel-config-timed:
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ INSTALL_REQUIRES = [
|
||||
# additional OctoPrint plugins that are maintained on a different release cycle
|
||||
"OctoPrint-FileCheck>=2021.2.23",
|
||||
"OctoPrint-FirmwareCheck>=2021.10.11",
|
||||
"OctoPrint-PiSupport>=2021.8.2",
|
||||
"OctoPrint-PiSupport>=2021.10.28",
|
||||
# the following dependencies are non trivial to update since later versions
|
||||
# introduce backwards incompatible changes that might affect plugins, or due to
|
||||
# other observed problems
|
||||
|
||||
@@ -398,6 +398,10 @@ class TemplatePlugin(OctoPrintPlugin, ReloadNeedingPlugin):
|
||||
``TemplatePlugin`` is a :class:`~octoprint.plugin.core.ReloadNeedingPlugin`.
|
||||
"""
|
||||
|
||||
@property
|
||||
def template_folder_key(self):
|
||||
return f"plugin_{self._identifier}"
|
||||
|
||||
def get_template_configs(self):
|
||||
"""
|
||||
Allows configuration of injected navbar, sidebar, tab and settings templates (and also additional templates of
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
<p>{{ _('Restore settings & files from an uploaded backup archive.') }}</p>
|
||||
|
||||
{% set plugin_backup_upload_form_id='settings-backup-upload' %}
|
||||
{% include "snippets/plugin/backup/backup_plugin_upload_form.jinja2" %}
|
||||
{% include "snippets/backup_plugin_upload_form.jinja2" %}
|
||||
</div>
|
||||
|
||||
<div data-bind="visible: !restoreSupported()">
|
||||
|
||||
@@ -5,4 +5,4 @@
|
||||
</p>{% endtrans %}
|
||||
|
||||
{% set plugin_backup_upload_form_id='wizard-backup-upload' %}
|
||||
{% include "snippets/plugin/backup/backup_plugin_upload_form.jinja2" %}
|
||||
{% include "snippets/backup_plugin_upload_form.jinja2" %}
|
||||
File renamed without changes.
@@ -18,10 +18,10 @@ from octoprint.util.version import (
|
||||
)
|
||||
|
||||
SENTRY_URL_SERVER = (
|
||||
"https://3d510fcb31be49c8a811639b7ed18377@o118517.ingest.sentry.io/1373987"
|
||||
"https://6600411b6f6b4a959d53037e782a8f73@o118517.ingest.sentry.io/1373987"
|
||||
)
|
||||
SENTRY_URL_COREUI = (
|
||||
"https://c6ab43a97f224198ae62a6e11e253cf0@o118517.ingest.sentry.io/1374096"
|
||||
"https://72b9fc82150d47bead5c940ccbd05995@o118517.ingest.sentry.io/1374096"
|
||||
)
|
||||
|
||||
SETTINGS_DEFAULTS = {
|
||||
|
||||
@@ -371,6 +371,7 @@ $(function () {
|
||||
|
||||
self._configureLayerSlider(layerSliderElement);
|
||||
self._configureLayerCommandSlider(commandSliderElement);
|
||||
self._configureContainerElement(containerElement);
|
||||
|
||||
self.settings.firstRequest.done(function () {
|
||||
var initResult = GCODE.ui.init({
|
||||
@@ -475,6 +476,18 @@ $(function () {
|
||||
.on("slide", self.changeCommandRange);
|
||||
};
|
||||
|
||||
self._configureContainerElement = function (containerElement) {
|
||||
// Prevent the default browser action for the mouse wheel down event. The desired behavor is to have the
|
||||
// gocde canvas pan on mouse down + drag, which happens. But if we don't prevent the default action, the browser
|
||||
// will also scroll the entire page.
|
||||
containerElement.mousedown(function (event) {
|
||||
// Middle mouse button
|
||||
if (event.which === 2) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
self.loadFile = function (path, date) {
|
||||
self.enableReload(false);
|
||||
self.needsLoad = false;
|
||||
|
||||
@@ -50,7 +50,7 @@ $(function () {
|
||||
return !item.enabled;
|
||||
}
|
||||
},
|
||||
"popularity",
|
||||
"name",
|
||||
[],
|
||||
[
|
||||
["bundled", "3rdparty"],
|
||||
@@ -138,7 +138,7 @@ $(function () {
|
||||
return !plugin.abandoned;
|
||||
}
|
||||
},
|
||||
"title",
|
||||
"popularity",
|
||||
["filter_installed", "filter_incompatible"],
|
||||
[],
|
||||
0
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -158,11 +158,11 @@
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="form-horizontal" onsubmit="return false;">
|
||||
{% include "snippets/plugins/softwareupdate/versionTracking.jinja2" %}
|
||||
{% include "snippets/plugins/softwareupdate/trackedBranch.jinja2" %}
|
||||
{% include "snippets/plugins/softwareupdate/checkoutFolder.jinja2" %}
|
||||
{% include "snippets/plugins/softwareupdate/pipTarget.jinja2" %}
|
||||
{% include "snippets/plugins/softwareupdate/pipEnableCheck.jinja2" %}
|
||||
{% include "snippets/versionTracking.jinja2" %}
|
||||
{% include "snippets/trackedBranch.jinja2" %}
|
||||
{% include "snippets/checkoutFolder.jinja2" %}
|
||||
{% include "snippets/pipTarget.jinja2" %}
|
||||
{% include "snippets/pipEnableCheck.jinja2" %}
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Version cache TTL') }}</label>
|
||||
<div class="controls">
|
||||
|
||||
+3
-3
@@ -7,9 +7,9 @@
|
||||
</p>{% endtrans %}
|
||||
|
||||
<form class="form-horizontal" onsubmit="return false;">
|
||||
{% include "snippets/plugins/softwareupdate/versionTracking.jinja2" %}
|
||||
{% include "snippets/plugins/softwareupdate/checkoutFolder.jinja2" %}
|
||||
{% include "snippets/plugins/softwareupdate/trackedBranch.jinja2" %}
|
||||
{% include "snippets/versionTracking.jinja2" %}
|
||||
{% include "snippets/checkoutFolder.jinja2" %}
|
||||
{% include "snippets/trackedBranch.jinja2" %}
|
||||
</form>
|
||||
|
||||
{% trans %}<p>
|
||||
|
||||
File renamed without changes.
File renamed without changes.
@@ -1,6 +1,6 @@
|
||||
<h3>{{ _('Anonymous Usage Tracking') }}</h3>
|
||||
|
||||
{% include "snippets/plugins/tracking/trackingDescription.jinja2" %}
|
||||
{% include "snippets/trackingDescription.jinja2" %}
|
||||
|
||||
<form class="form-horizontal" onsubmit="return false;">
|
||||
<div class="control-group">
|
||||
@@ -59,4 +59,4 @@
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{% include "snippets/plugins/tracking/trackingDetails.jinja2" %}
|
||||
{% include "snippets/trackingDetails.jinja2" %}
|
||||
@@ -1,8 +1,8 @@
|
||||
<h3>{{ _('Configure Anonymous Usage Tracking') }}</h3>
|
||||
|
||||
{% include "snippets/plugins/tracking/trackingDescription.jinja2" %}
|
||||
{% include "snippets/trackingDescription.jinja2" %}
|
||||
|
||||
{% include "snippets/plugins/tracking/trackingDetails.jinja2" %}
|
||||
{% include "snippets/trackingDetails.jinja2" %}
|
||||
|
||||
<p>
|
||||
{{ _('<strong>Note:</strong> You can always change your decision and also access more granular controls via Settings > Anonymous Usage Tracking.') }}
|
||||
|
||||
@@ -254,8 +254,6 @@ class Server:
|
||||
|
||||
self._lifecycle_callbacks = defaultdict(list)
|
||||
|
||||
self._template_searchpaths = []
|
||||
|
||||
self._intermediary_server = None
|
||||
|
||||
def run(self):
|
||||
@@ -1338,9 +1336,13 @@ class Server:
|
||||
OctoPrintFlaskResponse,
|
||||
OctoPrintJsonEncoder,
|
||||
OctoPrintSessionInterface,
|
||||
PrefixAwareJinjaEnvironment,
|
||||
ReverseProxiedEnvironment,
|
||||
)
|
||||
|
||||
# we must set this here because setting app.debug will access app.jinja_env
|
||||
app.jinja_environment = PrefixAwareJinjaEnvironment
|
||||
|
||||
app.config["TEMPLATES_AUTO_RELOAD"] = True
|
||||
app.config["JSONIFY_PRETTYPRINT_REGULAR"] = False
|
||||
|
||||
@@ -1536,12 +1538,9 @@ class Server:
|
||||
|
||||
import octoprint.util.jinja
|
||||
|
||||
filesystem_loader = octoprint.util.jinja.FilteredFileSystemLoader(
|
||||
[], path_filter=lambda x: not octoprint.util.is_hidden_path(x)
|
||||
)
|
||||
filesystem_loader.searchpath = self._template_searchpaths
|
||||
app.jinja_env.prefix_loader = jinja2.PrefixLoader({})
|
||||
|
||||
loaders = [app.jinja_loader, filesystem_loader]
|
||||
loaders = [app.jinja_loader, app.jinja_env.prefix_loader]
|
||||
if octoprint.util.is_running_from_source():
|
||||
from markdown import markdown
|
||||
|
||||
@@ -1556,8 +1555,16 @@ class Server:
|
||||
)
|
||||
)
|
||||
|
||||
jinja_loader = jinja2.ChoiceLoader(loaders)
|
||||
app.jinja_loader = jinja_loader
|
||||
# TODO: Remove this in 2.0.0
|
||||
warning_message = "Loading plugin template '{template}' from '{filename}' without plugin prefix, this is deprecated and will soon no longer be supported."
|
||||
loaders.append(
|
||||
octoprint.util.jinja.WarningLoader(
|
||||
octoprint.util.jinja.PrefixChoiceLoader(app.jinja_env.prefix_loader),
|
||||
warning_message,
|
||||
)
|
||||
)
|
||||
|
||||
app.jinja_loader = jinja2.ChoiceLoader(loaders)
|
||||
|
||||
self._register_template_plugins()
|
||||
|
||||
@@ -1728,14 +1735,27 @@ class Server:
|
||||
)
|
||||
|
||||
def _register_additional_template_plugin(self, plugin):
|
||||
import octoprint.util.jinja
|
||||
|
||||
folder = plugin.get_template_folder()
|
||||
if folder is not None and folder not in self._template_searchpaths:
|
||||
self._template_searchpaths.append(folder)
|
||||
if (
|
||||
folder is not None
|
||||
and plugin.template_folder_key not in app.jinja_env.prefix_loader.mapping
|
||||
):
|
||||
loader = octoprint.util.jinja.FilteredFileSystemLoader(
|
||||
[plugin.get_template_folder()],
|
||||
path_filter=lambda x: not octoprint.util.is_hidden_path(x),
|
||||
)
|
||||
|
||||
app.jinja_env.prefix_loader.mapping[plugin.template_folder_key] = loader
|
||||
|
||||
def _unregister_additional_template_plugin(self, plugin):
|
||||
folder = plugin.get_template_folder()
|
||||
if folder is not None and folder in self._template_searchpaths:
|
||||
self._template_searchpaths.remove(folder)
|
||||
if (
|
||||
folder is not None
|
||||
and plugin.template_folder_key in app.jinja_env.prefix_loader.mapping
|
||||
):
|
||||
del app.jinja_env.prefix_loader.mapping[plugin.template_folder_key]
|
||||
|
||||
def _setup_blueprints(self):
|
||||
# do not remove or the index view won't be found
|
||||
|
||||
@@ -34,6 +34,11 @@ from octoprint.server.util.flask import (
|
||||
from octoprint.settings import settings, valid_boolean_trues
|
||||
from octoprint.util import sv, time_this
|
||||
|
||||
try:
|
||||
from urllib.parse import quote as urlquote
|
||||
except ImportError:
|
||||
from urllib import quote as urlquote # noqa: F401
|
||||
|
||||
# ~~ GCODE file handling
|
||||
|
||||
_file_cache = {}
|
||||
@@ -322,7 +327,7 @@ def _getFileList(
|
||||
"resource": url_for(
|
||||
".readGcodeFile",
|
||||
target=FileDestinations.SDCARD,
|
||||
filename=f["name"],
|
||||
filename=urlquote(f["name"]),
|
||||
_external=True,
|
||||
)
|
||||
},
|
||||
@@ -384,7 +389,7 @@ def _getFileList(
|
||||
"resource": url_for(
|
||||
".readGcodeFile",
|
||||
target=FileDestinations.LOCAL,
|
||||
filename=path + file_or_folder["name"],
|
||||
filename=urlquote(path + file_or_folder["name"]),
|
||||
_external=True,
|
||||
)
|
||||
}
|
||||
@@ -438,14 +443,14 @@ def _getFileList(
|
||||
"resource": url_for(
|
||||
".readGcodeFile",
|
||||
target=FileDestinations.LOCAL,
|
||||
filename=file_or_folder["path"],
|
||||
filename=urlquote(file_or_folder["path"]),
|
||||
_external=True,
|
||||
),
|
||||
"download": url_for("index", _external=True)
|
||||
+ "downloads/files/"
|
||||
+ FileDestinations.LOCAL
|
||||
+ "/"
|
||||
+ file_or_folder["path"],
|
||||
+ urlquote(file_or_folder["path"]),
|
||||
}
|
||||
|
||||
result.append(file_or_folder)
|
||||
@@ -684,7 +689,7 @@ def uploadGcodeFile(target):
|
||||
location = url_for(
|
||||
".readGcodeFile",
|
||||
target=FileDestinations.LOCAL,
|
||||
filename=filename,
|
||||
filename=urlquote(filename),
|
||||
_external=True,
|
||||
)
|
||||
files.update(
|
||||
@@ -699,7 +704,7 @@ def uploadGcodeFile(target):
|
||||
+ "downloads/files/"
|
||||
+ FileDestinations.LOCAL
|
||||
+ "/"
|
||||
+ filename,
|
||||
+ urlquote(filename),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -709,7 +714,7 @@ def uploadGcodeFile(target):
|
||||
location = url_for(
|
||||
".readGcodeFile",
|
||||
target=FileDestinations.SDCARD,
|
||||
filename=sdFilename,
|
||||
filename=urlquote(sdFilename),
|
||||
_external=True,
|
||||
)
|
||||
files.update(
|
||||
@@ -761,7 +766,7 @@ def uploadGcodeFile(target):
|
||||
location = url_for(
|
||||
".readGcodeFile",
|
||||
target=FileDestinations.LOCAL,
|
||||
filename=added_folder,
|
||||
filename=urlquote(added_folder),
|
||||
_external=True,
|
||||
)
|
||||
folder = {
|
||||
@@ -1031,7 +1036,10 @@ def gcodeFileCommand(filename, target):
|
||||
abort(404, description="Unknown profile")
|
||||
|
||||
location = url_for(
|
||||
".readGcodeFile", target=target, filename=full_path, _external=True
|
||||
".readGcodeFile",
|
||||
target=target,
|
||||
filename=urlquote(full_path),
|
||||
_external=True,
|
||||
)
|
||||
result = {
|
||||
"name": destination,
|
||||
@@ -1044,7 +1052,7 @@ def gcodeFileCommand(filename, target):
|
||||
+ "downloads/files/"
|
||||
+ target
|
||||
+ "/"
|
||||
+ full_path,
|
||||
+ urlquote(full_path),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1149,7 +1157,10 @@ def gcodeFileCommand(filename, target):
|
||||
fileManager.move_folder(target, filename, destination)
|
||||
|
||||
location = url_for(
|
||||
".readGcodeFile", target=target, filename=destination, _external=True
|
||||
".readGcodeFile",
|
||||
target=target,
|
||||
filename=urlquote(destination),
|
||||
_external=True,
|
||||
)
|
||||
result = {
|
||||
"name": name,
|
||||
@@ -1163,7 +1174,7 @@ def gcodeFileCommand(filename, target):
|
||||
+ "downloads/files/"
|
||||
+ target
|
||||
+ "/"
|
||||
+ destination
|
||||
+ urlquote(destination)
|
||||
)
|
||||
|
||||
r = make_response(jsonify(result), 201)
|
||||
|
||||
@@ -21,6 +21,11 @@ from octoprint.server.util.flask import (
|
||||
)
|
||||
from octoprint.settings import settings, valid_boolean_trues
|
||||
|
||||
try:
|
||||
from urllib.parse import quote as urlquote
|
||||
except ImportError:
|
||||
from urllib import quote as urlquote # noqa: F401
|
||||
|
||||
_DATA_FORMAT_VERSION = "v2"
|
||||
|
||||
# ~~ timelapse handling
|
||||
@@ -137,7 +142,7 @@ def getTimelapseData():
|
||||
finished_list = []
|
||||
for f in files:
|
||||
output = dict(f)
|
||||
output["url"] = url_for("index") + "downloads/timelapse/" + f["name"]
|
||||
output["url"] = url_for("index") + "downloads/timelapse/" + urlquote(f["name"])
|
||||
finished_list.append(output)
|
||||
|
||||
result = {
|
||||
@@ -157,7 +162,7 @@ def getTimelapseData():
|
||||
@Permissions.TIMELAPSE_DOWNLOAD.require(403)
|
||||
def downloadTimelapse(filename):
|
||||
return redirect_to_tornado(
|
||||
request, url_for("index") + "downloads/timelapse/" + filename
|
||||
request, url_for("index") + "downloads/timelapse/" + urlquote(filename)
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ from os import scandir
|
||||
import flask
|
||||
import flask.json
|
||||
import flask.sessions
|
||||
import flask.templating
|
||||
import flask_assets
|
||||
import flask_login
|
||||
import netaddr
|
||||
@@ -591,6 +592,36 @@ class OctoPrintSessionInterface(flask.sessions.SecureCookieSessionInterface):
|
||||
return super().save_session(app, session, response)
|
||||
|
||||
|
||||
# ~~ jinja environment
|
||||
|
||||
|
||||
class PrefixAwareJinjaEnvironment(flask.templating.Environment):
|
||||
def __init__(self, *args, **kwargs):
|
||||
flask.templating.Environment.__init__(self, *args, **kwargs)
|
||||
self.prefix_loader = None
|
||||
self._cached_templates = {}
|
||||
|
||||
def join_path(self, template, parent):
|
||||
if parent and "/" in parent:
|
||||
prefix, _ = parent.split("/", 1)
|
||||
if template in self._templates_for_prefix(prefix) and not template.startswith(
|
||||
prefix + "/"
|
||||
):
|
||||
return prefix + "/" + template
|
||||
|
||||
return template
|
||||
|
||||
def _templates_for_prefix(self, prefix):
|
||||
if prefix in self._cached_templates:
|
||||
return self._cached_templates[prefix]
|
||||
|
||||
templates = []
|
||||
if prefix in self.prefix_loader.mapping:
|
||||
templates = self.prefix_loader.mapping[prefix].list_templates()
|
||||
self._cached_templates[prefix] = templates
|
||||
return templates
|
||||
|
||||
|
||||
# ~~ passive login helper
|
||||
|
||||
_cached_local_networks = None
|
||||
|
||||
@@ -1484,6 +1484,12 @@ def _process_template_config(name, implementation, rule, config=None, counter=1)
|
||||
|
||||
if "template" not in data:
|
||||
data["template"] = rule["template"](name)
|
||||
data["template"] = implementation.template_folder_key + "/" + data["template"]
|
||||
|
||||
if "template_header" in data:
|
||||
data["template_header"] = (
|
||||
implementation.template_folder_key + "/" + data["template_header"]
|
||||
)
|
||||
|
||||
if "name" not in data:
|
||||
data["name"] = implementation._plugin_name
|
||||
|
||||
@@ -90,7 +90,7 @@ default_settings = {
|
||||
"port": None,
|
||||
"baudrate": None,
|
||||
"exclusive": True,
|
||||
"lowLatency": True,
|
||||
"lowLatency": False,
|
||||
"autoconnect": False,
|
||||
"log": False,
|
||||
"timeout": {
|
||||
|
||||
@@ -426,5 +426,11 @@
|
||||
});
|
||||
};
|
||||
|
||||
OctoPrintClient.escapePath = function (path) {
|
||||
return _.map(path.split("/"), function (p) {
|
||||
return encodeURIComponent(p);
|
||||
}).join("/");
|
||||
};
|
||||
|
||||
return OctoPrintClient;
|
||||
});
|
||||
@@ -14,19 +14,19 @@
|
||||
};
|
||||
|
||||
var resourceForLocation = function (location) {
|
||||
return url + "/" + location;
|
||||
return url + "/" + OctoPrintClient.escapePath(location);
|
||||
};
|
||||
|
||||
var downloadForLocation = function (location) {
|
||||
return downloadUrl + "/" + location;
|
||||
return downloadUrl + "/" + OctoPrintClient.escapePath(location);
|
||||
};
|
||||
|
||||
var downloadForEntry = function (location, filename) {
|
||||
return downloadForLocation(location) + "/" + filename;
|
||||
return downloadForLocation(location) + "/" + OctoPrintClient.escapePath(filename);
|
||||
};
|
||||
|
||||
var resourceForEntry = function (location, filename) {
|
||||
return resourceForLocation(location) + "/" + filename;
|
||||
return resourceForLocation(location) + "/" + OctoPrintClient.escapePath(filename);
|
||||
};
|
||||
|
||||
var preProcessList = function (response) {
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
var bulkDownloadUrl = "downloads/timelapses";
|
||||
|
||||
var timelapseUrl = function (filename) {
|
||||
return url + "/" + filename;
|
||||
return url + "/" + OctoPrintClient.escapePath(filename);
|
||||
};
|
||||
|
||||
var timelapseDownloadUrl = function (filename) {
|
||||
return downloadUrl + "/" + filename;
|
||||
return downloadUrl + "/" + OctoPrintClient.escapePath(filename);
|
||||
};
|
||||
|
||||
var unrenderedTimelapseUrl = function (name) {
|
||||
return url + "/unrendered/" + name;
|
||||
return url + "/unrendered/" + OctoPrintClient.escapePath(name);
|
||||
};
|
||||
|
||||
var OctoPrintTimelapseClient = function (base) {
|
||||
|
||||
@@ -39,6 +39,7 @@ $(function () {
|
||||
.fail(function () {
|
||||
usernameElement.val("");
|
||||
passwordElement.val("");
|
||||
usernameElement.focus();
|
||||
|
||||
overlayElement.removeClass("in");
|
||||
errorElement.addClass("in");
|
||||
|
||||
@@ -110,6 +110,42 @@ class SelectedFilesWithConversionLoader(SelectedFilesLoader):
|
||||
return contents
|
||||
|
||||
|
||||
class PrefixChoiceLoader(BaseLoader):
|
||||
def __init__(self, loader):
|
||||
self.loader = loader
|
||||
|
||||
def get_source(self, environment, template):
|
||||
for prefix in sorted(self.loader.mapping.keys()):
|
||||
try:
|
||||
return self.loader.mapping[prefix].get_source(environment, template)
|
||||
except TemplateNotFound:
|
||||
pass
|
||||
|
||||
raise TemplateNotFound(template)
|
||||
|
||||
|
||||
class WarningLoader(BaseLoader):
|
||||
"""
|
||||
Logs a warning if the loader is used to successfully load a template.
|
||||
"""
|
||||
|
||||
def __init__(self, loader, warning_message):
|
||||
self.loader = loader
|
||||
self.warning_message = warning_message
|
||||
|
||||
def get_source(self, environment, template):
|
||||
import logging
|
||||
|
||||
try:
|
||||
contents, filename, uptodate = self.loader.get_source(environment, template)
|
||||
logging.getLogger(__name__).warning(
|
||||
self.warning_message.format(template=template, filename=filename)
|
||||
)
|
||||
return contents, filename, uptodate
|
||||
except TemplateNotFound:
|
||||
raise
|
||||
|
||||
|
||||
def get_all_template_paths(loader):
|
||||
def walk_folder(folder):
|
||||
files = []
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
from octoprint.util import bom_aware_open
|
||||
|
||||
|
||||
def load_from_file(file=None, path=None):
|
||||
"""
|
||||
Safely and performantly loads yaml data from the given source. Either a
|
||||
@@ -12,7 +9,7 @@ def load_from_file(file=None, path=None):
|
||||
"""
|
||||
if path is not None:
|
||||
assert file is None
|
||||
with bom_aware_open(path, mode="rt", encoding="utf-8") as f:
|
||||
with open(path, mode="rt", encoding="utf-8-sig") as f:
|
||||
return load_from_file(file=f)
|
||||
|
||||
if file is not None:
|
||||
|
||||
Reference in new issue
Block a user