initial commit

This commit is contained in:
Massimo Di Pierro
2011-11-22 23:30:42 -06:00
commit d421c1321b
580 changed files with 115527 additions and 0 deletions
+233
View File
@@ -0,0 +1,233 @@
{{extend 'layout.html'}}
<script><!--
jQuery(document).ready(function(){
jQuery("table.sortable tbody tr").mouseover( function() {
jQuery(this).addClass("highlight"); }).mouseout( function() {
jQuery(this).removeClass("highlight"); });
jQuery('table.sortable tbody tr:odd').addClass('odd');
jQuery('table.sortable tbody tr:even').addClass('even');
});
//--></script>
{{if request.function=='index':}}
<h1>{{=T("Available databases and tables")}}</h1>
{{if not databases:}}{{=T("No databases in this application")}}{{pass}}
{{for db in sorted(databases):}}
{{for table in databases[db].tables:}}
{{qry='%s.%s.id>0'%(db,table)}}
{{tbl=databases[db][table]}}
{{if hasattr(tbl,'_primarykey'):}}
{{if tbl._primarykey:}}
{{firstkey=tbl[tbl._primarykey[0]]}}
{{if firstkey.type in ['string','text']:}}
{{qry='%s.%s.%s!=""'%(db,table,firstkey.name)}}
{{else:}}
{{qry='%s.%s.%s>0'%(db,table,firstkey.name)}}
{{pass}}
{{else:}}
{{qry=''}}
{{pass}}
{{pass}}
<h2>{{=A("%s.%s" % (db,table),_href=URL('select',args=[db],vars=dict(query=qry)))}}
</h2>
[ {{=A(str(T('insert new'))+' '+table,_href=URL('insert',args=[db,table]))}} ]
<br /><br />
{{pass}}
{{pass}}
{{elif request.function=='select':}}
<h1>{{=XML(str(T("database %s select"))%A(request.args[0],_href=URL('index'))) }}
</h1>
{{if table:}}
[ {{=A(str(T('insert new %s'))%table,_href=URL('insert',args=[request.args[0],table]))}} ]<br/><br/>
<h2>{{=T("Rows in table")}}</h2><br/>
{{else:}}
<h2>{{=T("Rows selected")}}</h2><br/>
{{pass}}
{{=form}}
<p>{{=T('The "query" is a condition like "db.table1.field1==\'value\'". Something like "db.table1.field1==db.table2.field2" results in a SQL JOIN.')}}<br/>
{{=T('Use (...)&(...) for AND, (...)|(...) for OR, and ~(...) for NOT to build more complex queries.')}}<br/>
{{=T('"update" is an optional expression like "field1=\'newvalue\'". You cannot update or delete the results of a JOIN')}}</p>
<br/><br/>
<h3>{{=nrows}} {{=T("selected")}}</h3>
{{if start>0:}}[ {{=A(T('previous 100 rows'),_href=URL('select',args=request.args[0],vars=dict(start=start-100)))}} ]{{pass}}
{{if stop<nrows:}}[ {{=A(T('next 100 rows'),_href=URL('select',args=request.args[0],vars=dict(start=start+100)))}} ]{{pass}}
{{if rows:}}
<div style="overflow: auto;" width="80%">
{{linkto=URL('update',args=request.args[0])}}
{{upload=URL('download',args=request.args[0])}}
{{=SQLTABLE(rows,linkto,upload,orderby=True,_class='sortable')}}
</div>
{{pass}}
<br/><br/><h2>{{=T("Import/Export")}}</h2><br/>
[ <a href="{{=URL('csv',args=request.args[0],vars=dict(query=query))}}">{{=T("export as csv file")}}</a> ]
{{if table:}}
{{=FORM(str(T('or import from csv file'))+" ",INPUT(_type='file',_name='csvfile'),INPUT(_type='hidden',_value=table,_name='table'),INPUT(_type='submit',_value='import'))}}
{{pass}}
{{elif request.function=='insert':}}
<h1>{{=T("database")}} {{=A(request.args[0],_href=URL('index'))}}
{{if hasattr(table,'_primarykey'):}}
{{fieldname=table._primarykey[0]}}
{{dbname=request.args[0]}}
{{tablename=request.args[1]}}
{{cond = table[fieldname].type in ['string','text'] and '!=""' or '>0'}}
{{=T("table")}} {{=A(tablename,_href=URL('select',args=dbname,vars=dict(query='%s.%s.%s%s'%(dbname,tablename,fieldname,cond))))}}
{{else:}}
{{=T("table")}} {{=A(request.args[1],_href=URL('select',args=request.args[0],vars=dict(query='%s.%s.id>0'%tuple(request.args[:2]))))}}
{{pass}}
</h1>
<h2>{{=T("New Record")}}</h2><br/>
{{=form}}
{{elif request.function=='update':}}
<h1>{{=T("database")}} {{=A(request.args[0],_href=URL('index'))}}
{{if hasattr(table,'_primarykey'):}}
{{fieldname=request.vars.keys()[0]}}
{{dbname=request.args[0]}}
{{tablename=request.args[1]}}
{{cond = table[fieldname].type in ['string','text'] and '!=""' or '>0'}}
{{=T("table")}} {{=A(tablename,_href=URL('select',args=dbname,vars=dict(query='%s.%s.%s%s'%(dbname,tablename,fieldname,cond))))}}
{{=T("record")}} {{=A('%s=%s'%request.vars.items()[0],_href=URL('update',args=request.args[:2],vars=request.vars))}}
{{else:}}
{{=T("table")}} {{=A(request.args[1],_href=URL('select',args=request.args[0],vars=dict(query='%s.%s.id>0'%tuple(request.args[:2]))))}}
{{=T("record id")}} {{=A(request.args[2],_href=URL('update',args=request.args[:3]))}}
{{pass}}
</h1>
<h2>{{=T("Edit current record")}}</h2><br/><br/>{{=form}}
{{elif request.function=='state':}}
<h1>{{=T("Internal State")}}</h1>
<h2>{{=T("Current request")}}</h2>
{{=BEAUTIFY(request)}}
<br/><h2>{{=T("Current response")}}</h2>
{{=BEAUTIFY(response)}}
<br/><h2>{{=T("Current session")}}</h2>
{{=BEAUTIFY(session)}}
{{elif request.function == 'ccache':}}
<h1>Cache</h1>
<div class="wrapper">
<div class="list">
<div class="list-header">
<h2>Statistics</h2>
</div>
<div class="content">
<h3>Overview</h3>
<p>Number of entries: <strong>{{=total['entries']}}</strong>
{{if total['entries'] > 0:}}
<p>
Hit Ratio:
<strong>{{=total['ratio']}}%</strong>
(<strong>{{=total['hits']}}</strong> hits
and <strong>{{=total['misses']}}</strong> misses)
</p>
<p>
Size of cache:
{{if object_stats:}}
<strong>{{=total['objects']}}</strong> items,
<strong>{{=total['bytes']}}</strong> bytes
{{if total['bytes'] > 524287:}}
(<strong>{{="%.0d" % (total['bytes'] / 1048576)}} MB</strong>)
{{pass}}
{{else:}} <strong>not available</strong> (requires the Python <a href="http://pypi.python.org/pypi/guppy/" target="_blank">guppy</a> library)
{{pass}}
</p>
<p>
Cache contains items up to
<strong>{{="%02d" % total['oldest'][0]}}</strong> hours
<strong>{{="%02d" % total['oldest'][1]}}</strong> minutes
<strong>{{="%02d" % total['oldest'][2]}}</strong> seconds old.
</p>
{{=BUTTON(T('Cache Keys'), _onclick='jQuery("#all_keys").toggle();')}}
<div class="hidden" id="all_keys">
{{=total['keys']}}
</div>
<br />
{{pass}}
<h3>RAM</h3>
<p>Number of entries: <strong>{{=ram['entries']}}</strong>
{{if ram['entries'] > 0:}}
<p>
Hit Ratio:
<strong>{{=ram['ratio']}}%</strong>
(<strong>{{=ram['hits']}}</strong> hits
and <strong>{{=ram['misses']}}</strong> misses)
</p>
<p>
Size of cache:
{{if object_stats:}}
<strong>{{=ram['objects']}}</strong> items,
<strong>{{=ram['bytes']}}</strong> bytes
{{if ram['bytes'] > 524287:}}
(<strong>{{=ram['bytes'] / 1048576}} MB</strong>)
{{pass}}
{{else:}} <strong>not available</strong> (requires the Python <a href="http://pypi.python.org/pypi/guppy/" target="_blank">guppy</a> library)
{{pass}}
</p>
<p>
RAM contains items up to
<strong>{{="%02d" % ram['oldest'][0]}}</strong> hours
<strong>{{="%02d" % ram['oldest'][1]}}</strong> minutes
<strong>{{="%02d" % ram['oldest'][2]}}</strong> seconds old.
</p>
{{=BUTTON(T('RAM Cache Keys'), _onclick='jQuery("#ram_keys").toggle();')}}
<div class="hidden" id="ram_keys">
{{=ram['keys']}}
</div>
<br />
{{pass}}
<h3>DISK</h3>
<p>Number of entries: <strong>{{=disk['entries']}}</strong>
{{if disk['entries'] > 0:}}
<p>
Hit Ratio:
<strong>{{=disk['ratio']}}%</strong>
(<strong>{{=disk['hits']}}</strong> hits
and <strong>{{=disk['misses']}}</strong> misses)
</p>
<p>
Size of cache:
{{if object_stats:}}
<strong>{{=disk['objects']}}</strong> items,
<strong>{{=disk['bytes']}}</strong> bytes
{{if disk['bytes'] > 524287:}}
(<strong>{{=disk['bytes'] / 1048576}} MB</strong>)
{{pass}}
{{else:}} <strong>not available</strong> (requires the Python <a href="http://pypi.python.org/pypi/guppy/" target="_blank">guppy</a> library)
{{pass}}
</p>
<p>
DISK contains items up to
<strong>{{="%02d" % disk['oldest'][0]}}</strong> hours
<strong>{{="%02d" % disk['oldest'][1]}}</strong> minutes
<strong>{{="%02d" % disk['oldest'][2]}}</strong> seconds old.
</p>
{{=BUTTON(T('Disk Cache Keys'), _onclick='jQuery("#disk_keys").toggle();')}}
<div class="hidden" id="disk_keys">
{{=disk['keys']}}
</div>
<br />
{{pass}}
</div>
<div class="list-header">
<h2>Manage Cache</h2>
</div>
<div class="content">
<p>
{{=form}}
</p>
</div>
</div>
<div class="clear"></div>
</div>
{{pass}}
@@ -0,0 +1,31 @@
{{left_sidebar_enabled,right_sidebar_enabled=False,True}}
{{extend 'layout.html'}}
{{if 'message' in globals():}}
<h3>{{=message}}</h3>
<h4/>{{=T('How did you get here?')}}</h4>
<ol>
<li>{{=T('You are successfully running web2py')}}</li>
<li>{{=T('You visited the url')}} {{=A(request.env.path_info,_href=request.env.path_info)}}</li>
<li>{{=T('Which called the function')}} {{=A(request.function+'()',_href='#')}} {{=T('located in the file')}}
{{=A('web2py/applications/%(application)s/controllers/%(controller)s.py'%request,_href=URL('admin','default','peek',args=(request.application,'controllers',request.controller+'.py')))}}</li>
<li>{{=T('The output of the file is a dictionary that was rendered by the view')}}
{{=A('web2py/applications/%(application)s/views/%(controller)s/index.html'%request,_href=URL('admin','default','peek',args=(request.application,'views',request.controller,'index.html')))}}</li>
<li>{{=T('You can modify this application and adapt it to your needs')}}</li>
</ul>
</ol>
{{else:}}
{{=BEAUTIFY(response._vars)}}
{{pass}}
{{block right_sidebar}}
{{=A(T("Administrative Interface"), _href=URL('admin','default','index'), _class='button',
_style='margin-top: 1em;')}}
<h6>{{=T("Don't know what to do?")}}</h6>
<ul>
<li>{{=A(T("Online examples"), _href=URL('examples','default','index'))}}</li>
<li><a href="http://web2py.com">web2py.com</a></li>
<li><a href="http://web2py.com/book">{{=T('Documentation')}}</a></li>
</ul>
{{end}}
@@ -0,0 +1,18 @@
{{extend 'layout.html'}}
<h2>{{=T( request.args(0).replace('_',' ').capitalize() )}}</h2>
<div id="web2py_user_form">
{{=form}}
{{if request.args(0)=='login':}}
{{if not 'register' in auth.settings.actions_disabled:}}
<br/>
<a href="{{=URL(args='register')}}">{{=T('Register')}}</a>
{{pass}}
{{if not 'request_reset_password' in auth.settings.actions_disabled:}}
<br/>
<a href="{{=URL(args='request_reset_password')}}">{{=T('Lost Password')}}</a>
{{pass}}
{{pass}}
</div>
<script language="javascript"><!--
jQuery("#web2py_user_form input:visible:enabled:first").focus();
//--></script>
+16
View File
@@ -0,0 +1,16 @@
{{extend 'layout.html'}}
{{"""
You should not modify this file.
It is used as default when a view is not provided for your controllers
"""}}
<h2>{{=' '.join(x.capitalize() for x in request.function.split('_'))}}</h2>
{{if len(response._vars)==1:}}
{{=response._vars.values()[0]}}
{{elif len(response._vars)>1:}}
{{=BEAUTIFY(response._vars)}}
{{pass}}
{{if request.is_local:}}
{{=response.toolbar()}}
{{pass}}
+1
View File
@@ -0,0 +1 @@
{{from gluon.serializers import json}}{{=XML(json(response._vars))}}
+16
View File
@@ -0,0 +1,16 @@
{{
###
# response._vars contains the dictionary returned by the controller action
###
try:
from gluon.serializers import json
result = "%s(%s)" % (request.vars['callback'], json(response._vars))
response.write(result, escape=False)
response.headers['Content-Type'] = 'application/jsonp'
except (TypeError, ValueError):
raise HTTP(405, 'JSON serialization error')
except ImportError:
raise HTTP(405, 'JSON not available')
except:
raise HTTP(405, 'JSON error')
}}
+30
View File
@@ -0,0 +1,30 @@
{{'''
# License: Public Domain
# Author: Iceberg at 21cn dot com
With this generic.load file, you can use same function to serve two purposes.
= regular action
- ajax callback (when called with .load)
Example modified from http://www.web2py.com/AlterEgo/default/show/252:
def index():
return dict(
part1='hello world',
part2=LOAD(url=URL(r=request,f='auxiliary.load'),ajax=True))
def auxiliary():
form=SQLFORM.factory(Field('name'))
if form.accepts(request.vars):
response.flash = 'ok'
return dict(message="Hello %s" % form.vars.name)
return dict(form=form)
Notice:
- no need to set response.headers['web2py-response-flash']
- no need to return a string
even if the function is called via ajax.
'''}}{{if len(response._vars)==1:}}{{=response._vars.values()[0]}}{{else:}}{{=BEAUTIFY(response._vars)}}{{pass}}
+11
View File
@@ -0,0 +1,11 @@
{{
import os
from gluon.contrib.generics import pdf_from_html
filename = '%s/%s.html' % (request.controller,request.function)
if os.path.exists(os.path.join(request.folder,'views',filename)):
html=response.render(filename)
else:
html=BODY(BEAUTIFY(response._vars)).xml()
pass
=pdf_from_html(html)
}}
+10
View File
@@ -0,0 +1,10 @@
{{
###
# response._vars contains the dictionary returned by the controller action
# for this to work the action must return something like
#
# dict(title=...,link=...,description=...,created_on='...',items=...)
#
# items is a list of dictionaries each with title, link, description, pub_date.
###
from gluon.serializers import rss}}{{=XML(rss(response._vars))}}
+1
View File
@@ -0,0 +1 @@
{{from gluon.serializers import xml}}{{=XML(xml(response._vars,quote=False))}}
+163
View File
@@ -0,0 +1,163 @@
<!DOCTYPE html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]><html class="ie ie6 ie-lte9 ie-lte8 ie-lte7 no-js" lang="{{=T.accepted_language or 'en'}}"> <![endif]-->
<!--[if IE 7]><html class="ie ie7 ie-lte9 ie-lte8 ie-lte7 no-js" lang="{{=T.accepted_language or 'en'}}"> <![endif]-->
<!--[if IE 8]><html class="ie ie8 ie-lte9 ie-lte8 no-js" lang="{{=T.accepted_language or 'en'}}"> <![endif]-->
<!--[if IE 9]><html class="ie9 ie-lte9 no-js" lang="{{=T.accepted_language or 'en'}}"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class="no-js" lang="{{=T.accepted_language or 'en'}}"> <!--<![endif]-->
<head>
<meta charset="utf-8" />
<!-- www.phpied.com/conditional-comments-block-downloads/ -->
<!-- Always force latest IE rendering engine
(even in intranet) & Chrome Frame
Remove this if you use the .htaccess -->
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<![endif]-->
<title>{{=response.title or request.application}}</title>
<!-- http://dev.w3.org/html5/markup/meta.name.html -->
<meta name="application-name" content="{{=request.application}}" />
<!-- Speaking of Google, don't forget to set your site up:
http://google.com/webmasters -->
<meta name="google-site-verification" content="" />
<!-- Mobile Viewport Fix
j.mp/mobileviewport & davidbcalhoun.com/2010/viewport-metatag
device-width: Occupy full width of the screen in its current orientation
initial-scale = 1.0 retains dimensions instead of zooming out if page height > device height
user-scalable = yes allows the user to zoom in -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<!-- Place favicon.ico and apple-touch-icon.png in the root of your domain and delete these references -->
<link rel="shortcut icon" href="{{=URL('static','favicon.ico')}}" type="image/x-icon">
<link rel="apple-touch-icon" href="{{=URL('static','favicon.png')}}">
<!-- All JavaScript at the bottom, except for Modernizr which enables
HTML5 elements & feature detects -->
<script src="{{=URL('static','js/modernizr.custom.js')}}"></script>
<!-- include stylesheets -->
{{
response.files.append(URL('static','css/skeleton.css'))
response.files.append(URL('static','css/web2py.css'))
response.files.append(URL('static','css/superfish.css'))
response.files.append(URL('static','js/superfish.js'))
}}
{{include 'web2py_ajax.html'}}
<script type="text/javascript">
jQuery(function(){ jQuery('ul.sf-menu').supersubs({minWidth:12,maxWidth:30,extraWidth:3}).superfish(); });
</script>
{{
# using sidebars need to know what sidebar you want to use
left_sidebar_enabled = globals().get('left_sidebar_enabled',False)
right_sidebar_enabled = globals().get('right_sidebar_enabled',False)
middle_columns = {0:'sixteen',1:'twelve',2:'eight'}[
(left_sidebar_enabled and 1 or 0)+(right_sidebar_enabled and 1 or 0)]
}}
<!-- uncomment here to load jquery-ui
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/base/jquery-ui.css" type="text/css" media="all" />
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script>
uncomment to load jquery-ui //-->
</head>
<body>
<div class="wrapper"><!-- for sticky footer -->
<div class="topbar">
<div class="container">
<div class="sixteen columns">
<div id="navbar">{{='auth' in globals() and auth.navbar(separators=(' ',' | ',''))}}</div>
{{is_mobile=request.user_agent().is_mobile}}
<div id="menu">{{=MENU(response.menu, _class='mobile-menu' if is_mobile else 'sf-menu',mobile=is_mobile)}}
</div>
</div>
</div>
</div><!-- topbar -->
<div class="flash">{{=response.flash or ''}}</div>
<div class="header">
<div class="container">
<div class="sixteen columns">
<h1 class="remove-bottom" style="margin-top: .5em;">
{{=response.title or request.application}}
</h1>
<h5>{{=response.subtitle or ''}}</h5>
</div>
<div class="sixteen columns">
<div class="statusbar">
{{block statusbar}}
<span class="breadcrumbs">{{=request.function.replace('_', ' ').title()}}</span>
{{end}}
<!-- AddToAny BEGIN -->
<div style="float:right; padding-top: .25em;" class="a2a_kit a2a_default_style">
<a class="a2a_dd" href="http://www.addtoany.com/share_save">Share</a></div>
<script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script>
<!-- AddToAny END -->
</div>
</div>
</div>
</div>
<div class="main">
<div class="container">
{{if left_sidebar_enabled:}}
<div class="four columns left-sidebar">
{{block left_sidebar}}
<h3>Left Sidebar</h3>
<p></p>
{{end}}
</div>
{{pass}}
<div class="{{=middle_columns}} columns center">
{{block center}}
{{include}}
{{end}}
</div>
{{if right_sidebar_enabled:}}
<div class="four columns">
{{block right_sidebar}}
<h3>Right Sidebar</h3>
<p></p>
{{end}}
</div>
{{pass}}
</div><!-- container -->
</div><!-- main -->
<div class="push"></div>
</div><!-- wrapper -->
<div class="footer">
<div class="container">
<div class="sixteen columns">
{{block footer}} <!-- this is default footer -->
<div class="footer-content" >
{{=T('Copyright')}} &#169; 2011
<div style="float: right;">
<a href="http://www.web2py.com/">
<img style="padding-bottom: 0;" src="{{=URL('static','images/poweredby.png')}}"/>
</a>
</div>
</div>
{{end}}
</div>
</div><!-- container -->
</div><!-- footer -->
<!--[if lt IE 7 ]>
<script src="{{=URL('static','js/dd_belatedpng.js')}}"></script>
<script> DD_belatedPNG.fix('img, .png_bg'); //fix any <img> or .png_bg background-images </script>
<![endif]-->
{{if response.google_analytics_id:}}<script>/* http://mathiasbynens.be/notes/async-analytics-snippet */ var _gaq=[['_setAccount','{{=response.google_analytics_id}}'],['_trackPageview']];(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.src='//www.google-analytics.com/ga.js';s.parentNode.insertBefore(g,s)}(document,'script')) </script>{{pass}}
</body>
</html>
@@ -0,0 +1,14 @@
<script type="text/javascript"><!--
// These variables are used by the web2py_ajax_init function in web2py_ajax.js (which is loaded below).
var w2p_ajax_confirm_message = "{{=T('Are you sure you want to delete this object?')}}";
var w2p_ajax_date_format = "{{=T('%Y-%m-%d')}}";
var w2p_ajax_datetime_format = "{{=T('%Y-%m-%d %H:%M:%S')}}";
//--></script>
{{
response.files.insert(0,URL('static','js/jquery.js'))
response.files.insert(1,URL('static','css/anytime.css'))
response.files.insert(2,URL('static','js/anytime.js'))
response.files.insert(3,URL('static','js/web2py.js'))
response.include_meta()
response.include_files()
}}