automatic, command-line conversion
This commit is contained in:
parent
b9c0341c0c
commit
f24d460522
|
@ -1,10 +1,11 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
#
|
#
|
||||||
# Script to convert Friendica internal template files into Smarty template files
|
# Script to convert Friendica internal template files into Smarty template files
|
||||||
# Copyright 2012 Zach Prezkuta
|
# Copyright 2013 Zach Prezkuta
|
||||||
# Licensed under GPL v3
|
# Licensed under GPL v3
|
||||||
|
|
||||||
import os, re, string
|
import os, re, string
|
||||||
|
import sys, getopt
|
||||||
|
|
||||||
ldelim = '{{'
|
ldelim = '{{'
|
||||||
rdelim = '}}'
|
rdelim = '}}'
|
||||||
|
@ -170,7 +171,37 @@ def convert(filename, tofilename, php_tpl):
|
||||||
tofilename.write(newline)
|
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:] != '/':
|
if path[-1:] != '/':
|
||||||
path = path + '/'
|
path = path + '/'
|
||||||
|
|
||||||
|
|
64
mods/updatetpl.py
Executable file
64
mods/updatetpl.py
Executable file
|
@ -0,0 +1,64 @@
|
||||||
|
#!/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 + '/'
|
||||||
|
|
||||||
|
tplpaths = ['view/']
|
||||||
|
names = os.listdir(path + 'view/')
|
||||||
|
for name in names:
|
||||||
|
if os.path.isdir(path + 'view/' + name):
|
||||||
|
if name != 'smarty3' and name != 'theme':
|
||||||
|
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 + '/')
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
|
@ -7,7 +7,7 @@ erhalten.
|
||||||
|
|
||||||
Du kannst sein/ihr Profil unter {{$url}} finden.
|
Du kannst sein/ihr Profil unter {{$url}} finden.
|
||||||
|
|
||||||
Bitte melde dich an um die komplette Vorstellung einzusehen
|
Bitte melde dich an um die komplette Anfrage einzusehen
|
||||||
und die Anfrage zu bestätigen oder zu ignorieren oder abzulehnen.
|
und die Anfrage zu bestätigen oder zu ignorieren oder abzulehnen.
|
||||||
|
|
||||||
{{$siteurl}}
|
{{$siteurl}}
|
||||||
|
|
Loading…
Reference in a new issue