Mercurial > libervia-backend
comparison sat_frontends/tools/composition.py @ 2562:26edcf3a30eb
core, setup: huge cleaning:
- moved directories from src and frontends/src to sat and sat_frontends, which is the recommanded naming convention
- move twisted directory to root
- removed all hacks from setup.py, and added missing dependencies, it is now clean
- use https URL for website in setup.py
- removed "Environment :: X11 Applications :: GTK", as wix is deprecated and removed
- renamed sat.sh to sat and fixed its installation
- added python_requires to specify Python version needed
- replaced glib2reactor which use deprecated code by gtk3reactor
sat can now be installed directly from virtualenv without using --system-site-packages anymore \o/
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 02 Apr 2018 19:44:50 +0200 |
parents | frontends/src/tools/composition.py@2daf7b4c6756 |
children | 56f94936df1e |
comparison
equal
deleted
inserted
replaced
2561:bd30dc3ffe5a | 2562:26edcf3a30eb |
---|---|
1 #!/usr/bin/env python2 | |
2 # -*- coding: utf-8 -*- | |
3 | |
4 """ | |
5 Libervia: a Salut à Toi frontend | |
6 Copyright (C) 2013-2016 Adrien Cossa <souliane@mailoo.org> | |
7 | |
8 This program is free software: you can redistribute it and/or modify | |
9 it under the terms of the GNU Affero General Public License as published by | |
10 the Free Software Foundation, either version 3 of the License, or | |
11 (at your option) any later version. | |
12 | |
13 This program is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 GNU Affero General Public License for more details. | |
17 | |
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/>. | |
20 """ | |
21 | |
22 # Map the messages recipient types to their properties. | |
23 RECIPIENT_TYPES = {"To": {"desc": "Direct recipients", "optional": False}, | |
24 "Cc": {"desc": "Carbon copies", "optional": True}, | |
25 "Bcc": {"desc": "Blind carbon copies", "optional": True}} | |
26 | |
27 # Rich text buttons icons and descriptions | |
28 RICH_BUTTONS = { | |
29 "bold": {"tip": "Bold", "icon": "media/icons/dokuwiki/toolbar/16/bold.png"}, | |
30 "italic": {"tip": "Italic", "icon": "media/icons/dokuwiki/toolbar/16/italic.png"}, | |
31 "underline": {"tip": "Underline", "icon": "media/icons/dokuwiki/toolbar/16/underline.png"}, | |
32 "code": {"tip": "Code", "icon": "media/icons/dokuwiki/toolbar/16/mono.png"}, | |
33 "strikethrough": {"tip": "Strikethrough", "icon": "media/icons/dokuwiki/toolbar/16/strike.png"}, | |
34 "heading": {"tip": "Heading", "icon": "media/icons/dokuwiki/toolbar/16/hequal.png"}, | |
35 "numberedlist": {"tip": "Numbered List", "icon": "media/icons/dokuwiki/toolbar/16/ol.png"}, | |
36 "list": {"tip": "List", "icon": "media/icons/dokuwiki/toolbar/16/ul.png"}, | |
37 "link": {"tip": "Link", "icon": "media/icons/dokuwiki/toolbar/16/linkextern.png"}, | |
38 "horizontalrule": {"tip": "Horizontal rule", "icon": "media/icons/dokuwiki/toolbar/16/hr.png"}, | |
39 "image": {"tip": "Image", "icon": "media/icons/dokuwiki/toolbar/16/image.png"}, | |
40 } | |
41 | |
42 # 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 | |
44 # position, sample text to write if the marker is not applied on a selection, | |
45 # suffix to the selection or cursor position. | |
46 # FIXME: must not be hard-coded like this | |
47 RICH_SYNTAXES = {"markdown": {"bold": ("**", "bold", "**"), | |
48 "italic": ("*", "italic", "*"), | |
49 "code": ("`", "code", "`"), | |
50 "heading": ("\n# ", "Heading 1", "\n## Heading 2\n"), | |
51 "link": ("[desc](", "link", ")"), | |
52 "list": ("\n* ", "item", "\n + subitem\n"), | |
53 "horizontalrule": ("\n***\n", "", ""), | |
54 "image": ("![desc](", "path", ")"), | |
55 }, | |
56 "bbcode": {"bold": ("[b]", "bold", "[/b]"), | |
57 "italic": ("[i]", "italic", "[/i]"), | |
58 "underline": ("[u]", "underline", "[/u]"), | |
59 "code": ("[code]", "code", "[/code]"), | |
60 "strikethrough": ("[s]", "strikethrough", "[/s]"), | |
61 "link": ("[url=", "link", "]desc[/url]"), | |
62 "list": ("\n[list] [*]", "item 1", " [*]item 2 [/list]\n"), | |
63 "image": ("[img alt=\"desc\]", "path", "[/img]"), | |
64 }, | |
65 "dokuwiki": {"bold": ("**", "bold", "**"), | |
66 "italic": ("//", "italic", "//"), | |
67 "underline": ("__", "underline", "__"), | |
68 "code": ("<code>", "code", "</code>"), | |
69 "strikethrough": ("<del>", "strikethrough", "</del>"), | |
70 "heading": ("\n==== ", "Heading 1", " ====\n=== Heading 2 ===\n"), | |
71 "link": ("[[", "link", "|desc]]"), | |
72 "list": ("\n * ", "item\n", "\n * subitem\n"), | |
73 "horizontalrule": ("\n----\n", "", ""), | |
74 "image": ("{{", "path", " |desc}}"), | |
75 }, | |
76 "XHTML": {"bold": ("<b>", "bold", "</b>"), | |
77 "italic": ("<i>", "italic", "</i>"), | |
78 "underline": ("<u>", "underline", "</u>"), | |
79 "code": ("<pre>", "code", "</pre>"), | |
80 "strikethrough": ("<s>", "strikethrough", "</s>"), | |
81 "heading": ("\n<h3>", "Heading 1", "</h3>\n<h4>Heading 2</h4>\n"), | |
82 "link": ("<a href=\"", "link", "\">desc</a>"), | |
83 "list": ("\n<ul><li>", "item 1", "</li><li>item 2</li></ul>\n"), | |
84 "horizontalrule": ("\n<hr/>\n", "", ""), | |
85 "image": ("<img src=\"", "path", "\" alt=\"desc\"/>"), | |
86 } | |
87 } | |
88 | |
89 # 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"]. | |
91 # Values will be used to call execCommand(cmd, False, arg), they can be: | |
92 # - a string used for cmd and arg is assumed empty | |
93 # - 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 | |
95 # value to use directly without asking the user if prompt is empty. | |
96 COMMANDS = {"bold": "bold", | |
97 "italic": "italic", | |
98 "underline": "underline", | |
99 "code": ("formatBlock", "", "pre"), | |
100 "strikethrough": "strikeThrough", | |
101 "heading": ("heading", "Please specify the heading level (h1, h2, h3...)", ""), | |
102 "link": ("createLink", "Please specify an URL", ""), | |
103 "list": "insertUnorderedList", | |
104 "horizontalrule": "insertHorizontalRule", | |
105 "image": ("insertImage", "Please specify an image path", ""), | |
106 } | |
107 | |
108 # 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 | |
110 # the plugin's values from here is not possible because Libervia would fail. | |
111 PARAM_KEY_COMPOSITION = "Composition" | |
112 PARAM_NAME_SYNTAX = "Syntax" | |
113 |