age
697d5f9b0c
included some new functions from the perl file the clearsilver templates have to be modified next
29 lines
898 B
Python
29 lines
898 B
Python
try:
|
|
import neo_cgi, neo_util, neo_cs
|
|
except:
|
|
print "could not import clearsilver modules! Try apt-get install python-clearsilver."
|
|
|
|
class CryptoBoxWebserverRender:
|
|
def render(self, website):
|
|
'''
|
|
render a clearsilver template and return the result.
|
|
|
|
gets:
|
|
- path to clearsilver template
|
|
- dictionary with settings (optional)
|
|
- path to hdf dataset (optional)
|
|
'''
|
|
|
|
## overload to the max
|
|
website.log.info("rendering site: "+website.settings["Data.Action"]+" "+str(website.settings))
|
|
cs_path = website.cbxPrefs["Settings"]["TemplateDir"]+"/main.cs"
|
|
hdf_path = website.cbxPrefs["Settings"]["LangDir"]+"/"+website.cbxPrefs["Settings"]["Language"]+".hdf"
|
|
hdf = neo_util.HDF()
|
|
if hdf_path != "":
|
|
hdf.readFile(hdf_path)
|
|
for key in website.settings.keys():
|
|
hdf.setValue(key,str(website.settings[key]))
|
|
cs = neo_cs.CS(hdf)
|
|
cs.parseFile(cs_path)
|
|
return cs.render()
|
|
|