old-web: deleting, it is no longer valuable

This commit is contained in:
Brian S. Stephan 2015-05-15 21:24:25 -05:00
parent 1bd57a8c3b
commit b15afcade8
26 changed files with 0 additions and 771 deletions

View File

@ -1,11 +0,0 @@
import os
import sys
path = '/home/bss/Programs/dr.botzo/web'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

View File

@ -1,6 +0,0 @@
from django.shortcuts import render_to_response
def index(request):
return render_to_response('index.html')
# vi:tabstop=4:expandtab:autoindent

View File

@ -1,47 +0,0 @@
from django.db import models
class LogEntry(models.Model):
id = models.IntegerField(primary_key=True)
key = models.CharField(max_length=255)
delta = models.IntegerField(choices=((1, u'++'), (-1, u'--')))
who = models.CharField(max_length=30)
userhost = models.CharField(max_length=512)
timestamp = models.DateTimeField(db_column='karmatime')
def __unicode__(self):
return "%s given %s by %s on %s" % (self.key, self.delta,
self.who, self.timestamp)
class Meta:
db_table = 'karma_log'
ordering = ['timestamp']
managed = False
class User(models.Model):
who = models.CharField(max_length=30, primary_key=True)
pos = models.IntegerField()
neg = models.IntegerField()
def _get_total(self):
return self.pos + self.neg
total = property(_get_total)
def __unicode__(self):
return "Karma User %s (%s/%s)" % (self.who, self,pos, self.neg)
class Meta:
db_table = 'karma_users'
ordering = ['who']
managed = False
class Value(models.Model):
key = models.CharField(max_length=255, primary_key=True)
value = models.IntegerField()
def __unicode__(self):
return "Karma Value %s (%s)" % (self.key, self.value)
class Meta:
db_table = 'karma_values'
ordering = ['value']
managed = False

View File

@ -1,23 +0,0 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

View File

@ -1,8 +0,0 @@
from django.conf.urls.defaults import *
urlpatterns = patterns('karma.views',
(r'^$', 'index'),
(r'^givers/$', 'givers'),
(r'^stats/$', 'stats'),
(r'^stats/(?P<key>.*)/$', 'key_detail', dict(), 'key_detail'),
)

View File

@ -1,24 +0,0 @@
from django.shortcuts import render_to_response
from django.template import RequestContext
from karma.models import Value, User, LogEntry
def index(request):
karma_values = len(Value.objects.all())
karma_users = len(User.objects.all())
return render_to_response('karma/index.html', {'value_count': karma_values,
'user_count': karma_users})
def stats(request):
values = Value.objects.all().order_by('-value')
return render_to_response('karma/stats.html', {'values': values})
def givers(request):
users = User.objects.all().order_by('who')
return render_to_response('karma/givers.html', {'users': users})
def key_detail(request, key):
deltas = LogEntry.objects.filter(key=key)
return render_to_response('karma/key_detail.html', {'key': key,'deltas': deltas}, context_instance=RequestContext(request))
# vi:tabstop=4:expandtab:autoindent

View File

@ -1,11 +0,0 @@
#!/usr/bin/env python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
sys.exit(1)
if __name__ == "__main__":
execute_manager(settings)

View File

@ -1,113 +0,0 @@
# Django settings for web project.
import os.path
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
('Mike Bloy', 'mike@bloy.org'),
)
MANAGERS = ADMINS
DB_LOCATION = os.path.normpath(
os.path.join(os.path.abspath(os.path.dirname(__file__)),
'..', 'dr.botzo.data'))
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': DB_LOCATION, # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = ''
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'x(mks19qjlqj=l)werudifqhhr_3b6v($kwihs+=p^ldqcc4$q'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
ROOT_URLCONF = 'urls'
TEMPLATE_BASE_LOC = os.path.normpath(
os.path.join(os.path.abspath(os.path.dirname(__file__)),
'templates'))
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
TEMPLATE_BASE_LOC,
)
INSTALLED_APPS = (
#'django.contrib.auth',
#'django.contrib.contenttypes',
#'django.contrib.sessions',
#'django.contrib.sites',
'django.contrib.messages',
# Uncomment the next line to enable the admin:
#'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'karma',
'storycraft',
)
if __name__ == "__main__":
print DB_LOCATION
print TEMPLATE_DIRS

View File

@ -1,167 +0,0 @@
* {
padding: 0px;
margin: 0px;
}
html {
height: 100%;
}
body {
color: #333333;
background: #efefef;
font-family: 'Bitstream Vera Sans', sans-serif;
font-size: 9pt;
height: 100%;
}
#container {
background: white;
min-height: 100%;
border-left: 1px solid #666666;
border-right: 1px solid #666666;
width: 85%;
margin-left: auto;
margin-right: auto;
}
#messages {
background: white;
padding: 5px;
margin: 5px;
border: 1px solid black;
}
#messages .messagelist .error {
list-style-type: none;
color: red;
}
#mainpage {
padding: 5px;
overflow: auto;
padding-bottom: 10px;
margin-bottom: 50px;
}
#mainpage #title {
text-align: center;
padding: 20px;
}
#mainpage #title h1 {
font-family: 'Cardo', 'Times New Roman', serif;
font-size: 32pt;
font-weight: normal;
}
.gameitem {
margin: 10px;
border: 1px solid #999999;
}
.gameitem .gameinfo {
padding: 0px;
display: table;
width: 100%;
}
.gameitem .gameplayers {
padding: 5px;
border: 1px solid #e0e0e0;
display: table;
width: 100%;
}
.gameitem .gameinfo li {
padding: 5px;
display: table-cell;
border: 1px solid #e0e0e0;
}
.gameitem .gameplayers li {
display: inline;
}
.gameitem .gameplayers li:before {
content: ", ";
}
.gameitem .gameplayers li:first-child:before {
content: "Players: ";
}
.gameitem .gameinfo li.gameid {
width: 45%;
background: #e0e0e0;
color: #333333;
}
.gameitem .gameinfo li.gamestatus {
width: 25%;
}
.gameitem .gameinfo li.gamecode {
width: 30%;
}
.gameitem a {
color: #333333;
text-decoration: none;
}
.gameitem .progressblock {
width: 100%;
margin: 10px;
}
.progressbar .yui-pb {
height: 10px;
}
.progressbar .yui-pb-bar {
background-color: #811610;
}
.storyblock {
border: 1px solid #e0e0e0;
margin: 0px 10px;
padding: 10px;
}
.gamestory {
font-family: 'Cardo', 'Times New Roman', serif;
font-size: 11pt;
line-height: 1.5em;
}
.gamestory p {
margin-bottom: 20px;
}
#footer {
position: relative;
margin-top: -50px;
height: 50px;
clear: both;
text-align: center;
background: #333333;
color: #999999;
}
#footer p {
padding-top: 10px;
font-size: 8pt;
}
.hidden {
display: none;
}
/*
vi:tabstop=4:expandtab:autoindent
*/

View File

@ -1,64 +0,0 @@
from django.db import models
class StorycraftGame(models.Model):
id = models.IntegerField(primary_key=True)
round_mode = models.IntegerField()
game_length = models.IntegerField()
line_length = models.IntegerField()
random_method = models.IntegerField()
lines_per_turn = models.IntegerField()
status = models.CharField()
owner_nick = models.CharField()
owner_userhost = models.CharField()
start_time = models.DateTimeField()
end_time = models.DateTimeField()
class Meta:
db_table = 'storycraft_game'
ordering = ['id']
managed = False
def __unicode__(self):
"""Return a terse summary of the vital game info."""
return '#{0:d} - created on {1:s} by {2:s}, {3:s}'.format(self.id, self.start_time, self.owner_nick, self.status)
def is_completed(self):
"""Return if this game is completed."""
return self.status == 'COMPLETED' and self.end_time
class StorycraftPlayer(models.Model):
id = models.IntegerField(primary_key=True)
game = models.ForeignKey(StorycraftGame)
nick = models.CharField()
userhost = models.CharField()
class Meta:
db_table = 'storycraft_player'
ordering = ['id']
managed = False
def __unicode__(self):
"""Return the nick!user@host."""
return '{0:s}!{1:s}'.format(self.nick, self.userhost)
class StorycraftLine(models.Model):
id = models.IntegerField(primary_key=True)
game = models.ForeignKey(StorycraftGame)
player = models.ForeignKey(StorycraftPlayer)
line = models.TextField()
time = models.DateTimeField()
class Meta:
db_table = 'storycraft_line'
ordering = ['id']
managed = False
def __unicode__(self):
"""Just return the line."""
return '{0:s}'.format(self.line)
# vi:tabstop=4:expandtab:autoindent

View File

@ -1,8 +0,0 @@
from django.conf.urls.defaults import *
urlpatterns = patterns('storycraft.views',
(r'^$', 'index'),
(r'^games/(?P<game_id>\d+)/$', 'game_index', dict(), 'game_index'),
)
# vi:tabstop=4:expandtab:autoindent

View File

@ -1,48 +0,0 @@
from django.contrib import messages
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
from django.utils.html import escape
from django.utils.safestring import mark_safe
from storycraft.models import StorycraftGame, StorycraftLine, StorycraftPlayer
def index(request):
"""Display a short list of each game (and its summary) in the system.
TODO: add paginator.
"""
games = StorycraftGame.objects.all()
return render_to_response('storycraft/index.html', {'games': games}, context_instance=RequestContext(request))
def game_index(request, game_id):
"""Display one individual game's details, including the story, if it's done."""
game = get_object_or_404(StorycraftGame, pk=game_id)
players = StorycraftPlayer.objects.filter(game=game.id)
lines = StorycraftLine.objects.filter(game=game.id)
pretty_story = []
if game.is_completed():
# make a HTML-formatted string that is the entire story, in
# which we've added paragraphs and such.
period_count = 0
pretty_story.append('<p>')
for line in lines:
period_count = period_count + line.line.count('.')
if period_count > 6:
period_count = 0
split = line.line.rsplit('.', 1)
pretty_story.append('<span title="' + line.player.nick + ' @ ' + line.time + '">' + escape(split[0]) + '.</span></p>')
pretty_story.append('<p><span title="' + line.player.nick + ' @ ' + line.time + '">' + escape(split[1]) + '</span>')
else:
pretty_story.append('<span title="' + line.player.nick + ' @ ' + line.time + '">' + escape(line.line) + '</span>')
pretty_story.append('</p>')
pretty_story_text = ' '.join(pretty_story)
mark_safe(pretty_story_text)
return render_to_response('storycraft/game_index.html', {'game': game, 'players': players, 'lines': lines, 'prettystory': pretty_story_text}, context_instance=RequestContext(request))
# vi:tabstop=4:expandtab:autoindent

View File

@ -1,13 +0,0 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>dr.botzo</title>
</head>
<body>
<ul>
<li><a href="/dr.botzo/karma/">Karma</a></li>
<li><a href="/dr.botzo/storycraft/">Storycraft</a></li>
</ul>
</body>
</html>

View File

@ -1,9 +0,0 @@
{% autoescape on %}
<ul>
{% for user in users %}
<li>
{{ user.who }} - {{ user.pos }} positive, {{ user.neg }} negative, {{ user.total }} total
</li>
{% endfor %}
</ul>
{% endautoescape %}

View File

@ -1,6 +0,0 @@
{% autoescape on %}
<ul>
<li><a href="/karma/stats/">Karma Stats</a> ({{ value_count }} karma entries)</li>
<li><a href="/karma/givers/">Karma Giver Stats</a> ({{ user_count }} karma givers)</li>
</ul>
{% endautoescape %}

View File

@ -1,31 +0,0 @@
{% autoescape on %}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>dr.botzo &mdash; Karma &mdash; {{ key }}</title>
</head>
<body>
{% if messages %}
<div id="messages">
<ul class="messagelist">
{% for message in messages %}
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
<div id="container">
<ul>
{% for delta in deltas %}
<li>{{ delta }}</li>
{% endfor %}
</ul>
</div>
</body>
</html>
<!--
vi:tabstop=2:expandtab:autoindent
-->
{% endautoescape %}

View File

@ -1,9 +0,0 @@
{% autoescape on %}
<ol>
{% for value in values %}
<li>
<a href="{% url key_detail value.key %}">{{ value.key }}</a> ({{ value.value }})
</li>
{% endfor %}
</ol>
{% endautoescape %}

View File

@ -1,49 +0,0 @@
{% autoescape on %}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<link href='http://fonts.googleapis.com/css?family=Cardo&amp;subset=latin' rel='stylesheet' type='text/css' />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>dr.botzo &mdash; Storycraft #{{ game.id }}</title>
<link rel="stylesheet" href="/static/storycraft/page.css" type="text/css" />
<!-- Required CSS -->
<link type="text/css" rel="stylesheet" href="http://yui.yahooapis.com/2.8.2r1/build/progressbar/assets/skins/sam/progressbar.css">
<!-- Dependency source file -->
<script src = "http://yui.yahooapis.com/2.8.2r1/build/yahoo-dom-event/yahoo-dom-event.js" ></script>
<script src = "http://yui.yahooapis.com/2.8.2r1/build/element/element-min.js" ></script>
<!-- Optional dependency source file -->
<script src="http://yui.yahooapis.com/2.8.2r1/build/animation/animation-min.js" type="text/javascript"></script>
<!-- ProgressBar source file -->
<script src = "http://yui.yahooapis.com/2.8.2r1/build/progressbar/progressbar-min.js" ></script>
</head>
<body>
{% if messages %}
<div id="messages">
<ul class="messagelist">
{% for message in messages %}
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
<div id="container">
<div id="mainpage">
<div id="title">
<h1>Storycraft #{{ game.id }}</h1>
</div>
<div id="gamesummary">
{% include 'storycraft/tmpl_game_summary.html' %}
</div>
{% include 'storycraft/tmpl_game_story.html' %}
</div>
</div>
{% include 'storycraft/tmpl_footer.html' %}
</body>
</html>
<!--
vi:tabstop=2:expandtab:autoindent
-->
{% endautoescape %}

View File

@ -1,52 +0,0 @@
{% autoescape on %}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<link href='http://fonts.googleapis.com/css?family=Cardo&amp;subset=latin' rel='stylesheet' type='text/css' />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>dr.botzo &mdash; Storycraft</title>
<link rel="stylesheet" href="/static/storycraft/page.css" type="text/css" />
<!-- Required CSS -->
<link type="text/css" rel="stylesheet" href="http://yui.yahooapis.com/2.8.2r1/build/progressbar/assets/skins/sam/progressbar.css">
<!-- Dependency source file -->
<script src = "http://yui.yahooapis.com/2.8.2r1/build/yahoo-dom-event/yahoo-dom-event.js" ></script>
<script src = "http://yui.yahooapis.com/2.8.2r1/build/element/element-min.js" ></script>
<!-- Optional dependency source file -->
<script src="http://yui.yahooapis.com/2.8.2r1/build/animation/animation-min.js" type="text/javascript"></script>
<!-- ProgressBar source file -->
<script src = "http://yui.yahooapis.com/2.8.2r1/build/progressbar/progressbar-min.js" ></script>
</head>
<body>
{% if messages %}
<div id="messages">
<ul class="messagelist">
{% for message in messages %}
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
<div id="container">
<div id="mainpage">
<div id="title">
<h1>Storycraft</h1>
</div>
<div id="gamelist">
{% for game in games %}
{% include 'storycraft/tmpl_game_summary.html' %}
{% empty %}
<p>No storycraft games. :(</p>
{% endfor %}
</div>
</div>
</div>
{% include 'storycraft/tmpl_footer.html' %}
</body>
</html>
<!--
vi:tabstop=2:expandtab:autoindent
-->
{% endautoescape %}

View File

@ -1,9 +0,0 @@
{% autoescape on %}
<div id="footer">
<p>Storycraft is a game of collaborative storytelling, intentionally leading to much insanity and nonsense. All stories were made to be funny but may not even be coherent. Void where prohibited.</p>
</div>
<!--
vi:tabstop=2:expandtab:autoindent
-->
{% endautoescape %}

View File

@ -1,15 +0,0 @@
{% autoescape on %}
<div class="storyblock">
{% if game.is_completed %}
<div class="gamestory">{{ prettystory|safe }}</div>
{% else %}
<div class="gamenostory">
<p>This game has not been completed yet. Come back later (or get to work).</p>
</div>
{% endif %}
</div>
<!--
vi:tabstop=2:expandtab:autoindent
-->
{% endautoescape %}

View File

@ -1,28 +0,0 @@
{% autoescape on %}
<div class="gameitem">
<h3 class="hidden">Game Info</h3>
<ul class="gameinfo">
<li class="gameid"><span><a href="{% url game_index game.id %}">{{ game.id }}: {{ game.start_time }} &ndash; {{ game.end_time }}</a></span></li>
<li class="gamestatus"><span>{{ game.status }}</span></li>
<li class="gamecode"><span>o:{{ game.round_mode }}[{{ game.game_length }}],{{ game.line_length }},{{ game.random_method }},{{ game.lines_per_turn }}</span></li>
</ul>
{% if players %}
<h3 class="hidden">Player List</h3>
<ul class="gameplayers">
{% for player in players %}
<li>{{ player.nick }}</li>
{% endfor %}
</ul>
{% endif %}
{% if lines %}
<div class="progressblock" id="progressblock{{game.id}}">
<div class="progressbar" id="progressbar{{game.id}}"></div>
</div>
<script>var pb = new YAHOO.widget.ProgressBar().render('progressbar{{game.id}}'); var space = YAHOO.util.Dom.getRegion('progressblock{{game.id}}'); pb.set('width', space.width-35); pb.set('minValue', 0); pb.set('maxValue', {{ game.game_length }}); pb.set('value', 0); if (0) { pb.set('anim', true); var anim = pb.get('anim'); anim.duration = 2; } pb.set('value', {{ lines|length }}-1);</script>
{% endif %}
</div>
<!--
vi:tabstop=2:expandtab:autoindent
-->
{% endautoescape %}

View File

@ -1,20 +0,0 @@
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
urlpatterns = patterns(
'',
(r'^$', 'index.views.index'),
(r'^karma/', include('karma.urls')),
(r'^storycraft/', include('storycraft.urls')),
# Example:
# (r'^web/', include('web.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
# (r'^admin/', include(admin.site.urls)),
)