casweb/README | 21 +++++++++++++++++++++ casweb/cas.py | 36 +++++++++++++++++++++++++++++++----- casweb/media/css/main.css | 27 +++++++++++++++++++++++++++ casweb/media/img/cas_logo.png |binary casweb/templates/base.html | 21 +++++++++++++++++++++ casweb/templates/index.html | 5 +++++ casweb/templates/job.html | 3 +++ casweb/templates/jobs.html | 16 ++++++++++++++++ 8 files changed, 124 insertions(+), 5 deletions(-)
New commits: commit a736f7483fdd2e74daebe45797fce395aba37b8d Author: adam stokes astokes@fedoraproject.org Date: Wed Jan 27 15:58:31 2010 -0500
- more web work
diff --git a/casweb/README b/casweb/README index 1e84257..631026a 100644 --- a/casweb/README +++ b/casweb/README @@ -1,3 +1,24 @@ installation: - see http://webpy.org/install for getting framework installed and setup on webserver +- make sure to do wsgi installation, so httpd and mod_wsgi needs + to be installed. + # yum install httpd mod_wsgi + +- example for virtual host on ip alias 192.168.1.103 +<VirtualHost 192.168.1.103:80> + ServerName casweb + WSGIScriptAlias / /mnt/usbdrive/projects/casweb/cas.py + Alias /media /mnt/usbdrive/projects/casweb/media + <Directory "/mnt/usbdrive/projects/casweb"> + Options FollowSymlinks + AllowOverride None + Order allow,deny + Allow from all + </Directory> + <Location /media> + Options All + SetHandler None + </Location> +</VirtualHost> + diff --git a/casweb/cas.py b/casweb/cas.py index f647dc5..a22742d 100644 --- a/casweb/cas.py +++ b/casweb/cas.py @@ -1,15 +1,41 @@ import web +import os + +try: + from cas.db import CasStorage +except ImportError: + raise Exception("Unable to import CasStorage, make sure CAS is installed") + + +# do not edit below this line unless you know what you are doing +render = web.template.render(os.path.join(os.path.dirname(__file__),'templates').replace('\','/'), cache=False) +web.template.Template.globals['ctx'] = web.ctx
urls = ( - '/(.*)', 'index' + '/', 'index', + '/job/(\d+)', 'job', + '/jobs', 'jobs', ) + app = web.application(urls, globals())
+# build connection +global casDB +casDB=CasStorage('/var/db/cas/cas.db') +casDB.connect() + class index: - def GET(self, name): - if not name: - name = 'World' - return 'Hello, ' + name + '!' + def GET(self): + return render.base(render.index()) + +class job: + def GET(self, id): + return render.base(render.job(id)) + +class jobs: + def GET(self): + allJobs = casDB.getAllJobs() + return render.base(render.jobs(allJobs))
app = web.application(urls, globals(), autoreload=False) application = app.wsgifunc() diff --git a/casweb/media/css/main.css b/casweb/media/css/main.css new file mode 100644 index 0000000..7ef24e4 --- /dev/null +++ b/casweb/media/css/main.css @@ -0,0 +1,27 @@ +body { + font-size: 1em; + font-family: sans-serif; +} + +#header { + width: 750px; + margin-left: auto; + margin-right: auto; + font-size: .7em; +} + +#header .menu { + float:right; + border: 1px solid black; + padding: 5px; +} + +#content { + width: 750px; + margin-left: auto; + margin-right: auto; + clear:both; +} + +/* vim:ts=2 sw=2 et + * / diff --git a/casweb/media/img/cas_logo.png b/casweb/media/img/cas_logo.png new file mode 100644 index 0000000..39e2302 Binary files /dev/null and b/casweb/media/img/cas_logo.png differ diff --git a/casweb/templates/base.html b/casweb/templates/base.html index e69de29..0fbef41 100644 --- a/casweb/templates/base.html +++ b/casweb/templates/base.html @@ -0,0 +1,21 @@ +$def with (page) +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html><head><title>casweb</title> + <link rel="stylesheet" type="text/css" href="/media/css/main.css"/> +</head> +<body> +<div id="header"> + <img src="/media/img/cas_logo.png"/> + <div class="menu"> + <strong>navigator</strong><br/> + <a href="$ctx.homepath/">home</a><br/> + <a href="$ctx.homepath/jobs">jobs</a> + </div> +</div> +<div id="content"> + $:page +</div> +</body> +</html> + +$# vim:ts=2 sw=2 et diff --git a/casweb/templates/index.html b/casweb/templates/index.html new file mode 100644 index 0000000..181f60d --- /dev/null +++ b/casweb/templates/index.html @@ -0,0 +1,5 @@ +<h3>CAS Web Administration</h3> + Welcome to the CAS web frontend. This application gives the ability to view recent jobs, +schedule new jobs, and perform minor maintenance work through the administration panel. + +$# vim:ts=2 sw=2 et diff --git a/casweb/templates/job.html b/casweb/templates/job.html new file mode 100644 index 0000000..b01d138 --- /dev/null +++ b/casweb/templates/job.html @@ -0,0 +1,3 @@ +$def with (id=0) + +job status on $id diff --git a/casweb/templates/jobs.html b/casweb/templates/jobs.html new file mode 100644 index 0000000..f62399d --- /dev/null +++ b/casweb/templates/jobs.html @@ -0,0 +1,16 @@ +$def with (allJobs) + +<h3>Recent Jobs</h3> +<table> +<tr> + <th width="50%">submitter</th><th width="50%">jobid</th> +</tr> +$for job in allJobs[:25]: + $code: + dbid, jobid, timestamp, email = job + <tr> + <td>$:email</td><td><a href="$ctx.homepath/job/$jobid">$:timestamp</a></td> + </tr> +</table> + +
cas@lists.stg.fedorahosted.org