Mercurial > libervia-backend
comparison sat_frontends/tools/composition.py @ 2624:56f94936df1e
code style reformatting using black
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 27 Jun 2018 20:14:46 +0200 |
parents | 26edcf3a30eb |
children | 559a625a236b |
comparison
equal
deleted
inserted
replaced
2623:49533de4540b | 2624:56f94936df1e |
---|---|
18 You should have received a copy of the GNU Affero General Public License | 18 You should have received a copy of the GNU Affero General Public License |
19 along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 """ | 20 """ |
21 | 21 |
22 # Map the messages recipient types to their properties. | 22 # Map the messages recipient types to their properties. |
23 RECIPIENT_TYPES = {"To": {"desc": "Direct recipients", "optional": False}, | 23 RECIPIENT_TYPES = { |
24 "Cc": {"desc": "Carbon copies", "optional": True}, | 24 "To": {"desc": "Direct recipients", "optional": False}, |
25 "Bcc": {"desc": "Blind carbon copies", "optional": True}} | 25 "Cc": {"desc": "Carbon copies", "optional": True}, |
26 "Bcc": {"desc": "Blind carbon copies", "optional": True}, | |
27 } | |
26 | 28 |
27 # Rich text buttons icons and descriptions | 29 # Rich text buttons icons and descriptions |
28 RICH_BUTTONS = { | 30 RICH_BUTTONS = { |
29 "bold": {"tip": "Bold", "icon": "media/icons/dokuwiki/toolbar/16/bold.png"}, | 31 "bold": {"tip": "Bold", "icon": "media/icons/dokuwiki/toolbar/16/bold.png"}, |
30 "italic": {"tip": "Italic", "icon": "media/icons/dokuwiki/toolbar/16/italic.png"}, | 32 "italic": {"tip": "Italic", "icon": "media/icons/dokuwiki/toolbar/16/italic.png"}, |
31 "underline": {"tip": "Underline", "icon": "media/icons/dokuwiki/toolbar/16/underline.png"}, | 33 "underline": { |
34 "tip": "Underline", | |
35 "icon": "media/icons/dokuwiki/toolbar/16/underline.png", | |
36 }, | |
32 "code": {"tip": "Code", "icon": "media/icons/dokuwiki/toolbar/16/mono.png"}, | 37 "code": {"tip": "Code", "icon": "media/icons/dokuwiki/toolbar/16/mono.png"}, |
33 "strikethrough": {"tip": "Strikethrough", "icon": "media/icons/dokuwiki/toolbar/16/strike.png"}, | 38 "strikethrough": { |
39 "tip": "Strikethrough", | |
40 "icon": "media/icons/dokuwiki/toolbar/16/strike.png", | |
41 }, | |
34 "heading": {"tip": "Heading", "icon": "media/icons/dokuwiki/toolbar/16/hequal.png"}, | 42 "heading": {"tip": "Heading", "icon": "media/icons/dokuwiki/toolbar/16/hequal.png"}, |
35 "numberedlist": {"tip": "Numbered List", "icon": "media/icons/dokuwiki/toolbar/16/ol.png"}, | 43 "numberedlist": { |
44 "tip": "Numbered List", | |
45 "icon": "media/icons/dokuwiki/toolbar/16/ol.png", | |
46 }, | |
36 "list": {"tip": "List", "icon": "media/icons/dokuwiki/toolbar/16/ul.png"}, | 47 "list": {"tip": "List", "icon": "media/icons/dokuwiki/toolbar/16/ul.png"}, |
37 "link": {"tip": "Link", "icon": "media/icons/dokuwiki/toolbar/16/linkextern.png"}, | 48 "link": {"tip": "Link", "icon": "media/icons/dokuwiki/toolbar/16/linkextern.png"}, |
38 "horizontalrule": {"tip": "Horizontal rule", "icon": "media/icons/dokuwiki/toolbar/16/hr.png"}, | 49 "horizontalrule": { |
39 "image": {"tip": "Image", "icon": "media/icons/dokuwiki/toolbar/16/image.png"}, | 50 "tip": "Horizontal rule", |
40 } | 51 "icon": "media/icons/dokuwiki/toolbar/16/hr.png", |
52 }, | |
53 "image": {"tip": "Image", "icon": "media/icons/dokuwiki/toolbar/16/image.png"}, | |
54 } | |
41 | 55 |
42 # Define here your rich text syntaxes, the key must match the ones used in button. | 56 # Define here your rich text syntaxes, the key must match the ones used in button. |
43 # Tupples values must have 3 elements : prefix to the selection or cursor | 57 # Tupples values must have 3 elements : prefix to the selection or cursor |
44 # position, sample text to write if the marker is not applied on a selection, | 58 # position, sample text to write if the marker is not applied on a selection, |
45 # suffix to the selection or cursor position. | 59 # suffix to the selection or cursor position. |
46 # FIXME: must not be hard-coded like this | 60 # FIXME: must not be hard-coded like this |
47 RICH_SYNTAXES = {"markdown": {"bold": ("**", "bold", "**"), | 61 RICH_SYNTAXES = { |
48 "italic": ("*", "italic", "*"), | 62 "markdown": { |
49 "code": ("`", "code", "`"), | 63 "bold": ("**", "bold", "**"), |
50 "heading": ("\n# ", "Heading 1", "\n## Heading 2\n"), | 64 "italic": ("*", "italic", "*"), |
51 "link": ("[desc](", "link", ")"), | 65 "code": ("`", "code", "`"), |
52 "list": ("\n* ", "item", "\n + subitem\n"), | 66 "heading": ("\n# ", "Heading 1", "\n## Heading 2\n"), |
53 "horizontalrule": ("\n***\n", "", ""), | 67 "link": ("[desc](", "link", ")"), |
54 "image": ("![desc](", "path", ")"), | 68 "list": ("\n* ", "item", "\n + subitem\n"), |
55 }, | 69 "horizontalrule": ("\n***\n", "", ""), |
56 "bbcode": {"bold": ("[b]", "bold", "[/b]"), | 70 "image": ("![desc](", "path", ")"), |
57 "italic": ("[i]", "italic", "[/i]"), | 71 }, |
58 "underline": ("[u]", "underline", "[/u]"), | 72 "bbcode": { |
59 "code": ("[code]", "code", "[/code]"), | 73 "bold": ("[b]", "bold", "[/b]"), |
60 "strikethrough": ("[s]", "strikethrough", "[/s]"), | 74 "italic": ("[i]", "italic", "[/i]"), |
61 "link": ("[url=", "link", "]desc[/url]"), | 75 "underline": ("[u]", "underline", "[/u]"), |
62 "list": ("\n[list] [*]", "item 1", " [*]item 2 [/list]\n"), | 76 "code": ("[code]", "code", "[/code]"), |
63 "image": ("[img alt=\"desc\]", "path", "[/img]"), | 77 "strikethrough": ("[s]", "strikethrough", "[/s]"), |
64 }, | 78 "link": ("[url=", "link", "]desc[/url]"), |
65 "dokuwiki": {"bold": ("**", "bold", "**"), | 79 "list": ("\n[list] [*]", "item 1", " [*]item 2 [/list]\n"), |
66 "italic": ("//", "italic", "//"), | 80 "image": ('[img alt="desc\]', "path", "[/img]"), |
67 "underline": ("__", "underline", "__"), | 81 }, |
68 "code": ("<code>", "code", "</code>"), | 82 "dokuwiki": { |
69 "strikethrough": ("<del>", "strikethrough", "</del>"), | 83 "bold": ("**", "bold", "**"), |
70 "heading": ("\n==== ", "Heading 1", " ====\n=== Heading 2 ===\n"), | 84 "italic": ("//", "italic", "//"), |
71 "link": ("[[", "link", "|desc]]"), | 85 "underline": ("__", "underline", "__"), |
72 "list": ("\n * ", "item\n", "\n * subitem\n"), | 86 "code": ("<code>", "code", "</code>"), |
73 "horizontalrule": ("\n----\n", "", ""), | 87 "strikethrough": ("<del>", "strikethrough", "</del>"), |
74 "image": ("{{", "path", " |desc}}"), | 88 "heading": ("\n==== ", "Heading 1", " ====\n=== Heading 2 ===\n"), |
75 }, | 89 "link": ("[[", "link", "|desc]]"), |
76 "XHTML": {"bold": ("<b>", "bold", "</b>"), | 90 "list": ("\n * ", "item\n", "\n * subitem\n"), |
77 "italic": ("<i>", "italic", "</i>"), | 91 "horizontalrule": ("\n----\n", "", ""), |
78 "underline": ("<u>", "underline", "</u>"), | 92 "image": ("{{", "path", " |desc}}"), |
79 "code": ("<pre>", "code", "</pre>"), | 93 }, |
80 "strikethrough": ("<s>", "strikethrough", "</s>"), | 94 "XHTML": { |
81 "heading": ("\n<h3>", "Heading 1", "</h3>\n<h4>Heading 2</h4>\n"), | 95 "bold": ("<b>", "bold", "</b>"), |
82 "link": ("<a href=\"", "link", "\">desc</a>"), | 96 "italic": ("<i>", "italic", "</i>"), |
83 "list": ("\n<ul><li>", "item 1", "</li><li>item 2</li></ul>\n"), | 97 "underline": ("<u>", "underline", "</u>"), |
84 "horizontalrule": ("\n<hr/>\n", "", ""), | 98 "code": ("<pre>", "code", "</pre>"), |
85 "image": ("<img src=\"", "path", "\" alt=\"desc\"/>"), | 99 "strikethrough": ("<s>", "strikethrough", "</s>"), |
86 } | 100 "heading": ("\n<h3>", "Heading 1", "</h3>\n<h4>Heading 2</h4>\n"), |
87 } | 101 "link": ('<a href="', "link", '">desc</a>'), |
102 "list": ("\n<ul><li>", "item 1", "</li><li>item 2</li></ul>\n"), | |
103 "horizontalrule": ("\n<hr/>\n", "", ""), | |
104 "image": ('<img src="', "path", '" alt="desc"/>'), | |
105 }, | |
106 } | |
88 | 107 |
89 # Define here the commands that are supported by the WYSIWYG edition. | 108 # Define here the commands that are supported by the WYSIWYG edition. |
90 # Keys must be the same than the ones used in RICH_SYNTAXES["XHTML"]. | 109 # Keys must be the same than the ones used in RICH_SYNTAXES["XHTML"]. |
91 # Values will be used to call execCommand(cmd, False, arg), they can be: | 110 # Values will be used to call execCommand(cmd, False, arg), they can be: |
92 # - a string used for cmd and arg is assumed empty | 111 # - a string used for cmd and arg is assumed empty |
93 # - a tuple (cmd, prompt, arg) with cmd the name of the command, | 112 # - a tuple (cmd, prompt, arg) with cmd the name of the command, |
94 # prompt the text to display for asking a user input and arg is the | 113 # prompt the text to display for asking a user input and arg is the |
95 # value to use directly without asking the user if prompt is empty. | 114 # value to use directly without asking the user if prompt is empty. |
96 COMMANDS = {"bold": "bold", | 115 COMMANDS = { |
97 "italic": "italic", | 116 "bold": "bold", |
98 "underline": "underline", | 117 "italic": "italic", |
99 "code": ("formatBlock", "", "pre"), | 118 "underline": "underline", |
100 "strikethrough": "strikeThrough", | 119 "code": ("formatBlock", "", "pre"), |
101 "heading": ("heading", "Please specify the heading level (h1, h2, h3...)", ""), | 120 "strikethrough": "strikeThrough", |
102 "link": ("createLink", "Please specify an URL", ""), | 121 "heading": ("heading", "Please specify the heading level (h1, h2, h3...)", ""), |
103 "list": "insertUnorderedList", | 122 "link": ("createLink", "Please specify an URL", ""), |
104 "horizontalrule": "insertHorizontalRule", | 123 "list": "insertUnorderedList", |
105 "image": ("insertImage", "Please specify an image path", ""), | 124 "horizontalrule": "insertHorizontalRule", |
106 } | 125 "image": ("insertImage", "Please specify an image path", ""), |
126 } | |
107 | 127 |
108 # These values should be equal to the ones in plugin_misc_text_syntaxes | 128 # These values should be equal to the ones in plugin_misc_text_syntaxes |
109 # FIXME: should the plugin import them from here to avoid duplicity? Importing | 129 # FIXME: should the plugin import them from here to avoid duplicity? Importing |
110 # the plugin's values from here is not possible because Libervia would fail. | 130 # the plugin's values from here is not possible because Libervia would fail. |
111 PARAM_KEY_COMPOSITION = "Composition" | 131 PARAM_KEY_COMPOSITION = "Composition" |
112 PARAM_NAME_SYNTAX = "Syntax" | 132 PARAM_NAME_SYNTAX = "Syntax" |
113 |