Ejemplo n.º 1
0
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)