ProjectDjangoTagsMenu/DjangoTagsMenuHandler.py

Wed, 30 Dec 2020 11:02:07 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:02:07 +0100
changeset 51
29c461f7bea0
parent 49
ef6c805ae218
child 52
c264091162a2
permissions
-rw-r--r--

Updated copyright for 2021.

2
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
51
29c461f7bea0 Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 49
diff changeset
3 # Copyright (c) 2014 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
2
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the Django tags menu handler.
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
5
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
10 import os
9
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
11 import datetime
5
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
12
26
b21b4fc418bc Ported to PyQt5 and eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
13 from PyQt5.QtCore import QObject
b21b4fc418bc Ported to PyQt5 and eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
14 from PyQt5.QtWidgets import QMenu, QInputDialog, QDialog, QApplication
2
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 from E5Gui.E5Application import e5App
9
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
17 from E5Gui import E5FileDialog, E5MessageBox
2
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
19 from .DjangoTagInputDialog import DjangoTagInputDialog
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
20
9
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
21 import Utilities
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
22
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
23
2
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 class DjangoTagsMenuHandler(QObject):
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 Class implementing the Django tags menu handler.
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 def __init__(self, ui, parent=None):
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 Constructor
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @param ui reference to the user interface object (UI.UserInterface)
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @param parent reference to the parent object (QObject)
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 """
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 super(DjangoTagsMenuHandler, self).__init__(parent)
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.__ui = ui
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.__findDialog = None
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
40 def closeAllWindows(self):
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
41 """
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
42 Public method to close all dialogs managed by the handler.
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
43 """
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
44 if self.__findDialog:
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
45 self.__findDialog.close()
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
46
2
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 def initMenus(self, mainMenu):
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 Public method to initialize the various menus.
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 @param mainMenu reference to the main tags menu (QMenu)
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 """
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 mainMenu.addAction(self.tr("Django Template Tags Locator"),
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.__findTemplateTag)
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
55 mainMenu.addSeparator()
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
56 mainMenu.addMenu(self.__initTagsMenu())
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
57 mainMenu.addMenu(self.__initFiltersMenu())
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
58 mainMenu.addMenu(self.__initHumanizeMenu())
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
59 mainMenu.addMenu(self.__initWebDesignMenu())
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
60 mainMenu.addMenu(self.__initStaticMenu())
9
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
61 mainMenu.addMenu(self.__initCommentsMenu())
10
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
62 mainMenu.addMenu(self.__initInternationalizationMenu())
12
8bc18ea91897 Finished the implementation and corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
63 mainMenu.addMenu(self.__initLocalizationMenu())
10
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
64 mainMenu.addMenu(self.__initTimezoneMenu())
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
65
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
66 def __initTagsMenu(self):
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
67 """
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
68 Private method to initialize the tags menu.
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
69
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
70 @return generated menu (QMenu)
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
71 """
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
72 menu = QMenu(self.tr("Tags"))
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
73 menu.addAction(
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
74 self.tr("autoescape - Auto Escape Characters"),
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
75 lambda: self.__applyTemplate("autoescape"))
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
76 menu.addSeparator()
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
77 menu.addAction(
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
78 self.tr("block - Named Block"),
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
79 lambda: self.__applyTemplate("block"))
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
80 menu.addSeparator()
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
81 menu.addAction(
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
82 self.tr("comment - Multiline Comment"),
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
83 lambda: self.__applyTemplate("comment"))
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
84 menu.addAction(
5
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
85 self.tr("csrf_token - Cross Site Request Forgery Token"),
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
86 lambda: self.__applyTemplate("csrf_token"))
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
87 menu.addAction(
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
88 self.tr("cycle - Cycle variables each time used"),
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
89 lambda: self.__applyTemplate("cycle"))
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
90 menu.addSeparator()
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
91 menu.addAction(
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
92 self.tr("debug - Output Debug Information"),
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
93 lambda: self.__applyTemplate("debug"))
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
94 menu.addSeparator()
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
95 menu.addAction(
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
96 self.tr("extends - Extend a template with variable contents"),
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
97 lambda: self.__applyTemplate("extendsvariable"))
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
98 menu.addAction(
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
99 self.tr("extends - Extend a template with file"),
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
100 lambda: self.__applyTemplate("extendsfile"))
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
101 menu.addSeparator()
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
102 menu.addAction(
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
103 self.tr("filter - Filtered Block for one or more filters"),
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
104 lambda: self.__applyTemplate("filter"))
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
105 menu.addAction(
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
106 self.tr("firstof - Outputs first argument variable that is True"),
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
107 lambda: self.__applyTemplate("firstof"))
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
108 menu.addAction(
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
109 self.tr("for - For Loop"),
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
110 lambda: self.__applyTemplate("for"))
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
111 menu.addAction(
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
112 self.tr("for...empty - For Loop with fallback for empty loop"),
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
113 lambda: self.__applyTemplate("for...empty"))
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
114 menu.addSeparator()
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
115 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
116 self.tr("if - if...elif...else... clauses"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
117 lambda: self.__applyTemplate("if"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
118 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
119 self.tr("ifchanged - Check if a value has changed"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
120 lambda: self.__applyTemplate("ifchanged"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
121 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
122 self.tr("ifequal - Output block if variables are equal"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
123 lambda: self.__applyTemplate("ifequal"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
124 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
125 self.tr("ifnotequal - Output block if variables are not equal"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
126 lambda: self.__applyTemplate("ifnotequal"))
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
127 menu.addAction(
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
128 self.tr("include - Render template given by variable"),
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
129 lambda: self.__applyTemplate("includevariable"))
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
130 menu.addAction(
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
131 self.tr("include - Render template given by file name"),
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
132 lambda: self.__applyTemplate("includefile"))
5
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
133 menu.addSeparator()
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
134 menu.addAction(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
135 self.tr("load - Load a custom template tag set"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
136 lambda: self.__applyTemplate("load"))
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
137 menu.addSeparator()
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
138 menu.addAction(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
139 self.tr("now - Display current date and time"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
140 lambda: self.__applyTemplate("now"))
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
141 menu.addSeparator()
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
142 menu.addAction(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
143 self.tr("regroup - Regroup list of alike objects by a common"
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
144 " attribute"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
145 lambda: self.__applyTemplate("regroup"))
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
146 menu.addSeparator()
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
147 menu.addAction(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
148 self.tr("spaceless - Remove whitespace between HTML tags"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
149 lambda: self.__applyTemplate("spaceless"))
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
150 menu.addAction(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
151 self.tr("ssi - Output contents of a given file into the page"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
152 lambda: self.__applyTemplate("ssi"))
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
153 menu.addAction(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
154 self.tr("ssi - Output contents of a given file into the page"
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
155 " (dialog selection)"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
156 lambda: self.__applyTemplate("ssifile"))
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
157 menu.addSeparator()
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
158 menu.addAction(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
159 self.tr("templatetag - Output syntax characters used for"
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
160 " template"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
161 lambda: self.__applyTemplate("templatetag"))
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
162 menu.addSeparator()
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
163 menu.addAction(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
164 self.tr("url - Return an absolute path reference"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
165 lambda: self.__applyTemplate("url"))
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
166 menu.addAction(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
167 self.tr("url...as - Return an absolute path reference"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
168 lambda: self.__applyTemplate("urlas"))
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
169 menu.addSeparator()
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
170 menu.addAction(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
171 self.tr("verbatim - Output block contents without rendering"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
172 lambda: self.__applyTemplate("verbatim"))
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
173 menu.addSeparator()
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
174 menu.addAction(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
175 self.tr("widthratio - Calculate width ratio"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
176 lambda: self.__applyTemplate("verbatim"))
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
177 menu.addAction(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
178 self.tr("with - Cache a complex variable under a simpler name"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
179 lambda: self.__applyTemplate("verbatim"))
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
180
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
181 self.__tagsMenu = menu
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
182 return menu
2
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
184 def __initFiltersMenu(self):
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
185 """
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
186 Private method to initialize the filters menu.
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
187
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
188 @return generated menu (QMenu)
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
189 """
9
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
190 mainMenu = QMenu(self.tr("Filters"))
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
191
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
192 menu = QMenu(self.tr("A-I"), mainMenu)
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
193 menu.addAction(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
194 self.tr("add - Add variable or string"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
195 lambda: self.__applyTemplate("add"))
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
196 menu.addAction(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
197 self.tr("addslashes - Add slashes before quotes"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
198 lambda: self.__applyTemplate("addslashes"))
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
199 menu.addSeparator()
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
200 menu.addAction(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
201 self.tr("capfirst - Capitalize first character"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
202 lambda: self.__applyTemplate("capfirst"))
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
203 menu.addAction(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
204 self.tr("center - Center value"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
205 lambda: self.__applyTemplate("center"))
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
206 menu.addAction(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
207 self.tr("cut - Cut characters"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
208 lambda: self.__applyTemplate("cut"))
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
209 menu.addSeparator()
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
210 menu.addAction(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
211 self.tr("date - Format date"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
212 lambda: self.__applyTemplate("date"))
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
213 menu.addAction(
13
84479ae76729 Added translations and supporting files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 12
diff changeset
214 self.tr("default - Use default if False"),
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
215 lambda: self.__applyTemplate("default"))
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
216 menu.addAction(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
217 self.tr("default_if_none - Use default if None"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
218 lambda: self.__applyTemplate("default_if_none"))
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
219 menu.addAction(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
220 self.tr("dictsort - Sort dictionaries"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
221 lambda: self.__applyTemplate("dictsort"))
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
222 menu.addAction(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
223 self.tr("dictsortreversed - Sort dictionaries reversed"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
224 lambda: self.__applyTemplate("dictsortreversed"))
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
225 menu.addAction(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
226 self.tr("divisibleby - Check divisibility"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
227 lambda: self.__applyTemplate("divisibleby"))
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
228 menu.addSeparator()
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
229 menu.addAction(
13
84479ae76729 Added translations and supporting files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 12
diff changeset
230 self.tr("escape - Escape as HTML"),
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
231 lambda: self.__applyTemplate("escape"))
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
232 menu.addAction(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
233 self.tr("escapejs - Escape as JavaScript"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
234 lambda: self.__applyTemplate("escapejs"))
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
235 menu.addSeparator()
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
236 menu.addAction(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
237 self.tr("filesizeformat - Format file sizes"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
238 lambda: self.__applyTemplate("filesizeformat"))
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
239 menu.addAction(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
240 self.tr("first - First item of a list"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
241 lambda: self.__applyTemplate("first"))
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
242 menu.addAction(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
243 self.tr("fix_ampersands - Replace ampersands"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
244 lambda: self.__applyTemplate("fix_ampersands"))
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
245 menu.addAction(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
246 self.tr("floatformat - Format floating numbers"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
247 lambda: self.__applyTemplate("floatformat"))
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
248 menu.addAction(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
249 self.tr("force_escape - Escape as HTML immediately"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
250 lambda: self.__applyTemplate("force_escape"))
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
251 menu.addSeparator()
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
252 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
253 self.tr("get_digit - Extract rightmost digit"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
254 lambda: self.__applyTemplate("get_digit"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
255 menu.addSeparator()
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
256 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
257 self.tr("iriencode - Convert IRI to string"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
258 lambda: self.__applyTemplate("iriencode"))
9
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
259 mainMenu.addMenu(menu)
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
260
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
261 menu = QMenu(self.tr("J-R"), mainMenu)
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
262 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
263 self.tr("join - Join list"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
264 lambda: self.__applyTemplate("join"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
265 menu.addSeparator()
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
266 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
267 self.tr("last - Return last item in list"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
268 lambda: self.__applyTemplate("last"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
269 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
270 self.tr("length - Return length of the value"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
271 lambda: self.__applyTemplate("length"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
272 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
273 self.tr("length_is - Check length"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
274 lambda: self.__applyTemplate("length_is"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
275 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
276 self.tr("linebreaks - Replace line breaks with HTML"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
277 lambda: self.__applyTemplate("linebreaks"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
278 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
279 self.tr("linebreaksbr - Replace line breaks with <br/>"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
280 lambda: self.__applyTemplate("linebreaksbr"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
281 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
282 self.tr("linenumbers - Display text with line numbers"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
283 lambda: self.__applyTemplate("linenumbers"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
284 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
285 self.tr("ljust - Left-align value"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
286 lambda: self.__applyTemplate("ljust"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
287 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
288 self.tr("lower - Convert to lowercase"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
289 lambda: self.__applyTemplate("lower"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
290 menu.addSeparator()
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
291 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
292 self.tr("make_list - Turn value into a list"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
293 lambda: self.__applyTemplate("make_list"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
294 menu.addSeparator()
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
295 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
296 self.tr("phone2numeric - Convert phone number into numeric"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
297 lambda: self.__applyTemplate("phone2numeric"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
298 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
299 self.tr("pluralize - Return plural suffix"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
300 lambda: self.__applyTemplate("pluralize"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
301 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
302 self.tr("pprint - Pretty Print"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
303 lambda: self.__applyTemplate("pprint"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
304 menu.addSeparator()
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
305 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
306 self.tr("random - Return random item from list"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
307 lambda: self.__applyTemplate("random"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
308 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
309 self.tr("removetags - Remove HTML tags"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
310 lambda: self.__applyTemplate("removetags"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
311 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
312 self.tr("rjust - Right-align value"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
313 lambda: self.__applyTemplate("rjust"))
9
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
314 mainMenu.addMenu(menu)
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
315
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
316 menu = QMenu(self.tr("S-Z"), mainMenu)
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
317 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
318 self.tr("safe - Mark as not requiring HTML escaping "),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
319 lambda: self.__applyTemplate("safe"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
320 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
321 self.tr("safeseq - Mark as a safe sequence"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
322 lambda: self.__applyTemplate("safeseq"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
323 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
324 self.tr("slice - Return a slice of a list"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
325 lambda: self.__applyTemplate("slice"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
326 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
327 self.tr("slugify - Return value slugified"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
328 lambda: self.__applyTemplate("slugify"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
329 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
330 self.tr("stringformat - Format variable"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
331 lambda: self.__applyTemplate("stringformat"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
332 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
333 self.tr("striptags - Strip all HTML tags"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
334 lambda: self.__applyTemplate("striptags"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
335 menu.addSeparator()
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
336 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
337 self.tr("time - Format time"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
338 lambda: self.__applyTemplate("time"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
339 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
340 self.tr("timesince - Format as time since"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
341 lambda: self.__applyTemplate("timesince"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
342 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
343 self.tr("timeuntil - Format as time until"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
344 lambda: self.__applyTemplate("timeuntil"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
345 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
346 self.tr("title - Convert to titlecase"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
347 lambda: self.__applyTemplate("title"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
348 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
349 self.tr("truncatechars - Truncate after a number of characters"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
350 lambda: self.__applyTemplate("truncatechars"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
351 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
352 self.tr("truncatewords - Truncate after a number of words"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
353 lambda: self.__applyTemplate("truncatewords"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
354 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
355 self.tr("truncatewords_html - Truncate after a number of words"
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
356 " (HTML aware)"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
357 lambda: self.__applyTemplate("truncatewords_html"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
358 menu.addSeparator()
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
359 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
360 self.tr("unordered_list - Return HTML unordered list"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
361 lambda: self.__applyTemplate("unordered_list"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
362 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
363 self.tr("upper - Convert to uppercase"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
364 lambda: self.__applyTemplate("upper"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
365 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
366 self.tr("urlencode - Escape as URL"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
367 lambda: self.__applyTemplate("urlencode"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
368 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
369 self.tr("urlize - Convert URLs as clickable links"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
370 lambda: self.__applyTemplate("urlize"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
371 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
372 self.tr("urlizetrunc - Convert URLs as clickable links and"
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
373 " truncate"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
374 lambda: self.__applyTemplate("urlizetrunc"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
375 menu.addSeparator()
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
376 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
377 self.tr("wordcount - Return number of word"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
378 lambda: self.__applyTemplate("wordcount"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
379 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
380 self.tr("wordwrap - Wrap words"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
381 lambda: self.__applyTemplate("wordwrap"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
382 menu.addSeparator()
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
383 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
384 self.tr("yesno - Map True, False and None"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
385 lambda: self.__applyTemplate("yesno"))
9
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
386 mainMenu.addMenu(menu)
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
387
9
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
388 self.__filtersMenu = mainMenu
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
389 return mainMenu
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
390
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
391 def __initHumanizeMenu(self):
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
392 """
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
393 Private method to initialize the humanize menu.
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
394
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
395 @return generated menu (QMenu)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
396 """
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
397 menu = QMenu(self.tr("Humanize"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
398 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
399 self.tr("Load Package"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
400 lambda: self.__applyTemplate("loadhumanize"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
401 menu.addSeparator()
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
402 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
403 self.tr("apnumber - Format integer the Associated Press style"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
404 lambda: self.__applyTemplate("apnumber"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
405 menu.addSeparator()
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
406 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
407 self.tr("intcomma - Format integer with commas"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
408 lambda: self.__applyTemplate("intcomma"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
409 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
410 self.tr("intword - Convert integer to word"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
411 lambda: self.__applyTemplate("intword"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
412 menu.addSeparator()
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
413 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
414 self.tr("naturalday - Format date naturally"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
415 lambda: self.__applyTemplate("naturalday"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
416 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
417 self.tr("naturaltime - Format time naturally"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
418 lambda: self.__applyTemplate("naturaltime"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
419 menu.addSeparator()
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
420 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
421 self.tr("ordinal - Convert integer to ordinal"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
422 lambda: self.__applyTemplate("ordinal"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
423
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
424 self.__humanizeMenu = menu
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
425 return menu
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
426
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
427 def __initWebDesignMenu(self):
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
428 """
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
429 Private method to initialize the web design menu.
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
430
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
431 @return generated menu (QMenu)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
432 """
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
433 menu = QMenu(self.tr("Web Design"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
434 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
435 self.tr("Load Package"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
436 lambda: self.__applyTemplate("loadweb"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
437 menu.addSeparator()
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
438 menu.addAction(
13
84479ae76729 Added translations and supporting files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 12
diff changeset
439 self.tr("lorem - Builtin Lorem Ipsum Generator"),
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
440 lambda: self.__applyTemplate("lorem"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
441
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
442 self.__webMenu = menu
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
443 return menu
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
444
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
445 def __initStaticMenu(self):
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
446 """
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
447 Private method to initialize the static menu.
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
448
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
449 @return generated menu (QMenu)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
450 """
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
451 menu = QMenu(self.tr("Static"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
452 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
453 self.tr("Load Package"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
454 lambda: self.__applyTemplate("loadstatic"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
455 menu.addSeparator()
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
456 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
457 self.tr("static - Link to static file"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
458 lambda: self.__applyTemplate("staticfile"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
459 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
460 self.tr("static - Link to static file (via variable)"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
461 lambda: self.__applyTemplate("staticvariable"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
462 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
463 self.tr("get_static_prefix - Insert static URL"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
464 lambda: self.__applyTemplate("get_static_prefix"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
465 menu.addAction(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
466 self.tr("get_media_prefix - Insert media URL"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
467 lambda: self.__applyTemplate("get_media_prefix"))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
468
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
469 self.__staticMenu = menu
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
470 return menu
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
471
9
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
472 def __initCommentsMenu(self):
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
473 """
10
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
474 Private method to initialize the comments menu.
9
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
475
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
476 @return generated menu (QMenu)
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
477 """
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
478 menu = QMenu(self.tr("Comment"))
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
479 menu.addAction(
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
480 self.tr("Single Line Comment Selected Text"),
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
481 lambda: self.__applyTemplate("singlelinecommentselect"))
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
482 menu.addAction(
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
483 self.tr("Multi Line Comment Selected Text"),
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
484 lambda: self.__applyTemplate("multilinecommentselect"))
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
485 menu.addSeparator()
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
486 menu.addAction(
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
487 self.tr("Single Line Comment from Input Dialog"),
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
488 lambda: self.__applyTemplate("singlelinecommentdialog"))
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
489 menu.addAction(
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
490 self.tr("Multi Line Comment from Input Dialog"),
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
491 lambda: self.__applyTemplate("multilinecommentdialog"))
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
492 menu.addSeparator()
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
493 menu.addAction(
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
494 self.tr("Single Line Comment from Clipboard"),
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
495 lambda: self.__applyTemplate("singlelinecommentclipboard"))
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
496 menu.addAction(
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
497 self.tr("Multi Line Comment from Clipboard"),
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
498 lambda: self.__applyTemplate("multilinecommentclipboard"))
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
499 menu.addSeparator()
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
500 menu.addAction(
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
501 self.tr("Multi Line Comment from File"),
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
502 lambda: self.__applyTemplate("multilinecommentfile"))
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
503 menu.addSeparator()
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
504 menu.addAction(
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
505 self.tr("Single Line Comment from Date Time Now"),
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
506 lambda: self.__applyTemplate("singlelinecommentdatetime"))
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
507 menu.addSeparator()
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
508 menu.addAction(
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
509 self.tr("HTML Comment Out Selected Text"),
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
510 lambda: self.__applyTemplate("htmlcomment"))
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
511 menu.addAction(
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
512 self.tr("MS IE Conditional Comment Selected Text"),
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
513 lambda: self.__applyTemplate("iecomment"))
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
514
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
515 self.__commentsMenu = menu
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
516 return menu
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
517
10
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
518 def __initInternationalizationMenu(self):
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
519 """
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
520 Private method to initialize the static menu.
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
521
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
522 @return generated menu (QMenu)
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
523 """
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
524 mainMenu = QMenu(self.tr("Internationalization (i18n)"))
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
525 mainMenu.addAction(
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
526 self.tr("Load Package"),
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
527 lambda: self.__applyTemplate("loadi18n"))
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
528 mainMenu.addSeparator()
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
529
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
530 menu = QMenu(self.tr("Tags"), mainMenu)
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
531 menu.addAction(
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
532 self.tr("trans - Translate String or Variable"),
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
533 lambda: self.__applyTemplate("trans"))
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
534 menu.addAction(
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
535 self.tr("trans..as - Translate String into Variable"),
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
536 lambda: self.__applyTemplate("trans..as"))
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
537 menu.addSeparator()
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
538 menu.addAction(
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
539 self.tr("blocktrans - Translate Block"),
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
540 lambda: self.__applyTemplate("blocktrans"))
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
541 menu.addAction(
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
542 self.tr("blocktrans..with - Translate Block with Attributes"),
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
543 lambda: self.__applyTemplate("blocktrans..with"))
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
544 menu.addAction(
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
545 self.tr("plural - Plural Block"),
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
546 lambda: self.__applyTemplate("plural"))
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
547 menu.addAction(
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
548 self.tr("language - Switch language"),
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
549 lambda: self.__applyTemplate("language"))
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
550 menu.addSeparator()
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
551 menu.addAction(
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
552 self.tr("get_current_language - Current language"),
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
553 lambda: self.__applyTemplate("get_current_language"))
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
554 menu.addAction(
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
555 self.tr("get_available_languages - Available languages"),
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
556 lambda: self.__applyTemplate("get_available_languages"))
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
557 menu.addAction(
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
558 self.tr("get_current_language_bidi - Current language's"
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
559 " direction"),
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
560 lambda: self.__applyTemplate("get_current_language_bidi"))
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
561 menu.addAction(
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
562 self.tr("get_language_info - Language Information"),
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
563 lambda: self.__applyTemplate("get_language_info"))
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
564 menu.addAction(
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
565 self.tr("get_language_info_list - Language Information for a list"
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
566 " of languages"),
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
567 lambda: self.__applyTemplate("get_language_info_list"))
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
568 mainMenu.addMenu(menu)
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
569
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
570 menu = QMenu(self.tr("Filters"), mainMenu)
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
571 menu.addAction(
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
572 self.tr("language_name - Language name"),
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
573 lambda: self.__applyTemplate("language_name"))
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
574 menu.addAction(
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
575 self.tr("language_name_local - Language name translated"),
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
576 lambda: self.__applyTemplate("language_name_local"))
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
577 menu.addAction(
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
578 self.tr("bidi - Language's direction"),
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
579 lambda: self.__applyTemplate("bidi"))
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
580 mainMenu.addMenu(menu)
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
581
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
582 self.__internationalizationMenu = mainMenu
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
583 return mainMenu
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
584
12
8bc18ea91897 Finished the implementation and corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
585 def __initLocalizationMenu(self):
10
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
586 """
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
587 Private method to initialize the static menu.
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
588
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
589 @return generated menu (QMenu)
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
590 """
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
591 mainMenu = QMenu(self.tr("Localization (l10n)"))
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
592 mainMenu.addAction(
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
593 self.tr("Load Package"),
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
594 lambda: self.__applyTemplate("loadl10n"))
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
595 mainMenu.addSeparator()
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
596
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
597 menu = QMenu(self.tr("Tags"), mainMenu)
11
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
598 menu.addAction(
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
599 self.tr("localize on - Activate Localization"),
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
600 lambda: self.__applyTemplate("localize_on"))
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
601 menu.addAction(
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
602 self.tr("localize off - Dectivate Localization"),
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
603 lambda: self.__applyTemplate("localize_off"))
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
604 mainMenu.addMenu(menu)
10
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
605
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
606 menu = QMenu(self.tr("Filters"), mainMenu)
11
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
607 menu.addAction(
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
608 self.tr("localize - Output value localized"),
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
609 lambda: self.__applyTemplate("localize"))
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
610 menu.addAction(
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
611 self.tr("unlocalize - Output value non-localized"),
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
612 lambda: self.__applyTemplate("unlocalize"))
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
613 mainMenu.addMenu(menu)
10
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
614
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
615 self.__localizationMenu = mainMenu
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
616 return mainMenu
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
617
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
618 def __initTimezoneMenu(self):
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
619 """
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
620 Private method to initialize the static menu.
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
621
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
622 @return generated menu (QMenu)
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
623 """
11
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
624 mainMenu = QMenu(self.tr("Timezone (tz)"))
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
625 mainMenu.addAction(
10
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
626 self.tr("Load Package"),
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
627 lambda: self.__applyTemplate("loadtz"))
11
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
628 mainMenu.addSeparator()
10
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
629
11
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
630 menu = QMenu(self.tr("Tags"), mainMenu)
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
631 menu.addAction(
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
632 self.tr("localtime on - Activate date and time conversion"),
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
633 lambda: self.__applyTemplate("localtime_on"))
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
634 menu.addAction(
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
635 self.tr("localtime off - Deactivate date and time conversion"),
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
636 lambda: self.__applyTemplate("localtime_off"))
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
637 menu.addAction(
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
638 self.tr("timezone - Set timezone for date and time conversion"),
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
639 lambda: self.__applyTemplate("timezone_set"))
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
640 menu.addAction(
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
641 self.tr("timezone None - Unset timezone for date and time"
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
642 " conversion"),
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
643 lambda: self.__applyTemplate("timezone_unset"))
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
644 menu.addAction(
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
645 self.tr("get_current_timezone - Get current time zone"),
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
646 lambda: self.__applyTemplate("get_current_timezone"))
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
647 mainMenu.addMenu(menu)
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
648
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
649 menu = QMenu(self.tr("Filters"), mainMenu)
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
650 menu.addAction(
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
651 self.tr("localtime - Convert to local time zone"),
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
652 lambda: self.__applyTemplate("localtime"))
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
653 menu.addAction(
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
654 self.tr("utc - Convert to UTC"),
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
655 lambda: self.__applyTemplate("utc"))
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
656 menu.addAction(
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
657 self.tr("timezone - Convert to a specific time zone"),
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
658 lambda: self.__applyTemplate("timezone"))
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
659 mainMenu.addMenu(menu)
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
660
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
661 self.__timezoneMenu = mainMenu
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
662 return mainMenu
10
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
663
2
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
664 def __findTemplateTag(self):
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
665 """
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
666 Private slot to find a template tag and insert its text.
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
667 """
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
668 if self.__findDialog is None:
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
669 from .FindTemplateTagDialog import FindTemplateTagDialog
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
670 self.__findDialog = FindTemplateTagDialog()
2
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
671 self.__findDialog.tag.connect(self.__applyTemplate)
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
672 self.__findDialog.show()
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
673 self.__findDialog.raise_()
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
674 self.__findDialog.activateWindow()
2
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
675
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
676 def __applyTemplate(self, tag):
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
677 """
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
678 Private slot to generate and insert the template text.
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
679
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
680 @param tag name of the tag to insert (string)
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
681 """
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
682 editor = e5App().getObject("ViewManager").activeWindow()
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
683 if editor is None:
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
684 return
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
685
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
686 templateText, replace = self.__generateTemplateText(
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
687 tag, editor.selectedText())
2
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
688
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
689 if templateText:
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
690 editor.beginUndoAction()
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
691 if replace:
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
692 editor.replaceSelectedText(templateText)
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
693 else:
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
694 editor.insert(templateText)
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
695 editor.endUndoAction()
2
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
696
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
697 def __generateTemplateText(self, tag, selectedText):
2
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
698 """
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
699 Private slot to generate the template text.
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
700
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
701 @param tag name of the tag to insert (string)
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
702 @param selectedText selected text of the current editor (string)
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
703 @return tuple of generated template text (string), a flag indicating
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
704 to perform a replace operation (boolean)
2
4be31b0908c7 Started implementing the tags functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
705 """
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
706 replace = False # safe value
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
707 ok = True
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
708 templateText = ""
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
709
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
710 ####################################################
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
711 ## Template Tags ##
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
712 ####################################################
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
713
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
714 if tag == "autoescape":
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
715 templateText = (
5
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
716 "{{% autoescape on %}} {0} {{% endautoescape %}}".format(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
717 selectedText))
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
718 replace = True
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
719 elif tag == "block":
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
720 data, ok = DjangoTagInputDialog.getText(
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
721 None,
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
722 self.tr("Named Block"),
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
723 [self.tr("Enter block name:")],
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
724 ["block_name"])
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
725 if ok:
5
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
726 templateText = "{{% block {0} %}} {1} {{% endblock %}}".format(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
727 data[0], selectedText)
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
728 replace = True
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
729 elif tag == "comment":
5
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
730 templateText = "{{% comment %}} {0} {{% endcomment %}}".format(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
731 selectedText)
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
732 replace = True
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
733 elif tag == "csrf_token":
5
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
734 templateText = "{% csrf_token %}"
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
735 elif tag == "cycle":
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
736 data, ok = DjangoTagInputDialog.getText(
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
737 None,
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
738 self.tr("Cycle Variables"),
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
739 [self.tr("Enter items to cycle, space separated")],
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
740 ["item1 item2 item3"])
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
741 if ok:
5
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
742 templateText = "{{% cycle {0} %}}".format(data[0])
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
743 elif tag == "debug":
5
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
744 templateText = "{% debug %}"
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
745 elif tag == "extendsvariable":
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
746 data, ok = DjangoTagInputDialog.getText(
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
747 None,
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
748 self.tr("Extends"),
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
749 [self.tr("Enter variable name:")],
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
750 ["variable"])
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
751 if ok:
5
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
752 templateText = "{{% extends {0} %}}".format(data[0])
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
753 elif tag == "extendsfile":
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
754 data, ok = DjangoTagInputDialog.getText(
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
755 None,
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
756 self.tr("Extends"),
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
757 [self.tr("Enter parent file name:")],
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
758 ["base.html"])
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
759 if ok:
5
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
760 templateText = '{{% extends "{0}" %}}'.format(data[0])
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
761 elif tag == "filter":
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
762 data, ok = DjangoTagInputDialog.getText(
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
763 None,
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
764 self.tr("Tag Filters"),
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
765 [self.tr("Multiple filters with arguments, pipes separated:")],
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
766 ["lower|safe"])
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
767 if ok:
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
768 templateText = (
5
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
769 "{{% filter {0} %}} {1} {{% endfilter %}}".format(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
770 data[0], selectedText))
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
771 replace = True
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
772 elif tag == "firstof":
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
773 data, ok = DjangoTagInputDialog.getText(
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
774 None,
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
775 self.tr("First Of"),
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
776 [self.tr("Enter multiple variables, space separated:"),
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
777 self.tr("Enter fallback value:")],
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
778 ["var1 var2", "fallback_value"])
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
779 if ok:
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
780 templateText = (
5
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
781 '{{% filter force_escape %}}{{% firstof {0} "{1}" %}}'
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
782 ' {2} {{% endfilter %}}'.format(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
783 data[0], data[1], selectedText))
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
784 replace = True
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
785 elif tag == "for":
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
786 data, ok = DjangoTagInputDialog.getText(
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
787 None,
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
788 self.tr("For Loop"),
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
789 [self.tr("Enter variable to use for iteration:"),
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
790 self.tr("Enter sequence to iterate over:")],
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
791 ["item", "values"])
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
792 if ok:
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
793 templateText = (
5
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
794 "{{% for {0} in {1} %}} {2} {{% endfor %}}".format(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
795 data[0], data[1], selectedText))
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
796 replace = True
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
797 elif tag == "for...empty":
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
798 data, ok = DjangoTagInputDialog.getText(
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
799 None,
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
800 self.tr("For Loop"),
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
801 [self.tr("Enter variable to use for iteration:"),
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
802 self.tr("Enter sequence to iterate over:"),
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
803 self.tr("Enter output to use if loop is empty:")],
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
804 ["item", "values", '"Nothing."'])
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
805 if ok:
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
806 templateText = (
5
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
807 "{{% for {0} in {1} %}} {2} {{% empty %}} {3}"
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
808 " {{% endfor %}}".format(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
809 data[0], data[1], selectedText, data[2]))
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
810 replace = True
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
811 elif tag == "if":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
812 from .IfTagInputDialog import IfTagInputDialog
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
813 dlg = IfTagInputDialog()
49
ef6c805ae218 Changed calls of exec_() into exec().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 47
diff changeset
814 if dlg.exec() == QDialog.Accepted:
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
815 templateText = dlg.getTag()
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
816 elif tag == "ifchanged":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
817 data, ok = DjangoTagInputDialog.getText(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
818 None,
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
819 self.tr("Check Variables for Changes"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
820 [self.tr("Enter variables to check (space separated):")],
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
821 ["variable1 variable2"])
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
822 if ok:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
823 templateText = (
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
824 '{{% ifchanged {0} %}}{1}{{% endifchanged %}}'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
825 .format(data[0], selectedText))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
826 replace = True
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
827 elif tag == "ifequal":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
828 data, ok = DjangoTagInputDialog.getText(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
829 None,
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
830 self.tr("Check If Equal"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
831 [self.tr("Enter first variable or string to check:"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
832 self.tr("Enter second variable or string to check:")],
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
833 ["user.username", '"adrian"'])
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
834 if ok:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
835 templateText = (
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
836 '{{% ifequal {0} {1} %}}{2}{{% endifequal %}}'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
837 .format(data[0], data[1], selectedText))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
838 replace = True
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
839 elif tag == "ifnotequal":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
840 data, ok = DjangoTagInputDialog.getText(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
841 None,
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
842 self.tr("Check If Not Equal"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
843 [self.tr("Enter first variable or string to check:"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
844 self.tr("Enter second variable or string to check:")],
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
845 ["user.username", '"adrian"'])
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
846 if ok:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
847 templateText = (
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
848 '{{% ifnotequal {0} {1} %}}{2}{{% endifnotequal %}}'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
849 .format(data[0], data[1], selectedText))
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
850 replace = True
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
851 elif tag == "includevariable":
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
852 data, ok = DjangoTagInputDialog.getText(
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
853 None,
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
854 self.tr("Include"),
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
855 [self.tr("Enter variable name:")],
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
856 ["variable"])
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
857 if ok:
5
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
858 templateText = '{{% include {0} %}}'.format(data[0])
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
859 elif tag == "includefile":
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
860 data, ok = DjangoTagInputDialog.getText(
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
861 None,
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
862 self.tr("Include"),
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
863 [self.tr("Enter file name:")],
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
864 ["other.html"])
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
865 if ok:
5
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
866 templateText = '{{% include "{0}" %}}'.format(data[0])
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
867 elif tag == "load":
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
868 data, ok = DjangoTagInputDialog.getText(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
869 None,
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
870 self.tr("Load"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
871 [self.tr("Enter template tag set to load:")],
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
872 ["foo bar"])
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
873 if ok:
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
874 templateText = '{{% load "{0}" %}}'.format(data[0])
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
875 elif tag == "now":
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
876 dateformat, ok = QInputDialog.getItem(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
877 None,
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
878 self.tr("Now"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
879 self.tr("Current date time format:"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
880 ["DATETIME_FORMAT", "SHORT_DATETIME_FORMAT",
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
881 "SHORT_DATE_FORMAT", "DATE_FORMAT"],
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
882 0, False)
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
883 if ok:
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
884 templateText = '{{% now "{0}" %}}'.format(dateformat)
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
885 elif tag == "regroup":
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
886 data, ok = DjangoTagInputDialog.getText(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
887 None,
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
888 self.tr("Regroup List"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
889 [self.tr("List Variable:"), self.tr("Common Attribute:"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
890 self.tr("Name of resulting list:")],
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
891 ["cities", "country", "country_list"])
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
892 if ok:
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
893 templateText = '{{% regroup {0} by {1} as {2} %}}'.format(
6
5f1c0ebbdf5f Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
894 data[0], data[1], data[2])
5
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
895 elif tag == "spaceless":
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
896 templateText = "{{% spaceless %}} {0} {{% endspaceless %}}".format(
6
5f1c0ebbdf5f Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
897 selectedText)
5
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
898 replace = True
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
899 elif tag == "ssi":
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
900 data, ok = DjangoTagInputDialog.getText(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
901 None,
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
902 self.tr("SSI"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
903 [self.tr("Full path to template:")],
47
825bf5861f89 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
904 ["/tmp/ssi_template.html"]) # secok
5
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
905 if ok:
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
906 templateText = '{{% ssi "{0}" parsed %}}'.format(data[0])
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
907 elif tag == "ssifile":
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
908 ssi = E5FileDialog.getOpenFileName(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
909 None,
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
910 self.tr("SSI"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
911 os.path.expanduser("~"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
912 self.tr("All Files (*)"))
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
913 if ssi:
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
914 templateText = '{{% ssi "{0}" parsed %}}'.format(ssi)
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
915 elif tag == "templatetag":
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
916 templatetag, ok = QInputDialog.getItem(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
917 None,
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
918 self.tr("Template Tag"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
919 self.tr("Argument:"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
920 ["block", "variable", "brace", "comment"],
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
921 0, False)
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
922 if ok:
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
923 templateText = (
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
924 '{{% templatetag open{0} %}} {1} {{% templatetag'
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
925 ' close{0} %}}'.format(templatetag, selectedText))
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
926 replace = True
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
927 elif tag == "url":
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
928 data, ok = DjangoTagInputDialog.getText(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
929 None,
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
930 self.tr("URL"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
931 [self.tr("View method name:"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
932 self.tr("Optional arguments (space separated):")],
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
933 ["path.to.some_view", "var1 var2"])
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
934 if ok:
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
935 if data[1]:
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
936 data[1] = ' ' + data[1]
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
937 templateText = '{{% url "{0}"{1} %}}'.format(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
938 data[0], data[1])
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
939 elif tag == "urlas":
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
940 data, ok = DjangoTagInputDialog.getText(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
941 None,
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
942 self.tr("URL...as"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
943 [self.tr("View method name:"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
944 self.tr("Optional arguments (space separated):"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
945 self.tr("URL name:")],
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
946 ["path.to.some_view", "var1 var2", "url_name"])
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
947 if ok:
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
948 if data[1]:
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
949 data[1] = ' ' + data[1]
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
950 templateText = '{{% url "{0}"{1} as {2} %}}'.format(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
951 data[0], data[1], data[2])
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
952 elif tag == "verbatim":
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
953 templateText = "{{% verbatim %}} {0} {{% endverbatim %}}".format(
6
5f1c0ebbdf5f Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
954 selectedText)
5
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
955 replace = True
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
956 elif tag == "widthratio":
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
957 data, ok = DjangoTagInputDialog.getText(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
958 None,
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
959 self.tr("Width Ratio"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
960 [self.tr("Variable:"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
961 self.tr("Maximum Value:"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
962 self.tr("Maximum Width:")],
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
963 ["variable", "max_value", "max_width"])
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
964 if ok:
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
965 templateText = "{{% widthratio {0} {1} {2} %}}".format(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
966 data[0], data[1], data[2])
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
967 elif tag == "with":
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
968 data, ok = DjangoTagInputDialog.getText(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
969 None,
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
970 self.tr("Cache Variables"),
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
971 [self.tr("Variables to cache as key=value (space separated):")
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
972 ],
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
973 ["variable1=foo.bar variable2=bar.baz"])
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
974 if ok:
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
975 templateText = '{{% with {0} %}} {1} {{% endwith %}}'.format(
e2b08694e945 Completed template tags(except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
976 data[0], selectedText)
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
977
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
978 ####################################################
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
979 ## Template Filters ##
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
980 ####################################################
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
981
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
982 elif tag == "add":
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
983 data, ok = DjangoTagInputDialog.getText(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
984 None,
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
985 self.tr("Add Variable or String"),
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
986 [self.tr("Variables or String to add:")],
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
987 ["variable"])
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
988 if ok:
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
989 templateText = "|add:{0}".format(data[0])
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
990 elif tag == "addslashes":
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
991 templateText = "|addslashes"
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
992 elif tag == "capfirst":
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
993 templateText = "|capfirst"
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
994 elif tag == "center":
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
995 width, ok = QInputDialog.getInt(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
996 None,
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
997 self.tr("Center Value"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
998 self.tr("Enter width of the output:"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
999 10, 1, 99, 1)
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1000 if ok:
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1001 templateText = '|center:"{0}"'.format(width)
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1002 elif tag == "cut":
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1003 data, ok = DjangoTagInputDialog.getText(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1004 None,
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1005 self.tr("Cut Characters"),
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1006 [self.tr("Characters to cut:")],
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1007 [" "])
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1008 if ok:
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1009 templateText = '|cut:"{0}"'.format(data[0])
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1010 elif tag == "date":
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1011 date, ok = QInputDialog.getItem(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1012 None,
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1013 self.tr("Format Date"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1014 self.tr("Enter date format:"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1015 ["DATETIME_FORMAT", "SHORT_DATETIME_FORMAT",
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1016 "SHORT_DATE_FORMAT", "DATE_FORMAT"],
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1017 0, True)
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1018 if ok:
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1019 if date:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1020 templateText = '|date:"{0}"'.format(date)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1021 else:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1022 templateText = '|date'
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1023 elif tag == "default":
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1024 data, ok = DjangoTagInputDialog.getText(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1025 None,
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1026 self.tr("Default Value if False"),
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1027 [self.tr("Enter default value if result is False:")],
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1028 ["nothing"])
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1029 if ok:
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1030 templateText = '|default:"{0}"'.format(data[0])
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1031 elif tag == "default_if_none":
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1032 data, ok = DjangoTagInputDialog.getText(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1033 None,
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1034 self.tr("Default Value if None"),
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1035 [self.tr("Enter default value if result is None:")],
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1036 ["nothing"])
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1037 if ok:
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1038 templateText = '|default:"{0}"'.format(data[0])
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1039 elif tag == "dictsort":
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1040 data, ok = DjangoTagInputDialog.getText(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1041 None,
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1042 self.tr("Sort Dictionaries"),
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1043 [self.tr("Enter key to sort on:")],
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1044 ["key"])
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1045 if ok:
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1046 templateText = '|dictsort:"{0}"'.format(data[0])
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1047 elif tag == "dictsortreversed":
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1048 data, ok = DjangoTagInputDialog.getText(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1049 None,
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1050 self.tr("Sort Dictionaries reversed"),
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1051 [self.tr("Enter key to sort on:")],
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1052 ["key"])
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1053 if ok:
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1054 templateText = '|dictsortreversed:"{0}"'.format(data[0])
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1055 elif tag == "divisibleby":
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1056 divisor, ok = QInputDialog.getInt(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1057 None,
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1058 self.tr("Check Divisibility"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1059 self.tr("Enter divisor value:"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1060 2, 1, 99, 1)
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1061 if ok:
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1062 templateText = '|divisibleby:"{0}"'.format(divisor)
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1063 elif tag == "escape":
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1064 templateText = '|escape'
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1065 elif tag == "escapejs":
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1066 templateText = '|escapejs'
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1067 elif tag == "filesizeformat":
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1068 templateText = '|filesizeformat'
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1069 elif tag == "first":
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1070 templateText = '|first'
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1071 elif tag == "fix_ampersands":
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1072 templateText = '|fix_ampersands'
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1073 elif tag == "floatformat":
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1074 decimals, ok = QInputDialog.getInt(
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1075 None,
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1076 self.tr("Format Floating Number"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1077 self.tr("Enter number of decimal places:"),
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1078 2, -20, 20, 1)
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1079 if ok:
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1080 templateText = '|floatformat:"{0}"'.format(decimals)
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1081 elif tag == "force_escape":
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1082 templateText = '|force_escape'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1083 elif tag == "get_digit":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1084 digit, ok = QInputDialog.getInt(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1085 None,
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1086 self.tr("Get Rightmost Digit"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1087 self.tr("Enter index of digit:"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1088 1, 1, 99, 1)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1089 if ok:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1090 templateText = '|get_digit:"{0}"'.format(digit)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1091 elif tag == "iriencode":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1092 templateText = '|iriencode'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1093 elif tag == "join":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1094 data, ok = DjangoTagInputDialog.getText(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1095 None,
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1096 self.tr("Join List"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1097 [self.tr("Enter string to join by:")],
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1098 ["//"])
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1099 if ok:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1100 templateText = '|join:"{0}"'.format(data[0])
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1101 elif tag == "last":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1102 templateText = '|last'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1103 elif tag == "length":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1104 templateText = '|length'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1105 elif tag == "length_is":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1106 length, ok = QInputDialog.getInt(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1107 None,
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1108 self.tr("Check Length"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1109 self.tr("Enter desired length:"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1110 10, 1, 99, 1)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1111 if ok:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1112 templateText = '|length_is:"{0}"'.format(length)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1113 elif tag == "linebreaks":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1114 templateText = '|linebreaks'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1115 elif tag == "linebreaksbr":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1116 templateText = '|linebreaksbr'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1117 elif tag == "linenumbers":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1118 templateText = '|linenumbers'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1119 elif tag == "ljust":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1120 width, ok = QInputDialog.getInt(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1121 None,
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1122 self.tr("Left-align Value"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1123 self.tr("Enter width of the output:"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1124 10, 1, 99, 1)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1125 if ok:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1126 templateText = '|ljust:"{0}"'.format(width)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1127 elif tag == "lower":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1128 templateText = '|lower'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1129 elif tag == "make_list":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1130 templateText = '|make_list'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1131 elif tag == "phone2numeric":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1132 templateText = '|phone2numeric'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1133 elif tag == "pluralize":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1134 data, ok = DjangoTagInputDialog.getText(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1135 None,
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1136 self.tr("Plural Suffix"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1137 [self.tr("Enter plural suffix (nothing for default):")],
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1138 [""])
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1139 if ok:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1140 if data[0]:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1141 templateText = '|pluralize:"{0}"'.format(data[0])
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1142 else:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1143 templateText = '|pluralize'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1144 elif tag == "pprint":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1145 templateText = '|pprint'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1146 elif tag == "random":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1147 templateText = '|random'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1148 elif tag == "removetags":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1149 data, ok = DjangoTagInputDialog.getText(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1150 None,
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1151 self.tr("Remove HTML Tags"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1152 [self.tr("Enter HTML tags to remove (space separated):")],
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1153 ["b span"])
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1154 if ok:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1155 templateText = '|removetags:"{0}"'.format(data[0])
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1156 elif tag == "rjust":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1157 width, ok = QInputDialog.getInt(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1158 None,
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1159 self.tr("Right-align Value"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1160 self.tr("Enter width of the output:"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1161 10, 1, 99, 1)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1162 if ok:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1163 templateText = '|rjust:"{0}"'.format(width)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1164 elif tag == "safe":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1165 templateText = '|safe'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1166 elif tag == "safeseq":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1167 templateText = '|safeseq'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1168 elif tag == "slice":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1169 data, ok = DjangoTagInputDialog.getText(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1170 None,
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1171 self.tr("Extract slice of a list"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1172 [self.tr("Enter Python like slice expression:")],
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1173 ["1:5"])
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1174 if ok:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1175 templateText = '|slice:"{0}"'.format(data[0])
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1176 elif tag == "slugify":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1177 templateText = '|slugify'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1178 elif tag == "stringformat":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1179 data, ok = DjangoTagInputDialog.getText(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1180 None,
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1181 self.tr("Perform String Formatting"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1182 [self.tr("Enter Python like string format:")],
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1183 [""])
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1184 if ok:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1185 templateText = '|stringformat:"{0}"'.format(data[0])
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1186 elif tag == "striptags":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1187 templateText = '|striptags'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1188 elif tag == "time":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1189 time, ok = QInputDialog.getItem(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1190 None,
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1191 self.tr("Format Date"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1192 self.tr("Enter date format:"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1193 ["TIME_FORMAT"],
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1194 0, True)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1195 if ok:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1196 if time:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1197 templateText = '|time:"{0}"'.format(time)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1198 else:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1199 templateText = '|time'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1200 elif tag == "timesince":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1201 data[0], ok = DjangoTagInputDialog.getText(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1202 None,
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1203 self.tr("Time Since"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1204 [self.tr("Enter variable containing time reference:")],
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1205 ["comment_date"])
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1206 if ok:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1207 if data[0]:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1208 templateText = '|timesince:{0}'.format(data[0])
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1209 else:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1210 templateText = '|timesince'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1211 elif tag == "timeuntil":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1212 data[0], ok = DjangoTagInputDialog.getText(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1213 None,
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1214 self.tr("Time Until"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1215 [self.tr("Enter variable containing time reference:")],
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1216 ["from_date"])
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1217 if ok:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1218 if data[0]:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1219 templateText = '|timeuntil:{0}'.format(data[0])
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1220 else:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1221 templateText = '|timeuntil'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1222 elif tag == "title":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1223 templateText = '|title'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1224 elif tag == "truncatechars":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1225 characters, ok = QInputDialog.getInt(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1226 None,
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1227 self.tr("Truncate String"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1228 self.tr("Enter number of characters:"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1229 10, 1, 99, 1)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1230 if ok:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1231 templateText = '|truncatechars:{0}'.format(characters)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1232 elif tag == "truncatewords":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1233 words, ok = QInputDialog.getInt(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1234 None,
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1235 self.tr("Truncate String"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1236 self.tr("Enter number of words:"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1237 10, 1, 99, 1)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1238 if ok:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1239 templateText = '|truncatewords:{0}'.format(words)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1240 elif tag == "truncatewords_html":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1241 words, ok = QInputDialog.getInt(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1242 None,
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1243 self.tr("Truncate String"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1244 self.tr("Enter number of words:"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1245 10, 1, 99, 1)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1246 if ok:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1247 templateText = '|truncatewords_html:{0}'.format(words)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1248 elif tag == "unordered_list":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1249 templateText = '|unordered_list'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1250 elif tag == "upper":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1251 templateText = '|upper'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1252 elif tag == "urlencode":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1253 templateText = '|urlencode'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1254 elif tag == "urlize":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1255 templateText = '|urlize'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1256 elif tag == "urlizetrunc":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1257 characters, ok = QInputDialog.getInt(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1258 None,
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1259 self.tr("Convert URLs as clickable links and truncate"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1260 self.tr("Enter number of characters:"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1261 10, 1, 199, 1)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1262 if ok:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1263 templateText = '|urlizetrunc:{0}'.format(characters)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1264 elif tag == "wordcount":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1265 templateText = '|wordcount'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1266 elif tag == "wordwrap":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1267 characters, ok = QInputDialog.getInt(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1268 None,
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1269 self.tr("Wrap words"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1270 self.tr("Enter number of characters:"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1271 10, 1, 99, 1)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1272 if ok:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1273 templateText = '|wordwrap:{0}'.format(characters)
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1274 elif tag == "yesno":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1275 data, ok = DjangoTagInputDialog.getText(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1276 None,
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1277 self.tr("Map True, False and None"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1278 [self.tr("Enter mapping (comma separated):")],
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1279 ["yeah,no,maybe"])
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1280 if ok:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1281 if data[0]:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1282 templateText = '|yesno:"{0}"'.format(data[0])
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1283 else:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1284 templateText = '|yesno'
7
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1285
8d928ad07c0a Implemented template filters 'a' to 'f'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6
diff changeset
1286 ####################################################
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1287 ## Humanize Template Tags ##
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1288 ####################################################
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1289
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1290 elif tag == "loadhumanize":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1291 templateText = '{% load humanize %}'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1292 elif tag == "apnumber":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1293 templateText = '|apnumber'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1294 elif tag == "intcomma":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1295 templateText = '|intcomma'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1296 elif tag == "intword":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1297 templateText = '|intword'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1298 elif tag == "naturalday":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1299 templateText = '|naturalday'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1300 elif tag == "naturaltime":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1301 templateText = '|naturaltime'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1302 elif tag == "ordinal":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1303 templateText = '|ordinal'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1304
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1305 ####################################################
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1306 ## Web Design Template Tags ##
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1307 ####################################################
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1308
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1309 elif tag == "loadweb":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1310 templateText = '{% load webdesign %}'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1311 elif tag == "lorem":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1312 from .LoremTagInputDialog import LoremTagInputDialog
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1313 dlg = LoremTagInputDialog()
49
ef6c805ae218 Changed calls of exec_() into exec().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 47
diff changeset
1314 if dlg.exec() == QDialog.Accepted:
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1315 templateText = "{{% {0} %}}".format(dlg.getTag())
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1316
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1317 ####################################################
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1318 ## Static Template Tags ##
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1319 ####################################################
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1320
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1321 elif tag == "loadstatic":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1322 templateText = '{% load static %}'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1323 elif tag == "staticfile":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1324 data, ok = DjangoTagInputDialog.getText(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1325 None,
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1326 self.tr("Link to static file"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1327 [self.tr("Enter relative path of static file:")],
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1328 ["images/hi.jpg"])
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1329 if ok:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1330 templateText = '{{% static "{0}" %}}'.format(data[0])
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1331 elif tag == "staticvariable":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1332 data, ok = DjangoTagInputDialog.getText(
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1333 None,
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1334 self.tr("Link to static file"),
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1335 [self.tr("Enter variable containing relative path of"
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1336 " static file:")],
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1337 ["user_stylesheet"])
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1338 if ok:
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1339 templateText = '{{% static {0} %}}'.format(data[0])
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1340 elif tag == "get_static_prefix":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1341 templateText = '{% get_static_prefix %}'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1342 elif tag == "get_media_prefix":
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1343 templateText = '{% get_media_prefix %}'
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1344
9
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1345 ####################################################
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1346 ## Comments ##
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1347 ####################################################
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1348
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1349 elif tag == "singlelinecommentselect":
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1350 templateText = '{{# {0} #}}'.format(selectedText)
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1351 replace = True
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1352 elif tag == "multilinecommentselect":
35
e98f7b5ed394 Bug fixes
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 34
diff changeset
1353 templateText = '{{% comment %}} {0} {{% endcomment %}}'.format(
9
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1354 selectedText)
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1355 replace = True
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1356 elif tag == "singlelinecommentdialog":
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1357 data, ok = DjangoTagInputDialog.getText(
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1358 None,
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1359 self.tr("Single Line Comment"),
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1360 [self.tr("Enter comment:")],
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1361 [""])
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1362 if ok:
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1363 templateText = '{{# {0} #}}'.format(data[0])
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1364 elif tag == "multilinecommentdialog":
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1365 from .MultiLineInputDialog import MultiLineInputDialog
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1366 comment, ok = MultiLineInputDialog.getText(
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1367 None, self.tr("Multi Line Comment"),
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1368 self.tr("Enter comment:"), "")
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1369 if ok:
35
e98f7b5ed394 Bug fixes
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 34
diff changeset
1370 templateText = '{{% comment %}} {0} {{% endcomment %}}'.format(
9
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1371 comment)
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1372 elif tag == "singlelinecommentclipboard":
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1373 templateText = '{{# {0} #}}'.format(
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1374 QApplication.clipboard().text().strip())
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1375 elif tag == "multilinecommentclipboard":
35
e98f7b5ed394 Bug fixes
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 34
diff changeset
1376 templateText = '{{% comment %}} {0} {{% endcomment %}}'.format(
9
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1377 QApplication.clipboard().text().strip())
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1378 elif tag == "multilinecommentfile":
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1379 filename = E5FileDialog.getOpenFileName(
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1380 None,
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1381 self.tr("Comment File"),
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1382 Utilities.getHomeDir(),
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1383 self.tr("All Files (*)"))
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1384 if filename:
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1385 try:
49
ef6c805ae218 Changed calls of exec_() into exec().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 47
diff changeset
1386 with open(filename, "r", encoding="utf-8") as f:
ef6c805ae218 Changed calls of exec_() into exec().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 47
diff changeset
1387 comment = f.read()
9
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1388 templateText = (
35
e98f7b5ed394 Bug fixes
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 34
diff changeset
1389 '{{% comment %}} {0} {{% endcomment %}}'.format(
9
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1390 comment))
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1391 except (IOError, OSError) as err:
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1392 E5MessageBox.critical(
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1393 None,
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1394 self.tr("Comment File"),
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1395 self.tr("""<p>The file <b>{0}</b> could not be"""
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1396 """ read.</p><p>Reason: {1}</p>""").format(
10
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1397 str(err)))
9
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1398 elif tag == "singlelinecommentdatetime":
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1399 templateText = '{{# {0} by {1} #}}'.format(
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1400 datetime.datetime.now().isoformat().split(),
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1401 Utilities.getUserName())
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1402 elif tag == "htmlcomment":
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1403 templateText = '<!-- {0} -->'.format(selectedText)
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1404 replace = True
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1405 elif tag == "iecomment":
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1406 from .IeCommentDialog import IeCommentDialog
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1407 tag, ok = IeCommentDialog.getTag(selectedText)
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1408 if ok:
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1409 templateText = '<!--{0}-->'.format(tag)
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1410 replace = True
1b11bf54b3b2 Implemented the comments menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8
diff changeset
1411
10
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1412 ####################################################
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1413 ## Internationalization ##
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1414 ####################################################
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1415
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1416 elif tag == "loadi18n":
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1417 templateText = '{% load i18n %}'
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1418 ## Tags ##
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1419 elif tag == "trans":
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1420 if ' ' in selectedText:
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1421 selectedText = '"{0}"'.format(selectedText)
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1422 templateText = '{{% trans {0} %}}'.format(selectedText)
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1423 replace = True
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1424 elif tag == "trans..as":
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1425 data, ok = DjangoTagInputDialog.getText(
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1426 None,
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1427 self.tr("Translate String into Variable"),
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1428 [self.tr("Enter variable receiving translation:")],
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1429 ["translation"])
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1430 if ok:
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1431 templateText = '{{% trans "{0}" as {1} %}}'.format(
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1432 selectedText, data[0])
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1433 replace = True
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1434 elif tag == "blocktrans":
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1435 templateText = '{{% blocktrans %}}{0}{{% endblocktrans %}}'.format(
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1436 selectedText)
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1437 replace = True
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1438 elif tag == "blocktrans..with":
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1439 data, ok = DjangoTagInputDialog.getText(
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1440 None,
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1441 self.tr("Translate Block with Attributes"),
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1442 [self.tr("Enter attribute binding expressions"
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1443 " (space separated):")],
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1444 ["myvar1=value1 myvar2=value2"])
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1445 if ok:
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1446 templateText = (
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1447 '{{% blocktrans with {0} %}}{1}{{% endblocktrans %}}'
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1448 .format(data[0], selectedText))
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1449 replace = True
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1450 elif tag == "plural":
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1451 templateText = '{{% plural %}} {0}'.format(selectedText)
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1452 replace = True
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1453 elif tag == "language":
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1454 data, ok = DjangoTagInputDialog.getText(
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1455 None,
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1456 self.tr("Switch language"),
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1457 [self.tr("Enter language:")],
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1458 ["en"])
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1459 if ok:
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1460 templateText = (
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1461 "{{% language '{0}' %}}{1}{{% endlanguage %}}"
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1462 .format(data[0], selectedText))
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1463 replace = True
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1464 elif tag == "get_current_language":
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1465 templateText = '{% get_current_language as LANGUAGE_CODE %}'
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1466 elif tag == "get_available_languages":
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1467 templateText = '{% get_available_languages as LANGUAGES %}'
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1468 elif tag == "get_current_language_bidi":
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1469 templateText = '{% get_current_language_bidi as LANGUAGE_BIDI %}'
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1470 elif tag == "get_language_info":
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1471 data, ok = DjangoTagInputDialog.getText(
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1472 None,
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1473 self.tr("Language Information"),
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1474 [self.tr("Enter language string or variable (empty for"
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1475 " LANGUAGE_CODE):")],
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1476 ['"en"'])
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1477 if ok:
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1478 if data[0]:
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1479 templateText = (
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1480 '{{% get_language_info for "{0}" as lang %}}'
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1481 .format(data[0]))
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1482 else:
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1483 templateText = ("{% get_language_info for LANGUAGE_CODE"
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1484 " as lang %}")
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1485 elif tag == "get_language_info_list":
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1486 data, ok = DjangoTagInputDialog.getText(
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1487 None,
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1488 self.tr("Language Information for a list of languages"),
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1489 [self.tr("Enter language list variable (empty for"
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1490 " LANGUAGES):")],
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1491 ["available_languages"])
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1492 if ok:
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1493 if data[0]:
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1494 templateText = (
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1495 '{{% get_language_info_list for {0} as langs %}}'
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1496 .format(data[0]))
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1497 else:
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1498 templateText = ("{% get_language_info_list for LANGUAGES"
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1499 " as langs %}")
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1500 ## Filters ##
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1501 elif tag == "language_name":
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1502 templateText = '|language_name'
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1503 elif tag == "language_name_local":
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1504 templateText = '|language_name_local'
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1505 elif tag == "bidi":
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1506 templateText = '|bidi'
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1507
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1508 ####################################################
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1509 ## Localization ##
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1510 ####################################################
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1511
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1512 elif tag == "loadl10n":
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1513 templateText = '{% load l10n %}'
11
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1514 ## Tags ##
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1515 elif tag == "localize_on":
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1516 templateText = '{{% localize on %}}{0}{{% endlocalize %}}'.format(
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1517 selectedText)
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1518 replace = True
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1519 elif tag == "localize_off":
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1520 templateText = '{{% localize off %}}{0}{{% endlocalize %}}'.format(
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1521 selectedText)
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1522 replace = True
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1523 ## Filters ##
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1524 elif tag == "localize":
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1525 templateText = '|localize'
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1526 elif tag == "unlocalize":
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1527 templateText = '|unlocalize'
10
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1528
8
7e8f788fe340 Finished the filter tags and implemented the 'humanize', 'web design' and 'static' tags and the various 'if' tags.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1529 ####################################################
10
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1530 ## Timezone ##
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1531 ####################################################
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1532
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1533 elif tag == "loadtz":
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1534 templateText = '{% load tz %}'
11
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1535 ## Tags ##
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1536 elif tag == "localtime_on":
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1537 templateText = (
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1538 '{{% localtime on %}}{0}{{% endlocaltime %}}'.format(
12
8bc18ea91897 Finished the implementation and corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
1539 selectedText))
11
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1540 replace = True
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1541 elif tag == "localtime_off":
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1542 templateText = (
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1543 '{{% localtime off %}}{0}{{% endlocaltime %}}'.format(
12
8bc18ea91897 Finished the implementation and corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
1544 selectedText))
11
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1545 replace = True
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1546 elif tag == "timezone_set":
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1547 from .TimezoneSelectionDialog import TimezoneSelectionDialog
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1548 timezone, ok = TimezoneSelectionDialog.getTimezone()
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1549 if ok:
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1550 templateText = (
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1551 '{{% timezone "{0}" %}}{1}{{% endtimezone %}}'.format(
12
8bc18ea91897 Finished the implementation and corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
1552 timezone, selectedText))
11
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1553 replace = True
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1554 elif tag == "timezone_unset":
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1555 templateText = (
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1556 '{{% timezone None %}}{0}{{% endlocaltime %}}'.format(
12
8bc18ea91897 Finished the implementation and corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
1557 selectedText))
11
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1558 replace = True
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1559 elif tag == "get_current_timezone":
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1560 templateText = '{% get_current_timezone as TIME_ZONE %}'
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1561 ## Filters ##
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1562 elif tag == "localtime":
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1563 templateText = '|localtime'
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1564 elif tag == "utc":
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1565 templateText = '|utc'
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1566 elif tag == "timezone":
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1567 from .TimezoneSelectionDialog import TimezoneSelectionDialog
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1568 timezone, ok = TimezoneSelectionDialog.getTimezone()
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1569 if ok:
7e3e1ee102c5 Implemented the localization and timezone menus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
1570 templateText = '|timezone:"{0}"'.format(timezone)
10
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1571
ef5694c0bf3a Implemented the 'internatinalization' menu and some Python2 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9
diff changeset
1572 ####################################################
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1573 ## Fallback: return just the tag name ##
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1574 ####################################################
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1575
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1576 else:
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1577 templateText = tag
4
ba04ed0b14a1 Implemented template tags 'f' to 'i' (except 'if').
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
1578
3
6d10c1249cb8 Implemented template tags 'a' to 'e'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
1579 return templateText, replace

eric ide

mercurial