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 ++++++-- 7 files changed, 63 insertions(+), 15 deletions(-) create mode 100644 bn_django/git_wiki/templates/git_wiki/newitems_table (limited to 'bn_django/git_wiki') 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) -- cgit v1.2.3