Blame Scripts/Python/Webenv/cgi-bin/Apps/Sponsors/page.py

3566ff
"""Support module for page layout inside `Sponsors' web application.
8c93bb
3566ff
"""
8c93bb
from Apps import page
8c93bb
8c93bb
app = page.Layout()
8c93bb
8c93bb
e55c28
def page_navibar():
8c93bb
    """Returns application's main pages.
8c93bb
    
8c93bb
    The application's main pages are organized as tabs in the
8c93bb
    application navigation bar. There is one tab for each main page
8c93bb
    inside the application.
8c93bb
    
8c93bb
    """
8c93bb
    names = ['Hardware', 'Hosting', 'Others']
8c93bb
    attrs = []
8c93bb
8c93bb
    for i in names:
76894e
        if 'app' in page.qs.keys():
bd2a79
            attrs.append({'href': '/webenv/?app=' + page.qs['app'][0].lower() + '&p=' + i.lower()})
8c93bb
        else:
bd2a79
            attrs.append({'href': '/webenv/?p=' + i.lower()})
8c93bb
76894e
    if 'p' in page.qs.keys():
76894e
        focus = page.qs['p'][0].lower()
8c93bb
    else:
3566ff
        focus = names[0].lower()
8c93bb
e55c28
    return app.page_navibar(names, attrs, focus)
8c93bb
8c93bb
8c93bb
def page_content():
8c93bb
    """Returns page content.
8c93bb
    
8c93bb
    The page content to show is determined from the query string,
8c93bb
    specifically from the value of `p' variable.
8c93bb
    
8c93bb
    """
76894e
    if 'p' in page.qs.keys():
76894e
        p = page.qs['p'][0].lower()
8c93bb
    else:
8c93bb
        p = 'hardware'
8c93bb
8c93bb
    if p == 'hardware':
8c93bb
        output = app.tag_h1({'class': 'title'}, [12, 1], 'Hardware Sponsors' )
8c93bb
    elif p == 'hosting':
8c93bb
        output = app.tag_h1({'class': 'title'}, [12, 1], 'Hosting Sponsors' )
8c93bb
    elif p == 'others':
8c93bb
        output = app.tag_h1({'class': 'title'}, [12, 1], 'Other Sponsors' )
8c93bb
    else:
8c93bb
        output = app.tag_p('', [12, 1], 'Page empty.')
8c93bb
e55c28
    return output
8c93bb
3566ff
8c93bb
def main():
8c93bb
    """Returns final output."""
8c93bb
3566ff
    # Define page name. This value is used as reference to determine
3566ff
    # which application to load and what tab in the navigation bar to
3566ff
    # focus on.
8c93bb
    app.name = 'Sponsors'
8c93bb
3566ff
    # Define page title. This value is dislayed on the browser's title
3566ff
    # bar. Notice that we concatenated the page class default value
3566ff
    # here.
8c93bb
    app.title += ' :: Sponsors'
8c93bb
3566ff
    # Define page header. This is the information displayed
3566ff
    # between the page top and the page content.
3566ff
    app.header = app.logo()
76894e
    app.header += app.google_ad_example()
e55c28
    app.header += app.navibar()
e55c28
    app.header += app.page_links()
e55c28
    app.header += page_navibar()
3566ff
3566ff
    # Define page body. This is the information displayed between the
3566ff
    # page header and page footer.
3566ff
    app.body = page_content()
3566ff
3566ff
    # Define page footer. This is the information displayed between
3566ff
    # the page bottom and the page content, the last information
3566ff
    # displayed in the page.
3566ff
    app.footer = app.credits()
3566ff
3566ff
    # Define page final layout. 
3566ff
    html = app.page()
8c93bb
8c93bb
    return html