🚧 Flavor override dialog finally works
This commit is contained in:
1 parent
67047c006c
commit
2bf7eceb8e
14 files changed
+4687
-2201
No files matched your search
@@ -21,9 +21,11 @@
|
||||
* [JQuery Slimscroll](http://rocha.la/jQuery-slimScroll): MIT, GPL (dual licensed)
|
||||
* [JQuery UI Core, Mouse, Slider and Widget](http://jqueryui.com): MIT
|
||||
* [Knockout](http://knockoutjs.com/): MIT
|
||||
* [Knockout.Markdown](https://github.com/grofit/knockout.markdown): MIT
|
||||
* [LESS](http://lesscss.org): Apache License 2.0
|
||||
* [lodash](https://lodash.com): MIT
|
||||
* [Loglevel](https://github.com/pimterry/loglevel): MIT
|
||||
* [Markdown-it](https://markdown-it.github.io/): MIT
|
||||
* [Modernizr](http://modernizr.com): MIT
|
||||
* [Moment.js](http://momentjs.com/): MIT
|
||||
* [PNotify](http://sciactive.com/pnotify/): GPL, LGPL, MPL (triple licensed)
|
||||
|
||||
@@ -23,12 +23,13 @@ from octoprint.comm.protocol.reprap.util.queues import ScriptQueue, JobQueue, Co
|
||||
|
||||
from octoprint.comm.scripts import InvalidScript, UnknownScript
|
||||
|
||||
from octoprint.comm.util.parameters import ChoiceType, Value, ParamGroup, BooleanType, FloatType, IntegerType, SmallChoiceType
|
||||
from octoprint.comm.util.parameters import GroupChoiceType, Value, ParamGroup, BooleanType, FloatType, SmallChoiceType, SmallListType
|
||||
|
||||
from octoprint.comm.job import LocalGcodeFilePrintjob, SDFilePrintjob, \
|
||||
LocalGcodeStreamjob, CopyJobMixin
|
||||
|
||||
from octoprint.util import TypedQueue, TypeAlreadyInQueue, ResettableTimer, to_bytes, to_unicode, protectedkeydict, CountedEvent, monotonic_time
|
||||
from octoprint.util import dummy_gettext as gettext
|
||||
|
||||
from octoprint.events import Events
|
||||
|
||||
@@ -125,34 +126,143 @@ class ReprapGcodeProtocol(Protocol, ThreeDPrinterProtocolMixin, MotorControlProt
|
||||
|
||||
@classmethod
|
||||
def get_connection_options(cls):
|
||||
return [ChoiceType("flavor", "Firmware Flavor",
|
||||
sorted([Value(f.key, title=f.name) for f in all_flavors()], key=lambda x: x.title),
|
||||
default="generic"),
|
||||
ParamGroup("flavor_overrides",
|
||||
"Flavor Overrides",
|
||||
[BooleanType("always_send_checksum", "Always send checksum", help="Check this to always send checksums", default=False),
|
||||
SmallChoiceType("trigger_ok_after_resend",
|
||||
"Trigger ok after resend",
|
||||
[Value("detect", title="As detected"),
|
||||
Value("always", title="Always"),
|
||||
Value("never", title="Never")],
|
||||
default="detect")],
|
||||
help="Just a test",
|
||||
return [GroupChoiceType("flavor",
|
||||
"Firmware Flavor",
|
||||
sorted([Value(f.key,
|
||||
title=f.name) for f in all_flavors()],
|
||||
key=lambda x: x.title),
|
||||
ParamGroup("flavor_overrides",
|
||||
"Flavor Overrides",
|
||||
[SmallChoiceType("send_checksum",
|
||||
gettext("Send a checksum with the command"),
|
||||
[Value("printing", title=gettext("When printing")),
|
||||
Value("always", title=gettext("Always")),
|
||||
Value("never", title=gettext("Never"))]),
|
||||
SmallChoiceType("trigger_ok_after_resend",
|
||||
gettext("Trigger ok after resend"),
|
||||
[Value("detect", title=gettext("As detected")),
|
||||
Value("always", title=gettext("Always")),
|
||||
Value("never", title=gettext("Never"))]),
|
||||
SmallListType("blocked_commands",
|
||||
gettext("Blocked commands"),
|
||||
help=gettext("Use this to specify commands that should never be sent to the printer. Just the G or M code, comma separated. Defaults to `M0` and `M1` since most firmware will block until a button on the controller has been pressed if it receives either of those two commands.")),
|
||||
SmallListType("checksum_requiring_commands",
|
||||
gettext("Checksum requiring commands"),
|
||||
help=gettext("")),
|
||||
SmallListType("long_running_commands",
|
||||
gettext("Long running commands"),
|
||||
help=gettext("")),
|
||||
SmallListType("asynchronous_commands",
|
||||
gettext("Asynchronous commands"),
|
||||
help=gettext("")),
|
||||
SmallListType("pausing_commands",
|
||||
gettext("Pausing commands"),
|
||||
help=gettext("")),
|
||||
SmallListType("emergency_commands",
|
||||
gettext("Emergency commands"),
|
||||
help=gettext(""))
|
||||
],
|
||||
help=gettext("You can override the firmware flavor default settings here. You usually should *not* need to do that. Only change anything if the defaults don't work for your printer."),
|
||||
advanced=True),
|
||||
defaults=dict((f.key, f.overridable()) for f in all_flavors()),
|
||||
default="generic"),
|
||||
ParamGroup("error_handling",
|
||||
gettext("Error handling"),
|
||||
[SmallChoiceType("firmware_errors", gettext("What to do on a firmware error (`Error:` or `!!`)"),
|
||||
[Value("disconnect",
|
||||
title=gettext("Disconnect from the printer")),
|
||||
Value("cancel",
|
||||
title=gettext("Cancel any ongoing prints but stay connected to the printer"),
|
||||
help=gettext("Please note that if you choose this, OctoPrint will still disconnect from the printer in case of *fatal* errors reported by your firmware (e.g. `kill() called`, `fatal:`)")),
|
||||
Value("ignore",
|
||||
title=gettext("Ignore"),
|
||||
warning=True,
|
||||
help=gettext("Only choose this if your firmware sends error messages that are not actual errors. Might mask printer issues (even fatal errors!), be careful!"))],
|
||||
default="disconnect")],
|
||||
advanced=True),
|
||||
ParamGroup("timeouts_and_intervals",
|
||||
"Timeouts and Intervals",
|
||||
[FloatType("detection_timeout", "Detection", default=1),
|
||||
FloatType("connection_timeout", "Connection", default=10),
|
||||
FloatType("communication_timeout_normal", "Communication", default=30),
|
||||
FloatType("communication_timeout_busy", "Communication (busy)", default=3),
|
||||
FloatType("temperature_interval_idle", "Temperature (idle)", default=5),
|
||||
FloatType("temperature_interval_target", "Temperature (target set)", default=2),
|
||||
FloatType("temperature_interval_auto", "Temperature (autoreport)", default=2),
|
||||
FloatType("sdstatus_interval_normal", "SD Status", default=1),
|
||||
FloatType("sdstatus_interval_auto", "SD status (autoreport)", default=1),
|
||||
FloatType("resendok_timeout", "Resend OK", default=.5),
|
||||
FloatType("baudrate_detection_pause", "Baudrate Detection Pause", default=1.0),
|
||||
FloatType("position_log_wait", "Position Log Wait", default=10)],
|
||||
ParamGroup("pausing",
|
||||
gettext("Pausing"),
|
||||
[BooleanType("log_position_on_pause",
|
||||
gettext("Log position on pause"),
|
||||
default=True,
|
||||
warning=True,
|
||||
help=gettext("If you disable this, the `pause_position` placeholders in your pause/resume GCODE scripts will stay unpopulated! However, pausing speed might improve slightly."))],
|
||||
advanced=True),
|
||||
ParamGroup("cancelling",
|
||||
gettext("Cancelling"),
|
||||
[BooleanType("log_position_on_cancel",
|
||||
gettext("Log position on cancel"),
|
||||
default=True,
|
||||
warning=True,
|
||||
help=gettext("If you disable this, the `cancel_position` placeholders in your cancel GCODE script and the corresponding data in the print recovery data will stay unpopulated! However, cancelling speed might improve slightly.")),
|
||||
BooleanType("abort_heatups",
|
||||
"Attempt to abort any blocking heatups on cancel via `M108`",
|
||||
default=True,
|
||||
help=gettext("Uncheck this if your firmware doesn't support `M108` for aborting blocking heatups!"))],
|
||||
advanced=True),
|
||||
ParamGroup("intervals",
|
||||
gettext("Query intervals"),
|
||||
[FloatType("temperature_interval_idle",
|
||||
gettext("Temperature (idle)"),
|
||||
default=5,
|
||||
unit="sec",
|
||||
help=gettext("When printing or idle")),
|
||||
FloatType("temperature_interval_target",
|
||||
gettext("Temperature (target set)"),
|
||||
default=2,
|
||||
unit="sec",
|
||||
help=gettext("When idle and a target temperature is set")),
|
||||
FloatType("temperature_interval_auto",
|
||||
gettext("Temperature (autoreport)"),
|
||||
default=2,
|
||||
unit="sec",
|
||||
help=gettext("Autoreport interval to request from the firmware")),
|
||||
FloatType("sdstatus_interval_normal",
|
||||
gettext("SD Status"),
|
||||
default=1,
|
||||
unit="sec",
|
||||
help=gettext("When printing from the printer's SD")),
|
||||
FloatType("sdstatus_interval_auto",
|
||||
gettext("SD status (autoreport)"),
|
||||
default=1,
|
||||
unit="sec",
|
||||
help=gettext("Autoreport interval to request from the firmware"))],
|
||||
advanced=True),
|
||||
ParamGroup("timeouts",
|
||||
gettext("Timeouts"),
|
||||
[FloatType("communication_timeout_normal",
|
||||
gettext("Communication"),
|
||||
default=30,
|
||||
unit="sec",
|
||||
help=gettext("`busy` protocol support not detected")),
|
||||
FloatType("communication_timeout_busy",
|
||||
gettext("Communication (busy)"),
|
||||
default=3,
|
||||
unit="sec",
|
||||
help=gettext("`busy` protocol support detected")),
|
||||
FloatType("connection_timeout",
|
||||
gettext("Connection"),
|
||||
default=10,
|
||||
unit="sec"),
|
||||
FloatType("detection_timeout",
|
||||
gettext("Autodetection"),
|
||||
default=1,
|
||||
unit="sec",
|
||||
help=""),
|
||||
FloatType("position_log_wait",
|
||||
gettext("Position Log Wait"),
|
||||
default=10,
|
||||
unit="sec"),
|
||||
FloatType("baudrate_detection_pause",
|
||||
gettext("Initial baudrate detection pause"),
|
||||
default=1.0,
|
||||
unit="sec",
|
||||
help=gettext("Some controllers need a bit of a breather before baudrate detection after initial connect. If baudrate detection fails due to a hanging controller, try increasing this value.")),
|
||||
FloatType("resendok_timeout",
|
||||
gettext("Timeout for `ok` after resend detection"),
|
||||
default=.5,
|
||||
unit="sec",
|
||||
help=gettext("Some firmwares do not send an `ok` after a resend request. This timeout configures how long OctoPrint will wait for one until it assumes this particular bug to be present and generate its own."))],
|
||||
advanced=True)]
|
||||
|
||||
@staticmethod
|
||||
@@ -165,15 +275,6 @@ class ReprapGcodeProtocol(Protocol, ThreeDPrinterProtocolMixin, MotorControlProt
|
||||
|
||||
def __init__(self,
|
||||
flavor=None,
|
||||
connection_timeout=30.0,
|
||||
communication_timeout=10.0,
|
||||
communication_busy_timeout=2.0,
|
||||
temperature_interval_idle=5.0,
|
||||
temperature_interval_printing=5.0,
|
||||
temperature_interval_autoreport=2.0,
|
||||
sd_status_interval=2.0,
|
||||
sd_status_interval_autoreport=1.0,
|
||||
trigger_ok_after_resend=None,
|
||||
*args,
|
||||
**kwargs):
|
||||
super(ReprapGcodeProtocol, self).__init__(*args, **kwargs)
|
||||
@@ -195,18 +296,18 @@ class ReprapGcodeProtocol(Protocol, ThreeDPrinterProtocolMixin, MotorControlProt
|
||||
self._terminal_log = collections.deque([], 20)
|
||||
|
||||
self.timeouts = dict(
|
||||
connection=connection_timeout,
|
||||
communication=communication_timeout,
|
||||
communication_busy=communication_busy_timeout
|
||||
connection=kwargs.get("timeouts", dict()).get("connection_timeout", 30.0),
|
||||
communication=kwargs.get("timeouts", dict()).get("communication_timeout_normal", 10.0),
|
||||
communication_busy=kwargs.get("timeouts", dict()).get("communication_timeout_busy", 2.0)
|
||||
)
|
||||
self.interval = dict(
|
||||
temperature_idle=temperature_interval_idle,
|
||||
temperature_printing=temperature_interval_printing,
|
||||
temperature_autoreport=temperature_interval_autoreport,
|
||||
sd_status=sd_status_interval,
|
||||
sd_status_autoreport=sd_status_interval_autoreport
|
||||
temperature_idle=kwargs.get("intervals", dict()).get("temperature_interval_idle", 5.0),
|
||||
temperature_printing=kwargs.get("intervals", dict()).get("temperature_interval_printing", 5.0),
|
||||
temperature_autoreport=kwargs.get("intervals", dict()).get("temperature_interval_autoreport", 2.0),
|
||||
sd_status=kwargs.get("intervals", dict()).get("sd_status_interval_normal", 2.0),
|
||||
sd_status_autoreport=kwargs.get("intervals", dict()).get("sd_status_interval_auto", 1.0)
|
||||
)
|
||||
self._trigger_ok_after_resend = FallbackValue(trigger_ok_after_resend, fallback=self.flavor.trigger_ok_after_resend)
|
||||
self._trigger_ok_after_resend = self.flavor.trigger_ok_after_resend
|
||||
|
||||
flavor_comm_attrs = self.get_flavor_attributes_starting_with(self.flavor, "comm_")
|
||||
flavor_message_attrs = self.get_flavor_attributes_starting_with(self.flavor, "message_")
|
||||
@@ -2014,9 +2115,9 @@ class ReprapGcodeProtocol(Protocol, ThreeDPrinterProtocolMixin, MotorControlProt
|
||||
@property
|
||||
def _checksum_enabled(self):
|
||||
if not self._transport.message_integrity:
|
||||
return not self.flavor.never_send_checksum and (self.state == ProtocolState.PROCESSING # TODO does job need checksum?
|
||||
or self.flavor.always_send_checksum
|
||||
or not self._internal_flags["firmware_identified"])
|
||||
return self.flavor.send_checksum != "never" and (self.state == ProtocolState.PROCESSING # TODO does job need checksum?
|
||||
or self.flavor.send_checksum == "always"
|
||||
or not self._internal_flags["firmware_identified"])
|
||||
else:
|
||||
# transport has message integrity, no checksum
|
||||
return False
|
||||
|
||||
@@ -15,6 +15,7 @@ from octoprint.util import chunks, monotonic_time
|
||||
|
||||
from future.utils import with_metaclass
|
||||
|
||||
|
||||
_flavor_registry = dict()
|
||||
|
||||
|
||||
@@ -49,8 +50,7 @@ class GenericFlavor(with_metaclass(FlavorMeta, object)):
|
||||
unknown_requires_ack = False
|
||||
unknown_with_checksum = False
|
||||
|
||||
always_send_checksum = False
|
||||
never_send_checksum = False
|
||||
send_checksum = "printing"
|
||||
|
||||
detect_external_heatups = True
|
||||
block_while_dwelling = False
|
||||
@@ -114,6 +114,23 @@ class GenericFlavor(with_metaclass(FlavorMeta, object)):
|
||||
def with_overrides(cls, overrides):
|
||||
return type(b"{}WithOverrides".format(cls.__name__), (cls,), overrides)
|
||||
|
||||
@classmethod
|
||||
def overridable(cls):
|
||||
return dict(unknown_requires_ack=cls.unknown_requires_ack,
|
||||
unknown_with_checksum=cls.unknown_with_checksum,
|
||||
send_checksum=cls.send_checksum,
|
||||
detect_external_heatups=cls.detect_external_heatups,
|
||||
block_while_dwelling=cls.block_while_dwelling,
|
||||
trigger_ok_after_resend=cls.trigger_ok_after_resend,
|
||||
sd_relative_path=cls.sd_relative_path,
|
||||
checksum_requiring_commands=cls.checksum_requiring_commands,
|
||||
long_running_commands=cls.long_running_commands,
|
||||
asynchronous_commands=cls.asynchronous_commands,
|
||||
blocked_commands=cls.blocked_commands,
|
||||
pausing_commands=cls.pausing_commands,
|
||||
emergency_commands=cls.emergency_commands,
|
||||
heatup_abortable=cls.heatup_abortable)
|
||||
|
||||
##~~ Identifier
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -15,7 +15,7 @@ class RepetierFlavor(GenericFlavor):
|
||||
key = "repetier"
|
||||
name = "Repetier"
|
||||
|
||||
always_send_checksum = True
|
||||
send_checksum = "always"
|
||||
identical_resends_countdown = 5
|
||||
block_while_dwelling = True
|
||||
detect_external_heatups = False
|
||||
|
||||
@@ -21,11 +21,16 @@ def get_param_dict(data, options):
|
||||
class ParamType(object):
|
||||
type = "generic"
|
||||
|
||||
def __init__(self, name, title, default=None, advanced=False, help=None):
|
||||
def __init__(self, name, title, default=None, advanced=False, warning=False, labels=None, help=None):
|
||||
if labels is None:
|
||||
labels = []
|
||||
|
||||
self.name = name
|
||||
self.title = title
|
||||
self.default = default
|
||||
self.advanced = advanced
|
||||
self.warning = warning
|
||||
self.labels = labels
|
||||
self.help = help
|
||||
|
||||
def as_dict(self):
|
||||
@@ -33,6 +38,8 @@ class ParamType(object):
|
||||
title=self.title,
|
||||
default=self.default,
|
||||
advanced=self.advanced,
|
||||
warning=self.warning,
|
||||
labels=self.labels,
|
||||
help=self.help,
|
||||
type=self.type)
|
||||
|
||||
@@ -135,6 +142,24 @@ class ChoiceType(ParamType):
|
||||
class SmallChoiceType(ChoiceType):
|
||||
type = "smallchoice"
|
||||
|
||||
class GroupChoiceType(ChoiceType):
|
||||
type = "groupchoice"
|
||||
|
||||
def __init__(self, name, title, choices, group, defaults=None, **kwargs):
|
||||
if defaults is None:
|
||||
defaults = dict()
|
||||
|
||||
ChoiceType.__init__(self, name, title, choices, **kwargs)
|
||||
|
||||
self.group = group
|
||||
self.defaults = defaults
|
||||
|
||||
def as_dict(self):
|
||||
result = ChoiceType.as_dict(self)
|
||||
result["group"] = self.group.as_dict()
|
||||
result["defaults"] = self.defaults
|
||||
return result
|
||||
|
||||
class SuggestionType(ParamType):
|
||||
type = "suggestion"
|
||||
|
||||
@@ -151,7 +176,10 @@ class SuggestionType(ParamType):
|
||||
class ListType(ParamType):
|
||||
type = "list"
|
||||
|
||||
def __init__(self, name, title, factory, **kwargs):
|
||||
def __init__(self, name, title, factory=None, **kwargs):
|
||||
if factory is None:
|
||||
factory = lambda x: x
|
||||
|
||||
self.factory = factory
|
||||
ParamType.__init__(self, name, title, **kwargs)
|
||||
|
||||
@@ -165,11 +193,14 @@ class ListType(ParamType):
|
||||
|
||||
return list(map(self.factory, items))
|
||||
|
||||
class SmallListType(ListType):
|
||||
type = "smalllist"
|
||||
|
||||
class ParamGroup(ParamType):
|
||||
type = "group"
|
||||
|
||||
def __init__(self, name, title, params, help=None, advanced=False):
|
||||
ParamType.__init__(self, name, title, help=help, advanced=advanced)
|
||||
def __init__(self, name, title, params, **kwargs):
|
||||
ParamType.__init__(self, name, title, **kwargs)
|
||||
self.params = params
|
||||
|
||||
def as_dict(self):
|
||||
@@ -183,12 +214,20 @@ class ParamGroup(ParamType):
|
||||
return dict((k, v.convert()) for k, v in value.items())
|
||||
|
||||
class Value(object):
|
||||
def __init__(self, value, title=None, help=None):
|
||||
def __init__(self, value, title=None, warning=False, labels=None, help=None):
|
||||
if labels is None:
|
||||
labels = []
|
||||
|
||||
self.value = value
|
||||
self.title = title if title else value
|
||||
self.warning = warning
|
||||
self.labels = labels
|
||||
self.help = help
|
||||
|
||||
def as_dict(self):
|
||||
return dict(value=self.value,
|
||||
title=self.title,
|
||||
warning=self.warning,
|
||||
labels=self.labels,
|
||||
help=self.help)
|
||||
|
||||
@@ -1465,8 +1465,10 @@ class Server(object):
|
||||
"js/lib/modernizr.custom.js",
|
||||
"js/lib/lodash.min.js",
|
||||
"js/lib/sprintf.min.js",
|
||||
"js/lib/markdown-it.min.js",
|
||||
"js/lib/knockout.js",
|
||||
"js/lib/knockout.mapping-latest.js",
|
||||
"js/lib/knockout.markdown.js",
|
||||
"js/lib/babel.js",
|
||||
"js/lib/avltree.js",
|
||||
"js/lib/bootstrap/bootstrap.js",
|
||||
|
||||
@@ -8,23 +8,59 @@ $(function() {
|
||||
self.printerProfiles = parameters[3];
|
||||
self.access = parameters[4];
|
||||
|
||||
var convertValue = function(v, o) {
|
||||
if (v === undefined && o.default !== undefined) {
|
||||
v = o.default;
|
||||
}
|
||||
|
||||
if (v && (o.type === "list" || o.type === "smalllist")) {
|
||||
v = v.join(", ");
|
||||
}
|
||||
|
||||
return v;
|
||||
};
|
||||
|
||||
var extendOption = function(option, value) {
|
||||
if (option.type === "group") {
|
||||
if (value === undefined) {
|
||||
value = {};
|
||||
}
|
||||
_.each(option.params, function(option) {
|
||||
_.each(option.params, function (option) {
|
||||
extendOption(option, value[option.name]);
|
||||
});
|
||||
} else {
|
||||
if (value === undefined && option.default !== undefined) {
|
||||
value = option.default;
|
||||
value = convertValue(value, option);
|
||||
|
||||
if (option.type === "groupchoice") {
|
||||
_.each(option.group.params, function(p) {
|
||||
extendOption(p, option.defaults[option.default][p.name]);
|
||||
});
|
||||
}
|
||||
|
||||
if (option.value) {
|
||||
option.value(value);
|
||||
} else {
|
||||
option.value = ko.observable(value);
|
||||
option.value = ko.observable(value);
|
||||
if (option.type === "groupchoice" && option.defaults) {
|
||||
var updateDefaults = function() {
|
||||
_.each(option.choices, function(c) {
|
||||
if (c.value === option.value()) {
|
||||
_.each(option.group.params, function(p) {
|
||||
if (option.defaults[c.value]) {
|
||||
var d = option.defaults[c.value][p.name];
|
||||
if (d !== undefined) {
|
||||
p.value(convertValue(d, p));
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
option.value.subscribe(updateDefaults);
|
||||
updateDefaults();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
@@ -294,6 +330,11 @@ $(function() {
|
||||
_.each(parameters, function(parameter) {
|
||||
if (parameter.type === "group") {
|
||||
result[parameter.name] = toOptions(parameter.params);
|
||||
} else if (parameter.type === "groupchoice") {
|
||||
result[parameter.name] = parameter.value();
|
||||
result[parameter.group.name] = toOptions(parameter.group.params);
|
||||
} else if (parameter.type === "list" || parameter.type === "smalllist") {
|
||||
result[parameter.name] = splitTextToArray(parameter.value(), ",", true);
|
||||
} else {
|
||||
result[parameter.name] = parameter.value();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
(function (factory) {
|
||||
// Module systems magic dance.
|
||||
|
||||
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
|
||||
// CommonJS or Node: hard-coded dependency on "knockout"
|
||||
factory(require("knockout"), require("markdown-it"));
|
||||
} else if (typeof define === "function" && define["amd"]) {
|
||||
// AMD anonymous module with hard-coded dependency on "knockout"
|
||||
define(["knockout"], ["markdown-it"], factory);
|
||||
} else {
|
||||
// <script> tag: use the global `ko` object, attaching a `mapping` property
|
||||
factory(ko, markdownit);
|
||||
}
|
||||
}(function (ko, markdown) {
|
||||
ko.markdown = markdown();
|
||||
|
||||
ko.bindingHandlers.markdown = {
|
||||
update: function (element, valueAccessor) {
|
||||
var markdownData = ko.unwrap(valueAccessor());
|
||||
if (markdownData) element.innerHTML = ko.markdown.render(markdownData);
|
||||
}
|
||||
};
|
||||
|
||||
ko.bindingHandlers.markdownInline = {
|
||||
update: function (element, valueAccessor) {
|
||||
var markdownData = ko.unwrap(valueAccessor());
|
||||
if (markdownData) element.innerHTML = ko.markdown.renderInline(markdownData);
|
||||
}
|
||||
};
|
||||
}));
|
||||
@@ -0,0 +1 @@
|
||||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).markdownit=e()}}(function(){return function o(i,a,c){function l(t,e){if(!a[t]){if(!i[t]){var r="function"==typeof require&&require;if(!e&&r)return r(t,!0);if(u)return u(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var s=a[t]={exports:{}};i[t][0].call(s.exports,function(e){var r=i[t][1][e];return l(r||e)},s,s.exports,o,i,a,c)}return a[t].exports}for(var u="function"==typeof require&&require,e=0;e<c.length;e++)l(c[e]);return l}({1:[function(e,r,t){"use strict";r.exports=e("entities/maps/entities.json")},{"entities/maps/entities.json":52}],2:[function(e,r,t){"use strict";r.exports=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","meta","nav","noframes","ol","optgroup","option","p","param","section","source","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"]},{}],3:[function(e,r,t){"use strict";var n="<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^\"'=<>`\\x00-\\x20]+|'[^']*'|\"[^\"]*\"))?)*\\s*\\/?>",s="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",o=new RegExp("^(?:"+n+"|"+s+"|\x3c!----\x3e|\x3c!--(?:-?[^>-])(?:-?[^-])*--\x3e|<[?].*?[?]>|<![A-Z]+\\s+[^>]*>|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>)"),i=new RegExp("^(?:"+n+"|"+s+")");r.exports.HTML_TAG_RE=o,r.exports.HTML_OPEN_CLOSE_TAG_RE=i},{}],4:[function(e,r,t){"use strict";var n=Object.prototype.hasOwnProperty;function i(e,r){return n.call(e,r)}function a(e){return!(55296<=e&&e<=57343)&&(!(64976<=e&&e<=65007)&&(65535!=(65535&e)&&65534!=(65535&e)&&(!(0<=e&&e<=8)&&(11!==e&&(!(14<=e&&e<=31)&&(!(127<=e&&e<=159)&&!(1114111<e)))))))}function c(e){if(65535<e){var r=55296+((e-=65536)>>10),t=56320+(1023&e);return String.fromCharCode(r,t)}return String.fromCharCode(e)}var s=/\\([!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~])/g,o=new RegExp(s.source+"|"+/&([a-z#][a-z0-9]{1,31});/gi.source,"gi"),l=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i,u=e("./entities");var p=/[&<>"]/,h=/[&<>"]/g,f={"&":"&","<":"<",">":">",'"':"""};function d(e){return f[e]}var m=/[.?*+^$[\]\\(){}|-]/g;var _=e("uc.micro/categories/P/regex");t.lib={},t.lib.mdurl=e("mdurl"),t.lib.ucmicro=e("uc.micro"),t.assign=function(t){return Array.prototype.slice.call(arguments,1).forEach(function(r){if(r){if("object"!=typeof r)throw new TypeError(r+"must be object");Object.keys(r).forEach(function(e){t[e]=r[e]})}}),t},t.isString=function(e){return"[object String]"===(r=e,Object.prototype.toString.call(r));var r},t.has=i,t.unescapeMd=function(e){return e.indexOf("\\")<0?e:e.replace(s,"$1")},t.unescapeAll=function(e){return e.indexOf("\\")<0&&e.indexOf("&")<0?e:e.replace(o,function(e,r,t){return r||(n=e,o=0,i(u,s=t)?u[s]:35===s.charCodeAt(0)&&l.test(s)&&a(o="x"===s[1].toLowerCase()?parseInt(s.slice(2),16):parseInt(s.slice(1),10))?c(o):n);var n,s,o})},t.isValidEntityCode=a,t.fromCodePoint=c,t.escapeHtml=function(e){return p.test(e)?e.replace(h,d):e},t.arrayReplaceAt=function(e,r,t){return[].concat(e.slice(0,r),t,e.slice(r+1))},t.isSpace=function(e){switch(e){case 9:case 32:return!0}return!1},t.isWhiteSpace=function(e){if(8192<=e&&e<=8202)return!0;switch(e){case 9:case 10:case 11:case 12:case 13:case 32:case 160:case 5760:case 8239:case 8287:case 12288:return!0}return!1},t.isMdAsciiPunct=function(e){switch(e){case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 124:case 125:case 126:return!0;default:return!1}},t.isPunctChar=function(e){return _.test(e)},t.escapeRE=function(e){return e.replace(m,"\\$&")},t.normalizeReference=function(e){return e.trim().replace(/\s+/g," ").toUpperCase()}},{"./entities":1,mdurl:58,"uc.micro":65,"uc.micro/categories/P/regex":63}],5:[function(e,r,t){"use strict";t.parseLinkLabel=e("./parse_link_label"),t.parseLinkDestination=e("./parse_link_destination"),t.parseLinkTitle=e("./parse_link_title")},{"./parse_link_destination":6,"./parse_link_label":7,"./parse_link_title":8}],6:[function(e,r,t){"use strict";var a=e("../common/utils").isSpace,c=e("../common/utils").unescapeAll;r.exports=function(e,r,t){var n,s,o=r,i={ok:!1,pos:0,lines:0,str:""};if(60===e.charCodeAt(r)){for(r++;r<t;){if(10===(n=e.charCodeAt(r))||a(n))return i;if(62===n)return i.pos=r+1,i.str=c(e.slice(o+1,r)),i.ok=!0,i;92===n&&r+1<t?r+=2:r++}return i}for(s=0;r<t&&32!==(n=e.charCodeAt(r))&&!(n<32||127===n);)if(92===n&&r+1<t)r+=2;else{if(40===nLine truncated
|
||||
@@ -34,48 +34,74 @@
|
||||
|
||||
<script type="text/html" id="connection_dialog_template_text">
|
||||
<div class="control-group">
|
||||
<label class="control-label" data-bind="text: $data.title"></label>
|
||||
<label class="control-label" data-bind="markdownInline: $data.title"></label>
|
||||
<div class="controls">
|
||||
<input class="input-block-level" type="text" data-bind="value: $data.value, attr: {placeholder: $data.default}, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()">
|
||||
<span class="help-block" data-bind="visible: $data.help, text: $data.help"></span>
|
||||
<span class="help-block" data-bind="visible: $data.help, markdownInline: $data.help"></span>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
<script type="text/html" id="connection_dialog_template_integer">
|
||||
<div class="control-group">
|
||||
<label class="control-label" data-bind="text: $data.title"></label>
|
||||
<label class="control-label" data-bind="markdownInline: $data.title"></label>
|
||||
<div class="controls">
|
||||
<input class="input-block-level" type="number" step="1" data-bind="value: $data.value, attr: {placeholder: $data.default, min: $data.min, max: $data.max}, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()">
|
||||
<span class="help-block" data-bind="visible: $data.help, text: $data.help"></span>
|
||||
<!-- ko if: $data.unit -->
|
||||
<div class="input-append">
|
||||
<input class="input-small" type="number" step="1" data-bind="value: $data.value, attr: {placeholder: $data.default, min: $data.min, max: $data.max}, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()">
|
||||
<span class="add-on" data-bind="text: $data.unit"></span>
|
||||
</div>
|
||||
<!-- /ko -->
|
||||
<!-- ko unless: $data.unit -->
|
||||
<input class="input-small" type="number" step="1" data-bind="value: $data.value, attr: {placeholder: $data.default, min: $data.min, max: $data.max}, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()">
|
||||
<!-- /ko -->
|
||||
<span class="help-block" data-bind="visible: $data.help, markdownInline: $data.help"></span>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
<script type="text/html" id="connection_dialog_template_float">
|
||||
<div class="control-group">
|
||||
<label class="control-label" data-bind="text: $data.title"></label>
|
||||
<label class="control-label" data-bind="markdownInline: $data.title"></label>
|
||||
<div class="controls">
|
||||
<input class="input-block-level" type="number" data-bind="value: $data.value, attr: {placeholder: $data.default, min: $data.min, max: $data.max}, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()">
|
||||
<span class="help-block" data-bind="visible: $data.help, text: $data.help"></span>
|
||||
<!-- ko if: $data.unit -->
|
||||
<div class="input-append">
|
||||
<input class="input-small" type="number" data-bind="value: $data.value, attr: {placeholder: $data.default, min: $data.min, max: $data.max}, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()">
|
||||
<span class="add-on" data-bind="text: $data.unit"></span>
|
||||
</div>
|
||||
<!-- /ko -->
|
||||
<!-- ko ifnot: $data.unit -->
|
||||
<input class="input-small" type="number" data-bind="value: $data.value, attr: {placeholder: $data.default, min: $data.min, max: $data.max}, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()">
|
||||
<!-- /ko -->
|
||||
<span class="help-block" data-bind="visible: $data.help, markdownInline: $data.help"></span>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
<script type="text/html" id="connection_dialog_template_choice">
|
||||
<div class="control-group">
|
||||
<label class="control-label" data-bind="text: $data.title"></label>
|
||||
<label class="control-label" data-bind="markdownInline: $data.title"></label>
|
||||
<div class="controls">
|
||||
<select class="input-block-level" data-bind="options: $data.choices, optionsText: 'title', optionsValue: 'value', value: $data.value, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"></select>
|
||||
<span class="help-block" data-bind="visible: $data.help, text: $data.help"></span>
|
||||
<span class="help-block" data-bind="visible: $data.help, markdownInline: $data.help"></span>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
<script type="text/html" id="connection_dialog_template_groupchoice">
|
||||
<div class="control-group">
|
||||
<label class="control-label" data-bind="markdownInline: $data.title"></label>
|
||||
<div class="controls">
|
||||
<select class="input-block-level" data-bind="options: $data.choices, optionsText: 'title', optionsValue: 'value', value: $data.value, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"></select>
|
||||
<span class="help-block" data-bind="visible: $data.help, markdownInline: $data.help"></span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- ko template: { name: 'connection_dialog_template_group', data: group } --><!-- /ko -->
|
||||
</script>
|
||||
<script type="text/html" id="connection_dialog_template_smallchoice">
|
||||
<div class="control-group">
|
||||
<label class="control-label" data-bind="text: $data.title"></label>
|
||||
<label class="control-label" data-bind="markdownInline: $data.title"></label>
|
||||
<div class="controls">
|
||||
<!-- ko foreach: choices -->
|
||||
<label class="radio">
|
||||
<input type="radio" data-bind="attr: { name: 'connection_dialog_' + $parent.name + '_group' }, value: $data.value, checked: $parent.value"> <span data-bind="text: $data.title"></span>
|
||||
<span class="help-block" data-bind="visible: $data.help, text: $data.help"></span>
|
||||
<input type="radio" data-bind="attr: { name: 'connection_dialog_' + $parent.name + '_group' }, value: $data.value, checked: $parent.value"> <span data-bind="markdownInline: $data.title"></span> <span class="label label-important" data-bind="visible: $data.warning">{{ _('Warning') }}</span> <!-- ko foreach: $data.labels --><span class="label" data-bind="text: $data"></span><!-- /ko -->
|
||||
<span class="help-block" data-bind="visible: $data.help, markdownInline: $data.help"></span>
|
||||
</label>
|
||||
<!-- /ko -->
|
||||
</div>
|
||||
@@ -85,34 +111,43 @@
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: $data.value, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"> <span data-bind="text: $data.title"></span>
|
||||
<input type="checkbox" data-bind="checked: $data.value, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"> <span data-bind="markdownInline: $data.title"></span> <span class="label label-important" data-bind="visible: $data.warning">{{ _('Warning') }}</span> <!-- ko foreach: $data.labels --><span class="label" data-bind="text: $data"></span><!-- /ko -->
|
||||
</label>
|
||||
<span class="help-block" data-bind="visible: $data.help, text: $data.help"></span>
|
||||
<span class="help-block" data-bind="visible: $data.help, markdownInline: $data.help"></span>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
<script type="text/html" id="connection_dialog_template_suggestion">
|
||||
<div class="control-group">
|
||||
<label class="control-label" data-bind="text: $data.title"></label>
|
||||
<label class="control-label" data-bind="markdownInline: $data.title"></label>
|
||||
<div class="controls">
|
||||
<select class="input-block-level" data-bind="options: $data.suggestions, optionsText: 'title', optionsValue: 'value', value: $data.value, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"></select>
|
||||
<span class="help-block" data-bind="visible: $data.help, text: $data.help"></span>
|
||||
<span class="help-block" data-bind="visible: $data.help, markdownInline: $data.help"></span>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
<script type="text/html" id="connection_dialog_template_list">
|
||||
<div class="control-group">
|
||||
<label class="control-label" data-bind="text: $data.title"></label>
|
||||
<label class="control-label" data-bind="markdownInline: $data.title"></label>
|
||||
<div class="controls">
|
||||
<textarea data-bind="value: $data.value, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"></textarea>
|
||||
<span class="help-block" data-bind="visible: $data.help, text: $data.help"></span>
|
||||
<span class="help-block" data-bind="visible: $data.help, markdownInline: $data.help"></span>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
<script type="text/html" id="connection_dialog_template_smalllist">
|
||||
<div class="control-group">
|
||||
<label class="control-label" data-bind="markdownInline: $data.title"></label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: $data.value, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()">
|
||||
<span class="help-block" data-bind="visible: $data.help, markdownInline: $data.help"></span>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
<script type="text/html" id="connection_dialog_template_group">
|
||||
<fieldset>
|
||||
<legend data-bind="text: $data.title"></legend>
|
||||
<p data-bind="visible: $data.help, text: $data.help"></p>
|
||||
<legend data-bind="markdownInline: $data.title"></legend>
|
||||
<p data-bind="visible: $data.help, markdownInline: $data.help"></p>
|
||||
<!-- ko foreach: params -->
|
||||
<!-- ko template: { name: 'connection_dialog_template_' + $data.type, data: $data } --><!-- /ko -->
|
||||
<!-- /ko -->
|
||||
|
||||
@@ -83,9 +83,25 @@
|
||||
<label data-bind="text: $data.title, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"></label>
|
||||
<textarea data-bind="value: $data.value, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"></textarea>
|
||||
</script>
|
||||
<script type="text/html" id="connection_template_smalllist">
|
||||
<label data-bind="text: $data.title, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"></label>
|
||||
<input type="text" class="input-block-level" data-bind="value: $data.value, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()">
|
||||
</script>
|
||||
<script type="text/html" id="connection_template_group">
|
||||
<label data-bind="text: $data.title"></label>
|
||||
<!-- ko foreach: params -->
|
||||
<!-- ko template: { name: 'connection_template_' + $data.type, data: $data } --><!-- /ko -->
|
||||
<!-- /ko -->
|
||||
</script>
|
||||
<script type="text/html" id="connection_template_groupchoice">
|
||||
<label data-bind="text: $data.title, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"></label>
|
||||
<select class="input-block-level" data-bind="options: $data.choices, optionsText: 'title', optionsValue: 'value', value: $data.value, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"></select>
|
||||
<!-- ko if: !$data.group.advanced -->
|
||||
<label data-bind="text: $data.group.title"></label>
|
||||
<!-- ko foreach: $data.group.params -->
|
||||
<!-- ko if: !advanced -->
|
||||
<!-- ko template: { name: 'connection_template_' + $data.type, data: $data } --><!-- /ko -->
|
||||
<!-- /ko -->
|
||||
<!-- /ko -->
|
||||
<!-- /ko -->
|
||||
</script>
|
||||
@@ -38,6 +38,10 @@ from past.builtins import basestring, unicode
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def dummy_gettext(string):
|
||||
return string
|
||||
|
||||
|
||||
def to_bytes(s_or_u, encoding="utf-8", errors="strict"):
|
||||
# type: (Union[unicode, bytes], str, str) -> bytes
|
||||
"""Make sure ``s_or_u`` is a bytestring."""
|
||||
|
||||
+3273
-1408
File diff suppressed because it is too large.
Load diff
+1044
-711
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user