Blame Scripts/CentOS-Web/Apps/Home/page.py

4e1c91
"""Support module for page layout inside `Home' web application.
8c93bb
4e1c91
"""
8c93bb
from Apps import page
8c93bb
8c93bb
app = page.Layout()
8c93bb
8c93bb
ced782
def page_navibar():
4e1c91
    """Returns application main pages.
8c93bb
    
4e1c91
    The application 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
    """
32172d
    names = ['Page1', 'Page2', 'Page3']
8c93bb
    attrs = []
8c93bb
8c93bb
    for i in names:
8c93bb
        attrs.append({'href': '/centos-web/?p=' + i.lower()})
8c93bb
8c93bb
    if 'p' in app.qs.keys():
4e1c91
        focus = app.qs['p'][0].lower()
8c93bb
    else:
32172d
        focus = ''
8c93bb
ced782
    return app.page_navibar(names, attrs, focus)
8c93bb
8c93bb
8c93bb
def page_content():
8c93bb
    """Returns page content.
8c93bb
    
4e1c91
    The page content is determined from the query string, specifically
4e1c91
    from the value of `p' variable.
8c93bb
    
8c93bb
    """
8c93bb
    if 'p' in app.qs.keys():
8c93bb
        p = app.qs['p'][0].lower()
8c93bb
    else:
32172d
        p = ''
32172d
32172d
    if p == 'page1':
8c93bb
        output = app.tag_p('', [12, 1], 'Page Empty.')
32172d
    elif p == 'page2':
32172d
        output = app.tag_p('', [12, 1], 'Page Empty.')
32172d
    elif p == 'page3':
32172d
        output = app.tag_p({}, [12, 1], 'Page Empty' )
2b9a8a
    elif p == 'entry':
2b9a8a
        output = app.content_details()
32172d
    else:
2b9a8a
        output = app.content_list()
8c93bb
ced782
    return output
8c93bb
8c93bb
8c93bb
def main():
8c93bb
    """Returns final output."""
8c93bb
4e1c91
    # Define page name. This value is used as reference to determine
4e1c91
    # which application to load and what tab in the navigation bar to
4e1c91
    # focus on.
8c93bb
    app.name = 'Home'
8c93bb
4e1c91
    # Define page title. This value is dislayed on the browser's title
4e1c91
    # bar. Notice that we concatenated the page class default value
4e1c91
    # here.
8c93bb
    app.title += ' :: Home'
8c93bb
4e1c91
    # Define page header. This is the information displayed
32172d
    # between the page top and page content.
4e1c91
    app.header = app.logo()
ced782
    app.header += app.google()
ced782
    app.header += app.navibar()
ced782
    app.header += app.releases()
ced782
    app.header += app.page_links()
ced782
    app.header += page_navibar()
4e1c91
4e1c91
    # Define page body. This is the information displayed between the
4e1c91
    # page header and page footer.
4e1c91
    app.body = page_content()
4e1c91
4e1c91
    # Define page footer. This is the information displayed between
4e1c91
    # the page bottom and the page content, the last information
4e1c91
    # displayed in the page.
4e1c91
    app.footer = app.credits()
4e1c91
4e1c91
    # Define page final layout. 
4e1c91
    html = app.page()
8c93bb
8c93bb
    return html