From a30bf1b72a14d4d9f478ab45fbf5f4ad426e8137 Mon Sep 17 00:00:00 2001 From: Joe Presbrey Date: Sun, 18 Apr 2010 12:01:02 +0000 Subject: [PATCH] mako SQL interface git-svn-id: svn://sql.mit.edu/sql@185 a142d4bd-2cfb-0310-9673-cb33a7e74f58 --- etc/lighttpd/lighttpd.conf | 28 ++-- lib/python/mitsql/interface/__init__.py | 41 ++--- lib/python/mitsql/interface/cheetah.py | 158 ------------------- lib/python/mitsql/interface/databases.py | 20 +++ lib/python/mitsql/interface/display.py | 2 - lib/python/mitsql/interface/handler.py | 96 +++++++---- lib/python/mitsql/interface/templates.py | 39 +++++ sbin/interface | 3 + www/etc/devel.conf | 8 - www/etc/interface.conf | 6 + www/etc/live.conf | 11 -- www/root/{assets => }/css/style.css | 4 +- www/templates/{common/_404.tmpl => 404} | 8 +- www/templates/{common/_500.tmpl => 500} | 8 +- www/templates/common/shell.tmpl | 1 - www/templates/common/skeleton.tmpl | 61 ------- www/templates/{main/contact.tmpl => contact} | 9 +- www/templates/database | 31 ++++ www/templates/footer | 15 ++ www/templates/header | 40 +++++ www/templates/{main/index.tmpl => index} | 10 +- www/templates/main/db_list.tmpl | 39 ----- www/templates/{main/passwd.tmpl => passwd} | 7 +- www/templates/{main/signup.tmpl => signup} | 8 +- 24 files changed, 263 insertions(+), 390 deletions(-) delete mode 100644 lib/python/mitsql/interface/cheetah.py create mode 100644 lib/python/mitsql/interface/databases.py delete mode 100644 lib/python/mitsql/interface/display.py create mode 100644 lib/python/mitsql/interface/templates.py create mode 100755 sbin/interface delete mode 100644 www/etc/devel.conf create mode 100644 www/etc/interface.conf delete mode 100644 www/etc/live.conf rename www/root/{assets => }/css/style.css (98%) rename www/templates/{common/_404.tmpl => 404} (60%) rename www/templates/{common/_500.tmpl => 500} (73%) delete mode 100644 www/templates/common/shell.tmpl delete mode 100644 www/templates/common/skeleton.tmpl rename www/templates/{main/contact.tmpl => contact} (54%) create mode 100644 www/templates/database create mode 100644 www/templates/footer create mode 100644 www/templates/header rename www/templates/{main/index.tmpl => index} (90%) delete mode 100644 www/templates/main/db_list.tmpl rename www/templates/{main/passwd.tmpl => passwd} (91%) rename www/templates/{main/signup.tmpl => signup} (88%) diff --git a/etc/lighttpd/lighttpd.conf b/etc/lighttpd/lighttpd.conf index e17178e..dd29d4e 100644 --- a/etc/lighttpd/lighttpd.conf +++ b/etc/lighttpd/lighttpd.conf @@ -1,8 +1,8 @@ server.modules = ( "mod_rewrite", "mod_alias", "mod_access", "mod_auth", "mod_proxy_core", "mod_proxy_backend_fastcgi", "mod_redirect", "mod_magnet", "mod_accesslog" ) server.errorlog = "/var/log/lighttpd/error_log" -$HTTP["useragent"] !~ "^check_http" { - accesslog.filename = "/var/log/lighttpd/access_log" -} +#$HTTP["useragent"] !~ "^check_http" { +# accesslog.filename = "/var/log/lighttpd/access_log" +#} etag.use-inode = "disable" index-file.names = ( "index.php", "index.html" ) url.access-deny = ( "~", ".inc", ".svn", "CVS" ) @@ -10,7 +10,7 @@ static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) server.port = 80 server.pid-file = "/var/run/lighttpd.pid" server.username = "lighttpd" -server.groupname = "lighttpd" +server.groupname = "apache" $PHYSICAL["existing-path"] =~ "\.php$" { proxy-core.balancer = "round-robin" @@ -35,6 +35,7 @@ url.redirect = ( "^/phpMyAdmin(.*)" => "http://scripts.mit.edu/~sql/phpMyAdmin$1 ssl.verifyclient.username = "SSL_CLIENT_S_DN_emailAddress" $SERVER["socket"] == "0.0.0.0:443" { + server.document-root = "/srv/www/root/" ssl.engine = "enable" ssl.pemfile = "/etc/lighttpd/sql.mit.edu.pem" ssl.ca-file = "/etc/lighttpd/mitCAclient.pem" @@ -42,15 +43,16 @@ $SERVER["socket"] == "0.0.0.0:443" { ssl.verifyclient.enforce = "disable" ssl.verifyclient.depth = 2 - $HTTP["url"] =~ "^/api(/|$)" { - $HTTP["useragent"] =~ "AppleWebKit" { - url.access-deny = ("") - } - auth.backend = "gssapi" - auth.backend.gssapi.principal = "HTTP/sql.mit.edu" - auth.backend.gssapi.keytab = "/etc/lighttpd/krb5.keytab" - auth.require = ( "/" => ( "method" => "gssapi", "realm" => "ATHENA.MIT.EDU", "require" => "valid-user")) - magnet.attract-raw-url-to = ( "/srv/www/api.lua" ) + url.redirect += ( "^/$" => "/manage/" ) + $HTTP["url"] =~ "^/manage(/|$)" { + proxy-core.balancer = "round-robin" + proxy-core.protocol = "fastcgi" + proxy-core.backends = ( "unix:/srv/var/run/interface.sock" ) + proxy-core.max-pool-size = 4 + proxy-core.rewrite-request = ( + "_pathinfo" => ( "^/manage(/.*)" => "$1" ), + "_scriptname" => ( "^(/manage/)" => "$1" ) + ) } } diff --git a/lib/python/mitsql/interface/__init__.py b/lib/python/mitsql/interface/__init__.py index 4636607..076cffa 100644 --- a/lib/python/mitsql/interface/__init__.py +++ b/lib/python/mitsql/interface/__init__.py @@ -1,32 +1,15 @@ -import mitsql -config = mitsql.config.interface - -from MySQLdb import Connection as _connect -from MySQLdb.cursors import DictCursor as _cursor - -def _connect(*argv, **kw): - return _connect(config.db_host, config.db_user, config.db_pass, config.db_name, cursorclass=_Cursor) +import templates + +from cherrypy.process.plugins import DropPrivileges +class DropSock(DropPrivileges): + def start(self): + if cherrypy.server.socket_file: + import os + os.chown(cherrypy.server.socket_file, self.uid, self.gid) + DropPrivileges.start(self) + start.priority = 78 +import cherrypy +DropSock(cherrypy.engine, uid='lighttpd', gid='apache').subscribe() from handler import Root as _root root = _root() - -from cheetah import load -load(mitsql._base + '/www/templates') - -import cherrypy -cherrypy.tree.mount(root, '/') -cherrypy.config.update({'error_page.404': root.error._404, - 'error_page.500': root.error._500, - 'tools.staticdir.on': True, - 'tools.staticdir.dir': mitsql._base + '/www/root'}) - -def map_uri(): - print root.default() - #from cherrypy.lib.httpauth import parseAuthorization - #if not cherrypy.request.login: - # authorization = cherrypy.request.headers.get('Authorization', None) - # if authorization: - # cherrypy.request.login = parseAuthorization(authorization) - -#cherrypy.tools.map_uri = cherrypy.Tool('on_start_resource', map_uri) -#cherrypy.tools.map_uri = cherrypy.Tool('before_request_body', map_uri) diff --git a/lib/python/mitsql/interface/cheetah.py b/lib/python/mitsql/interface/cheetah.py deleted file mode 100644 index 22a2b17..0000000 --- a/lib/python/mitsql/interface/cheetah.py +++ /dev/null @@ -1,158 +0,0 @@ -import qwobl -import os, sys, types, time -import threading -from pyinotify import WatchManager, Notifier, EventsCodes -from Cheetah.Template import Template as _Template -import logging - -class Template(object): - def __init__(self, name='templates', ns={}, path=[]): - self._name, self._ns, self._path = name, ns, len(path) and path+[name] or [name] - if len(self._path) > 1: - assert self._template() - - def _template(self): - return sys.modules['.'.join(self._path)] - - def __getattr__(self, name): - return Template(name, self._ns, self._path) - - def __call__(self, **kw): - namespaces = self._ns.copy() - namespaces.update(kw) - return getattr(self._template(), - self._name)(namespaces=namespaces).respond() - -class Loader(object): - _mask = EventsCodes.ALL_FLAGS['IN_CREATE'] \ - | EventsCodes.ALL_FLAGS['IN_MODIFY'] \ - | EventsCodes.ALL_FLAGS['IN_DELETE'] \ - | EventsCodes.ALL_FLAGS['IN_ATTRIB'] - _watch_manager = None - _notifier = None - _thread = None - - _loaded = False - _files = {} - _modules = {} - - def __init__(self, global_namespace={}): - self._event_init() - self._assert_module('templates') - self._globals = global_namespace - self._thread = threading.Thread(target=self.loop) - self._thread.setDaemon(True) - self._thread.start() - - def _tree_walk(self, tree, path, func): - path = list(path) - if len(path) > 1: - x = path.pop(0) - if not x in tree: - tree[x] = {} - return self._tree_walk(tree[x], path, func) - elif callable(func): - return func(tree, path[0]) - - def _tree_add(self, tree, path, value): - def _add(tree, key): - tree[key] = value - return value - print self._tree_walk(tree, path, _add) - - def _assert_module(self, name, path=None): - if not name in self._modules: - self._modules[name] = types.ModuleType(name) - if path: - self._modules[name].__path__ = path - sys.modules[name] = self._modules[name] - - def _get_template_path(self, path_name, template_file): - r = template_file.startswith(path_name) \ - and template_file[len(path_name)+1:].split(os.path.sep) or [] - if r[-1].endswith('.tmpl'): - r[-1] = r[-1][:-5] - return tuple(r) - - def _compile(self, template_path): - template = _Template.compile(file=self._files[template_path], - returnAClass=False, - moduleName='.'.join(['templates']+list(template_path)), - className=template_path[-1], - useCache=False, - compilerSettings={'useStackFrames':False}) - return template - - def add(self, path_name, template_file): - template_path = self._get_template_path(path_name, template_file) - template_name = '.'.join(['templates']+list(template_path)) - template_pkg = '.'.join(['templates']+list(template_path[:-1])) - template_py = os.path.join(os.path.dirname(template_file), '%s.py' % template_path[-1]) - self._assert_module(template_pkg, [os.path.dirname(template_file)]) - self._files[template_path] = template_file - code = self._compile(template_path) - f_code = file(template_py, 'w') - f_code.write(code) - f_code.close() - if template_name in sys.modules: - reload(sys.modules[template_name]) - - def remove(self, template_file): - #print 'removing', template_file - pass - - def _walk_path(self, path_name): - def _walk_load(args, dname, fnames): - for fname in fnames: - if fname.endswith('.tmpl'): - template_file = os.path.join(dname, fname) - self.add(path_name, template_file) - return _walk_load - - def load(self, path_name): - os.path.walk(path_name, self._walk_path(path_name), None) - for path, filename in self._files.items(): - logging.debug('TEMPLATE LOAD [%s] %s', path, filename) - __import__('.'.join(['templates']+list(path))) - self._event_add_watch(path_name) - - def _path_event_handler(self, path_name): - def _event_handler(event): - logging.debug('TEMPLATE EVENT: %s', repr(event.__dict__.items())) - if event.name.endswith('.tmpl') and not event.name.startswith('.'): - if event.maskname == 'IN_DELETE': - self.remove(event.pathname) - else: - time.sleep(0.5) - self.add(path_name, event.pathname) - return _event_handler - - def _event_init(self): - self._watch_manager = WatchManager() - self._notifier = Notifier(self._watch_manager) - - def _event_add_watch(self, path_name): - r = self._watch_manager.add_watch(path_name, - self._mask, - self._path_event_handler(path_name), - rec=True, - auto_add=True) - - def loop(self): - while True: - try: - self._notifier.process_events() - if self._notifier.check_events(): - self._notifier.read_events() - except KeyboardInterrupt: - self._notifier.stop() - break - -_loader = Loader() -load = _loader.load -templates = Template() - -__all__ = ['load', 'templates'] - -if __name__ == '__main__': - t = Loader('/home/joe/templates') diff --git a/lib/python/mitsql/interface/databases.py b/lib/python/mitsql/interface/databases.py new file mode 100644 index 0000000..623699c --- /dev/null +++ b/lib/python/mitsql/interface/databases.py @@ -0,0 +1,20 @@ +import MySQLdb as _my, pgsql as _pg + +class Database(object): pass + +class MySQL(Database): + def list(self, username): + cxn = _my.connect('127.0.0.1', 'root', '', 'mysql') + cur = cxn.cursor() + cur.execute('SELECT Db FROM db WHERE User=%s AND Host="%%"', username) + return dict([(x[0],{'sz_tot':0,'sz_max':100}) for x in cur.fetchall()]) + +mysql = MySQL() + +class PgSQL(Database): + def list(self, username): + cxn = _pg.connect(user='postgres') + cur = cxn.execute('SELECT datname FROM pg_database INNER JOIN pg_user ON pg_user.usesysid=pg_database.datdba WHERE pg_user.usename=$1', username) + return dict([(x[0],{'sz_tot':0,'sz_max':100}) for x in cur.fetchall()]) + +pgsql = PgSQL() diff --git a/lib/python/mitsql/interface/display.py b/lib/python/mitsql/interface/display.py deleted file mode 100644 index e39d1ae..0000000 --- a/lib/python/mitsql/interface/display.py +++ /dev/null @@ -1,2 +0,0 @@ -def db_list_entry(name, size_tot, size_max): - return '%s: %s/%s' % (name, size_tot, size_max) \ No newline at end of file diff --git a/lib/python/mitsql/interface/handler.py b/lib/python/mitsql/interface/handler.py index 14eac9e..0d75cfd 100644 --- a/lib/python/mitsql/interface/handler.py +++ b/lib/python/mitsql/interface/handler.py @@ -1,48 +1,78 @@ import mitsql -from cheetah import templates + import cherrypy +mako = cherrypy.tools.mako from pprint import pformat -def _500(*argv, **kw): - s_exc = cherrypy._cperror.format_exc() - mitsql.logging.error(s_exc) - return templates.common.shell(title='%s (CherryPy %s)' % (kw.get('status'), kw.get('version')), - content=('

%s

' + (2*'
%s
')) - % (kw.get('message'), kw.get('traceback'), - _phtml(dict(filter(lambda x: not x[0][:2] == '__', - cherrypy.request.__dict__.items()))))) +#def _500(*argv, **kw): +# s_exc = cherrypy._cperror.format_exc() +# mitsql.logging.error(s_exc) +# return templates.common.shell(title='%s (CherryPy %s)' % (kw.get('status'), kw.get('version')), +# content=('

%s

' + (2*'
%s
')) +# % (kw.get('message'), kw.get('traceback'), +# _phtml(dict(filter(lambda x: not x[0][:2] == '__', +# cherrypy.request.__dict__.items()))))) + +def _before_request_body(): + if not cherrypy.request.login is None: + if cherrypy.request.login.endswith('@MIT.EDU'): + cherrypy.request.login = cherrypy.request.login[:-8] + else: + cherrypy.request.login = None + +from databases import mysql, pgsql class Root(object): - class Error(object): - @cherrypy.expose - def _404(*argv, **kw): - return templates.common._404() - def _500(*argv, **kw): - return _500(*argv, **kw) - error = Error() + _cp_config = { + 'hooks.before_request_body': _before_request_body, + 'tools.mako.collection_size': 500, + 'tools.mako.directories': mitsql._base+'/www/templates', + } + #class Error(object): + # def _404(*argv, **kw): + # return templates.common._404() + # def _500(*argv, **kw): + # return _500(*argv, **kw) + #error = Error() - class DB(object): - def list(*argv, **kw): - r = {'db_list': [], - 'size_tot': '1M', - 'size_max': '100M', - 'user': { - 'db_prefix': 'presbrey+' - }} - return templates.main.db_list(**r) - list.exposed = True - db = DB() - + @cherrypy.expose def test(self, *argv, **kw): cherrypy.response.headers['Content-type'] = 'text/plain' return pformat(dict(filter(lambda x: not x[0][:2] == '__', cherrypy.request.__dict__.items()))) - test.exposed = True + @cherrypy.expose + @mako(filename='index') def index(self, *argv, **kw): - return templates.main.index() - index.exposed = True + return { + 'title': 'SQL Service', + 'login': cherrypy.request.login, + } + @cherrypy.expose + @mako(filename='passwd') def passwd(self, *argv, **kw): - return templates.main.passwd() - passwd.exposed = True \ No newline at end of file + return { + 'title': 'Change Passwords', + 'login': cherrypy.request.login, + } + + @cherrypy.expose + @mako(filename='contact') + def contact(self, *argv, **kw): + return { + 'title': 'Contact', + } + + @cherrypy.expose + @mako(filename='database') + def database(self, *argv, **kw): + return { + 'title': 'Databases', + 'login': cherrypy.request.login, + 'mysql': mysql.list(cherrypy.request.login), + 'pgsql': pgsql.list(cherrypy.request.login), + } + +#Root._cp_config['error_page.404'] = Root.error._404 +#Root._cp_config['error_page.500'] = Root.error._500 diff --git a/lib/python/mitsql/interface/templates.py b/lib/python/mitsql/interface/templates.py new file mode 100644 index 0000000..45740ad --- /dev/null +++ b/lib/python/mitsql/interface/templates.py @@ -0,0 +1,39 @@ +import cherrypy +from mako.lookup import TemplateLookup + +class MakoHandler(cherrypy.dispatch.LateParamPageHandler): + """Callable which sets response.body.""" + + def __init__(self, template, next_handler): + self.template = template + self.next_handler = next_handler + + def __call__(self): + env = globals().copy() + env.update(self.next_handler()) + return self.template.render(**env) + +class MakoLoader(object): + + def __init__(self): + self.lookups = {} + + def __call__(self, filename, directories, module_directory=None, + collection_size=-1): + # Find the appropriate template lookup. + key = (tuple(directories), module_directory) + try: + lookup = self.lookups[key] + except KeyError: + lookup = TemplateLookup(directories=directories, + module_directory=module_directory, + collection_size=collection_size, + ) + self.lookups[key] = lookup + cherrypy.request.lookup = lookup + + # Replace the current handler. + cherrypy.request.template = t = lookup.get_template(filename) + cherrypy.request.handler = MakoHandler(t, cherrypy.request.handler) + +cherrypy.tools.mako = cherrypy.Tool('on_start_resource', MakoLoader()) diff --git a/sbin/interface b/sbin/interface new file mode 100755 index 0000000..b30bdc2 --- /dev/null +++ b/sbin/interface @@ -0,0 +1,3 @@ +#!/bin/bash + +cherryd -c /srv/www/etc/interface.conf -p /srv/var/run/interface.pid -f -i mitsql.interface "$@" diff --git a/www/etc/devel.conf b/www/etc/devel.conf deleted file mode 100644 index bdb7cfc..0000000 --- a/www/etc/devel.conf +++ /dev/null @@ -1,8 +0,0 @@ -[global] -server.socket_host: "0.0.0.0" -server.socket_port: 8336 -tools.encode.on: True -tools.encode.encoding: 'utf-8' -#tools.map_uri.on: True -#tools.header_auth.on: True -#request.show_tracebacks: True diff --git a/www/etc/interface.conf b/www/etc/interface.conf new file mode 100644 index 0000000..06b7abd --- /dev/null +++ b/www/etc/interface.conf @@ -0,0 +1,6 @@ +[global] +server.socket_file: mitsql._base + '/var/run/interface.sock' +tools.encode.on: True +tools.encode.encoding: 'utf-8' +tools.trailing_slash.on: False +tree.root.manage: cherrypy.Application(mitsql.interface.root, '/manage') diff --git a/www/etc/live.conf b/www/etc/live.conf deleted file mode 100644 index ef39428..0000000 --- a/www/etc/live.conf +++ /dev/null @@ -1,11 +0,0 @@ -[global] -tree.root: mitsql.interface.root -server.socket_file: '/tmp/mitsql.sock' - -tools.encode.on: True -tools.encode.encoding: 'utf-8' -#tools.map_uri.on: True -#autoreload.on: False -#checker.on: False -#engine.SIGHUP: None -#engine.SIGTERM: None diff --git a/www/root/assets/css/style.css b/www/root/css/style.css similarity index 98% rename from www/root/assets/css/style.css rename to www/root/css/style.css index 687aeed..b825662 100644 --- a/www/root/assets/css/style.css +++ b/www/root/css/style.css @@ -11,7 +11,7 @@ body { } #farouter { background: #ffffff; - width: 80%; + width: 760px; border: 1px solid #3A291F; margin: 10px auto 10px auto; text-align: left; /* IE 5.5 hack part II */ @@ -19,7 +19,7 @@ body { #outer div#masthead { margin: 1em; } #outer div#content_wide { margin: 1em; } #content { float: left; width: 490px; } -#content_wide { padding: 0 35px 0 35px; } +#content_wide { padding: 1em 2em; } #content_home { float: left; width: 490px; padding-top: 0px; } #menu { float: right; width: 175px; margin-right: 10px; border-left: 1px dashed #2050A0; } #nav { padding-left: 10px; } diff --git a/www/templates/common/_404.tmpl b/www/templates/404 similarity index 60% rename from www/templates/common/_404.tmpl rename to www/templates/404 index 3a63713..8010d54 100644 --- a/www/templates/common/_404.tmpl +++ b/www/templates/404 @@ -1,7 +1,5 @@ -#extends templates.common.shell +<%include file="header"/> -#def title: Page Not Found - -#block content

We're sorry! The page you requested does not exist. Please return to our homepage or contact us.

-#end block content + +<%include file="footer"/> diff --git a/www/templates/common/_500.tmpl b/www/templates/500 similarity index 73% rename from www/templates/common/_500.tmpl rename to www/templates/500 index 265af7a..af92432 100644 --- a/www/templates/common/_500.tmpl +++ b/www/templates/500 @@ -1,8 +1,6 @@ -#extends templates.common.shell +<%include file="header"/> -#def title: Page Error - -#block content

We're sorry! The requested you made caused an internal error we weren't expecting. The support team has been notified.

Please return to our homepage, go back and try again, or contact us.

-#end block content + +<%include file="footer"/> diff --git a/www/templates/common/shell.tmpl b/www/templates/common/shell.tmpl deleted file mode 100644 index d8d043d..0000000 --- a/www/templates/common/shell.tmpl +++ /dev/null @@ -1 +0,0 @@ -#extends skeleton diff --git a/www/templates/common/skeleton.tmpl b/www/templates/common/skeleton.tmpl deleted file mode 100644 index 761c0d2..0000000 --- a/www/templates/common/skeleton.tmpl +++ /dev/null @@ -1,61 +0,0 @@ -#from mitsql import config -#import cherrypy, time -#set global x_agent = cherrypy.request.headers.get('X-Agent', 'Mozilla') - - - - #set page_title = $title.split('|')[0] - $page_title - - - - #block head_append - #end block head_append - - -
-
-
-

$title

-

sql.mit.edu

-

MIT SIPB MySQL Service for Athena
- email: sql@mit.edu

-
-
- -
-
-
- #block body - #end block body -
-
- - - -
 
- -
-
- - diff --git a/www/templates/main/contact.tmpl b/www/templates/contact similarity index 54% rename from www/templates/main/contact.tmpl rename to www/templates/contact index 4b212cb..f5c241d 100644 --- a/www/templates/main/contact.tmpl +++ b/www/templates/contact @@ -1,11 +1,6 @@ -#extends templates.common.shell - -#def title: Contact - -#block body -

Contact/Help

+<%include file="header"/>

We welcome all questions, comments, and suggestions.

Please direct inquiries to sql@mit.edu

-#end block body \ No newline at end of file +<%include file="footer"/> diff --git a/www/templates/database b/www/templates/database new file mode 100644 index 0000000..23a51d3 --- /dev/null +++ b/www/templates/database @@ -0,0 +1,31 @@ +<%include file="header"/> + + +% if mysql is UNDEFINED: + +% else: + % for name, data in sorted(mysql.items()): + + % endfor +% endif + +
You have no MySQL databases. Add one below.
+${name} + +

drop

+
+
+
+ +
+ +
+

+ + + ${login}+ + +

+
+ +<%include file="footer"/> diff --git a/www/templates/footer b/www/templates/footer new file mode 100644 index 0000000..ba674e0 --- /dev/null +++ b/www/templates/footer @@ -0,0 +1,15 @@ + + + + + +
 
+ + + + + diff --git a/www/templates/header b/www/templates/header new file mode 100644 index 0000000..e27a27f --- /dev/null +++ b/www/templates/header @@ -0,0 +1,40 @@ + + + + ${title} + + + + + + +
+
+
+

${title}

+

sql.mit.edu

+

MIT SIPB MySQL Service for Athena
email: sql@mit.edu

+
+
+
+ +
+
+
+
diff --git a/www/templates/main/index.tmpl b/www/templates/index similarity index 90% rename from www/templates/main/index.tmpl rename to www/templates/index index cba7a22..087202e 100644 --- a/www/templates/main/index.tmpl +++ b/www/templates/index @@ -1,11 +1,8 @@ -#extends templates.common.shell +<%include file="header"/> -#def title: MySQL Services - -#block body

This service provides MySQL databases to MIT certificate holders. -You must choose a MySQL password (which should be different from your Athena account password) when you sign up, and +You must choose a MySQL password (which should be different from your Athena account password) when you sign up, and then use this interface to create and drop databases. All subsequent SQL commands can be issued from any host, client, and/or script of your choice; simply connect to the MySQL server at sql.mit.edu using your username and your new MySQL password. You may find it convenient to run scripts using the web script service or @@ -25,4 +22,5 @@ One nightly backup is available for your locker at /mit/sql/backup/LOCKER_

-#end block body \ No newline at end of file + +<%include file="footer"/> diff --git a/www/templates/main/db_list.tmpl b/www/templates/main/db_list.tmpl deleted file mode 100644 index 0a3b3ce..0000000 --- a/www/templates/main/db_list.tmpl +++ /dev/null @@ -1,39 +0,0 @@ -#extends templates.common.shell -#from mitsql.interface import display - -#def title: Manage Databases - -#block body - - -#if len($db_list) == 0: - -#else: -#for name, data in $db_list: - -#end for -#end if - -
You have no databases. Add one below.
-#echo display.db_list_entry($name, $data.size_tot, $data.size_max) - -

drop

-
-
-
-#echo display.db_list_entry('TOTAL', $size_tot, $size_max) -
- -
-

- - - $user.db_prefix - -

-
- -

Manage Data

-

One interface we recommend for managing SQL data is phpMyAdmin. Feel free to use it after you've created your databases.

- -#end block body \ No newline at end of file diff --git a/www/templates/main/passwd.tmpl b/www/templates/passwd similarity index 91% rename from www/templates/main/passwd.tmpl rename to www/templates/passwd index 0a0773b..527a1d7 100644 --- a/www/templates/main/passwd.tmpl +++ b/www/templates/passwd @@ -1,8 +1,5 @@ -#extends templates.common.shell +<%include file="header"/> -#def title: Change Password - -#block body

Your MySQL password should be different from your Athena account password.

@@ -25,4 +22,4 @@ MySQL accounts. Groups locker administrators can from any Athena prompt.
-#end block body \ No newline at end of file +<%include file="footer"/> diff --git a/www/templates/main/signup.tmpl b/www/templates/signup similarity index 88% rename from www/templates/main/signup.tmpl rename to www/templates/signup index 2df2c79..cdcde7c 100644 --- a/www/templates/main/signup.tmpl +++ b/www/templates/signup @@ -1,8 +1,5 @@ -#extends templates.common.shell +<%include file="header"/> -#def title: Change Password - -#block body

Your MySQL password should be different from your Athena account password.

@@ -15,4 +12,5 @@

Note: you need to also update your .my.cnf file on Athena if you want to use SIPB scripts auto-installers or access the MySQL service from the command-line.

-#end block body \ No newline at end of file + +<%include file="footer"/> -- 2.45.1