示例#1
0
def on_focus_gained(self, note, current_field_no):
    """
    Check if the current field contains Markdown. Change the appearance of
    the field if it does, or do nothing if not.
    """

    if not note.fields[current_field_no]:
        return

    Markdowner.manage_style(self, current_field_no)
    self.web.eval("""
    var field = $('#f%s');
    if (field.html().indexOf('SBAdata:') > -1) {
        var mdData = /<!----SBAdata:([a-zA-Z0-9+/]+=*)---->/.exec(field.html());
        var json = JSON.parse(atob(mdData[1]));
        if (json.isconverted) {
            if (!field.hasClass('mdstyle')) {
                field.addClass('mdstyle');
            }
            if (!$('#f%s + [class^=mdwarning]').length) {
                field.after($('<div/>', {class: 'mdwarning', text: '%s'}));
            }
            field.attr('title', '%s');
        }
    }
    """ % (current_field_no, current_field_no, markdown_warning_text, markdown_warning_text))
示例#2
0
        def cli_params(interval, requestrate, destination):
            """CLI for basic configuration parameters for rate limit plugins"""

            # generate ADR file with passed values
            md = Markdowner('rate_limit_adr_0001')
            rate_limit_configuration = {
                'interval': interval, 
                'requestrate': requestrate,
                'destination': destination
                }
            md.generate_ADR(
                'Rate Limit', 
                'None', 
                'Context for rate limiting pattern', 
                'Prosa about the decision in the ADD', 
                'Consequences for this rate', 
                rate_limit_configuration
                )
            rate_limit_config = md.grab_config_set()

            # pass configuration to parser component
            if provider == 'kong':
                self.parsing_kong(config_file, int(rate_limit_config['interval']) , int(rate_limit_config['requestrate']), rate_limit_config['destination'])
            elif provider == 'istio':
                self.parsing_istio(config_file, int(rate_limit_config['interval']) , int(rate_limit_config['requestrate']), rate_limit_config['destination'])
示例#3
0
def toggle_markdown(editor):
    editor.saveNow()
    current_field = editor.currentField
    html_field = editor.note.fields[current_field]
    if not html_field:
        html_field = u""
    markdowner = Markdowner(editor, editor.parentWindow, editor.note, html_field, current_field, preferences)
    markdowner.start()
    editor.web.setFocus()
    editor.web.eval("focusField(%d);" % editor.currentField)
示例#4
0
def toggleMarkdown(self):
    self.saveNow()
    current_field = self.currentField
    html_field = self.note.fields[current_field]
    if not html_field:
        html_field = u""
    markdowner = Markdowner(self, self.parentWindow, self.note, html_field, current_field)
    markdowner.start()
    # self.saveNow()
    self.web.setFocus()
    self.web.eval("focusField(%d);" % self.currentField)
示例#5
0
def toggleMarkdown(self):
    utility.start_safe_block(const.MARKDOWN_PREFS)
    self.saveNow()
    selected = self.web.selectedHtml()
    current_field = self.currentField
    html_field = self.note.fields[self.currentField]
    # if not isinstance(html_field, unicode):
    #     html_field = unicode(html_field)
    # if not isinstance(selected, unicode):
    #     selected = unicode(selected)
    if not html_field:
        html_field = u""
    if not selected:
        selected = u""
    markdowner = Markdowner(self, self.parentWindow, self.note,
                            html_field, current_field, selected)
    markdowner.apply_markdown()
    self.saveNow()
    self.web.setFocus()
    self.web.eval("focusField(%d);" % self.currentField)
    utility.end_safe_block(const.MARKDOWN_PREFS)
示例#6
0
def toggleMarkdown(self):
    utility.start_safe_block(const.MARKDOWN_PREFS)
    self.saveNow()
    selected = self.web.selectedHtml()
    current_field = self.currentField
    html_field = self.note.fields[self.currentField]
    # if not isinstance(html_field, unicode):
    #     html_field = unicode(html_field)
    # if not isinstance(selected, unicode):
    #     selected = unicode(selected)
    if not html_field:
        html_field = u""
    if not selected:
        selected = u""
    markdowner = Markdowner(self, self.parentWindow, self.note, html_field,
                            current_field, selected)
    markdowner.apply_markdown()
    self.saveNow()
    self.web.setFocus()
    self.web.eval("focusField(%d);" % self.currentField)
    utility.end_safe_block(const.MARKDOWN_PREFS)
示例#7
0
def on_focus_gained(self, note, field):

    tags = note.tags

    if not preferences.PREFS.get(const.MARKDOWN_OVERRIDE_EDITING):
        if const.MARKDOWN_PREFS.get("disable_buttons"):
            # disable all buttons except for the Markdown toggle
            self.disableButtons()
            markdown_button = self._buttons.get(const.MARKDOWN)
            if markdown_button:
                # markdown_button.setChecked(True)
                markdown_button.setEnabled(True)

    if const.MARKDOWN_PREFS.get("safe_block"):
        return
    else:
        utility.start_safe_block(const.MARKDOWN_PREFS)
        try:
            time.sleep(0.001)
            self.saveNow()
        except AttributeError as e:
            print e  # TODO: log error
        html_field = note.fields[field]
        # if not isinstance(html_field, unicode):
        #     html_field = unicode(html_field)
        if not html_field:
            html_field = u""
        markdowner = Markdowner(self, self.parentWindow, note,
                                html_field, field, u"")
        markdowner.on_focus_gained()
        self.web.setFocus()
        self.web.eval("focusField(%d);" % self.currentField)
        note.tags = tags
        try:
            time.sleep(0.001)
            self.updateTags()
        except AttributeError as e:
            print e  # TODO: log error
        utility.end_safe_block(const.MARKDOWN_PREFS)
示例#8
0
def on_focus_gained(self, note, field):

    tags = note.tags

    if not preferences.PREFS.get(const.MARKDOWN_OVERRIDE_EDITING):
        if const.MARKDOWN_PREFS.get("disable_buttons"):
            # disable all buttons except for the Markdown toggle
            self.disableButtons()
            markdown_button = self._buttons.get(const.MARKDOWN)
            if markdown_button:
                # markdown_button.setChecked(True)
                markdown_button.setEnabled(True)

    if const.MARKDOWN_PREFS.get("safe_block"):
        return
    else:
        utility.start_safe_block(const.MARKDOWN_PREFS)
        try:
            time.sleep(0.001)
            self.saveNow()
        except AttributeError as e:
            print e  # TODO: log error
        html_field = note.fields[field]
        # if not isinstance(html_field, unicode):
        #     html_field = unicode(html_field)
        if not html_field:
            html_field = u""
        markdowner = Markdowner(self, self.parentWindow, note, html_field,
                                field, u"")
        markdowner.on_focus_gained()
        self.web.setFocus()
        self.web.eval("focusField(%d);" % self.currentField)
        note.tags = tags
        try:
            time.sleep(0.001)
            self.updateTags()
        except AttributeError as e:
            print e  # TODO: log error
        utility.end_safe_block(const.MARKDOWN_PREFS)