aboutsummaryrefslogtreecommitdiffstats
path: root/mods
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-01-11 14:12:59 -0800
committerfriendica <info@friendica.com>2013-01-11 14:12:59 -0800
commit1a82c5b3306188889d90b0c8e9e1f71266d653c5 (patch)
treeed26131e01bc1e6eee0b75e41b9a03853bac2546 /mods
parent333eb14ac8b94fdff8f6284f223baa95bb85278a (diff)
parent8cf6b75e9c5f8f2cefa2afd986da423793a65a6a (diff)
downloadvolse-hubzilla-1a82c5b3306188889d90b0c8e9e1f71266d653c5.tar.gz
volse-hubzilla-1a82c5b3306188889d90b0c8e9e1f71266d653c5.tar.bz2
volse-hubzilla-1a82c5b3306188889d90b0c8e9e1f71266d653c5.zip
Merge https://github.com/friendica/red into zpull
Diffstat (limited to 'mods')
-rwxr-xr-xmods/friendica-to-smarty-tpl.py38
-rwxr-xr-xmods/updatetpl.py65
2 files changed, 101 insertions, 2 deletions
diff --git a/mods/friendica-to-smarty-tpl.py b/mods/friendica-to-smarty-tpl.py
index ff1a102a4..3e0add771 100755
--- a/mods/friendica-to-smarty-tpl.py
+++ b/mods/friendica-to-smarty-tpl.py
@@ -1,10 +1,11 @@
#!/usr/bin/python
#
# Script to convert Friendica internal template files into Smarty template files
-# Copyright 2012 Zach Prezkuta
+# Copyright 2013 Zach Prezkuta
# Licensed under GPL v3
import os, re, string
+import sys, getopt
ldelim = '{{'
rdelim = '}}'
@@ -93,6 +94,9 @@ def fix_element(element):
def convert(filename, tofilename, php_tpl):
+ header = ldelim + "*\n *\tAUTOMATICALLY GENERATED TEMPLATE\n *\tDO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN\n *\n *" + rdelim + "\n"
+ tofilename.write(header)
+
for line in filename:
newline = ''
st_pos = 0
@@ -170,7 +174,37 @@ def convert(filename, tofilename, php_tpl):
tofilename.write(newline)
-path = raw_input('Path to template folder to convert: ')
+def help(pname):
+ print "\nUsage:"
+ print "\t" + pname + " -h\n\n\t\t\tShow this help screen\n"
+ print "\t" + pname + " -p directory\n\n\t\t\tConvert all .tpl files in directory to\n\t\t\tSmarty templates in directory/smarty3/\n"
+ print "\t" + pname + "\n\n\t\t\tInteractive mode\n"
+
+
+
+
+#
+# Main script
+#
+
+path = ''
+
+try:
+ opts, args = getopt.getopt(sys.argv[1:], "hp:")
+ for opt, arg in opts:
+ if opt == '-h':
+ help(sys.argv[0])
+ sys.exit()
+ elif opt == '-p':
+ path = arg
+except getopt.GetoptError:
+ help(sys.argv[0])
+ sys.exit(2)
+
+
+if path == '':
+ path = raw_input('Path to template folder to convert: ')
+
if path[-1:] != '/':
path = path + '/'
diff --git a/mods/updatetpl.py b/mods/updatetpl.py
new file mode 100755
index 000000000..1319387c6
--- /dev/null
+++ b/mods/updatetpl.py
@@ -0,0 +1,65 @@
+#!/usr/bin/python
+#
+# Script to update Smarty template files from all internal templates
+# Copyright 2013 Zach Prezkuta
+# Licensed under GPL v3
+
+
+import os
+import sys, getopt
+import subprocess
+
+
+def help(pname):
+ print "\nUsage:"
+ print "\t" + pname + " -h\n\n\t\t\tShow this help screen\n"
+ print "\t" + pname + " -p directory\n\n\t\t\tConvert all .tpl files in top-level\n\t\t\tFriendica directory to Smarty templates\n"
+ print "\t" + pname + "\n\n\t\t\tInteractive mode\n"
+
+
+
+#
+# Main script
+#
+
+path = ''
+
+try:
+ opts, args = getopt.getopt(sys.argv[1:], "hp:")
+ for opt, arg in opts:
+ if opt == '-h':
+ help(sys.argv[0])
+ sys.exit()
+ elif opt == '-p':
+ path = arg
+except getopt.GetoptError:
+ help(sys.argv[0])
+ sys.exit(2)
+
+if path == '':
+ path = raw_input('Path to top-level Friendica directory: ')
+
+if path[-1:] != '/':
+ path = path + '/'
+
+excludepaths = ['css', 'img', 'js', 'php', 'theme']
+tplpaths = []
+names = os.listdir(path + 'view/')
+for name in names:
+ if os.path.isdir(path + 'view/' + name):
+ if name not in excludepaths:
+ tplpaths.append('view/' + name + '/')
+
+names = os.listdir(path + 'view/theme/')
+for name in names:
+ if os.path.isdir(path + 'view/theme/' + name):
+ tplpaths.append('view/theme/' + name + '/tpl/')
+
+fnull = open(os.devnull, "w")
+
+for tplpath in tplpaths:
+ print "Converting " + path + tplpath
+ subprocess.call(['python', path + 'mods/friendica-to-smarty-tpl.py', '-p', path + tplpath], stdout = fnull)
+
+fnull.close()
+