ProjectDjangoTagsMenu/DjangoTagsMenuHandler.py

Sun, 30 May 2021 11:51:44 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 30 May 2021 11:51:44 +0200
branch
eric7
changeset 55
5390ef66c327
parent 52
c264091162a2
child 60
85d3931419d3
permissions
-rw-r--r--

Ported the plug-in to PyQt6 for eric7.

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

eric ide

mercurial