Package pylal :: Module htmlutils
[hide private]
[frames] | no frames]

Module htmlutils

source code

Utilities for HTML generation on the LIGO Data Grid.

This module provides some useful functions for buildling HTML content on the LIGO Data Grid, and a few extensions to glue.markup to streamline GEO/LIGO tools that use very similar web interfaces.


Date: 2017-12-05 15:29:36 +0000

Author: Duncan M. Macleod <duncan.macleod@ligo.org>

Functions [hide private]
 
write_table(headers, data, classdict={})
Write table into glue.markup.page object.
source code
 
write_menu(sections, pages, current=None, classdict={"a": "menulink"})
Returns glue.markup.page object for <div id_="menubar">, constructing menu in HTML.
source code
 
write_glossary(entries, htag="h1", classdict={"p": "line","h4": "glossary closed"})
Write a glossary of DQ terms into the glue.markup.page object page using the list of (term,definition) tuples terms.
source code
 
get_web_server()
Find the web server for this host on the LIGO Data Grid.
source code
 
simple_page(header, htag="h1", desc=None, plotlist=None, args=None, version=None, classdict={}, init=False)
Returns a glue.markup.page object with an h1 heading, descriptive text, some plots, and the arguments used to generate it.
source code
 
build_page(icon=None, banner=None, homebutton=None, tabs=None, menu=None, frame=None, **initargs)
Build a complete HTML page from 6 components: icon banner homebutton tabs menu frame.
source code
 
summary_page(header=None, htag="h1", desc=None, plotlist=None, text=None, subplots=None, info=None, classdict={}, init=False)
Returns a glue.markup.page object with an heading, descriptive text, summary section with one plot and text, section with other plots, section with subplots, then section with info.
source code
 
about_page(executable, cmdargs, version=False, filedict={}, classdict={"h2": "open","p": "line","div": "about"}, init=False)
Returns a glue.markup.page object formatting the given executable, commandline arguments, and any included files.
source code
 
get_public_html()
Find the web readable directory for the user on thie host.
source code
Function Details [hide private]

write_table(headers, data, classdict={})

source code 

Write table into glue.markup.page object. headers are written with <th>,
multiple columns of data are written with <td>.

Arguments:

    page : glue.markup.page
        page object into which to write table
    headers : list
        list of table header elements
    data : list
        list (or nested list) of table data elements, list of lists used for
        multiple rows

Keyword arguments:

    classdict : dict
        dict containing tag:class pairs for table, td, th, and td HTML tags
        "table":"list" prints table with headers and data side-by-side,
        all others print all headers in one row, then all data in one row
        (use list of lists for multiple rows).

write_menu(sections, pages, current=None, classdict={"a": "menulink"})

source code 

Returns glue.markup.page object for <div id_="menubar">, constructing menu
in HTML.

Arguments:

    sections : list
        ordered list of menu entry names
    pages : dict
        dict of section:href pairs holding link paths for each element of
        sections list

Keyword arguments:

    current : str
        element of sections list to identify with class="open"
    classdict : dict
        dict of tag:class pairs for setting HTML tags

write_glossary(entries, htag="h1", classdict={"p": "line","h4": "glossary closed"})

source code 

Write a glossary of DQ terms into the glue.markup.page object page using the
list of (term,definition) tuples terms.

Arguments:

    entries : dict
        dict of term:definition pairs for inclusion in glossary

Keyword arguments:

    htag : str
        HTML tag to use for header, default <h1>
    classdict : dict
        dict of tag:class pairs for HTML class assignment

get_web_server()

source code 

Find the web server for this host on the LIGO Data Grid.

@returns the fully-qualified domain name of the web server associated with this host.

Example: >>> socket.getfqdn() ldas-pcdev1.ligo-la.caltech.edu >>> htmlutils.get_web_server() "https://ldas-jobs.ligo-la.caltech.edu"

simple_page(header, htag="h1", desc=None, plotlist=None, args=None, version=None, classdict={}, init=False)

source code 

Returns a glue.markup.page object with an h1 heading, descriptive text,    some plots, and the arguments used to generate it.

Designed for embedding/including as a frame in a larger page.

Arguments:

    header : str
        text to write as header  (<h1>)
    htag : str
        HTML tag to use for header, default <h1>
    desc : str
        descriptive text to print below header(s) (<p>)
    plotlist : list
        list of filepath strings or (path, title) tuples to include
        (<a>,<img>)
    args : [ str | list ]
        string with arguments used to generate plots, or list of arguments
        to be space-separated
    version : str
        code version str/number to include
    classdict : dict
        dict containing HTML class strings for each tag used
    init : [ True | False ]
        initialise the markup.page object, adds HTML and BODY tags

build_page(icon=None, banner=None, homebutton=None, tabs=None, menu=None, frame=None, **initargs)

source code 

Build a complete HTML page from 6 components: icon banner homebutton tabs
menu frame. All other args passed to glue.markup.page.init function.
See docstring of that function for help.

Body is built to the following format:

<div id_="container">
    <div class="content" id_="header">
        <div>
            <div class="nav">
                ICON
            </div>
            <div class="frame">
                BANNER
            </div>
        </div>
    </div>
    <div class="content" id_="tabs">
        <div>
            <div class="nav">
                HOMEBUTTON
            </div>
            <div class="frame">
                TABS
            </div>
        </div>
    </div>
    <div class="content" id_="main">
        <div>
            <div class="nav">
                MENUBAR
            </div>
            <div class="frame">
                FRAME
            </div>
        </div>
    </div>
</div>

summary_page(header=None, htag="h1", desc=None, plotlist=None, text=None, subplots=None, info=None, classdict={}, init=False)

source code 

Returns a glue.markup.page object with an heading, descriptive text,    summary section with one plot and text, section with other plots,
section with subplots, then section with info.

Designed for embedding/including as a frame in a larger page.

Keyword arguments:

    header : str
        text to write as header  (<h1>)
    htag : str
        HTML tag to use for header, default <h1>
    desc : str
        descriptive text to print below header(s) (<p>)
    plotlist : list
        list of filepath strings or (path, title) tuples to include
        (<a>,<img>)
    text : [ str | glue.markup.page ]
        text to print below summary plot (<p>), or glue.markup.page to
        drop in with no enclosing tags.
    subplotlist : list
        list of filepath strings or (path, title) tuples to include
        (<a>,<img>)
    info : str
        information to print below summary plot (<p>), or
        glue.markup.page to drop in with no enclosing tags.
    classdict : dict
        dict containing HTML class strings for each tag used
    init : [ True | False ]
        initialise the markup.page object, adds HTML and BODY tags

about_page(executable, cmdargs, version=False, filedict={}, classdict={"h2": "open","p": "line","div": "about"}, init=False)

source code 

Returns a glue.markup.page object formatting the given executable,    commandline arguments, and any included files.

Arguments:

    executable : string
        path of executable file (sys.argv[0])
    cmdargs : iterable
        set of command line arguments (sys.argv[1:])

Keyword arguments:

    filedict : [ dict | iterable ]
        iterable of ("name", filepath) pairs to insert in full into the page
    classdict : dict
        dict containing HTML class strings for each tag used
    init : [ True | False ]
        initialise the markup.page object, adds HTML and BODY tags

get_public_html()

source code 

Find the web readable directory for the user on thie host.

@returns the absolute path of the "public_html" equivalent directory on this host.

Example: >>> socket.getfqdn() ldas-pcdev1.ligo-la.caltech.edu >>> htmlutils.get_html_directory() "/home/duncan.macleod/public_html"