diff options
Diffstat (limited to 'bn_django/git_wiki')
-rw-r--r-- | bn_django/git_wiki/models.py | 8 | ||||
-rw-r--r-- | bn_django/git_wiki/settings.py | 6 | ||||
-rw-r--r-- | bn_django/git_wiki/templates/git_wiki/commit.html | 17 | ||||
-rw-r--r-- | bn_django/git_wiki/templates/git_wiki/frontpage.html | 8 | ||||
-rw-r--r-- | bn_django/git_wiki/templates/git_wiki/item.html | 2 | ||||
-rw-r--r-- | bn_django/git_wiki/templates/git_wiki/newitems_table | 27 | ||||
-rw-r--r-- | bn_django/git_wiki/views.py | 10 |
7 files changed, 63 insertions, 15 deletions
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 %} - <h3>Commit sha1 hash</h3> + <b>Commit sha1 hash: </b> <span class="hash">{{ commit.id }}</span><br /> - <h3>Parent sha1 hash</h3> + <b>Parent sha1 hash: </b> {% if commit.parenthash %} <a href="/k/commit/{{ commit.parenthash }}/"> <span class="hash">{{ commit.parenthash }}</span></a> {% else %}No parent... root commit?{% endif %} - <h3>Tree sha1 hash</h3> + <br /> + <b>Tree sha1 hash: </b> {% if commit.treehash %} <span class="hash">{{ commit.treehash }}</span> {% else %}No tree hash?{% endif %} - <h3>Author</h3> + <br /><b>Author: </b> {{ commit.author }}<br /> - <h3>Author Date</h3> + <b>Author Date: </b> {{ commit.author_date }}<br /> - <h3>Committer</h3> + <b>Committer: </b> {{ commit.committer }}<br /> - <h3>Committer Date</h3> + <b>Committer Date: </b> {{ commit.committer_date }}<br /> {% if commit.rawdiff %} <pre class="large">{{ commit.rawdiff }}</pre> 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 <a href="/code">code</a> section. <div class="right_stuff"> For more recent content see the <a href="/timeline/">timeline</a> </div> -<h3><a href="/k/">Browse the knowledge!</a></h3> -<h3>Latest knowledge</h3> +<h2><a href="/k/">Browse the knowledge!</a></h2> +<h3>Latest knowledge items</h3> +{% include "git_wiki/newitems_table" %} +<h3>Latest knowledge commits</h3> {% include "git_wiki/shortlog_table" %} -<hr /> <h3>Latest comments</h3> {% 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 %} <div class="content" id="commentary"> {% load comments %} +<br /><p><em>IMPORTANT: Comments only apply to this revision of the item! +They will be lost if the item is updated.</em></p> <h3>Post a comment</h3> {% 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 %} +<table class="listing"> + {% for i in newitems reversed %} + <tr> <td class="filename"> + {% ifequal i.type 'blob' %} + <a href='/k/{{ i.slug }}/' class="item"> + {{i.path}}</a> + </td><td type="links"> + <a href='/k/{{ i.slug }}/pdf/'>pdf</a> + </td> + {% else %} {% ifequal i.type 'tree' %} + <a href='/k/{{ i.slug }}/' class="tree"> + {{i.path}}/</a> + </td><td type="links"> + <a href='/k/{{ i.slug }}/'>browse</a> + </td> + {% else %} + <a href='/k/{{ i.slug }}/' class="item"> + {{i.name}}</a> + </td><td type="links"> + </td> + {% endifequal %}{% endifequal %} + </tr> + {% endfor %} +</table> +{% 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) |