Mercurial > libervia-backend
view frontends/src/tools/composition.py @ 817:c39117d00f35
jp: refactoring:
- imports from sat_frontends.jp instead of local imports
- added __init__.py
- commands now inherits from a base class: each base.CommandBase instance is a subcommand
- new arguments are added in CommandBase.add_parser_options methods, starting point si CommandBase.run or CommandBase.connected if a profile connection is needed
- commands are exported using a __commands__ variable at the top of the module
- sub-subcommand are easily added by using an other CommandBase instance as parent instead of using a Jp instance. In this case, the parent subcommand must be the one exported, and have a subcommands iterable (see cmd_file or cmd_pipe for examples).
- options which are often used (like --profile) are automatically added on demand (use_profile=True, use_progress=True)
- commands are automatically loaded when there are in a module named cmd_XXX
- restored --connect option
- restored progress bar
- restored getVersion bridge call on jp --version
- fixed file and pipe commands
- fixed forgotten translations
- fixed non SàT compliant docstrings
- better about/version dialog
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 10 Feb 2014 13:44:09 +0100 |
parents | 1fe00f0c9a91 |
children | c00d90bce252 |
line wrap: on
line source
#!/usr/bin/python # -*- coding: utf-8 -*- """ Libervia: a Salut à Toi frontend Copyright (C) 2013, 2014 Adrien Cossa <souliane@mailoo.org> This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ # Map the messages recipient types to their properties. RECIPIENT_TYPES = {"To": {"desc": "Direct recipients", "optional": False}, "Cc": {"desc": "Carbon copies", "optional": True}, "Bcc": {"desc": "Blind carbon copies", "optional": True}} # Rich text buttons icons and descriptions RICH_BUTTONS = { "bold": {"tip": "Bold", "icon": "media/icons/dokuwiki/toolbar/16/bold.png"}, "italic": {"tip": "Italic", "icon": "media/icons/dokuwiki/toolbar/16/italic.png"}, "underline": {"tip": "Underline", "icon": "media/icons/dokuwiki/toolbar/16/underline.png"}, "code": {"tip": "Code", "icon": "media/icons/dokuwiki/toolbar/16/mono.png"}, "strikethrough": {"tip": "Strikethrough", "icon": "media/icons/dokuwiki/toolbar/16/strike.png"}, "heading": {"tip": "Heading", "icon": "media/icons/dokuwiki/toolbar/16/hequal.png"}, "numberedlist": {"tip": "Numbered List", "icon": "media/icons/dokuwiki/toolbar/16/ol.png"}, "list": {"tip": "List", "icon": "media/icons/dokuwiki/toolbar/16/ul.png"}, "link": {"tip": "Link", "icon": "media/icons/dokuwiki/toolbar/16/linkextern.png"}, "horizontalrule": {"tip": "Horizontal rule", "icon": "media/icons/dokuwiki/toolbar/16/hr.png"} } # Define here your rich text formats, the key must match the ones used in button. # Tupples values must have 3 elements : prefix to the selection or cursor # position, sample text to write if the marker is not applied on a selection, # suffix to the selection or cursor position. # FIXME: must not be hard-coded like this RICH_FORMATS = {"markdown": {"bold": ("**", "bold", "**"), "italic": ("*", "italic", "*"), "code": ("`", "code", "`"), "heading": ("\n# ", "Heading 1", "\n## Heading 2\n"), "list": ("\n* ", "item", "\n + subitem\n"), "link": ("[desc](", "link", ")"), "horizontalrule": ("\n***\n", "", "") }, "bbcode": {"bold": ("[b]", "bold", "[/b]"), "italic": ("[i]", "italic", "[/i]"), "underline": ("[u]", "underline", "[/u]"), "strikethrough": ("[s]", "strikethrough", "[/s]"), "code": ("[code]", "code", "[/code]"), "link": ("[url=", "link", "]desc[/url]"), "list": ("\n[list] [*]", "item 1", " [*]item 2 [/list]\n") }, "dokuwiki": {"bold": ("**", "bold", "**"), "italic": ("//", "italic", "//"), "underline": ("__", "underline", "__"), "strikethrough": ("<del>", "strikethrough", "</del>"), "code": ("<code>", "code", "</code>"), "heading": ("\n==== ", "Heading 1", " ====\n=== Heading 2 ===\n"), "link": ("[[", "link", "|desc]]"), "list": ("\n * ", "item\n", "\n * subitem\n"), "horizontalrule": ("\n----\n", "", "") }, "XHTML": {"bold": ("<b>", "bold", "</b>"), "italic": ("<i>", "italic", "</i>"), "underline": ("<u>", "underline", "</u>"), "strikethrough": ("<s>", "strikethrough", "</s>"), "code": ("<pre>", "code", "</pre>"), "heading": ("\n<h3>", "Heading 1", "</h3>\n<h4>Heading 2</h4>\n"), "link": ("<a href=\"", "link", "\">desc</a>"), "list": ("\n<ul><li>", "item 1", "</li><li>item 2</li></ul>\n"), "horizontalrule": ("\n<hr/>\n", "", "") } } # These values should be equal to the ones in plugin_misc_text_syntaxes # FIXME: should the plugin import them from here to avoid duplicity? Importing # the plugin's values from here is not possible because Libervia would fail. PARAM_KEY_COMPOSITION = "Composition" PARAM_NAME_SYNTAX = "Syntax"