From 4cb380e6655facb09505ffbfbeccf8e8475e38c1 Mon Sep 17 00:00:00 2001 From: anthonybaxter Date: Tue, 24 Jul 2001 10:46:22 +0000 Subject: [PATCH] Added templatebuilder module. two functions - one to pack up the html base, one to unpack it. Packed up the two standard templates into htmlbases. Modified __init__ to install them. __init__.py magic was needed for the rather high levels of wierd import magic. Reducing level of import magic == (good, future) git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@72 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/init.py | 12 +- roundup/templatebuilder.py | 57 +++ roundup/templates/.cvsignore | 1 + roundup/templates/__init__.py | 2 + roundup/templates/classic/__init__.py | 11 +- roundup/templates/classic/dbinit.py | 6 +- roundup/templates/classic/htmlbase.py | 399 +++++++++++++++++++++ roundup/templates/extended/__init__.py | 11 +- roundup/templates/extended/htmlbase.py | 463 +++++++++++++++++++++++++ 9 files changed, 956 insertions(+), 6 deletions(-) create mode 100644 roundup/templatebuilder.py create mode 100644 roundup/templates/.cvsignore create mode 100644 roundup/templates/__init__.py create mode 100644 roundup/templates/classic/htmlbase.py create mode 100644 roundup/templates/extended/htmlbase.py diff --git a/roundup/init.py b/roundup/init.py index d2e39a5..ef7b1ae 100644 --- a/roundup/init.py +++ b/roundup/init.py @@ -1,4 +1,4 @@ -# $Id: init.py,v 1.3 2001-07-23 08:45:28 richard Exp $ +# $Id: init.py,v 1.4 2001-07-24 10:46:22 anthonybaxter Exp $ import os, shutil, sys @@ -35,10 +35,15 @@ def init(instance, template, backend, adminpw): ''' initialise an instance using the named template ''' # first, copy the template dir over + import roundup.templatebuilder + template_dir = os.path.split(__file__)[0] + template_name = template template = os.path.join(template_dir, 'templates', template) copytree(template, instance) + roundup.templatebuilder.installHtmlBase(template_name, instance) + # now select database db = '''# WARNING: DO NOT EDIT THIS FILE!!! from roundup.backends.back_%s import Database'''%backend @@ -52,6 +57,11 @@ from roundup.backends.back_%s import Database'''%backend # # $Log: not supported by cvs2svn $ +# Revision 1.3 2001/07/23 08:45:28 richard +# ok, so now "./roundup-admin init" will ask questions in an attempt to get a +# workable instance_home set up :) +# _and_ anydbm has had its first test :) +# # Revision 1.2 2001/07/22 12:09:32 richard # Final commit of Grande Splite # diff --git a/roundup/templatebuilder.py b/roundup/templatebuilder.py new file mode 100644 index 0000000..1cc06ed --- /dev/null +++ b/roundup/templatebuilder.py @@ -0,0 +1,57 @@ +preamble = """ +# Do Not Edit (Unless You Want To) +# This file automagically generated by roundup.htmldata.makeHtmlBase +# +""" + +def makeHtmlBase(templateDir): + """ make a htmlbase.py file in the given templateDir, from the + contents of templateDir/html """ + import os, glob, re + print "packing up templates in", templateDir + filelist = glob.glob(os.path.join(templateDir, 'html', '*')) + filelist = filter(os.path.isfile, filelist) # only want files + filelist.sort() + fd = open(os.path.join(templateDir, 'htmlbase.py'), 'w') + fd.write(preamble) + for file in filelist: + mangled_name = os.path.basename(re.sub(r'\.', 'DOT', file)) + fd.write('%s = """'%mangled_name) + fd.write(open(file).read()) + fd.write('"""\n\n') + fd.close() + +def installHtmlBase(template, installDir): + """ passed a template package and an installDir, unpacks the html files into + the installdir """ + import os,sys,re + + tdir = __import__('roundup.templates.%s.htmlbase'%template).templates + if hasattr(tdir, template): + tmod = getattr(tdir, template) + else: + raise "TemplateError", \ + "couldn't find roundup.template.%s.htmlbase"%template + htmlbase = tmod.htmlbase + + print "installing from", htmlbase.__file__, "into", installDir + modulecontents = dir(htmlbase) + for mangledfile in modulecontents: + if mangledfile[0] == "_": + continue + filename = re.sub('DOT', '.', mangledfile) + outfile = os.path.join(installDir, filename) + outfd = open(outfile, 'w') + data = getattr(htmlbase, mangledfile) + outfd.write(data) + + + +if __name__ == "__main__": + import sys + if len(sys.argv) == 2: + makeHtmlBase(sys.argv[1]) + elif len(sys.argv) == 3: + installHtmlBase(sys.argv[1], sys.argv[2]) + else: + raise "what you talkin about willis?" diff --git a/roundup/templates/.cvsignore b/roundup/templates/.cvsignore new file mode 100644 index 0000000..0d20b64 --- /dev/null +++ b/roundup/templates/.cvsignore @@ -0,0 +1 @@ +*.pyc diff --git a/roundup/templates/__init__.py b/roundup/templates/__init__.py new file mode 100644 index 0000000..139597f --- /dev/null +++ b/roundup/templates/__init__.py @@ -0,0 +1,2 @@ + + diff --git a/roundup/templates/classic/__init__.py b/roundup/templates/classic/__init__.py index f3008d6..0a5422e 100644 --- a/roundup/templates/classic/__init__.py +++ b/roundup/templates/classic/__init__.py @@ -1,11 +1,18 @@ -# $Id: __init__.py,v 1.1 2001-07-23 23:28:43 richard Exp $ +# $Id: __init__.py,v 1.2 2001-07-24 10:46:22 anthonybaxter Exp $ +import sys from instance_config import * -from dbinit import * +try: + from dbinit import * +except: + pass # in install dir (probably :) from interfaces import * # # $Log: not supported by cvs2svn $ +# Revision 1.1 2001/07/23 23:28:43 richard +# Adding the classic template +# # Revision 1.3 2001/07/23 23:16:01 richard # Split off the interfaces (CGI, mailgw) into a separate file from the DB stuff. # diff --git a/roundup/templates/classic/dbinit.py b/roundup/templates/classic/dbinit.py index 8148958..7bc71cc 100644 --- a/roundup/templates/classic/dbinit.py +++ b/roundup/templates/classic/dbinit.py @@ -1,10 +1,11 @@ -# $Id: dbinit.py,v 1.2 2001-07-24 01:06:43 richard Exp $ +# $Id: dbinit.py,v 1.3 2001-07-24 10:46:22 anthonybaxter Exp $ import os import instance_config from roundup import roundupdb, cgi_client, mailgw import select_db + from roundup.roundupdb import Class, FileClass class Database(roundupdb.Database, select_db.Database): @@ -106,6 +107,9 @@ def init(adminpw): # # $Log: not supported by cvs2svn $ +# Revision 1.2 2001/07/24 01:06:43 richard +# Oops - accidentally duped the keywords class +# # Revision 1.1 2001/07/23 23:28:43 richard # Adding the classic template # diff --git a/roundup/templates/classic/htmlbase.py b/roundup/templates/classic/htmlbase.py new file mode 100644 index 0000000..8121dbf --- /dev/null +++ b/roundup/templates/classic/htmlbase.py @@ -0,0 +1,399 @@ + +# Do Not Edit (Unless You Want To) +# This file automagically generated by roundup.htmldata.makeHtmlBase +# +fileDOTindex = """ + + + + + + + + +""" + +issueDOTfilter = """ + + Title + + + + Status + + + + Priority + + +""" + +issueDOTindex = """ + + + + + + + + + + + + + + +""" + +issueDOTitem = """ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Item Information
Title
Created + ()Last activity
PriorityStatus
SupersederNosy List
Change Note
 
Messages
Files
+ +""" + +msgDOTindex = """ + + + + + + + + + + + +""" + +msgDOTitem = """ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Message Information
Author
Recipients
Date
+
+
Files
History
+""" + +styleDOTcss = """h1 { + font-family: Verdana, Helvetica, sans-serif; + font-size: 18pt; + font-weight: bold; +} + +h2 { + font-family: Verdana, Helvetica, sans-serif; + font-size: 16pt; + font-weight: bold; +} + +h3 { + font-family: Verdana, Helvetica, sans-serif; + font-size: 12pt; + font-weight: bold; +} + +a:hover { + font-family: Verdana, Helvetica, sans-serif; + text-decoration: underline; + color: #333333; +} + +a:link { + font-family: Verdana, Helvetica, sans-serif; + text-decoration: none; + color: #000099; +} + +a { + font-family: Verdana, Helvetica, sans-serif; + text-decoration: none; + color: #000099; +} + +p { + font-family: Verdana, Helvetica, sans-serif; + font-size: 10pt; + color: #333333; +} + +th { + font-family: Verdana, Helvetica, sans-serif; + font-weight: bold; + font-size: 10pt; + color: #333333; +} + +.form-help { + font-family: Verdana, Helvetica, sans-serif; + font-size: 10pt; + color: #333333; +} + +.std-text { + font-family: Verdana, Helvetica, sans-serif; + font-size: 10pt; + color: #333333; +} + +.tab-small { + font-family: Verdana, Helvetica, sans-serif; + font-size: 8pt; + color: #333333; +} + +.location-bar { + background-color: #efefef; + border: none; +} + +.strong-header { + font-family: Verdana, Helvetica, sans-serif; + font-size: 12pt; + font-weight: bold; + background-color: #000000; + color: #ffffff; +} + +.list-header { + background-color: #c0c0c0; + border: none; +} + +.list-item { + font-family: Verdana, Helvetica, sans-serif; + font-size: 10pt; +} + +.list-nav { + font-family: Verdana, Helvetica, sans-serif; + font-size: 10pt; + font-weight: bold; +} + +.row-normal { + background-color: #ffffff; + border: none; + +} + +.row-hilite { + background-color: #efefef; + border: none; +} + +.section-bar { + background-color: #c0c0c0; + border: none; +} + +.system-msg { + font-family: Verdana, Helvetica, sans-serif; + font-size: 10pt; + background-color: #ffffff; + border: 1px solid #000000; + margin-bottom: 6px; + margin-top: 6px; + padding: 4px; + width: 100%; + color: #660033; +} + +.form-title { + font-family: Verdana, Helvetica, sans-serif; + font-weight: bold; + font-size: 12pt; + color: #333333; +} + +.form-label { + font-family: Verdana, Helvetica, sans-serif; + font-weight: bold; + font-size: 10pt; + color: #333333; +} + +.form-optional { + font-family: Verdana, Helvetica, sans-serif; + font-weight: bold; + font-style: italic; + font-size: 10pt; + color: #333333; +} + +.form-element { + font-family: Verdana, Helvetica, aans-serif; + font-size: 10pt; + color: #000000; +} + +.form-text { + font-family: Verdana, Helvetica, sans-serif; + font-size: 10pt; + color: #333333; +} + +.form-mono { + font-family: monospace; + font-size: 12px; + text-decoration: none; +} +""" + +userDOTindex = """ + + + + + + + + + + + + + + + + + +""" + +userDOTitem = """ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Your Details
Name
Login Name
Login Password
Phone
Organisation
E-mail address
 
History
+ +""" + diff --git a/roundup/templates/extended/__init__.py b/roundup/templates/extended/__init__.py index c6534be..2572c22 100644 --- a/roundup/templates/extended/__init__.py +++ b/roundup/templates/extended/__init__.py @@ -1,11 +1,18 @@ -# $Id: __init__.py,v 1.3 2001-07-23 23:16:01 richard Exp $ +# $Id: __init__.py,v 1.4 2001-07-24 10:46:22 anthonybaxter Exp $ from instance_config import * -from dbinit import * +try: + from dbinit import * +except ImportError: + pass # in installdir (probably :) + from interfaces import * # # $Log: not supported by cvs2svn $ +# Revision 1.3 2001/07/23 23:16:01 richard +# Split off the interfaces (CGI, mailgw) into a separate file from the DB stuff. +# # Revision 1.2 2001/07/23 04:33:21 anthonybaxter # split __init__.py into 2. dbinit and instance_config. # diff --git a/roundup/templates/extended/htmlbase.py b/roundup/templates/extended/htmlbase.py new file mode 100644 index 0000000..d121d5e --- /dev/null +++ b/roundup/templates/extended/htmlbase.py @@ -0,0 +1,463 @@ + +# Do Not Edit (Unless You Want To) +# This file automagically generated by roundup.htmldata.makeHtmlBase +# +fileDOTindex = """ + + + + + + + + +""" + +issueDOTfilter = """ + + Title + + + + Status + + + + Priority + + + + Platform + + + + Product + + + + Version + + + + Source + + + + Assigned to + + + + Customer name + + +""" + +issueDOTindex = """ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +""" + +issueDOTitem = """ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Item Information
Title
Product + version:Platform
Created + ()Last activity
PrioritySource
StatusRate
Assigned ToCustomer Name
SupersederNosy List
Change Note
 
Messages
Files
+ +""" + +msgDOTindex = """ + + + + + + + + + + + +""" + +msgDOTitem = """ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Message Information
Author
Recipients
Date
+
+
Files
History
+""" + +styleDOTcss = """h1 { + font-family: Verdana, Helvetica, sans-serif; + font-size: 18pt; + font-weight: bold; +} + +h2 { + font-family: Verdana, Helvetica, sans-serif; + font-size: 16pt; + font-weight: bold; +} + +h3 { + font-family: Verdana, Helvetica, sans-serif; + font-size: 12pt; + font-weight: bold; +} + +a:hover { + font-family: Verdana, Helvetica, sans-serif; + text-decoration: underline; + color: #333333; +} + +a:link { + font-family: Verdana, Helvetica, sans-serif; + text-decoration: none; + color: #000099; +} + +a { + font-family: Verdana, Helvetica, sans-serif; + text-decoration: none; + color: #000099; +} + +p { + font-family: Verdana, Helvetica, sans-serif; + font-size: 10pt; + color: #333333; +} + +th { + font-family: Verdana, Helvetica, sans-serif; + font-weight: bold; + font-size: 10pt; + color: #333333; +} + +.form-help { + font-family: Verdana, Helvetica, sans-serif; + font-size: 10pt; + color: #333333; +} + +.std-text { + font-family: Verdana, Helvetica, sans-serif; + font-size: 10pt; + color: #333333; +} + +.tab-small { + font-family: Verdana, Helvetica, sans-serif; + font-size: 8pt; + color: #333333; +} + +.location-bar { + background-color: #efefef; + border: none; +} + +.strong-header { + font-family: Verdana, Helvetica, sans-serif; + font-size: 12pt; + font-weight: bold; + background-color: #000000; + color: #ffffff; +} + +.list-header { + background-color: #c0c0c0; + border: none; +} + +.list-item { + font-family: Verdana, Helvetica, sans-serif; + font-size: 10pt; +} + +.list-nav { + font-family: Verdana, Helvetica, sans-serif; + font-size: 10pt; + font-weight: bold; +} + +.row-normal { + background-color: #ffffff; + border: none; + +} + +.row-hilite { + background-color: #efefef; + border: none; +} + +.section-bar { + background-color: #c0c0c0; + border: none; +} + +.system-msg { + font-family: Verdana, Helvetica, sans-serif; + font-size: 10pt; + background-color: #ffffff; + border: 1px solid #000000; + margin-bottom: 6px; + margin-top: 6px; + padding: 4px; + width: 100%; + color: #660033; +} + +.form-title { + font-family: Verdana, Helvetica, sans-serif; + font-weight: bold; + font-size: 12pt; + color: #333333; +} + +.form-label { + font-family: Verdana, Helvetica, sans-serif; + font-weight: bold; + font-size: 10pt; + color: #333333; +} + +.form-optional { + font-family: Verdana, Helvetica, sans-serif; + font-weight: bold; + font-style: italic; + font-size: 10pt; + color: #333333; +} + +.form-element { + font-family: Verdana, Helvetica, aans-serif; + font-size: 10pt; + color: #000000; +} + +.form-text { + font-family: Verdana, Helvetica, sans-serif; + font-size: 10pt; + color: #333333; +} + +.form-mono { + font-family: monospace; + font-size: 12px; + text-decoration: none; +} +""" + +userDOTindex = """ + + + + + + + + + + + + + + + + + +""" + +userDOTitem = """ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Your Details
Name
Login Name
Login Password
Phone
Organisation
E-mail address
 
History
+ +""" + -- 2.30.2