Add support for specification of summary and footer.
Wed Aug 24 18:38:04 UTC 2005 Alberto Bertogli <albertogli@telpin.com.ar>
* Add support for specification of summary and footer.
This patch adds support to allow you to specify the summary shown in the repo
list, as well as changing the default footer; all optional.
This is based on the patches sent by Zachary P. Landau and Remko Troncon.
diff -rN -u old-darcsweb/config.py.sample new-darcsweb/config.py.sample
--- old-darcsweb/config.py.sample 2014-04-24 08:50:57.000000000 +0000
+++ new-darcsweb/config.py.sample 2014-04-24 08:50:57.000000000 +0000
@@ -21,6 +21,14 @@
# normally what you want)
#darcspath = "/home/me/bin/"
+ # the text to appear in the top of repo list; this is also optional,
+ # and html-formatted
+ #summary = "I love darcs!"
+
+ # in case you want to change the beautiful default, you can specify an
+ # alternative footer here; it's optional, of course
+ #footer = "I don't like shoes"
+
#
# From now on, every class is a repo configuration, with the same format
@@ -52,6 +60,12 @@
# codec mangling and it needs special cases for UTF8.
repoencoding = "latin1"
+ # as with the base configuration, the footer is also optional, and it
+ # affects only this repository; if you don't specify, the one
+ # specified in base is used (and if you don't specify one there
+ # either, a default one is used)
+ #footer = "I don't like being cold"
+
class repo2:
reponame = 'repo2'
diff -rN -u old-darcsweb/darcsweb.cgi new-darcsweb/darcsweb.cgi
--- old-darcsweb/darcsweb.cgi 2014-04-24 08:50:57.000000000 +0000
+++ new-darcsweb/darcsweb.cgi 2014-04-24 08:50:59.000000000 +0000
@@ -230,9 +230,8 @@
def print_footer(put_rss = 1):
print """
<div class="page_footer">
-<div class="page_footer_text">Crece desde el pueblo el futuro /
- crece desde el pie</div>
- """
+<div class="page_footer_text">%s</div>
+ """ % config.footer
if put_rss:
print '<a class="rss_logo" href="%s;a=rss">RSS</a>' % \
(config.myurl + '/' + config.myreponame)
@@ -1266,8 +1265,7 @@
<a href="%(myname)s">repos</a> / index
</div>
<div class="index_include">
-This is the repository index for a darcsweb site.<br/>
-These are all the available repositories.<br/>
+%(summary)s
</div>
<table cellspacing="0">
<tr>
@@ -1276,10 +1274,11 @@
<th></th>
</tr>
""" % {
- 'myname': all_configs.base.myname,
- 'css': all_configs.base.cssfile,
- 'fav': all_configs.base.darcsfav,
- 'logo': all_configs.base.darcslogo
+ 'myname': config.myname,
+ 'css': config.cssfile,
+ 'fav': config.darcsfav,
+ 'logo': config.darcslogo,
+ 'summary': config.summary
}
# some python magic
@@ -1314,33 +1313,39 @@
print "</table>"
print_footer(put_rss = 0)
-def fill_config(name):
+def fill_config(name = None):
import config as all_configs
- for conf in dir(all_configs):
- if conf.startswith('__'):
- continue
- c = all_configs.__getattribute__(conf)
- if 'reponame' not in dir(c):
- continue
- if c.reponame == name:
- break
- else:
- # not found
- raise "RepoNotFound", name
+
+ if name:
+ # we only care about setting some configurations if a repo was
+ # specified; otherwise we only set the common configuration
+ # directives
+ for conf in dir(all_configs):
+ if conf.startswith('__'):
+ continue
+ c = all_configs.__getattribute__(conf)
+ if 'reponame' not in dir(c):
+ continue
+ if c.reponame == name:
+ break
+ else:
+ # not found
+ raise "RepoNotFound", name
# fill the configuration
base = all_configs.base
config.myname = base.myname
- config.myreponame = base.myname + '?r=' + urllib.quote(name)
config.myurl = base.myurl
config.darcslogo = base.darcslogo
config.darcsfav = base.darcsfav
config.cssfile = base.cssfile
- config.reponame = c.reponame
- config.repodesc = c.repodesc
- config.repodir = c.repodir
- config.repourl = c.repourl
- config.repoencoding = c.repoencoding
+ if name:
+ config.myreponame = base.myname + '?r=' + urllib.quote(name)
+ config.reponame = c.reponame
+ config.repodesc = c.repodesc
+ config.repodir = c.repodir
+ config.repourl = c.repourl
+ config.repoencoding = c.repoencoding
# optional parameters
if "darcspath" in dir(base):
@@ -1348,6 +1353,22 @@
else:
config.darcspath = ""
+ if "summary" in dir(base):
+ config.summary = base.summary
+ else:
+ config.summary = """
+This is the repository index for a darcsweb site.<br/>
+These are all the available repositories.<br/>
+ """
+
+ if name and "footer" in dir(c):
+ config.footer = c.footer
+ elif "footer" in dir(base):
+ config.footer = base.footer
+ else:
+ config.footer = "Crece desde el pueblo el futuro / " \
+ + "crece desde el pie"
+
#
# main
@@ -1357,6 +1378,7 @@
# if they don't specify a repo, print the list and exit
if not form.has_key('r'):
+ fill_config()
do_listrepos()
sys.exit(0)