#
#
# add_file "templates/databases.html"
# content [62aed068c3b9a101c1f473866ee73c81b34e3430]
#
# patch "handlers.py"
# from [f5978ee498a2bce37a15bdc0e509e8bb56609e33]
# to [c4dde78e911e10dd9430967cf4508e2b8656ed06]
#
# patch "templates/base.html"
# from [47574ccfc9aff518749857eb878ba93c8f2e9f48]
# to [7b1b4d764b1c6c17ce021c8f9b973947cded4fcf]
#
# patch "urls.py"
# from [74ec1a0af57afeb7d98bcf04248d799b8d9b2738]
# to [cdd1ef4f53a33f703915f1fa5661a79967268bf1]
#
# patch "viewmtn.py"
# from [c5366d46df9e87de6c4357412799dc5220e3a0cc]
# to [74a4f0416cdabd92532bb1ed2f1a6fbe7f52183f]
#
============================================================
--- templates/databases.html 62aed068c3b9a101c1f473866ee73c81b34e3430
+++ templates/databases.html 62aed068c3b9a101c1f473866ee73c81b34e3430
@@ -0,0 +1,24 @@
+#extends base
+
+#def body
+
+ViewMTN has been configured to serve the following databases.
+You are currently accessing the database $(dbname).
+Change to a database by accessing the corresponding link.
+
+
+
+| Database | Description |
+#for db in $databases
+
+ |
+ $db.name
+ |
+
+ $db.description
+ |
+
+#end for
+
+
+#end def
============================================================
--- handlers.py f5978ee498a2bce37a15bdc0e509e8bb56609e33
+++ handlers.py c4dde78e911e10dd9430967cf4508e2b8656ed06
@@ -755,6 +755,16 @@ class BranchHead(object):
anyhead=anyhead,
head_links=head_links)
+class Databases(object):
+ def GET(self, ctxt):
+ databases = []
+ for k in ctxt.db_summary:
+ databases.append ({'name':k, 'description':ctxt.db_summary[k]})
+ ctxt.render('databases.html',
+ page_title="Change database",
+ databases=databases)
+
+
class MimeIcon(object):
def GET(self, type, sub_type):
if not mimeicon:
@@ -768,12 +778,16 @@ class RobotsTxt(object):
return web.notfound()
class RobotsTxt(object):
- def GET(self):
+ def GET(self, ctxt):
web.header('Content-Type', 'text/plain')
print "User-agent: *"
- for revision_page in ['tar', 'downloadfile', 'graph', 'file', 'browse', 'diff', 'info', 'graph']:
- # the goal is just to let a robot trawl through the most recent changes, and deny access
- # to expensive pointless things. We don't want a robot indexing every file in every revision,
- # as this is an enormous amount of information.
- for access_method in ['/revision/', '/branch/head/', '/branch/anyhead/', '/branch/changes/from/', '/json/', '/mimeicon/']:
- print "Disallow:", access_method + revision_page
+ for dbname in [None] + ctxt.db_summary.keys():
+ for revision_page in ['tar', 'downloadfile', 'graph', 'file', 'browse', 'diff', 'info', 'graph']:
+ # the goal is just to let a robot trawl through the most recent changes, and deny access
+ # to expensive pointless things. We don't want a robot indexing every file in every revision,
+ # as this is an enormous amount of information.
+ for access_method in ['/revision/', '/branch/head/', '/branch/anyhead/', '/branch/changes/from/', '/json/', '/mimeicon/']:
+ disallow = access_method + revision_page
+ if not dbname is None:
+ disallow = '/' + dbname + disallow
+ print "Disallow:", disallow
============================================================
--- templates/base.html 47574ccfc9aff518749857eb878ba93c8f2e9f48
+++ templates/base.html 7b1b4d764b1c6c17ce021c8f9b973947cded4fcf
@@ -24,7 +24,11 @@
Branches |
Tags |
Help |
- About
+ About
+#if $have_multidb
+ | Change DB
+#end if
+
#block extramenu
#end block
============================================================
--- urls.py 74ec1a0af57afeb7d98bcf04248d799b8d9b2738
+++ urls.py cdd1ef4f53a33f703915f1fa5661a79967268bf1
@@ -15,7 +15,6 @@ common_urls = (
# as their first argument.
#
common_urls = (
- r'robots.txt', 'RobotsTxt', ## FIXME needs o exclude per-db paths
r'mimeicon/([A-Za-z0-9][a-z0-9\-\+\.]*)/([A-Za-z0-9][a-z0-9\-\+\.]*)', 'MimeIcon',
)
@@ -28,7 +27,9 @@ perdb_urls = (
r'about', 'About',
r'help', 'Help',
r'tags', 'Tags',
+ r'databases', 'Databases',
r'json/([A-Za-z]+)/(.*)', 'Json',
+ r'robots.txt', 'RobotsTxt', ## FIXME needs o exclude per-db paths
r'revision/browse/('+revision_re+')/(.*)', 'RevisionBrowse',
r'revision/browse/('+revision_re+')()', 'RevisionBrowse',
============================================================
--- viewmtn.py c5366d46df9e87de6c4357412799dc5220e3a0cc
+++ viewmtn.py 74a4f0416cdabd92532bb1ed2f1a6fbe7f52183f
@@ -50,6 +50,7 @@ class RequestContextFactory(object):
class RequestContextFactory(object):
def __init__ (self):
self.dbstore = { 'ops' : {}, 'branchdivs' : {}, 'dbdescr' : {}}
+ self.db_summary = {}
self.default = None
# has the user specified a dbfiles hash? if so, use it
if hasattr (config, "dbfiles"):
@@ -57,6 +58,7 @@ class RequestContextFactory(object):
self.add_to_store(name, ops=mtn.Operations([config.monotone, dbfile]),
branchdivs=branchdiv.BranchDivisions(),
dbdescr=description)
+ self.db_summary[name] = description
if hasattr (config, "defaultdb"):
self.default = config.defaultdb
have_multidb = True
@@ -84,7 +86,12 @@ class RequestContextFactory(object):
else:
dbdescr = self.get_from_store("dbdescr", name)
branchdivs = self.get_from_store("branchdivs", name)
- return RequestContext(dbname=name, ops=ops, dbdescr=dbdescr, branchdivs=branchdivs, renderer=self.renderer)
+ return RequestContext(dbname=name,
+ ops=ops,
+ dbdescr=dbdescr,
+ branchdivs=branchdivs,
+ renderer=self.renderer,
+ db_summary=self.db_summary)
def runfcgi_apache(func):
web.wsgi.runfcgi(func, None)