224 lambda: self.__applyTemplate("floatformat")) |
238 lambda: self.__applyTemplate("floatformat")) |
225 menu.addAction( |
239 menu.addAction( |
226 self.tr("force_escape - Escape as HTML immediately"), |
240 self.tr("force_escape - Escape as HTML immediately"), |
227 lambda: self.__applyTemplate("force_escape")) |
241 lambda: self.__applyTemplate("force_escape")) |
228 menu.addSeparator() |
242 menu.addSeparator() |
|
243 menu.addAction( |
|
244 self.tr("get_digit - Extract rightmost digit"), |
|
245 lambda: self.__applyTemplate("get_digit")) |
|
246 menu.addSeparator() |
|
247 menu.addAction( |
|
248 self.tr("iriencode - Convert IRI to string"), |
|
249 lambda: self.__applyTemplate("iriencode")) |
|
250 menu.addSeparator() |
|
251 menu.addAction( |
|
252 self.tr("join - Join list"), |
|
253 lambda: self.__applyTemplate("join")) |
|
254 menu.addSeparator() |
|
255 menu.addAction( |
|
256 self.tr("last - Return last item in list"), |
|
257 lambda: self.__applyTemplate("last")) |
|
258 menu.addAction( |
|
259 self.tr("length - Return length of the value"), |
|
260 lambda: self.__applyTemplate("length")) |
|
261 menu.addAction( |
|
262 self.tr("length_is - Check length"), |
|
263 lambda: self.__applyTemplate("length_is")) |
|
264 menu.addAction( |
|
265 self.tr("linebreaks - Replace line breaks with HTML"), |
|
266 lambda: self.__applyTemplate("linebreaks")) |
|
267 menu.addAction( |
|
268 self.tr("linebreaksbr - Replace line breaks with <br/>"), |
|
269 lambda: self.__applyTemplate("linebreaksbr")) |
|
270 menu.addAction( |
|
271 self.tr("linenumbers - Display text with line numbers"), |
|
272 lambda: self.__applyTemplate("linenumbers")) |
|
273 menu.addAction( |
|
274 self.tr("ljust - Left-align value"), |
|
275 lambda: self.__applyTemplate("ljust")) |
|
276 menu.addAction( |
|
277 self.tr("lower - Convert to lowercase"), |
|
278 lambda: self.__applyTemplate("lower")) |
|
279 menu.addSeparator() |
|
280 menu.addAction( |
|
281 self.tr("make_list - Turn value into a list"), |
|
282 lambda: self.__applyTemplate("make_list")) |
|
283 menu.addSeparator() |
|
284 menu.addAction( |
|
285 self.tr("phone2numeric - Convert phone number into numeric"), |
|
286 lambda: self.__applyTemplate("phone2numeric")) |
|
287 menu.addAction( |
|
288 self.tr("pluralize - Return plural suffix"), |
|
289 lambda: self.__applyTemplate("pluralize")) |
|
290 menu.addAction( |
|
291 self.tr("pprint - Pretty Print"), |
|
292 lambda: self.__applyTemplate("pprint")) |
|
293 menu.addSeparator() |
|
294 menu.addAction( |
|
295 self.tr("random - Return random item from list"), |
|
296 lambda: self.__applyTemplate("random")) |
|
297 menu.addAction( |
|
298 self.tr("removetags - Remove HTML tags"), |
|
299 lambda: self.__applyTemplate("removetags")) |
|
300 menu.addAction( |
|
301 self.tr("rjust - Right-align value"), |
|
302 lambda: self.__applyTemplate("rjust")) |
|
303 menu.addSeparator() |
|
304 menu.addAction( |
|
305 self.tr("safe - Mark as not requiring HTML escaping "), |
|
306 lambda: self.__applyTemplate("safe")) |
|
307 menu.addAction( |
|
308 self.tr("safeseq - Mark as a safe sequence"), |
|
309 lambda: self.__applyTemplate("safeseq")) |
|
310 menu.addAction( |
|
311 self.tr("slice - Return a slice of a list"), |
|
312 lambda: self.__applyTemplate("slice")) |
|
313 menu.addAction( |
|
314 self.tr("slugify - Return value slugified"), |
|
315 lambda: self.__applyTemplate("slugify")) |
|
316 menu.addAction( |
|
317 self.tr("stringformat - Format variable"), |
|
318 lambda: self.__applyTemplate("stringformat")) |
|
319 menu.addAction( |
|
320 self.tr("striptags - Strip all HTML tags"), |
|
321 lambda: self.__applyTemplate("striptags")) |
|
322 menu.addSeparator() |
|
323 menu.addAction( |
|
324 self.tr("time - Format time"), |
|
325 lambda: self.__applyTemplate("time")) |
|
326 menu.addAction( |
|
327 self.tr("timesince - Format as time since"), |
|
328 lambda: self.__applyTemplate("timesince")) |
|
329 menu.addAction( |
|
330 self.tr("timeuntil - Format as time until"), |
|
331 lambda: self.__applyTemplate("timeuntil")) |
|
332 menu.addAction( |
|
333 self.tr("title - Convert to titlecase"), |
|
334 lambda: self.__applyTemplate("title")) |
|
335 menu.addAction( |
|
336 self.tr("truncatechars - Truncate after a number of characters"), |
|
337 lambda: self.__applyTemplate("truncatechars")) |
|
338 menu.addAction( |
|
339 self.tr("truncatewords - Truncate after a number of words"), |
|
340 lambda: self.__applyTemplate("truncatewords")) |
|
341 menu.addAction( |
|
342 self.tr("truncatewords_html - Truncate after a number of words" |
|
343 " (HTML aware)"), |
|
344 lambda: self.__applyTemplate("truncatewords_html")) |
|
345 menu.addSeparator() |
|
346 menu.addAction( |
|
347 self.tr("unordered_list - Return HTML unordered list"), |
|
348 lambda: self.__applyTemplate("unordered_list")) |
|
349 menu.addAction( |
|
350 self.tr("upper - Convert to uppercase"), |
|
351 lambda: self.__applyTemplate("upper")) |
|
352 menu.addAction( |
|
353 self.tr("urlencode - Escape as URL"), |
|
354 lambda: self.__applyTemplate("urlencode")) |
|
355 menu.addAction( |
|
356 self.tr("urlize - Convert URLs as clickable links"), |
|
357 lambda: self.__applyTemplate("urlize")) |
|
358 menu.addAction( |
|
359 self.tr("urlizetrunc - Convert URLs as clickable links and" |
|
360 " truncate"), |
|
361 lambda: self.__applyTemplate("urlizetrunc")) |
|
362 menu.addSeparator() |
|
363 menu.addAction( |
|
364 self.tr("wordcount - Return number of word"), |
|
365 lambda: self.__applyTemplate("wordcount")) |
|
366 menu.addAction( |
|
367 self.tr("wordwrap - Wrap words"), |
|
368 lambda: self.__applyTemplate("wordwrap")) |
|
369 menu.addSeparator() |
|
370 menu.addAction( |
|
371 self.tr("yesno - Map True, False and None"), |
|
372 lambda: self.__applyTemplate("yesno")) |
229 |
373 |
230 self.__filtersMenu = menu |
374 self.__filtersMenu = menu |
|
375 return menu |
|
376 |
|
377 def __initHumanizeMenu(self): |
|
378 """ |
|
379 Private method to initialize the humanize menu. |
|
380 |
|
381 @return generated menu (QMenu) |
|
382 """ |
|
383 menu = QMenu(self.tr("Humanize")) |
|
384 menu.addAction( |
|
385 self.tr("Load Package"), |
|
386 lambda: self.__applyTemplate("loadhumanize")) |
|
387 menu.addSeparator() |
|
388 menu.addAction( |
|
389 self.tr("apnumber - Format integer the Associated Press style"), |
|
390 lambda: self.__applyTemplate("apnumber")) |
|
391 menu.addSeparator() |
|
392 menu.addAction( |
|
393 self.tr("intcomma - Format integer with commas"), |
|
394 lambda: self.__applyTemplate("intcomma")) |
|
395 menu.addAction( |
|
396 self.tr("intword - Convert integer to word"), |
|
397 lambda: self.__applyTemplate("intword")) |
|
398 menu.addSeparator() |
|
399 menu.addAction( |
|
400 self.tr("naturalday - Format date naturally"), |
|
401 lambda: self.__applyTemplate("naturalday")) |
|
402 menu.addAction( |
|
403 self.tr("naturaltime - Format time naturally"), |
|
404 lambda: self.__applyTemplate("naturaltime")) |
|
405 menu.addSeparator() |
|
406 menu.addAction( |
|
407 self.tr("ordinal - Convert integer to ordinal"), |
|
408 lambda: self.__applyTemplate("ordinal")) |
|
409 |
|
410 self.__humanizeMenu = menu |
|
411 return menu |
|
412 |
|
413 def __initWebDesignMenu(self): |
|
414 """ |
|
415 Private method to initialize the web design menu. |
|
416 |
|
417 @return generated menu (QMenu) |
|
418 """ |
|
419 menu = QMenu(self.tr("Web Design")) |
|
420 menu.addAction( |
|
421 self.tr("Load Package"), |
|
422 lambda: self.__applyTemplate("loadweb")) |
|
423 menu.addSeparator() |
|
424 menu.addAction( |
|
425 self.tr("lorem - Builtin Lorem Impsum Generator"), |
|
426 lambda: self.__applyTemplate("lorem")) |
|
427 |
|
428 self.__webMenu = menu |
|
429 return menu |
|
430 |
|
431 def __initStaticMenu(self): |
|
432 """ |
|
433 Private method to initialize the static menu. |
|
434 |
|
435 @return generated menu (QMenu) |
|
436 """ |
|
437 menu = QMenu(self.tr("Static")) |
|
438 menu.addAction( |
|
439 self.tr("Load Package"), |
|
440 lambda: self.__applyTemplate("loadstatic")) |
|
441 menu.addSeparator() |
|
442 menu.addAction( |
|
443 self.tr("static - Link to static file"), |
|
444 lambda: self.__applyTemplate("staticfile")) |
|
445 menu.addAction( |
|
446 self.tr("static - Link to static file (via variable)"), |
|
447 lambda: self.__applyTemplate("staticvariable")) |
|
448 menu.addAction( |
|
449 self.tr("get_static_prefix - Insert static URL"), |
|
450 lambda: self.__applyTemplate("get_static_prefix")) |
|
451 menu.addAction( |
|
452 self.tr("get_media_prefix - Insert media URL"), |
|
453 lambda: self.__applyTemplate("get_media_prefix")) |
|
454 |
|
455 self.__staticMenu = menu |
231 return menu |
456 return menu |
232 |
457 |
233 def __findTemplateTag(self): |
458 def __findTemplateTag(self): |
234 """ |
459 """ |
235 Private slot to find a template tag and insert its text. |
460 Private slot to find a template tag and insert its text. |
546 self.tr("Enter date format:"), |
808 self.tr("Enter date format:"), |
547 ["DATETIME_FORMAT", "SHORT_DATETIME_FORMAT", |
809 ["DATETIME_FORMAT", "SHORT_DATETIME_FORMAT", |
548 "SHORT_DATE_FORMAT", "DATE_FORMAT"], |
810 "SHORT_DATE_FORMAT", "DATE_FORMAT"], |
549 0, True) |
811 0, True) |
550 if ok: |
812 if ok: |
551 templateText = '|date:"{0}" '.format(date) |
813 if date: |
|
814 templateText = '|date:"{0}"'.format(date) |
|
815 else: |
|
816 templateText = '|date' |
552 elif tag == "default": |
817 elif tag == "default": |
553 data, ok = DjangoTagInputDialog.getText( |
818 data, ok = DjangoTagInputDialog.getText( |
554 None, |
819 None, |
555 self.tr("Default Value if False"), |
820 self.tr("Default Value if False"), |
556 [self.tr("Enter default value if result is False:") |
821 [self.tr("Enter default value if result is False:")], |
557 ], |
|
558 ["nothing"]) |
822 ["nothing"]) |
559 if ok: |
823 if ok: |
560 templateText = '|default:"{0}" '.format(data[0]) |
824 templateText = '|default:"{0}"'.format(data[0]) |
561 elif tag == "default_if_none": |
825 elif tag == "default_if_none": |
562 data, ok = DjangoTagInputDialog.getText( |
826 data, ok = DjangoTagInputDialog.getText( |
563 None, |
827 None, |
564 self.tr("Default Value if None"), |
828 self.tr("Default Value if None"), |
565 [self.tr("Enter default value if result is None:") |
829 [self.tr("Enter default value if result is None:")], |
566 ], |
|
567 ["nothing"]) |
830 ["nothing"]) |
568 if ok: |
831 if ok: |
569 templateText = '|default:"{0}" '.format(data[0]) |
832 templateText = '|default:"{0}"'.format(data[0]) |
570 elif tag == "dictsort": |
833 elif tag == "dictsort": |
571 data, ok = DjangoTagInputDialog.getText( |
834 data, ok = DjangoTagInputDialog.getText( |
572 None, |
835 None, |
573 self.tr("Sort Dictionaries"), |
836 self.tr("Sort Dictionaries"), |
574 [self.tr("Enter key to sort on:") |
837 [self.tr("Enter key to sort on:")], |
575 ], |
|
576 ["key"]) |
838 ["key"]) |
577 if ok: |
839 if ok: |
578 templateText = '|dictsort:"{0}" '.format(data[0]) |
840 templateText = '|dictsort:"{0}"'.format(data[0]) |
579 elif tag == "dictsortreversed": |
841 elif tag == "dictsortreversed": |
580 data, ok = DjangoTagInputDialog.getText( |
842 data, ok = DjangoTagInputDialog.getText( |
581 None, |
843 None, |
582 self.tr("Sort Dictionaries reversed"), |
844 self.tr("Sort Dictionaries reversed"), |
583 [self.tr("Enter key to sort on:") |
845 [self.tr("Enter key to sort on:")], |
584 ], |
|
585 ["key"]) |
846 ["key"]) |
586 if ok: |
847 if ok: |
587 templateText = '|dictsortreversed:"{0}" '.format(data[0]) |
848 templateText = '|dictsortreversed:"{0}"'.format(data[0]) |
588 elif tag == "divisibleby": |
849 elif tag == "divisibleby": |
589 divisor, ok = QInputDialog.getInt( |
850 divisor, ok = QInputDialog.getInt( |
590 None, |
851 None, |
591 self.tr("Check Divisibility"), |
852 self.tr("Check Divisibility"), |
592 self.tr("Enter divisor value:"), |
853 self.tr("Enter divisor value:"), |
593 2, 1, 99, 1) |
854 2, 1, 99, 1) |
594 if ok: |
855 if ok: |
595 templateText = '|divisibleby:"{0}" '.format(divisor) |
856 templateText = '|divisibleby:"{0}"'.format(divisor) |
596 elif tag == "escape": |
857 elif tag == "escape": |
597 templateText = '|escape ' |
858 templateText = '|escape' |
598 elif tag == "escapejs": |
859 elif tag == "escapejs": |
599 templateText = '|escapejs ' |
860 templateText = '|escapejs' |
600 elif tag == "filesizeformat": |
861 elif tag == "filesizeformat": |
601 templateText = '|filesizeformat ' |
862 templateText = '|filesizeformat' |
602 elif tag == "first": |
863 elif tag == "first": |
603 templateText = '|first ' |
864 templateText = '|first' |
604 elif tag == "fix_ampersands": |
865 elif tag == "fix_ampersands": |
605 templateText = '|fix_ampersands ' |
866 templateText = '|fix_ampersands' |
606 elif tag == "floatformat": |
867 elif tag == "floatformat": |
607 decimals, ok = QInputDialog.getInt( |
868 decimals, ok = QInputDialog.getInt( |
608 None, |
869 None, |
609 self.tr("Format Floating Number"), |
870 self.tr("Format Floating Number"), |
610 self.tr("Enter number of decimal places:"), |
871 self.tr("Enter number of decimal places:"), |
611 2, -20, 20, 1) |
872 2, -20, 20, 1) |
612 if ok: |
873 if ok: |
613 templateText = '|floatformat:"{0}" '.format(decimals) |
874 templateText = '|floatformat:"{0}"'.format(decimals) |
614 elif tag == "force_escape": |
875 elif tag == "force_escape": |
615 templateText = '|force_escape ' |
876 templateText = '|force_escape' |
616 |
877 elif tag == "get_digit": |
|
878 digit, ok = QInputDialog.getInt( |
|
879 None, |
|
880 self.tr("Get Rightmost Digit"), |
|
881 self.tr("Enter index of digit:"), |
|
882 1, 1, 99, 1) |
|
883 if ok: |
|
884 templateText = '|get_digit:"{0}"'.format(digit) |
|
885 elif tag == "iriencode": |
|
886 templateText = '|iriencode' |
|
887 elif tag == "join": |
|
888 data, ok = DjangoTagInputDialog.getText( |
|
889 None, |
|
890 self.tr("Join List"), |
|
891 [self.tr("Enter string to join by:")], |
|
892 ["//"]) |
|
893 if ok: |
|
894 templateText = '|join:"{0}"'.format(data[0]) |
|
895 elif tag == "last": |
|
896 templateText = '|last' |
|
897 elif tag == "length": |
|
898 templateText = '|length' |
|
899 elif tag == "length_is": |
|
900 length, ok = QInputDialog.getInt( |
|
901 None, |
|
902 self.tr("Check Length"), |
|
903 self.tr("Enter desired length:"), |
|
904 10, 1, 99, 1) |
|
905 if ok: |
|
906 templateText = '|length_is:"{0}"'.format(length) |
|
907 elif tag == "linebreaks": |
|
908 templateText = '|linebreaks' |
|
909 elif tag == "linebreaksbr": |
|
910 templateText = '|linebreaksbr' |
|
911 elif tag == "linenumbers": |
|
912 templateText = '|linenumbers' |
|
913 elif tag == "ljust": |
|
914 width, ok = QInputDialog.getInt( |
|
915 None, |
|
916 self.tr("Left-align Value"), |
|
917 self.tr("Enter width of the output:"), |
|
918 10, 1, 99, 1) |
|
919 if ok: |
|
920 templateText = '|ljust:"{0}"'.format(width) |
|
921 elif tag == "lower": |
|
922 templateText = '|lower' |
|
923 elif tag == "make_list": |
|
924 templateText = '|make_list' |
|
925 elif tag == "phone2numeric": |
|
926 templateText = '|phone2numeric' |
|
927 elif tag == "pluralize": |
|
928 data, ok = DjangoTagInputDialog.getText( |
|
929 None, |
|
930 self.tr("Plural Suffix"), |
|
931 [self.tr("Enter plural suffix (nothing for default):")], |
|
932 [""]) |
|
933 if ok: |
|
934 if data[0]: |
|
935 templateText = '|pluralize:"{0}"'.format(data[0]) |
|
936 else: |
|
937 templateText = '|pluralize' |
|
938 elif tag == "pprint": |
|
939 templateText = '|pprint' |
|
940 elif tag == "random": |
|
941 templateText = '|random' |
|
942 elif tag == "removetags": |
|
943 data, ok = DjangoTagInputDialog.getText( |
|
944 None, |
|
945 self.tr("Remove HTML Tags"), |
|
946 [self.tr("Enter HTML tags to remove (space separated):")], |
|
947 ["b span"]) |
|
948 if ok: |
|
949 templateText = '|removetags:"{0}"'.format(data[0]) |
|
950 elif tag == "rjust": |
|
951 width, ok = QInputDialog.getInt( |
|
952 None, |
|
953 self.tr("Right-align Value"), |
|
954 self.tr("Enter width of the output:"), |
|
955 10, 1, 99, 1) |
|
956 if ok: |
|
957 templateText = '|rjust:"{0}"'.format(width) |
|
958 elif tag == "safe": |
|
959 templateText = '|safe' |
|
960 elif tag == "safeseq": |
|
961 templateText = '|safeseq' |
|
962 elif tag == "slice": |
|
963 data, ok = DjangoTagInputDialog.getText( |
|
964 None, |
|
965 self.tr("Extract slice of a list"), |
|
966 [self.tr("Enter Python like slice expression:")], |
|
967 ["1:5"]) |
|
968 if ok: |
|
969 templateText = '|slice:"{0}"'.format(data[0]) |
|
970 elif tag == "slugify": |
|
971 templateText = '|slugify' |
|
972 elif tag == "stringformat": |
|
973 data, ok = DjangoTagInputDialog.getText( |
|
974 None, |
|
975 self.tr("Perform String Formatting"), |
|
976 [self.tr("Enter Python like string format:")], |
|
977 [""]) |
|
978 if ok: |
|
979 templateText = '|stringformat:"{0}"'.format(data[0]) |
|
980 elif tag == "striptags": |
|
981 templateText = '|striptags' |
|
982 elif tag == "time": |
|
983 time, ok = QInputDialog.getItem( |
|
984 None, |
|
985 self.tr("Format Date"), |
|
986 self.tr("Enter date format:"), |
|
987 ["TIME_FORMAT"], |
|
988 0, True) |
|
989 if ok: |
|
990 if time: |
|
991 templateText = '|time:"{0}"'.format(time) |
|
992 else: |
|
993 templateText = '|time' |
|
994 elif tag == "timesince": |
|
995 data[0], ok = DjangoTagInputDialog.getText( |
|
996 None, |
|
997 self.tr("Time Since"), |
|
998 [self.tr("Enter variable containing time reference:")], |
|
999 ["comment_date"]) |
|
1000 if ok: |
|
1001 if data[0]: |
|
1002 templateText = '|timesince:{0}'.format(data[0]) |
|
1003 else: |
|
1004 templateText = '|timesince' |
|
1005 elif tag == "timeuntil": |
|
1006 data[0], ok = DjangoTagInputDialog.getText( |
|
1007 None, |
|
1008 self.tr("Time Until"), |
|
1009 [self.tr("Enter variable containing time reference:")], |
|
1010 ["from_date"]) |
|
1011 if ok: |
|
1012 if data[0]: |
|
1013 templateText = '|timeuntil:{0}'.format(data[0]) |
|
1014 else: |
|
1015 templateText = '|timeuntil' |
|
1016 elif tag == "title": |
|
1017 templateText = '|title' |
|
1018 elif tag == "truncatechars": |
|
1019 characters, ok = QInputDialog.getInt( |
|
1020 None, |
|
1021 self.tr("Truncate String"), |
|
1022 self.tr("Enter number of characters:"), |
|
1023 10, 1, 99, 1) |
|
1024 if ok: |
|
1025 templateText = '|truncatechars:{0}'.format(characters) |
|
1026 elif tag == "truncatewords": |
|
1027 words, ok = QInputDialog.getInt( |
|
1028 None, |
|
1029 self.tr("Truncate String"), |
|
1030 self.tr("Enter number of words:"), |
|
1031 10, 1, 99, 1) |
|
1032 if ok: |
|
1033 templateText = '|truncatewords:{0}'.format(words) |
|
1034 elif tag == "truncatewords_html": |
|
1035 words, ok = QInputDialog.getInt( |
|
1036 None, |
|
1037 self.tr("Truncate String"), |
|
1038 self.tr("Enter number of words:"), |
|
1039 10, 1, 99, 1) |
|
1040 if ok: |
|
1041 templateText = '|truncatewords_html:{0}'.format(words) |
|
1042 elif tag == "unordered_list": |
|
1043 templateText = '|unordered_list' |
|
1044 elif tag == "upper": |
|
1045 templateText = '|upper' |
|
1046 elif tag == "urlencode": |
|
1047 templateText = '|urlencode' |
|
1048 elif tag == "urlize": |
|
1049 templateText = '|urlize' |
|
1050 elif tag == "urlizetrunc": |
|
1051 characters, ok = QInputDialog.getInt( |
|
1052 None, |
|
1053 self.tr("Convert URLs as clickable links and truncate"), |
|
1054 self.tr("Enter number of characters:"), |
|
1055 10, 1, 199, 1) |
|
1056 if ok: |
|
1057 templateText = '|urlizetrunc:{0}'.format(characters) |
|
1058 elif tag == "wordcount": |
|
1059 templateText = '|wordcount' |
|
1060 elif tag == "wordwrap": |
|
1061 characters, ok = QInputDialog.getInt( |
|
1062 None, |
|
1063 self.tr("Wrap words"), |
|
1064 self.tr("Enter number of characters:"), |
|
1065 10, 1, 99, 1) |
|
1066 if ok: |
|
1067 templateText = '|wordwrap:{0}'.format(characters) |
|
1068 elif tag == "yesno": |
|
1069 data, ok = DjangoTagInputDialog.getText( |
|
1070 None, |
|
1071 self.tr("Map True, False and None"), |
|
1072 [self.tr("Enter mapping (comma separated):")], |
|
1073 ["yeah,no,maybe"]) |
|
1074 if ok: |
|
1075 if data[0]: |
|
1076 templateText = '|yesno:"{0}"'.format(data[0]) |
|
1077 else: |
|
1078 templateText = '|yesno' |
|
1079 |
|
1080 #################################################### |
|
1081 ## Humanize Template Tags ## |
|
1082 #################################################### |
|
1083 |
|
1084 elif tag == "loadhumanize": |
|
1085 templateText = '{% load humanize %}' |
|
1086 elif tag == "apnumber": |
|
1087 templateText = '|apnumber' |
|
1088 elif tag == "intcomma": |
|
1089 templateText = '|intcomma' |
|
1090 elif tag == "intword": |
|
1091 templateText = '|intword' |
|
1092 elif tag == "naturalday": |
|
1093 templateText = '|naturalday' |
|
1094 elif tag == "naturaltime": |
|
1095 templateText = '|naturaltime' |
|
1096 elif tag == "ordinal": |
|
1097 templateText = '|ordinal' |
|
1098 |
|
1099 #################################################### |
|
1100 ## Web Design Template Tags ## |
|
1101 #################################################### |
|
1102 |
|
1103 elif tag == "loadweb": |
|
1104 templateText = '{% load webdesign %}' |
|
1105 elif tag == "lorem": |
|
1106 from .LoremTagInputDialog import LoremTagInputDialog |
|
1107 dlg = LoremTagInputDialog() |
|
1108 if dlg.exec_() == QDialog.Accepted: |
|
1109 templateText = "{{% {0} %}}".format(dlg.getTag()) |
|
1110 |
|
1111 #################################################### |
|
1112 ## Static Template Tags ## |
|
1113 #################################################### |
|
1114 |
|
1115 elif tag == "loadstatic": |
|
1116 templateText = '{% load static %}' |
|
1117 elif tag == "staticfile": |
|
1118 data, ok = DjangoTagInputDialog.getText( |
|
1119 None, |
|
1120 self.tr("Link to static file"), |
|
1121 [self.tr("Enter relative path of static file:")], |
|
1122 ["images/hi.jpg"]) |
|
1123 if ok: |
|
1124 templateText = '{{% static "{0}" %}}'.format(data[0]) |
|
1125 elif tag == "staticvariable": |
|
1126 data, ok = DjangoTagInputDialog.getText( |
|
1127 None, |
|
1128 self.tr("Link to static file"), |
|
1129 [self.tr("Enter variable containing relative path of" |
|
1130 " static file:")], |
|
1131 ["user_stylesheet"]) |
|
1132 if ok: |
|
1133 templateText = '{{% static {0} %}}'.format(data[0]) |
|
1134 elif tag == "get_static_prefix": |
|
1135 templateText = '{% get_static_prefix %}' |
|
1136 elif tag == "get_media_prefix": |
|
1137 templateText = '{% get_media_prefix %}' |
|
1138 |
|
1139 # TODO: add comment functions |
|
1140 # TODO: add internationalization tags |
617 #################################################### |
1141 #################################################### |
618 ## Fallback: return just the tag name ## |
1142 ## Fallback: return just the tag name ## |
619 #################################################### |
1143 #################################################### |
620 |
1144 |
621 else: |
1145 else: |