Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://doi.org/10.5281/zenodo.14598555
04 January 2025, 09:51:28 UTC
  • Code
  • Branches (0)
  • Releases (1)
  • Visits
    • Branches
    • Releases
      • 1
      • 1
    • 3979044
    • /
    • andreamoro-git-joyceconcordance-0b37896
    • /
    • htmlpage.py
    Raw File Download

    To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
    Select below a type of object currently browsed in order to display its associated SWHID and permalink.

    • content
    • directory
    • snapshot
    • release
    origin badgecontent badge
    swh:1:cnt:7a6384878c0838534b6a82bf62cfccaf31739543
    origin badgedirectory badge
    swh:1:dir:60ecff9800f0d759cf7c0f9bf6801e920b90ef71
    origin badgesnapshot badge
    swh:1:snp:84807f388bfa793cb7411d04e283f0a3f513cea3
    origin badgerelease badge
    swh:1:rel:01e75286ce8ff48c6149e824cb397f2ef8bc1894

    This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
    Select below a type of object currently browsed in order to generate citations for them.

    • content
    • directory
    • snapshot
    • release
    (requires biblatex-software package)
    Generating citation ...
    (requires biblatex-software package)
    Generating citation ...
    (requires biblatex-software package)
    Generating citation ...
    (requires biblatex-software package)
    Generating citation ...
    htmlpage.py
    #!/usr/bin/env python3
    # -*- coding: utf-8 -*-
    """
    Created on Wed Feb 21 16:51:23 2018
    @author: Andrea Moro, andrea at andreamoro.net
    @modified from http://www.tldp.org/LDP/LG/issue19/python.html
    
    """
    
    # this is how I import google analytics code
    try: 
        from gan import addga
    except :
        def addga():
            return ""
    
    #  Class for generating HTML pages
    #
        
    class htmlPage:
    
        def __init__ (self, t="", h=""):
            self.title = t
            self.heading = h
    
        def generate_header (self):
    	#
    	# Generate heading for a page
    	#
            tempstr = ""
            tempstr+= "Content-type:text/html\r\n\r\n"
            tempstr+= "<!DOCTYPE html> \n "
            tempstr+= "<html lang='en'>\n"
            tempstr+= "<head>\n"
            tempstr+= '<meta charset="UTF-8">\n'
            
            # add google analytics
            try :
                tempstr+= addga()
            except :
                1
            
            tempstr+= "<meta name='keywords' content='joyce ulysses concordance literature modernism'>\n"
            tempstr+= '<meta name="viewport" content="width=device-width, initial-scale=1">\n'
            tempstr+= '<link href="/css/ulysses.css" type="text/css" rel="stylesheet">\n'
            tempstr+= "<title>" + self.title + "</title>\n"
            tempstr+= '<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>'
            tempstr+= "<script src='/js/linkwords.js'></script> \n"
            tempstr+= '<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Arvo">'+"\n"
            tempstr+= '<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Raleway">'+"\n"
            tempstr+= "</head>\n"
            tempstr+= "<body>\n"
            tempstr+= "<h1>" + self.heading + "</h1>\n"
            return tempstr
    
        def generate_body (self):
    	#
    	# Empty function - to be redefined in a descendant
    	#
            return ""
    
        def generate_footer (self):
    	#
    	# generate the footer for a page
    	#
            tempstr = ""
            tempstr += "<div id='footer'>\n"
            tempstr += "<p>Ulysses text from <a href='http://www.gutenberg.org/files/4300'>gutenberg.org</a>\n"
            tempstr += "(<a href='http://www.gutenberg.org/wiki/Gutenberg:The_Project_Gutenberg_License'>license</a>)</p>\n"
            tempstr += "<p>By <a href='http://andreamoro.net'>Andrea Moro</a>, Vanderbilt University, "
            tempstr += "<a href='mailto:andrea@andreamoro.net'>andrea at andreamoro dot net </a>"
            tempstr += " - <a href='https://github.com/andreamoro-git/joyceconcordance'>Github code</a></p>\n"
            tempstr += "<a href='https://litconcordance.andreamoro.net''>Other concordances</a></p>\n</div>\n"
            tempstr +=  ("</body>\n")
            tempstr +=  ("</html>\n")
            return tempstr
    
        def generate (self):
            tempstr = self.generate_header()
            tempstr+= self.generate_body()
            tempstr+= self.generate_footer()
            return tempstr
    
    #
    # Code to test this class
    #
    
    if __name__ == "__main__":
        p = htmlPage ("This is the title", "<i>This is the top heading</i>")
        p.generate()
        print(p.generate())
    

    back to top

    Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
    The source code of Software Heritage itself is available on our development forge.
    The source code files archived by Software Heritage are available under their own copyright and licenses.
    Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API