|
|
8c93bb |
#!/usr/bin/python
|
|
|
8c93bb |
#
|
|
|
8c93bb |
# Apps.Home.page -- This module intantiates Apps.xhtml module to
|
|
|
8c93bb |
# create the xhtml output of home web applications.
|
|
|
8c93bb |
#
|
|
|
8c93bb |
# Copyright (C) 2009, 2010, 2011 The CentOS Project
|
|
|
8c93bb |
#
|
|
|
8c93bb |
# This program is free software; you can redistribute it and/or modify
|
|
|
8c93bb |
# it under the terms of the GNU General Public License as published by
|
|
|
8c93bb |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
8c93bb |
# your option) any later version.
|
|
|
8c93bb |
#
|
|
|
8c93bb |
# This program is distributed in the hope that it will be useful, but
|
|
|
8c93bb |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
8c93bb |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
8c93bb |
# General Public License for more details.
|
|
|
8c93bb |
#
|
|
|
8c93bb |
# You should have received a copy of the GNU General Public License
|
|
|
8c93bb |
# along with this program; if not, write to the Free Software
|
|
|
8c93bb |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
8c93bb |
#
|
|
|
8c93bb |
# ----------------------------------------------------------------------
|
|
|
8c93bb |
# $Id$
|
|
|
8c93bb |
# ----------------------------------------------------------------------
|
|
|
8c93bb |
|
|
|
8c93bb |
from Apps import page
|
|
|
8c93bb |
|
|
|
8c93bb |
app = page.Layout()
|
|
|
8c93bb |
|
|
|
8c93bb |
def page_ads_release():
|
|
|
8c93bb |
"""Returns last-release advertisements."""
|
|
|
8c93bb |
image = 'last-release.png'
|
|
|
8c93bb |
return app.ads_release(image)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def page_navibar_tabs():
|
|
|
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 = ['Erratas', 'Articles', 'Events']
|
|
|
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():
|
|
|
8c93bb |
focus = app.qs['p'][0]
|
|
|
8c93bb |
else:
|
|
|
8c93bb |
focus = names[0]
|
|
|
8c93bb |
|
|
|
8c93bb |
return app.navibar_app(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 |
"""
|
|
|
8c93bb |
if 'p' in app.qs.keys():
|
|
|
8c93bb |
p = app.qs['p'][0].lower()
|
|
|
8c93bb |
else:
|
|
|
8c93bb |
p = 'erratas'
|
|
|
8c93bb |
|
|
|
8c93bb |
if p == 'erratas':
|
|
|
8c93bb |
output = app.tag_h1({'class': 'title'}, [12, 1], 'Erratas' )
|
|
|
8c93bb |
output += app.tag_p({}, [12, 1], 'This is a paragraph. '*30 )
|
|
|
8c93bb |
output += app.tag_p({}, [12, 1], 'This is a paragraph in the sense of improvement. '*30 )
|
|
|
8c93bb |
output += app.tag_h2({'class': 'title'}, [12, 1], 'For A Better OS' )
|
|
|
8c93bb |
output += app.tag_p({}, [12, 1], 'This is a paragraph. '*30 )
|
|
|
8c93bb |
output += app.admonition('Caution', '', app.tag_p({}, [16, 1], 'This is a paragraph. '*5))
|
|
|
8c93bb |
output += app.tag_p({}, [12, 1], 'This is a paragraph. '*30 )
|
|
|
8c93bb |
elif p == 'articles':
|
|
|
8c93bb |
output = app.tag_h1({'class': 'title'}, [12, 1], 'Articles' )
|
|
|
8c93bb |
elif p == 'events':
|
|
|
8c93bb |
output = app.tag_h1({'class': 'title'}, [12, 1], 'Events' )
|
|
|
8c93bb |
else:
|
|
|
8c93bb |
output = app.tag_p('', [12, 1], 'Page Empty.')
|
|
|
8c93bb |
|
|
|
8c93bb |
return app.content(output)
|
|
|
8c93bb |
|
|
|
8c93bb |
|
|
|
8c93bb |
def main():
|
|
|
8c93bb |
"""Returns final output."""
|
|
|
8c93bb |
|
|
|
8c93bb |
# Define application name. This value is used as reference to
|
|
|
8c93bb |
# determine which application to load and what tab in the
|
|
|
8c93bb |
# navigation bar to focus.
|
|
|
8c93bb |
app.name = 'Home'
|
|
|
8c93bb |
|
|
|
8c93bb |
# Define application title. This value is dislayed on the
|
|
|
8c93bb |
# browser's title bar. Notice that we concatenated the page class
|
|
|
8c93bb |
# default value here.
|
|
|
8c93bb |
app.title += ' :: Home'
|
|
|
8c93bb |
|
|
|
8c93bb |
page_header = app.logo()
|
|
|
8c93bb |
page_header += app.ads_google()
|
|
|
8c93bb |
page_header += app.navibar_top()
|
|
|
8c93bb |
page_header += app.lastreleases()
|
|
|
8c93bb |
page_header += app.appslinks()
|
|
|
8c93bb |
page_header += page_navibar_tabs()
|
|
|
8c93bb |
page_header = app.tag_div({'id': 'page-header'}, [4, 1], page_header, 1)
|
|
|
8c93bb |
|
|
|
8c93bb |
page_body = page_content() + app.separator(indent=[12,1])
|
|
|
8c93bb |
page_body = app.tag_div({'id':'content'}, [8,1], page_body, 1)
|
|
|
8c93bb |
page_body = app.tag_div({'id':'page-body'}, [4,1], page_body, 1)
|
|
|
8c93bb |
|
|
|
8c93bb |
page_footer = app.tag_div({'id': 'page-footer'}, [4,1], app.credits(), 1)
|
|
|
8c93bb |
|
|
|
8c93bb |
top = app.tag_a({'name':'top'}, [0,1])
|
|
|
8c93bb |
wrap = app.tag_div({'id': 'wrap'}, [0,1], page_header + page_body + page_footer)
|
|
|
8c93bb |
body = app.tag_body('', [0,1], top + wrap)
|
|
|
8c93bb |
|
|
|
8c93bb |
html = app.preamble()
|
|
|
8c93bb |
html += app.tag_html({'xmlns': 'http://www.w3.org/1999/xhtml', 'dir': 'ltr',
|
|
|
8c93bb |
'lang': str(app.language), 'xml:lang':
|
|
|
8c93bb |
str(app.language)}, [0,1], app.metadata() + body)
|
|
|
8c93bb |
|
|
|
8c93bb |
return html
|