From 953fc002832a9afe59372bf513ef167916608e05 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Wed, 7 Mar 2007 14:56:46 -0800 Subject: comments progress, style changes --- bn_django/git_wiki/models.py | 8 +++++++ bn_django/git_wiki/settings.py | 6 ++--- bn_django/git_wiki/templates/git_wiki/commit.html | 17 ++++++++------ .../git_wiki/templates/git_wiki/frontpage.html | 8 ++++--- bn_django/git_wiki/templates/git_wiki/item.html | 2 ++ .../git_wiki/templates/git_wiki/newitems_table | 27 ++++++++++++++++++++++ bn_django/git_wiki/views.py | 10 ++++++-- bn_django/templates/about.html | 2 +- bn_django/templates/credits.html | 2 +- bn_django/templates/frontpage.html | 10 +++++++- bn_django/templates/newcomments_table | 26 +++++++++++++++++++++ bn_django/urls.py | 7 +++++- static/style/default.css | 10 +++++--- 13 files changed, 113 insertions(+), 22 deletions(-) create mode 100644 bn_django/git_wiki/templates/git_wiki/newitems_table create mode 100644 bn_django/templates/newcomments_table diff --git a/bn_django/git_wiki/models.py b/bn_django/git_wiki/models.py index ad3affb..78a26f6 100644 --- a/bn_django/git_wiki/models.py +++ b/bn_django/git_wiki/models.py @@ -82,6 +82,7 @@ class Item(models.Model): return "/k/%s/" % self.slug() def get_admin_url(self): return "%s/k/%s/" % (ADMIN_URL, self.id) + def update(self): import commands @@ -208,6 +209,13 @@ def reposcan(): f.close() return (heads, tags) +def newest_items(): + num = Item.objects.count() + min = num-7 + if min < 0: + min = 0 + return Item.objects.all()[min:num] + def shortlog(hash=None,tree=None): import commands diff --git a/bn_django/git_wiki/settings.py b/bn_django/git_wiki/settings.py index b94d318..965ac26 100644 --- a/bn_django/git_wiki/settings.py +++ b/bn_django/git_wiki/settings.py @@ -1,13 +1,13 @@ # full path to directory holding the wiki repository (or sys links to # the repositories) -GITWIKI_BASE = '/srv/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' GITWIKI_DIR = str(GITWIKI_BASE) + '/' + str(GITWIKI_NAME) + '.git' GITPREFIX = 'cd ' +str(GITWIKI_BASE) + '; ' + str(GITCOMMAND) + ' --git-dir=' \ diff --git a/bn_django/git_wiki/templates/git_wiki/commit.html b/bn_django/git_wiki/templates/git_wiki/commit.html index 5eb5dd0..8497311 100644 --- a/bn_django/git_wiki/templates/git_wiki/commit.html +++ b/bn_django/git_wiki/templates/git_wiki/commit.html @@ -1,24 +1,27 @@ {% extends "git_wiki/base.html" %} +{% block title %}Commit: {{ commit.committer_date}} +{% endblock %} {% block gitwiki %} {% if commit %} -

Commit sha1 hash

+ Commit sha1 hash: {{ commit.id }}
-

Parent sha1 hash

+ Parent sha1 hash: {% if commit.parenthash %} {{ commit.parenthash }} {% else %}No parent... root commit?{% endif %} -

Tree sha1 hash

+
+ Tree sha1 hash: {% if commit.treehash %} {{ commit.treehash }} {% else %}No tree hash?{% endif %} -

Author

+
Author: {{ commit.author }}
-

Author Date

+ Author Date: {{ commit.author_date }}
-

Committer

+ Committer: {{ commit.committer }}
-

Committer Date

+ Committer Date: {{ commit.committer_date }}
{% if commit.rawdiff %}
{{ commit.rawdiff }}
diff --git a/bn_django/git_wiki/templates/git_wiki/frontpage.html b/bn_django/git_wiki/templates/git_wiki/frontpage.html index 85698c4..0c8d245 100644 --- a/bn_django/git_wiki/templates/git_wiki/frontpage.html +++ b/bn_django/git_wiki/templates/git_wiki/frontpage.html @@ -20,12 +20,14 @@ If you're curious you can track my work in the code section.
For more recent content see the timeline
-

Browse the knowledge!

-

Latest knowledge

+

Browse the knowledge!

+

Latest knowledge items

+{% include "git_wiki/newitems_table" %} +

Latest knowledge commits

{% include "git_wiki/shortlog_table" %} -

Latest comments

{% if latest_comments %} +{% include "newcomments_table" %} {% else %} None yet! {% endif %} diff --git a/bn_django/git_wiki/templates/git_wiki/item.html b/bn_django/git_wiki/templates/git_wiki/item.html index 4258b1c..d9d33c9 100644 --- a/bn_django/git_wiki/templates/git_wiki/item.html +++ b/bn_django/git_wiki/templates/git_wiki/item.html @@ -31,6 +31,8 @@ {% block commentary %}
{% load comments %} +

IMPORTANT: Comments only apply to this revision of the item! +They will be lost if the item is updated.

Post a comment

{% if user.is_authenticated %} {% comment_form for git_wiki.item item.id with is_public yes %} diff --git a/bn_django/git_wiki/templates/git_wiki/newitems_table b/bn_django/git_wiki/templates/git_wiki/newitems_table new file mode 100644 index 0000000..d86c538 --- /dev/null +++ b/bn_django/git_wiki/templates/git_wiki/newitems_table @@ -0,0 +1,27 @@ +{% if newitems %} + + {% for i in newitems reversed %} + + {% else %} {% ifequal i.type 'tree' %} + + {{i.path}}/ + + {% else %} + + {{i.name}} + + {% endifequal %}{% endifequal %} + + {% endfor %} +
+ {% ifequal i.type 'blob' %} + + {{i.path}} + + pdf + + browse + +
+{% else %}No new items! +{% endif %} diff --git a/bn_django/git_wiki/views.py b/bn_django/git_wiki/views.py index c0681c7..b0dde21 100644 --- a/bn_django/git_wiki/views.py +++ b/bn_django/git_wiki/views.py @@ -7,14 +7,20 @@ import os, commands from models import * from settings import * +from django.contrib.comments.models import Comment,FreeComment # Create your views here. def frontpage(request): t = fromslug('') t.update() + #TODO: doesn't display free comments unless there's a comment + lc = Comment.objects.filter(content_type__name="item").order_by('-submit_date')[:6] + lfc = FreeComment.objects.filter(content_type__name="item").order_by('-submit_date')[:6] return render_to_response('git_wiki/frontpage.html', \ - dict(shortlog=shortlog(), tree=t)) + dict(shortlog=shortlog(), tree=t, + latest_comments=lc, latest_freecomments=lfc, + newitems=newest_items())) def tree(request, reqslug, tree=None): if not tree: @@ -52,7 +58,7 @@ def item(request, reqslug, blob=None): 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)) + dict(item=i,doc=parts,user=request.user)) def olditem(request, hash): i = get_object_or_404(Item, id=hash) diff --git a/bn_django/templates/about.html b/bn_django/templates/about.html index c9f9ce4..1ca9d60 100644 --- a/bn_django/templates/about.html +++ b/bn_django/templates/about.html @@ -10,7 +10,7 @@ {% block content %}

- the author
the perp
diff --git a/bn_django/templates/credits.html b/bn_django/templates/credits.html index b96d2a9..d1322b9 100644 --- a/bn_django/templates/credits.html +++ b/bn_django/templates/credits.html @@ -15,5 +15,5 @@ This site uses a variety of delicious software!

text editor

vim! fuck emacs!

versioning system

-

I use git as a revisioning system for the knowledge wiki and my software (including this site!). +

I use git as a revisioning system for the knowledge wiki and my software (including this site!). {% endblock %} diff --git a/bn_django/templates/frontpage.html b/bn_django/templates/frontpage.html index 1a7acc2..46906ef 100644 --- a/bn_django/templates/frontpage.html +++ b/bn_django/templates/frontpage.html @@ -35,7 +35,14 @@ For more recent content see the timeline

-
Latest knowledge
+
Latest knowledge items
+{% if newitems %} +{% include "git_wiki/newitems_table" %} +{% else %} +None yet! +{% endif %} +
+
Latest knowledge commits
{% if latest_knowledge %} {% include "newknowldge_table" %} {% else %} @@ -46,6 +53,7 @@ None yet!
Latest comments
{% if latest_comments %} +{% include "newcomments_table" %} {% else %} None yet! {% endif %} diff --git a/bn_django/templates/newcomments_table b/bn_django/templates/newcomments_table new file mode 100644 index 0000000..6c38d10 --- /dev/null +++ b/bn_django/templates/newcomments_table @@ -0,0 +1,26 @@ + +{% for c in latest_comments %} + + + + + +{% endfor %} +{% for c in latest_freecomments %} + + + + + +{% endfor %} +
+ {{ c.submit_date|date:"F jS" }} + {% if c.user.username %}{{ c.user.username }} + {% else %}anonymous{% endif%} + + {{ c.content_type.name }}
+ {{ c.submit_date|date:"F jS" }} + {% if c.person_name %}{{c.person_name}}{% else %}anonymous{% endif %} + + + {{ c.content_type.name }}
diff --git a/bn_django/urls.py b/bn_django/urls.py index 425066b..eaf991e 100644 --- a/bn_django/urls.py +++ b/bn_django/urls.py @@ -1,5 +1,6 @@ from django.conf.urls.defaults import * from photos.models import Photo +from django.contrib.comments.models import Comment,FreeComment import git_wiki.models urlpatterns = patterns('', @@ -9,7 +10,11 @@ urlpatterns = patterns('', {'template': 'frontpage.html','extra_context':dict({ \ 'latest_photos':Photo.objects.order_by('date')[:2], \ #'latest_comments':Photo.objects.order_by('date')[:4] \ - 'latest_knowledge':git_wiki.models.shortlog() \ + 'latest_knowledge':git_wiki.models.shortlog(), \ + 'latest_comments':Comment.objects.order_by('-submit_date')[:4], \ + 'latest_freecomments': \ + FreeComment.objects.order_by('-submit_date')[:4], \ + 'newitems':git_wiki.models.newest_items(), \ })}), (r'^about/$', 'django.views.generic.simple.direct_to_template', {'template': 'about.html'}), diff --git a/static/style/default.css b/static/style/default.css index 513f064..691dae8 100644 --- a/static/style/default.css +++ b/static/style/default.css @@ -8,6 +8,8 @@ body { background-color: #E3E3E3; } a { text-decoration: none; } +a:visited { + color: blue; } a:hover { text-decoration: underline; border-top: 0px solid blue; @@ -25,7 +27,7 @@ h3 { margin: 0px; padding-top: 8px; padding-bottom: 4px; - padding-left: 30px; + padding-left: 0px; padding-right: 30px; } p { margin: 0px; } @@ -69,7 +71,8 @@ pre.large { .path a { color: #6666DD; } .path a:visited { - color: #883388; } + /* color: #883388; */ + color: #6666DD; } .righty_content { text-align: center; margin-top: 5px; @@ -186,7 +189,8 @@ pre.large { .right_stuff a { color: #7777DD; } .right_stuff a:visited { - color: #BB77BB; } + /* color: #BB77BB; */ + color: #7777DD; } .right_stuff img { border: 1px solid black; } .photo_thumb { -- cgit v1.2.3