Beispiel #1
0
    def get(self):
		page = Page()

		# redPanda class that gets all the attributes from the AbstractAnimals class
		red_panda = Sound()
		red_panda.name = "Red Panda"
		red_panda.phylum = "Chordata"
		red_panda.cclass = "Mammalia"
		red_panda.order = "Carnivora"
		red_panda.family = "Ailuridae"
		red_panda.genus = "Ailurus"
		red_panda.url = "http://animaldiversity.ummz.umich.edu/collections/contributors/Kjeldsen_Per/Red_Panda7208/large.jpg"
		red_panda.alifespan = "The maximum lifespan of the red panda is 14 years, but the average is eight to ten."
		red_panda.habitat = "Red pandas live in temperate climates in deciduous and coniferous forests. There is usually an understory of bamboo and hollow trees. The average temperature is 10 to 25 degrees Celsius, and the average annual rainfall is 350 centimeters."
		red_panda.geolocation = "Red pandas are found throughout the Himalayan mountains between 2,200 and 4,800 meters in elevation in northern Burma, Nepal, Sikkim region of India, and the districts of western Sichuan and Yunnan in China. Their geographic range is bounded in the north by the Namlung Valley in the Mugo District and the Lake Rara region of northern Nepal, in the south by the Liakiang Range of western Yunnan, and the northern and eastern boundary is the upper Min Valley of western Sichuan."
		red_panda.sound = "Wieuw Wieuw"
		red_panda.update()

		# great_auk class that gets all the attributes from the AbstractAnimals class
		great_auk = Sound();
		great_auk.name = "Great Auk"
		great_auk.phylum = "Chordata"
		great_auk.cclass = "Aves"
		great_auk.order = "Charadriiformes"
		great_auk.family = "Alcidae"
		great_auk.genus = "Pinguinus"
		great_auk.url = "http://animaldiversity.ummz.umich.edu/collections/contributors/grzimek_birds/Alcidae/pinguinus_impennis/medium.jpg"
		great_auk.alifespan = "As in other large seabirds, annual survival is thought to have been relatively high. Estimated lifespan was from 20 to 25 years."
		great_auk.habitat = "In recorded history, great auks were found breeding only on isolated, rocky islands in the North Atlantic. They foraged in the open ocean when not breeding."
		great_auk.geolocation = "The last great auk was seen in 1852 off the Newfoundland Banks. They were extinct in the western Atlantic before 1800 and persisted a bit longer in some parts of the eastern Atlantic and off the coast of Iceland. They lived and bred on scattered, offshore islands in the northern Atlantic in recorded history, although it is possible they once occurred on continental coastlines but were extirpated from those areas earlier. They were found from Canada, Greenland, and Iceland to the British Isles and Scandinavia. Colonies in the western Atlantic may have been less numerous than in the eastern Atlantic. Archeological records indicate they once occurred as far south as southern Spain and New England in the United States, Pleistocene records indicate great auks occurred as far south as Italy and other parts of the Mediterranean. Great auks became extinct before any natural history studies were conducted, so little is known about their lives except for a few studies of lone, captive birds and the casual records of mariners."
		great_auk.sound = "Wrah Wrah"
		great_auk.update()

		# Leopard Cat class that gets all the attributes from the AbstractAnimals class
		leopard_cat = Sound()
		leopard_cat.name = "Leopard Cat"
		leopard_cat.phylum = "Chordata"
		leopard_cat.cclass = "Mammalia"
		leopard_cat.order = "Carnivora"
		leopard_cat.family = "Felidae"
		leopard_cat.genus = "Prionailurus"
		leopard_cat.url = "http://animaldiversity.ummz.umich.edu/collections/contributors/tanya_dewey/leopardcat/large.jpg"
		leopard_cat.alifespan = "In the wild, leopard cats have an average lifespan of about 4 years, and have been known to live up to 20 years in captivity. The lifespan of captive individuals varies greatly as individuals may die from the stress of transport. When leopard cats are released into non-native environments by breeders, they usually die not long after."
		leopard_cat.habitat = "Prionailurus bengalensis is found in tropical and temperate forests, coniferous forests, shrub land habitat, and grasslands. Its distribution is limited to areas with less than 10 cm of snow annually, and it is not found in steppe or arid climates. Prionailurus bengalensis has a fairly diverse diet and is able to find food in most habitats. It seems relatively impervious to human disturbance as populations in secondary growth and disturbed areas are stable and it is often found near agricultural fields and rural settlements. Prionailurus bengalensis is an exceptional swimmer, possibly explaining its distribution on islands, and is intolerant of temperatures above 35 C, possibly explaining its absence from central India. It is capable of living at higher elevations (i.e., 3000 m) with minimal snow fall."
		leopard_cat.geolocation = "Prionailurus bengalensis is one of the most widespread carnivore species in Asia, and can be found throughout most of southern Asia. Prionailurus bengalensis occupies eastern Afghanistan and northern Pakistan, northern and coastal India, Myanmar, Laos, Thailand, Indonesia, Malaysia, Vietnam, Taiwan, Sumatra, Java, Bali, Borneo, Nepal, Korea, Cambodia, parts of the Philippines, and Eastern China. Prionailurus bengalensis has been divided into a number of subspecies over its range that differ in coloration, pelage, body length, and reproductive cycles."	
		leopard_cat.sound = "Whish Whish"
		leopard_cat	.update()

		#Array with all the animals in it
		animals = [red_panda,great_auk,leopard_cat]

		self.response.write(page.head())
		self.response.write(page.nav())
		if self.request.GET:
			indexAnimal = int(self.request.GET['animal']) #Grabs the index number out of the URL on the top of the browser
			self.response.write(page.content(animals[indexAnimal])) #fills the templating in with the index number 
		 #Buttons on the page
		self.response.write(page.foot()) # Footer of the page. Currently blank		
Beispiel #2
0
def Storage(params=None):
    handle_params(params)

    data = []
    with pg_connection(*current_user.get_config()) as (con, cur, err):
        with pg_log_err('list storage query'):
            cur.execute(query('list-storage'))
            data = cur.fetchall()

    display_schemas = params.getlist('schema')
    schemas = set()
    treemap_data = {'name': 'root', 'children': []}
    for (schema_name, table_name, t_size, t_tuples) in data:
        schemas.add(schema_name)
        if schema_name in display_schemas or len(display_schemas) == 0:
            treemap_data['children'].append({'schema_name': schema_name, 'name': table_name,
                                             'size': int(t_size), 'rows': int(t_tuples)})

    p = Page()

    # Header
    p.add_page(Header(title='Storage',
                      js=['static/pages/storage.js',
                          'static/lib/d3/d3.js',
                          'static/lib/d3/lib/colorbrewer/colorbrewer.js'],
                      css=['static/pages/storage.css']))
    p.add_page(Navigation(page='storage'))
    with p.div({'class': 'container-fluid'}):
        with p.div({'class': 'row form-row'}):
            with p.div({'class': 'col-md-10'}):
                with p.form({'id': 'schema-form', 'class': 'form-inline'}):
                    for schema in schemas:
                        with p.label({'class': 'checkbox-inline'}):
                            checked = (schema in display_schemas or len(display_schemas) == 0) and 'checked' or ''
                            with p.input({'type': 'checkbox', 'name': 'schema', 'value': '%s' % schema}, args=[checked]):
                                p.content(schema)

            with p.div({'class': 'col-md-2'}):
                with p.form({'id': 'mode-form', 'class': 'form-inline'}):
                    with p.label({'class': 'radio-inline'}):
                        with p.input({'type': 'radio', 'name': 'mode', 'value': 'size'}, args=['checked']):
                            p.content('Size')
                    with p.label({'class': 'radio-inline'}):
                        with p.input({'type': 'radio', 'name': 'mode', 'value': 'rows'}):
                            p.content('Rows (est.)')

        with p.div({'class': 'row'}):
            with p.div({'class': 'col-md-12'}):
                with p.div({'id': 'treemap-chart'}): pass
                with p.script():
                    p.content('PGUI.STORAGE.mk_treemap_chart(%s);' % json.dumps(treemap_data))

    p.add_page(Footer())

    return p
Beispiel #3
0
def Navigation(params=None, page=None):
    p = Page()

    with p.nav({'class': 'navbar navbar-default'}):
        with p.div({'class': 'container-fluid'}):
            with p.div({'class': 'navbar-header'}):
                with p.button({
                        'type': 'button',
                        'class': 'navbar-toggle collapsed',
                        'data-toggle': 'collapse',
                        'data-target': '#navbar',
                        'aria-expanded': 'false',
                        'aria-controls': 'navbar'
                }):
                    with p.span({'class': 'sr-only'}):
                        p.content('Toggle navigation')
                    with p.span({'class': 'icon-bar'}):
                        pass
                    with p.span({'class': 'icon-bar'}):
                        pass
                    with p.span({'class': 'icon-bar'}):
                        pass

                with p.a({'class': 'navbar-brand', 'href': '/'}):
                    p.content('pgui')

            with p.div({'id': 'navbar', 'class': 'navbar-collapse collapse'}):
                with p.ul({'class': 'nav navbar-nav'}):
                    for i, page in enumerate(pages.index.PAGES, 1):
                        active = page['name'] == page and 'active' or ''
                        with p.li({'class': active}):
                            with p.a({
                                    'id': 'page-%s' % i,
                                    'href': '/%s' % page['name']
                            }):
                                with p.span({
                                        'class':
                                        'glyphicon glyphicon-%s' % page['icon']
                                }):
                                    pass
                                p.content(' %s' % page['name'].title())

                with p.ul({'class': 'nav navbar-nav navbar-right'}):
                    with p.li():
                        with p.a({'href': '/logout'}):
                            with p.span(
                                {'class': 'glyphicon glyphicon-log-out'}):
                                p.content(' Logout')

    return p
Beispiel #4
0
	def render(self, method, *args, **kwargs):
		# Use a dummy Page here so that we don't clobber the defaults
		# we set in __init__ when changing something in the actual app.
		data = Page()

		data.content=self.app.dispatch(method, *args, **kwargs)

		# Add page-level metadata, this is currently only for the base
		# template variable.
		data.update(self)

		if hasattr(self.app, 'metadata'):
			data.update(self.app.metadata)

		return self.renderer.render(data)
Beispiel #5
0
def admin_ajax(action):
    name = request.forms.name
    try:
        Validator.check_name(name)
        p = Page(name)
        if action == 'save':
            p.content = request.forms.content
            p.save()
        elif action == 'publish':
            p.publish()
        elif action == 'remove':
            delall = bool(request.forms.delall)
            p.remove(delall)
        else:
            raise PageError('No such action')
    except PageError, e:
        return {'status': 'fail', 'data': str(e)}
Beispiel #6
0
def Navigation(params=None, page=None):
    p = Page()

    with p.nav({'class': 'navbar navbar-default'}):
        with p.div({'class': 'container-fluid'}):
            with p.div({'class': 'navbar-header'}):
                with p.button({'type': 'button',
                               'class': 'navbar-toggle collapsed',
                               'data-toggle': 'collapse',
                               'data-target': '#navbar',
                               'aria-expanded': 'false',
                               'aria-controls': 'navbar'}):
                    with p.span({'class': 'sr-only'}):
                        p.content('Toggle navigation')
                    with p.span({'class': 'icon-bar'}): pass
                    with p.span({'class': 'icon-bar'}): pass
                    with p.span({'class': 'icon-bar'}): pass

                with p.a({'class': 'navbar-brand', 'href': '/'}):
                    p.content('pgui')

            with p.div({'id': 'navbar', 'class': 'navbar-collapse collapse'}):
                with p.ul({'class': 'nav navbar-nav'}):
                    for i, page in enumerate(pages.index.PAGES, 1):
                        active = page['name'] == page and 'active' or ''
                        with p.li({'class': active}):
                            with p.a({'id': 'page-%s' % i, 'href': '/%s' % page['name']}):
                                with p.span({'class': 'glyphicon glyphicon-%s' % page['icon']}): pass
                                p.content(' %s' % page['name'].title())

                with p.ul({'class': 'nav navbar-nav navbar-right'}):
                    with p.li():
                        with p.a({'href': '/logout'}):
                            with p.span({'class': 'glyphicon glyphicon-log-out'}):
                                p.content(' Logout')

    return p
Beispiel #7
0
def Query(params=None):
    handle_params(params)
    p = Page()

    # Header
    p.add_page(Header(title='Query',
                      js=['static/pages/query.js',
                          'static/pages/query_completion.js',
                          'static/pages/keywords.js',
                          'static/lib/springy/springy.js',
                          'static/lib/springy/springyui.js'],
                      css=['static/pages/query.css']))
    with p.script():
        p.content('PGUI.QUERY.keymap = "%s";' % current_user.keymap)
    p.add_page(Navigation(page='query'))

    with p.div({'class': 'container-fluid'}):
        # Modal dialog for displaying previous queries
        with p.div({'class': 'modal fade', 'id': 'query-history-dialog', 'tabindex': '-1', 'role': 'dialog', 'aria-labelledby': 'Query History'}):
            with p.div({'class': 'modal-dialog', 'role': 'document'}):
                with p.div({'class': 'modal-content'}):
                    with p.div({'class': 'modal-header'}):
                        with p.button({'type': 'button', 'class': 'close', 'data-dismiss': 'modal', 'aria-label': 'Close'}):
                            with p.span({'aria-hidden': 'true'}):
                                p.content('×')
                        with p.h4({'class': 'modal-title', 'id': 'query-history-label'}):
                            p.content('Query history')

                    with p.div({'clas': 'modal-body'}):
                        with p.div({'id': 'query-history'}): pass

        # Tab bar controls
        with p.div({'id': 'query-panel', 'role': 'tabpanel'}):
            with p.ul({'id': 'query-nav-tabs', 'class': 'nav nav-tabs', 'role': 'tablist'}):
                with p.li({'role': 'presentation'}):
                    with p.a({'id': 'show-query-history', 'href': 'javascript:void(0);'}):
                        with p.span({'class': 'add-tab glyphicon glyphicon-camera', 'aria-hidden': 'true'}): pass
                with p.li({'role': 'presentation'}):
                    with p.a({'id': 'add-tab', 'href': 'javascript:void(0);'}):
                        with p.span({'class': 'add-tab glyphicon glyphicon-plus', 'aria-hidden': 'true'}): pass
            # Tab bar contents
            with p.div({'id': 'query-tab-panes', 'class': 'tab-content'}): pass

    # Footer
    p.add_page(Footer())

    return p
Beispiel #8
0
def Header(params=None, title=None, css=None, js=None):
    p = Page()

    p.content('<!DOCTYPE html>')
    with p.html(close=False):
        with p.head():
            with p.title():
                p.content('pgui - %s/%s' % (cu.database, title))

            with p.meta({'charset': 'utf-8'}): pass
            with p.script({'src': 'static/lib/jquery/jquery-2.1.3.js'}): pass
            with p.script({'src': 'static/pgui.js'}): pass
            with p.link({'href': 'static/pgui.css', 'rel': 'stylesheet'}): pass
            with p.link({'href': 'static/lib/bootstrap/bootstrap-3.3.4-dist/css/bootstrap.css', 'rel': 'stylesheet'}): pass
            with p.link({'href': 'static/lib/codemirror/codemirror-5.1/lib/codemirror.css', 'rel': 'stylesheet'}): pass
            with p.link({'href': 'static/lib/codemirror/codemirror-5.1/theme/neo.css', 'rel': 'stylesheet'}): pass
            with p.link({'href': 'static/lib/codemirror/codemirror-5.1/addon/hint/show-hint.css', 'rel': 'stylesheet'}): pass
            if css:
                for c in css:
                    with p.link({'href': c, 'rel': 'stylesheet'}): pass
            with p.script({'src': 'static/lib/bootstrap/bootstrap-3.3.4-dist/js/bootstrap.js'}): pass
            with p.script({'src': 'static/lib/codemirror/codemirror-5.1/lib/codemirror.js'}): pass
            with p.script({'src': 'static/lib/codemirror/codemirror-5.1/keymap/emacs.js'}): pass
            with p.script({'src': 'static/lib/codemirror/codemirror-5.1/keymap/vim.js'}): pass
            with p.script({'src': 'static/lib/codemirror/codemirror-5.1/keymap/sublime.js'}): pass
            with p.script({'src': 'static/lib/codemirror/codemirror-5.1/mode/sql/sql.js'}): pass
            with p.script({'src': 'static/lib/codemirror/codemirror-5.1/addon/hint/show-hint.js'}): pass
            if js:
                for j in js:
                    with p.script({'src': j}): pass

        with p.body(close=False):
            config = 'PGUI.user = "******"; PGUI.db = "%s"; PGUI.host = "%s";' % (cu.name, cu.database, cu.host)
            with p.script():
                p.content(config)

    return p
Beispiel #9
0
import os
from page import Page
from colours import colour_print
from printer import instance as printer

page_number = os.path.splitext(os.path.basename(__file__))[0]
sub_page = Page(page_number)
sub_page.title = "Page Not Found"
sub_page.in_index=False
sub_page.content = colour_print(printer.text_to_ascii("404", padding={"left": 30}))
sub_page.content += "\n\n"
sub_page.content += colour_print(printer.text_to_ascii("Page Not Found", padding={"left": 2}))
Beispiel #10
0
        self.content = content

pages=[]
bus01 = BusPage("801","57596","Gower Street / UCH","N")
bus02 = BusPage("802","50975","Euston Square Station","P")
bus03 = BusPage("803","51664","Euston Station","H")
bus04 = BusPage("804","75100","Euston Station","AZ")
bus05 = BusPage("805","73933","Euston Station","C")
bus06 = BusPage("806","53602","Euston Bus Station","AP")
bus07 = BusPage("807","56230",Foreground.GREEN+"Euston Station"+Foreground.DEFAULT,"D")
bus08 = BusPage("808","47118","Euston Bus Station","G")
bus09 = BusPage("809","58234","Euston Station","E")
bus10 = BusPage("810","51581","Upper Woburn Place / Euston Road","L")
bus11 = BusPage("811","72926","Upper Woburn Place","M")
bus12 = BusPage("812","72238","Jubilee Road","PD")
bus13 = BusPage("813","58812","Jubilee Road","J")
bus14 = BusPage("814","55027","Wembley Park Station","O")
bus15 = BusPage("815","59287",Foreground.GREEN+"Euston Square Station"+Foreground.DEFAULT,"Q")

tv_page = Page("800")
tv_page.content = colour_print(printer.text_to_ascii("Buses Index"))+"\n"
tv_page.title = "Buses Index"
i=0
for page in pages:
    tv_page.content+=tv_page.colours.Foreground.RED+page[0]+tv_page.colours.Foreground.DEFAULT+" "+page[1]
    if i==1:
        tv_page.content += "\n"
    else:
        tv_page.content += " "*(38-len(page[0]+page[1]))
    i = 1-i
Beispiel #11
0
def Storage(params=None):
    handle_params(params)

    data = []
    with pg_connection(*current_user.get_config()) as (con, cur, err):
        with pg_log_err('list storage query'):
            cur.execute(query('list-storage'))
            data = cur.fetchall()

    display_schemas = params.getlist('schema')
    schemas = set()
    treemap_data = {'name': 'root', 'children': []}
    for (schema_name, table_name, t_size, t_tuples) in data:
        schemas.add(schema_name)
        if schema_name in display_schemas or len(display_schemas) == 0:
            treemap_data['children'].append({
                'schema_name': schema_name,
                'name': table_name,
                'size': int(t_size),
                'rows': int(t_tuples)
            })

    p = Page()

    # Header
    p.add_page(
        Header(title='Storage',
               js=[
                   'static/pages/storage.js', 'static/lib/d3/d3.js',
                   'static/lib/d3/lib/colorbrewer/colorbrewer.js'
               ],
               css=['static/pages/storage.css']))
    p.add_page(Navigation(page='storage'))
    with p.div({'class': 'container-fluid'}):
        with p.div({'class': 'row form-row'}):
            with p.div({'class': 'col-md-10'}):
                with p.form({'id': 'schema-form', 'class': 'form-inline'}):
                    for schema in schemas:
                        with p.label({'class': 'checkbox-inline'}):
                            checked = (schema in display_schemas
                                       or len(display_schemas)
                                       == 0) and 'checked' or ''
                            with p.input(
                                {
                                    'type': 'checkbox',
                                    'name': 'schema',
                                    'value': '%s' % schema
                                },
                                    args=[checked]):
                                p.content(schema)

            with p.div({'class': 'col-md-2'}):
                with p.form({'id': 'mode-form', 'class': 'form-inline'}):
                    with p.label({'class': 'radio-inline'}):
                        with p.input(
                            {
                                'type': 'radio',
                                'name': 'mode',
                                'value': 'size'
                            },
                                args=['checked']):
                            p.content('Size')
                    with p.label({'class': 'radio-inline'}):
                        with p.input({
                                'type': 'radio',
                                'name': 'mode',
                                'value': 'rows'
                        }):
                            p.content('Rows (est.)')

        with p.div({'class': 'row'}):
            with p.div({'class': 'col-md-12'}):
                with p.div({'id': 'treemap-chart'}):
                    pass
                with p.script():
                    p.content('PGUI.STORAGE.mk_treemap_chart(%s);' %
                              json.dumps(treemap_data))

    p.add_page(Footer())

    return p
Beispiel #12
0
def Login(params=None, title=None):
    """
    Renders the login page.

    There is no separate login for the application, this is passed to
    the database!
    """
    p = Page()
    p.content('<!DOCTYPE html>')
    with p.html():
        with p.head():
            with p.title():
                p.content('pgui - Login')
            with p.link({'href': 'static/lib/bootstrap/bootstrap-3.3.4-dist/css/bootstrap.css', 'rel': 'stylesheet'}): pass
            with p.link({'href': 'static/login.css', 'rel': 'stylesheet'}): pass

        with p.body():

            with p.div({'class': 'container'}):
                with p.form({'method': 'POST', 'class': 'login'}):
                    with p.h2({'class': 'login-header'}):
                        p.content('Connect to a postgres database server')

                    with p.label({'for': 'name', 'class': 'sr-only'}):
                        p.content('User name')
                    with p.input({'type': 'input', 'id': 'name', 'name': 'name', 'class': 'form-control', 'placeholder': 'User name'}): pass

                    with p.label({'for': 'password', 'class': 'sr-only'}):
                        p.content('Password')
                    with p.input({'type': 'password', 'id': 'password', 'name': 'password', 'class': 'form-control', 'placeholder': 'Password'}): pass

                    with p.label({'for': 'host', 'class': 'sr-only'}):
                        p.control('Host')
                    with p.input({'type': 'input', 'id': 'host', 'name': 'host', 'class': 'form-control', 'value': 'localhost'}): pass

                    with p.label({'for': 'port', 'class': 'sr-only'}):
                        p.content('Port')
                    with p.input({'type': 'input', 'id': 'port', 'name': 'port', 'class': 'form-control', 'value': '5432'}): pass

                    with p.button({'class': 'btn btn-lg btn-success btn-block', 'type': 'submit'}, args=['autofocus']):
                        p.content('Connect')


                with p.div({'class': 'login'}):
                    if 'err' in params and params['err']:
                        for err in params['err']:
                            with p.code():
                                p.content(err)

    return p
Beispiel #13
0
import os
from page import Page
from colours import colour_print
from printer import instance as printer

page_number = os.path.splitext(os.path.basename(__file__))[0]
sub_page = Page(page_number)
sub_page.title = "Subtitles"
sub_page.content = colour_print(
    printer.text_to_ascii("subtitles", padding={"left": 6}))
Beispiel #14
0
def Index(params=None):
    """
    Renders the index page which displays some generic connections
    information and links to all the activated modules.
    """
    handle_params(params)
    p = Page()

    # Header
    p.add_page(Header(title='Index'))
    p.add_page(Navigation(page='index'))

    with p.div({'class': 'container-fluid'}):
        # Connection information
        data, params = [], defaultdict(str)
        param_keys = ('server_version', 'server_encoding', 'client_encoding', 'is_superuser', 'TimeZone')
        with pg_connection(*current_user.get_config()) as (con, cur, err):
            for k in param_keys:
                params[k] = con.get_parameter_status(k)
            with pg_log_err('list databases'):
                cur.execute(query('list-databases'))
                data = cur.fetchall()

        with p.div({'class': 'row'}):
            with p.div({'class': 'col-md-2'}):
                with p.div({'class': 'btn-group'}):
                    with p.button({'class': 'btn btn-default dropdown-toggle', 'data-toggle': 'dropdown', 'aria-expanded': 'false'}):
                        p.content('Switch database <span class="caret"></span>')
                    with p.ul({'class': 'dropdown-menu', 'role': 'menu'}):
                        for n, d in enumerate(data):
                            with p.li():
                                with p.a({'href': 'index?database=%s' % d[0]}):
                                    p.content(d[0])
                            if n < len(data) - 1:
                                with p.li({'class': 'divider'}): pass

            with p.div({'class': 'col-md-4 small'}):
                p.content('<strong>%s</strong>' % current_user.database)
                p.content('<br>%s@%s:%s' % (current_user.name, current_user.host, current_user.port))

            with p.div({'class': 'col-md-6 small'}):
                with p.ul({'class': 'list-inline'}):
                    for k, v in sorted(params.items()):
                        with p.li():
                            p.content('%s: %s' % (k, v))

        with p.hr(): pass

        # Modules
        cols = 12
        col_size = 4
        col = 0
        for page in PAGES[1:]:
            if col == 0:
                with p.div({'class': 'row'}, close=False): pass

            with p.div({'class': 'col-md-%s' % col_size}):
                with p.a({'href': '/%s' % page['name']}):
                    with p.div({'class': 'page-link'}):
                        with p.span({'class': 'page-icon glyphicon glyphicon-%s' % page['icon']}): pass
                        with p.h3():
                            p.content(page['caption'])
                        p.content(page['desc'])

            col = (col + col_size) % cols
            if col == 0:
                p.close('div')

    p.add_page(Footer())

    return p
Beispiel #15
0
def Structure(params=None):
    handle_params(params)
    p = Page()

    # Header
    p.add_page(Header(title='Structure',
                      js=['static/pages/structure.js'],
                      css=['static/pages/structure.css']))
    p.add_page(Navigation(page='structure'))

    with p.div({'class': 'container-fluid'}):
        schemas, schema_cols, table_data, table_cols = get_data()

        with p.ul():
            for schema in schemas:
                with p.div({'class': 'panel panel-default'}):
                    with p.div({'class': 'panel-heading'}):
                        with p.div({'class': 'row'}):
                            with p.div({'class': 'col-md-2'}):
                                with p.a({'class': 'btn btn-success btn-xs schema-btn',
                                          'data-toggle': 'collapse',
                                          'href': '#%s' % schema[0],
                                          'aria-expanded': 'false',
                                          'aria-controls': schema[0]}):
                                    p.content('%s - %s' % (schema[0], schema[1]))

                            with p.div({'class': 'col-md-10'}):
                                with p.ul({'class': 'list-inline'}):
                                    for i, col in enumerate(schema_cols, 2):
                                        with p.li():
                                            p.content('<strong>%s</strong> %s' % (schema[i], col))

                    with p.div({'class': 'panel-body'}):
                        with p.div({'class': 'row collapse', 'id': schema[0]}):
                            with p.div({'class': 'col-md-2'}):
                                with p.div({'class': 'well'}):
                                    with p.b():
                                        p.content('Tables')

                                    with p.ul():
                                        for table in table_data[schema[0]]:
                                            with p.li():
                                                with p.a({'href': '#', 'onclick': 'PGUI.STRUCTURE.show_table_details(\'%s\', \'%s\'); return false;' % (schema[0], table)}):
                                                    p.content(table)

                            with p.div({'class': 'col-md-10'}):
                                for table in table_data[schema[0]]:
                                    with p.div({'id': 'table-details-%s-%s' % (schema[0], table), 'class': 'table-details table-details-%s' % schema[0]}):
                                        data = table_data[schema[0]][table]
                                        with p.p():
                                            p.content('Table size: ')
                                            with p.b():
                                                p.content(data['table-size'])

                                        with p.table({'class': 'table table-condensed'}):
                                            with p.tr():
                                                for tc in table_cols:
                                                    with p.th():
                                                        p.content(tc)
                                                with p.th({'id': 'col-size-header-%s-%s' % (schema[0], table)}):
                                                    with p.a({'href': '#',
                                                              'onclick': 'PGUI.STRUCTURE.get_col_size(\'%s\', \'%s\'); return false;' % (schema[0], table)}):
                                                        p.content('Get column sizes')

                                            for row in zip(*data['column-data'].values()):
                                                with p.tr():
                                                    for col in row:
                                                        with p.td():
                                                            p.content(col)
                                                    with p.td({'id': 'col-size-%s-%s-%s' % (schema[0], table, row[0])}):
                                                        pass

    p.add_page(Footer())

    return p
Beispiel #16
0
def Query(params=None):
    handle_params(params)
    p = Page()

    # Header
    p.add_page(
        Header(title='Query',
               js=[
                   'static/pages/query.js', 'static/pages/query_completion.js',
                   'static/pages/keywords.js', 'static/lib/springy/springy.js',
                   'static/lib/springy/springyui.js'
               ],
               css=['static/pages/query.css']))
    with p.script():
        p.content('PGUI.QUERY.keymap = "%s";' % current_user.keymap)
    p.add_page(Navigation(page='query'))

    with p.div({'class': 'container-fluid'}):
        # Modal dialog for displaying previous queries
        with p.div({
                'class': 'modal fade',
                'id': 'query-history-dialog',
                'tabindex': '-1',
                'role': 'dialog',
                'aria-labelledby': 'Query History'
        }):
            with p.div({'class': 'modal-dialog', 'role': 'document'}):
                with p.div({'class': 'modal-content'}):
                    with p.div({'class': 'modal-header'}):
                        with p.button({
                                'type': 'button',
                                'class': 'close',
                                'data-dismiss': 'modal',
                                'aria-label': 'Close'
                        }):
                            with p.span({'aria-hidden': 'true'}):
                                p.content('&times;')
                        with p.h4({
                                'class': 'modal-title',
                                'id': 'query-history-label'
                        }):
                            p.content('Query history')

                    with p.div({'clas': 'modal-body'}):
                        with p.div({'id': 'query-history'}):
                            pass

        # Tab bar controls
        with p.div({'id': 'query-panel', 'role': 'tabpanel'}):
            with p.ul({
                    'id': 'query-nav-tabs',
                    'class': 'nav nav-tabs',
                    'role': 'tablist'
            }):
                with p.li({'role': 'presentation'}):
                    with p.a({
                            'id': 'show-query-history',
                            'href': 'javascript:void(0);'
                    }):
                        with p.span({
                                'class': 'add-tab glyphicon glyphicon-camera',
                                'aria-hidden': 'true'
                        }):
                            pass
                with p.li({'role': 'presentation'}):
                    with p.a({'id': 'add-tab', 'href': 'javascript:void(0);'}):
                        with p.span({
                                'class': 'add-tab glyphicon glyphicon-plus',
                                'aria-hidden': 'true'
                        }):
                            pass
            # Tab bar contents
            with p.div({'id': 'query-tab-panes', 'class': 'tab-content'}):
                pass

    # Footer
    p.add_page(Footer())

    return p
Beispiel #17
0
def Index(params=None):
    """
    Renders the index page which displays some generic connections
    information and links to all the activated modules.
    """
    handle_params(params)
    p = Page()

    # Header
    p.add_page(Header(title='Index'))
    p.add_page(Navigation(page='index'))

    with p.div({'class': 'container-fluid'}):
        # Connection information
        data, params = [], defaultdict(str)
        param_keys = ('server_version', 'server_encoding', 'client_encoding',
                      'is_superuser', 'TimeZone')
        with pg_connection(*current_user.get_config()) as (con, cur, err):
            for k in param_keys:
                params[k] = con.get_parameter_status(k)
            with pg_log_err('list databases'):
                cur.execute(query('list-databases'))
                data = cur.fetchall()

        with p.div({'class': 'row'}):
            with p.div({'class': 'col-md-2'}):
                with p.div({'class': 'btn-group'}):
                    with p.button({
                            'class': 'btn btn-default dropdown-toggle',
                            'data-toggle': 'dropdown',
                            'aria-expanded': 'false'
                    }):
                        p.content(
                            'Switch database <span class="caret"></span>')
                    with p.ul({'class': 'dropdown-menu', 'role': 'menu'}):
                        for n, d in enumerate(data):
                            with p.li():
                                with p.a({'href': 'index?database=%s' % d[0]}):
                                    p.content(d[0])
                            if n < len(data) - 1:
                                with p.li({'class': 'divider'}):
                                    pass

            with p.div({'class': 'col-md-4 small'}):
                p.content('<strong>%s</strong>' % current_user.database)
                p.content(
                    '<br>%s@%s:%s' %
                    (current_user.name, current_user.host, current_user.port))

            with p.div({'class': 'col-md-6 small'}):
                with p.ul({'class': 'list-inline'}):
                    for k, v in sorted(params.items()):
                        with p.li():
                            p.content('%s: %s' % (k, v))

        with p.hr():
            pass

        # Modules
        cols = 12
        col_size = 4
        col = 0
        for page in PAGES[1:]:
            if col == 0:
                with p.div({'class': 'row'}, close=False):
                    pass

            with p.div({'class': 'col-md-%s' % col_size}):
                with p.a({'href': '/%s' % page['name']}):
                    with p.div({'class': 'page-link'}):
                        with p.span({
                                'class':
                                'page-icon glyphicon glyphicon-%s' %
                                page['icon']
                        }):
                            pass
                        with p.h3():
                            p.content(page['caption'])
                        p.content(page['desc'])

            col = (col + col_size) % cols
            if col == 0:
                p.close('div')

    p.add_page(Footer())

    return p
Beispiel #18
0
def Login(params=None, title=None):
    """
    Renders the login page.

    There is no separate login for the application, this is passed to
    the database!
    """
    p = Page()
    p.content('<!DOCTYPE html>')
    with p.html():
        with p.head():
            with p.title():
                p.content('pgui - Login')
            with p.link({
                    'href':
                    'static/lib/bootstrap/bootstrap-3.3.4-dist/css/bootstrap.css',
                    'rel': 'stylesheet'
            }):
                pass
            with p.link({'href': 'static/login.css', 'rel': 'stylesheet'}):
                pass

        with p.body():

            with p.div({'class': 'container'}):
                with p.form({'method': 'POST', 'class': 'login'}):
                    with p.h2({'class': 'login-header'}):
                        p.content('Connect to a postgres database server')

                    with p.label({'for': 'name', 'class': 'sr-only'}):
                        p.content('User name')
                    with p.input({
                            'type': 'input',
                            'id': 'name',
                            'name': 'name',
                            'class': 'form-control',
                            'placeholder': 'User name'
                    }):
                        pass

                    with p.label({'for': 'password', 'class': 'sr-only'}):
                        p.content('Password')
                    with p.input({
                            'type': 'password',
                            'id': 'password',
                            'name': 'password',
                            'class': 'form-control',
                            'placeholder': 'Password'
                    }):
                        pass

                    with p.label({'for': 'host', 'class': 'sr-only'}):
                        p.control('Host')
                    with p.input({
                            'type': 'input',
                            'id': 'host',
                            'name': 'host',
                            'class': 'form-control',
                            'value': 'localhost'
                    }):
                        pass

                    with p.label({'for': 'port', 'class': 'sr-only'}):
                        p.content('Port')
                    with p.input({
                            'type': 'input',
                            'id': 'port',
                            'name': 'port',
                            'class': 'form-control',
                            'value': '5432'
                    }):
                        pass

                    with p.button(
                        {
                            'class': 'btn btn-lg btn-success btn-block',
                            'type': 'submit'
                        },
                            args=['autofocus']):
                        p.content('Connect')

                with p.div({'class': 'login'}):
                    if 'err' in params and params['err']:
                        for err in params['err']:
                            with p.code():
                                p.content(err)

    return p
Beispiel #19
0
import os
from os.path import join,expanduser
from page import Page
from printer import instance as printer

page_number = os.path.splitext(os.path.basename(__file__))[0]
p_page = Page(page_number)

p_page.title = "House Points"
p_page.index_num = "402-403"

content = p_page.colours.colour_print(printer.text_to_ascii("house points"))

content += "\n\n"

R = p_page.colours.Foreground.RED
G = p_page.colours.Foreground.GREEN
D = p_page.colours.Foreground.DEFAULT

content += G+"Year " + " Gryffindor Slytherin Hufflepuff"    +   " Ravenclaw Durmstrang Squib Peeves"+D+"\n"
content += G+"2015a"+D+" 692        535       "+R+"1155"+D+"       702       440        513   0\n"
content += G+"2015b"+D+" 3382       408       "+R+"4614"+D+"       3591      606        2174  38\n"

p_page.content = content
Beispiel #20
0
def Header(params=None, title=None, css=None, js=None):
    p = Page()

    p.content('<!DOCTYPE html>')
    with p.html(close=False):
        with p.head():
            with p.title():
                p.content('pgui - %s/%s' % (cu.database, title))

            with p.meta({'charset': 'utf-8'}):
                pass
            with p.script({'src': 'static/lib/jquery/jquery-2.1.3.js'}):
                pass
            with p.script({'src': 'static/pgui.js'}):
                pass
            with p.link({'href': 'static/pgui.css', 'rel': 'stylesheet'}):
                pass
            with p.link({
                    'href':
                    'static/lib/bootstrap/bootstrap-3.3.4-dist/css/bootstrap.css',
                    'rel': 'stylesheet'
            }):
                pass
            with p.link({
                    'href':
                    'static/lib/codemirror/codemirror-5.1/lib/codemirror.css',
                    'rel': 'stylesheet'
            }):
                pass
            with p.link({
                    'href':
                    'static/lib/codemirror/codemirror-5.1/theme/neo.css',
                    'rel': 'stylesheet'
            }):
                pass
            with p.link({
                    'href':
                    'static/lib/codemirror/codemirror-5.1/addon/hint/show-hint.css',
                    'rel': 'stylesheet'
            }):
                pass
            if css:
                for c in css:
                    with p.link({'href': c, 'rel': 'stylesheet'}):
                        pass
            with p.script({
                    'src':
                    'static/lib/bootstrap/bootstrap-3.3.4-dist/js/bootstrap.js'
            }):
                pass
            with p.script({
                    'src':
                    'static/lib/codemirror/codemirror-5.1/lib/codemirror.js'
            }):
                pass
            with p.script({
                    'src':
                    'static/lib/codemirror/codemirror-5.1/keymap/emacs.js'
            }):
                pass
            with p.script(
                {'src': 'static/lib/codemirror/codemirror-5.1/keymap/vim.js'}):
                pass
            with p.script({
                    'src':
                    'static/lib/codemirror/codemirror-5.1/keymap/sublime.js'
            }):
                pass
            with p.script({
                    'src':
                    'static/lib/codemirror/codemirror-5.1/mode/sql/sql.js'
            }):
                pass
            with p.script({
                    'src':
                    'static/lib/codemirror/codemirror-5.1/addon/hint/show-hint.js'
            }):
                pass
            if js:
                for j in js:
                    with p.script({'src': j}):
                        pass

        with p.body(close=False):
            config = 'PGUI.user = "******"; PGUI.db = "%s"; PGUI.host = "%s";' % (
                cu.name, cu.database, cu.host)
            with p.script():
                p.content(config)

    return p
Beispiel #21
0
import colours
from printer import instance as printer

r1 = Page("581")
r1.title = "Bad Tempered Cake"
r1.in_index = False
r1.content = (colours.colour_print(
    printer.text_to_ascii("bad tempered cake"),
    colours.Background.RED,
    colours.Foreground.BLUE) +
"""
1/2 lb    Rich tea and/or digestive biscuits
    4 oz    Margarine
    1 dsp   Sugar
    3 dsp   Cocoa
    3 dsp   Drinking chocolate
1 1/2 tbsp  Golden syrup
    2 oz    Sultanas
    2 bars  Milk chocolate

1. Break the biscuits.
2. Melt the margarine, sugar, cocoa, drinking chocolate and syrup over a medium
   heat.
3. Mix with biscuits and sultanas and press down in baking tray.
4. Cover with melted milk chocolate.
5. Leave in the fridge to set""")

r2 = Page("582")
r2.title = "Huda Friendship Cake"
r2.in_index = False
r2.content = (colours.colour_print(
    printer.text_to_ascii("Huda Friendship Cake"),
Beispiel #22
0
content += "\nWho has the most Annawards?\n\n"

for i,award in enumerate(awards):
    content += "\n"+sub_page.colours.Foreground.GREEN+award[0]+sub_page.colours.Foreground.DEFAULT+" (see page "+pages[i]+")\n"
    max_ = 0
    max_p = None
    for person,number in award[1].items():
        if number>max_:
            max_p = person
            max_ = number
        elif number==max_:
            max_p = max_p+","+person
    if max_p is not None:
        content += "  " + max_p + "\n"
sub_page.content = content

def award_show(award):
    content = colours.Foreground.GREEN+award[0]+colours.Foreground.DEFAULT+"\n"
    max_len = 0
    for person in award[1]:
        max_len = max(max_len,len(person))
    for person,number in award[1].items():
        content += person + (" "*(max_len-len(person)))
        content += sub_page.colours.Foreground.RED+"|"+sub_page.colours.Foreground.DEFAULT
        for i in range(number):
            content += choice(sub_page.colours.Foreground.non_boring)
            content += u"o_O"+sub_page.colours.Foreground.DEFAULT
        content += "\n"
    return content
Beispiel #23
0
from page import Page
from random import choice

def colour_me(text):
    output = ""
    for i in text:
        output += choice(test_page.colours.Foreground.non_boring) + i
    output += test_page.colours.Foreground.DEFAULT
    return output

page_number = os.path.splitext(os.path.basename(__file__))[0]
test_page = Page(page_number)
test_page.title = "Test Page"
test_page.is_enabled = False

test_page.content = ""

test_page.content += "\n" + colour_me("TEST PAGE") + "\n"

# 000000011111111112222222222333333333344444444445555555555666666666677777777778
# 345678901234567890123456789012345678901234567890123456789012345678901234567890
#"          DEFAULT BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE"
#"BOLD      "
#"FAINT     "
#"STANDOUT  "
#"BLINK     "
#"UNDERLINE "
#"STRIKE    "
test_page.content += "\n" + colour_me("FOREGROUNDS & STYLES") + "\n"
for i in range(0,len(test_page.colours.Style.list)):
    test_page.content += test_page.colours.Style.delist[i] + " "*(13-len(test_page.colours.Style.delist[i]))