aboutsummaryrefslogtreecommitdiffstats
path: root/bn_django
diff options
context:
space:
mode:
Diffstat (limited to 'bn_django')
-rw-r--r--bn_django/git_wiki/models.py12
-rw-r--r--bn_django/git_wiki/settings.py11
-rw-r--r--bn_django/git_wiki/templates/git_wiki/item.html26
-rw-r--r--bn_django/git_wiki/views.py15
-rw-r--r--bn_django/photos/templates/photos/photo_detail.html20
-rw-r--r--bn_django/settings.py12
-rw-r--r--bn_django/templates/base.html7
-rw-r--r--bn_django/templates/comment_list16
-rw-r--r--bn_django/templates/comments/form.html36
-rw-r--r--bn_django/templates/comments/freeform.html11
-rw-r--r--bn_django/templates/frontpage.html1
-rw-r--r--bn_django/templates/newknowldge_table13
-rw-r--r--bn_django/urls.py29
13 files changed, 165 insertions, 44 deletions
diff --git a/bn_django/git_wiki/models.py b/bn_django/git_wiki/models.py
index ae9ef79..060e9d5 100644
--- a/bn_django/git_wiki/models.py
+++ b/bn_django/git_wiki/models.py
@@ -150,10 +150,10 @@ def fromslug(reqslug):
import commands
if reqslug == '' or reqslug == '/':
- f = open(GITWIKI_BASE + '/HEAD','r')
+ f = open(GITWIKI_DIR + '/HEAD','r')
head = f.readline().strip().split()[1]
f.close()
- f = open(GITWIKI_BASE + '/'+head,'r')
+ f = open(GITWIKI_DIR + '/'+head,'r')
hash = f.readline().strip()
f.close()
ret = Tree(id=hash)
@@ -198,13 +198,13 @@ def fromslug(reqslug):
def reposcan():
import os
heads = dict()
- for h in os.listdir(GITWIKI_BASE + '/refs/heads/'):
- f = open(GITWIKI_BASE + '/refs/heads/' + h,'r')
+ for h in os.listdir(GITWIKI_DIR + '/refs/heads/'):
+ f = open(GITWIKI_DIR + '/refs/heads/' + h,'r')
heads[h.strip()] = f.readline().strip()
f.close()
tags = dict()
- for t in os.listdir(GITWIKI_BASE + '/refs/tags/'):
- f = open(GITWIKI_BASE + '/refs/tags/' + t,'r')
+ for t in os.listdir(GITWIKI_DIR + '/refs/tags/'):
+ f = open(GITWIKI_DIR + '/refs/tags/' + t,'r')
tags[t.strip()] = f.readline().strip()
f.close()
return (heads, tags)
diff --git a/bn_django/git_wiki/settings.py b/bn_django/git_wiki/settings.py
index 882dd30..965ac26 100644
--- a/bn_django/git_wiki/settings.py
+++ b/bn_django/git_wiki/settings.py
@@ -1,13 +1,14 @@
# full path to directory holding the wiki repository (or sys links to
# the repositories)
-GITWIKI_BASE = '/srv/git/knowledge.git'
+GITWIKI_BASE = '/home/bnewbold/knowledge/'
# leave this blank (NO WHITE SPACE) unless you're using a bare repo
-GITWIKI_NAME = 'knowledge'
+GITWIKI_NAME = ''
# fill path to the git command
-GITCOMMAND = '/usr/bin/git'
+GITCOMMAND = '/usr/local/bin/git'
-GITPREFIX = 'cd ' +str(GITWIKI_BASE) + '/.. ; ' + str(GITCOMMAND) + ' --git-dir=' \
- + str(GITWIKI_BASE)
+GITWIKI_DIR = str(GITWIKI_BASE) + '/' + str(GITWIKI_NAME) + '.git'
+GITPREFIX = 'cd ' +str(GITWIKI_BASE) + '; ' + str(GITCOMMAND) + ' --git-dir=' \
+ + str(GITWIKI_DIR)
diff --git a/bn_django/git_wiki/templates/git_wiki/item.html b/bn_django/git_wiki/templates/git_wiki/item.html
index 7562fc6..16d3518 100644
--- a/bn_django/git_wiki/templates/git_wiki/item.html
+++ b/bn_django/git_wiki/templates/git_wiki/item.html
@@ -1,25 +1,29 @@
{% extends "git_wiki/base.html" %}
-{% load markup %}
+{% block stylesheets %}
+{{ block.super }}
+<link rel="STYLESHEET" type="text/css" href="/style/docutils.css" />
+{% endblock %}
{% block path %}{{ block.super }} &raquo; <a href="/k/{{ item.slug }}/">
{{ item.path }}</a>{% endblock %}
-{% block title %}Knowledge Item: {{ item.path }}{% endblock %}
+{% block title %}{% endblock %}
{% block gitwiki %}
- {{ item.contents|restructuredtext }}
+&nbsp;
+{{ doc.html_body }}
<br /><hr />
- <h3>Item name:</h3>
- <span class="hash">{{ item.name }}</span>
- <h3>Item sha1 hash:</h3>
- <span class="hash">{{ item.id }}</span>
- <h3>Raw Contents:</h3>
- <pre class="large">{{ item.contents|escape|wordwrap:80 }}</pre>
-
+ <h3>Meta</h3>
+ <b>Item name:</b>
+ <span class="hash">{{ item.name }}</span><br />
+ <b>Item sha1 hash:</b>
+ <span class="hash">{{ item.id }}</span><br />
<br />
<span class="righty">
- <a href="/k/{{ item.slug }}/pdf/">pdf</a> - <a href="/k/{{ item.slug }}/log">log</a>
+ <a href="/k/{{ item.slug }}/raw/">raw</a> -
+ <a href="/k/{{ item.slug }}/pdf/">pdf</a> -
+ <a href="/k/{{ item.slug }}/log">log</a>
</span>
<br />
{% endblock %}
diff --git a/bn_django/git_wiki/views.py b/bn_django/git_wiki/views.py
index 2e66061..c0681c7 100644
--- a/bn_django/git_wiki/views.py
+++ b/bn_django/git_wiki/views.py
@@ -1,7 +1,7 @@
from django import forms, http, template
from django.contrib.auth.decorators import login_required
from django.shortcuts import get_object_or_404, render_to_response
-from django.http import HttpResponse, Http404
+from django.http import HttpResponse, Http404, HttpResponseServerError
import os, commands
@@ -42,8 +42,17 @@ def item(request, reqslug, blob=None):
else:
i = blob
i.update()
- return render_to_response('git_wiki/item.html',
- dict(item=i))
+
+ try:
+ from docutils.core import publish_parts
+ except ImportError:
+ if settings.DEBUG:
+ raise HttpResponseServerError(request)
+ else:
+ docutils_settings = getattr(settings, "GITWIKI_REST_SETTINGS", {})
+ parts = publish_parts(source=i.contents, writer_name="html4css1", settings_overrides=docutils_settings)
+ return render_to_response('git_wiki/item.html',
+ dict(item=i,doc=parts))
def olditem(request, hash):
i = get_object_or_404(Item, id=hash)
diff --git a/bn_django/photos/templates/photos/photo_detail.html b/bn_django/photos/templates/photos/photo_detail.html
index 10bf8ba..0d5398d 100644
--- a/bn_django/photos/templates/photos/photo_detail.html
+++ b/bn_django/photos/templates/photos/photo_detail.html
@@ -1,5 +1,6 @@
{% extends "photos/base.html" %}
{# {% load markup %} #}
+{% load comments %}
{% block path %}
{{ block.super }}
@@ -94,6 +95,25 @@
{% else %}
<p>This is not the photo you are looking for.</p>
{% endif %}
+{% endblock %}
+{% block commentary %}
+<div class="content" id="commentary">
+{% load comments %}
+{% if user.is_authenticated %}
+{% comment_form for photos.photo photo.id with is_public yes %}
+comment form:<br />
+{% include "comments/form.html" %}
+{% else %}
+{% free_comment_form for photos.photo photo.id with is_public yes %}
+free comment form:<br />
+{% include "comments/freeform.html" %}
+{% endif %}
+
+comment list:<br />
+{% get_comment_list for photos.photo photo.id as comments %}
+{% get_free_comment_list for photos.photo photo.id as free_comments %}
+{% include "comment_list" %}
+</div>
{% endblock %}
diff --git a/bn_django/settings.py b/bn_django/settings.py
index d04cbe7..3183cdc 100644
--- a/bn_django/settings.py
+++ b/bn_django/settings.py
@@ -11,7 +11,7 @@ ADMINS = (
MANAGERS = ADMINS
DATABASE_ENGINE = 'sqlite3' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
-DATABASE_NAME = '/srv/django/bn_django.db' # Or path to database file if using sqlite3.
+DATABASE_NAME = '/home/bnewbold/bn-project/bn_django/bn_django.db' # Or path to database file if using sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
@@ -19,7 +19,7 @@ DATABASE_PORT = '' # Set to empty string for default. Not used with
# Local time zone for this installation. All choices can be found here:
# http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
-TIME_ZONE = 'America/Seattle'
+TIME_ZONE = 'America/Boston'
# Language code for this installation. All choices can be found here:
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
@@ -34,16 +34,16 @@ USE_I18N = True
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
-MEDIA_ROOT = '/srv/http/bryannewbold/static/'
+MEDIA_ROOT = '/home/bnewbold/bn-project/media/'
# URL that handles the media served from MEDIA_ROOT.
# Example: "http://media.lawrence.com"
-MEDIA_URL = 'http://static.bryannewbold.com/'
+MEDIA_URL = '/media/'
# 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 = 'http://static.bryannewbold.com/django-admin/'
+ADMIN_MEDIA_PREFIX = '/style/django-admin/'
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'jdsgk29845ldsfg0090204tv(GFD8g0(%$)*@$#R%U)#*ifd;/q'
@@ -70,7 +70,7 @@ 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.
- '/srv/django/bn-project/bn_django/templates',
+ '/home/bnewbold/bn-project/bn_django/templates',
)
INSTALLED_APPS = (
diff --git a/bn_django/templates/base.html b/bn_django/templates/base.html
index dd66c97..402a959 100644
--- a/bn_django/templates/base.html
+++ b/bn_django/templates/base.html
@@ -3,9 +3,9 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
{% block stylesheets %}
-<!--<link rel="STYLESHEET" type="text/css" href="style/default.css" />
-<link rel="STYLESHEET" type="text/css" href="/style/default.css" />-->
-<link rel="STYLESHEET" type="text/css" href="http://static.bryannewbold.com/style/default.css" />
+<link rel="STYLESHEET" type="text/css" href="style/default.css" />
+<link rel="STYLESHEET" type="text/css" href="/style/default.css" />
+<!--<link rel="STYLESHEET" type="text/css" href="http://static.bryannewbold.com/style/default.css" /> -->
{% endblock %}
{% block externaljs %} {% endblock %}
<title>{% block windowtitle %}bryannewbold.com{% endblock %}</title>
@@ -55,6 +55,7 @@
Here lies content!
{% endblock %}
</div>
+{% block commentary %} {% endblock %}
<div class="content_footer" id="footer" name="footer">
<b>
&nbsp;
diff --git a/bn_django/templates/comment_list b/bn_django/templates/comment_list
new file mode 100644
index 0000000..8ed411d
--- /dev/null
+++ b/bn_django/templates/comment_list
@@ -0,0 +1,16 @@
+
+{% if comments %}
+<table class="comments">
+{% for c in comments %}
+<tr><td class="comment_info">
+ <span class="comment_user">{{ c.user }}</span>
+ <span class="comment_date">{{ c.submit_date }}</span>
+ </td><td class="comment_content">
+ <span class="comment_headline">{{ c.headline|escape|wordwrap:80 }}</span>
+ <span class="comment_content">{{ c.content|escape|wordwrap:80 }}</span>
+</td</tr>
+{% endfor %}
+</table>
+{% else %}
+<h3>No comments yet!</h3>
+{% endif %}
diff --git a/bn_django/templates/comments/form.html b/bn_django/templates/comments/form.html
new file mode 100644
index 0000000..316d6a1
--- /dev/null
+++ b/bn_django/templates/comments/form.html
@@ -0,0 +1,36 @@
+{% load i18n %}
+<form {% if photos_optional or photos_required %}enctype="multipart/form-data" {% endif %}action="/comments/post/" method="post">
+
+{% if user.is_authenticated %}
+<p>{% trans "Username:" %} <strong>{{ user.username }}</strong> (<a href="/accounts/logout/">{% trans "Log out" %}</a>)</p>
+{% else %}
+<p><label for="id_username">{% trans "Username:" %}</label> <input type="text" name="username" id="id_username" /><br />{% trans "Password:" %} <input type="password" name="password" id="id_password" /> (<a href="/accounts/password_reset/">{% trans "Forgotten your password?" %}</a>)</p>
+{% endif %}
+
+{% if ratings_optional or ratings_required %}
+<p>{% trans "Ratings" %} ({% if ratings_required %}{% trans "Required" %}{% else %}{% trans "Optional" %}{% endif %}):</p>
+<table>
+<tr><th>&nbsp;</th>{% for value in rating_range %}<th>{{ value }}</th>{% endfor %}</tr>
+{% for rating in rating_choices %}
+<tr><th>{{ rating }}</th>{% for value in rating_range %}<th><input type="radio" name="rating{{ forloop.parentloop.counter }}" value="{{ value }}" /></th>{% endfor %}</tr>
+{% endfor %}
+</table>
+<input type="hidden" name="rating_options" value="{{ rating_options }}" />
+{% endif %}
+
+{% if photos_optional or photos_required %}
+<p><label for="id_photo">{% trans "Post a photo" %}</label> ({% if photos_required %}{% trans "Required" %}{% else %}{% trans "Optional" %}{% endif %}):
+<input type="file" name="photo" id="id_photo" /></p>
+<input type="hidden" name="photo_options" value="{{ photo_options }}" />
+{% endif %}
+
+<p><label for="id_comment">{% trans "Comment:" %}</label><br />
+<textarea name="comment" id="id_comment" rows="10" cols="60"></textarea></p>
+
+<p>
+<input type="hidden" name="options" value="{{ options }}" />
+<input type="hidden" name="target" value="{{ target }}" />
+<input type="hidden" name="gonzo" value="{{ hash }}" />
+<input type="submit" name="preview" value="{% trans "Preview comment" %}" />
+</p>
+</form>
diff --git a/bn_django/templates/comments/freeform.html b/bn_django/templates/comments/freeform.html
new file mode 100644
index 0000000..95e5153
--- /dev/null
+++ b/bn_django/templates/comments/freeform.html
@@ -0,0 +1,11 @@
+{% load i18n %}
+<form action="/comments/postfree/" method="post">
+<p><label for="id_person_name">{% trans "Your name:" %}</label> <input type="text" id="id_person_name" name="person_name" /></p>
+<p><label for="id_comment">{% trans "Comment:" %}</label><br /><textarea name="comment" id="id_comment" rows="10" cols="60"></textarea></p>
+<p>
+<input type="hidden" name="options" value="{{ options }}" />
+<input type="hidden" name="target" value="{{ target }}" />
+<input type="hidden" name="gonzo" value="{{ hash }}" />
+<input type="submit" name="preview" value="{% trans "Preview comment" %}" />
+</p>
+</form>
diff --git a/bn_django/templates/frontpage.html b/bn_django/templates/frontpage.html
index 52db15e..1a7acc2 100644
--- a/bn_django/templates/frontpage.html
+++ b/bn_django/templates/frontpage.html
@@ -37,6 +37,7 @@ For more recent content see the <a href="/timeline/">timeline</a>
<div class="col_right">
<div class="col_title">Latest knowledge</div>
{% if latest_knowledge %}
+{% include "newknowldge_table" %}
{% else %}
None yet!
{% endif %}
diff --git a/bn_django/templates/newknowldge_table b/bn_django/templates/newknowldge_table
new file mode 100644
index 0000000..686a12f
--- /dev/null
+++ b/bn_django/templates/newknowldge_table
@@ -0,0 +1,13 @@
+{% if latest_knowledge %}
+<table class="listing">
+{% for l in latest_knowledge %}
+<tr>
+ <td class="date">
+ {{ l.date }}</td>
+ <td class="description">
+ <a href="/k/commit/{{ l.hash }}/" class="description">
+ {{ l.description|truncatewords:6 }}</a></td>
+ </tr>
+{% endfor %}
+</table>
+{% else %}No shortlog!{% endif %}
diff --git a/bn_django/urls.py b/bn_django/urls.py
index 9ccf0a3..425066b 100644
--- a/bn_django/urls.py
+++ b/bn_django/urls.py
@@ -1,18 +1,22 @@
from django.conf.urls.defaults import *
from photos.models import Photo
+import git_wiki.models
urlpatterns = patterns('',
# Example:
# (r'^bn_django/', include('bn_django.foo.urls')),
- (r'^$', 'django.views.generic.simple.direct_to_template', {'template': 'frontpage.html','extra_context':dict({ \
- 'latest_photos':Photo.objects.order_by('date')[:2] \
+ (r'^$', 'django.views.generic.simple.direct_to_template',
+ {'template': 'frontpage.html','extra_context':dict({ \
+ 'latest_photos':Photo.objects.order_by('date')[:2], \
#'latest_comments':Photo.objects.order_by('date')[:4] \
- #'latest_knowledge':Photo.objects.order_by('date')[:4] \
+ 'latest_knowledge':git_wiki.models.shortlog() \
})}),
- (r'^about/$', 'django.views.generic.simple.direct_to_template', {'template': 'about.html'}),
- (r'^credits/$', 'django.views.generic.simple.direct_to_template', {'template': 'credits.html'}),
- (r'^copyright/$', 'django.views.generic.simple.direct_to_template', {'template': 'copyright.html'}),
-
+ (r'^about/$', 'django.views.generic.simple.direct_to_template',
+ {'template': 'about.html'}),
+ (r'^credits/$', 'django.views.generic.simple.direct_to_template',
+ {'template': 'credits.html'}),
+ (r'^copyright/$', 'django.views.generic.simple.direct_to_template',
+ {'template': 'copyright.html'}),
(r'^knowledge/$', 'bn_django.git_wiki.views.frontpage',),
(r'^k/', include('bn_django.git_wiki.urls')),
@@ -23,8 +27,13 @@ urlpatterns = patterns('',
# Uncomment this for admin:
(r'^admin/', include('django.contrib.admin.urls')),
+ (r'^comments/', include('django.contrib.comments.urls.comments')),
- (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/home/bnewbold/bn-project/static', 'show_indexes': True}),
- (r'^style/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/home/bnewbold/bn-project/static/style'}),
- (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/home/bnewbold/bn-project/media'}),
+ (r'^static/(?P<path>.*)$', 'django.views.static.serve',
+ {'document_root': '/home/bnewbold/bn-project/static',
+ 'show_indexes': True}),
+ (r'^style/(?P<path>.*)$', 'django.views.static.serve',
+ {'document_root': '/home/bnewbold/bn-project/static/style'}),
+ (r'^media/(?P<path>.*)$', 'django.views.static.serve',
+ {'document_root': '/home/bnewbold/bn-project/media'}),
)