ProjectDjangoTagsMenu/DjangoTagsMenuHandler.py

Wed, 01 Jan 2020 11:58:57 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 01 Jan 2020 11:58:57 +0100
changeset 44
3ea572ed13b6
parent 40
5f7149b13d6f
child 47
825bf5861f89
permissions
-rw-r--r--

Updated copyright for 2020.

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

eric ide

mercurial