Project

General

Profile

« Previous | Next » 

Revision 25be1125

Added by David Sorber about 11 years ago

Adding apache config and web interface install script.

View differences:

software/bookmark_library/bmklib/web/base_controller.py
from genshi.template import TemplateLoader
BASE_PATH = '/home/dsorber/Documents/phalanx-repo/software/bookmark_library/'
BASE_PATH = '/home/dsorber/Documents/repo/software/bookmark_library/'
DB_PATH = os.path.join('/var/www', 'bookmarks.db')
TEMPLATE_PATH = os.path.join(BASE_PATH, 'bmklib', 'web', 'templates')
......
# Load and store the template
loader = TemplateLoader(TEMPLATE_PATH, auto_reload=True)
self.template = loader.load(template_name)
self.template = loader.load(template_name, encoding='utf-8')
# This dict is used generate the response body
self.content = {}
......
def build_content(self):
self.body = 'hello there handsome'
class BaseRedirectController(object):
def __init__(self, environ):
software/bookmark_library/bmklib/web/config/bmklib.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# Replace "/home/dsorber/Documents" with the path containing `bmklib.wsgi`
<Directory /home/dsorber/Documents>
Options All
AllowOverride All
Require all granted
</Directory>
# Modify this path to be the absolute path to the bmklib.wsgi file
#WSGIScriptAlias /bmk /home/dsorber/Documents/repo/software/bookmark_library/bmklib/web/bmklib.wsgi
WSGIScriptAlias /bmk /var/www/bmklib.wsgi
Alias /htdocs /var/htdocs
<Directory /var/htdocs>
Require all granted
</Directory>
</VirtualHost>
software/bookmark_library/bmklib/web/controllers/main.py
db.execute("SELECT COUNT(*) FROM bookmarks")
self.content['total_num_bmks'] = db.fetchone()[0]
links = {'All Bookmarks': self.build_link('bookmarks'),
'All Tags': self.build_link('tags')}
software/bookmark_library/bmklib/web/htdocs/css/bmk_main.css
@font-face {
font-family: Roboto;
src: url(htdocs/Roboto-Regular.ttf);
}
body {
font-family: sans-serif;
font-family: Roboto, sans-serif, Arial;
font-size: 16px;
margin-left: 0px;
margin-right: 0px;
software/bookmark_library/bmklib/web/install.sh
#!/bin/bash
# This is a very, very crude way of doing this
APACHE_DIR="/etc/apache2/sites-available/"
HTDOCS_DIR="/var/htdocs/"
SERVE_DIR="/var/www/"
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
if [ ! -d "$SERVE_DIR" ]; then
echo "ERROR: $SERVE_DIR does not exist!"
echo "Make sure apache is installed and then try again"
exit 2
fi
if [ ! -d "$APACHE_DIR" ]; then
echo "ERROR: $APACHE_DIR does not exist!"
echo "Make sure apache is installed and then try again"
exit 2
fi
echo -e "\nInstalling bmklib web interface\n"
# Copy the .wsgi into place
echo "Copying .wsgi file..."
cp bmklib.wsgi $SERVE_DIR
cp htdocs/css/* $HTDOCS_DIR/css/
# Copy htdocs into place
if [ ! -d "$HTDOCS_DIR" ]; then
echo "Creating $HTDOCS_IDR..."
mkdir -p $HTDOCS_DIR
fi
echo "Copying htdocs..."
cp -R htdocs/* $HTDOCS_DIR/
# Copy the apache config into place and then enable it
echo "Copying apache config..."
cp config/bmklib.conf $APACHE_DIR
a2ensite bmklib
echo "Restarting apache..."
service apache2 restart
echo "DONE"
software/bookmark_library/bmklib/web/templates/main.html
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/">
<head>
<title>Bookmark Library</title>
<link rel="stylesheet" type="text/css" href="../htdocs/css/bmk_main.css"></link>
......
<body>
<h1>Bookmark Library</h1>
<p>There are currently ${total_num_bmks} bookmarks in the library.</p>
<ul>
<li py:for="title, link in links.items()"><a href="${link}">${title}</a></li>
</ul>

Also available in: Unified diff