class CollectionPage(WebPage): def __init__(self, config): self.config = config self.dao = DAO(config) self.um = URIManager(config) def get_collection_page(self, id): frag = "<h1>Collection: " + id + "</h1>" # list all of the containers in the collection cpath = self.dao.get_store_path(id) containers = os.listdir(cpath) frag += "<h2>Containers</h2><ul>" for container in containers: frag += "<li><a href=\"" + self.um.html_url(id, container) + "\">" + container + "</a></li>" frag += "</ul>" head_frag = "<link rel=\"http://purl.org/net/sword/terms/deposit\" href=\"" + self.um.col_uri(id) + "\"/>" return self._wrap_html("Collection: " + id, frag, head_frag)
class HomePage(WebPage): """ Welcome / home page """ def __init__(self, config): self.config = config self.dao = DAO(self.config) self.um = URIManager(config) def get_home_page(self): frag = "<h1>Simple SWORDv2 Server</h1>" frag += "<p><strong>Service Document (SD-IRI)</strong>: <a href=\"" + self.config.base_url + "sd-uri\">" + self.config.base_url + "sd-uri</a></p>" frag += "<p>If prompted, use the username <strong>" + self.config.user + "</strong> and the password <strong>" + self.config.password + "</strong></p>" frag += "<p>The On-Behalf-Of user to use is <strong>" + self.config.obo + "</strong></p>" # list the collections frag += "<h2>Collections</h2><ul>" for col in self.dao.get_collection_names(): frag += "<li><a href=\"" + self.um.html_url(col) + "\">" + col + "</a></li>" frag += "</ul>" head_frag = "<link rel=\"http://purl.org/net/sword/discovery/service-document\" href=\"" + self.config.base_url + "sd-uri\"/>" return self._wrap_html("Simple SWORDv2 Server", frag, head_frag)