aboutsummaryrefslogtreecommitdiffstats
path: root/bn_django
diff options
context:
space:
mode:
Diffstat (limited to 'bn_django')
-rw-r--r--bn_django/git_browse/__init__.py0
-rw-r--r--bn_django/git_browse/models.py262
-rw-r--r--bn_django/git_browse/settings.py.example2
-rw-r--r--bn_django/git_browse/templates/git_browse/base.html37
-rw-r--r--bn_django/git_browse/templates/git_browse/blob.html18
-rw-r--r--bn_django/git_browse/templates/git_browse/commit.html36
-rw-r--r--bn_django/git_browse/templates/git_browse/full_log.html17
-rw-r--r--bn_django/git_browse/templates/git_browse/heads_table23
-rw-r--r--bn_django/git_browse/templates/git_browse/obj.html16
-rw-r--r--bn_django/git_browse/templates/git_browse/repository_info.html14
-rw-r--r--bn_django/git_browse/templates/git_browse/repository_list.html50
-rw-r--r--bn_django/git_browse/templates/git_browse/repository_raw_output.html8
-rw-r--r--bn_django/git_browse/templates/git_browse/shortlog_table29
-rw-r--r--bn_django/git_browse/templates/git_browse/tags_table23
-rw-r--r--bn_django/git_browse/templates/git_browse/tree.html11
-rw-r--r--bn_django/git_browse/templates/git_browse/tree_table32
-rw-r--r--bn_django/git_browse/urls.py48
-rw-r--r--bn_django/git_browse/views.py167
-rw-r--r--bn_django/git_wiki/__init__.py0
-rw-r--r--bn_django/git_wiki/admin.py7
-rw-r--r--bn_django/git_wiki/latex_directive.py129
-rw-r--r--bn_django/git_wiki/models.py269
-rw-r--r--bn_django/git_wiki/settings.py.example17
-rw-r--r--bn_django/git_wiki/templates/git_wiki/base.html22
-rw-r--r--bn_django/git_wiki/templates/git_wiki/commit.html39
-rw-r--r--bn_django/git_wiki/templates/git_wiki/frontpage.html35
-rw-r--r--bn_django/git_wiki/templates/git_wiki/item.html55
-rw-r--r--bn_django/git_wiki/templates/git_wiki/newitems_table36
-rw-r--r--bn_django/git_wiki/templates/git_wiki/shortlog_table27
-rw-r--r--bn_django/git_wiki/templates/git_wiki/tree.html15
-rw-r--r--bn_django/git_wiki/templates/git_wiki/tree_table38
-rw-r--r--bn_django/git_wiki/urls.py35
-rw-r--r--bn_django/git_wiki/views.py234
-rw-r--r--bn_django/photos/models.py33
-rw-r--r--bn_django/templates/comments/form.html22
-rw-r--r--bn_django/templates/frontpage.html13
36 files changed, 6 insertions, 1813 deletions
diff --git a/bn_django/git_browse/__init__.py b/bn_django/git_browse/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/bn_django/git_browse/__init__.py
+++ /dev/null
diff --git a/bn_django/git_browse/models.py b/bn_django/git_browse/models.py
deleted file mode 100644
index 5241638..0000000
--- a/bn_django/git_browse/models.py
+++ /dev/null
@@ -1,262 +0,0 @@
-from django.db import models
-from django.conf import settings
-from django.utils.translation import ugettext as _
-
-try:
- GITCOMMAND = settings.GITCOMMAND
-except AttributeError:
- GITCOMMAND='git'
-
-try:
- ADMIN_URL = settings.ADMIN_URL
-except AttributeError:
- ADMIN_URL='/admin'
-if ADMIN_URL[-1] == '/':
- ADMIN_URL=ADMIN_URL[:-1]
-
-
-# Create your models here.
-class Repository(models.Model):
-# path = models.FilePathField("relative path to repository", \
-# path=GITBROWSE_BASE,recursive=True,match="\.git$",unique=True, \
-# blank=False)
- path = models.CharField("path to git dir", max_length=386, unique=True,\
- blank=False, default="/srv/git/")
- name = models.CharField(_("name"), max_length=80, unique=True)
- slug = models.SlugField("short description of repo", unique=True,\
- blank=False)
- git_version = models.CharField(_("git version"), max_length=100, \
- default="git version 1.4.4", blank=True, \
- help_text="Output of \'git --version\'")
-
- description = models.TextField("description of repo",blank=True)
-
- class Admin:
- list_display = ['name', 'slug', 'path']
- ordering = ['name']
- def __str__(self):
- return self.name
- def get_absolute_url(self):
- return "/code/%s/" % self.slug
- def get_admin_url(self):
- return "%s/code/repository/%s/" % (ADMIN_URL, self.slug)
-
- def getGITPREFIX(self):
- """returns the glued together combination of GITCOMMAND and
- GITBROWSE_BASE needed to call git commands on this repository"""
- return 'cd ' + str(self.path) + '; ' + str(GITCOMMAND) + ' --git-dir='\
- + str(self.path)
-
- def scan(self):
- import os
- GITPREFIX = self.getGITPREFIX()
- heads = dict()
- for h in os.listdir(self.path + '/refs/heads/'):
- f = open(self.path + '/refs/heads/' + h,'r')
- heads[h.strip()] = f.readline().strip()
- f.close()
- tags = dict()
- for t in os.listdir(self.path + '/refs/tags/'):
- f = open(self.path + '/refs/tags/' + t,'r')
- tags[t.strip()] = f.readline().strip()
- f.close()
- return (GITPREFIX, heads, tags)
-
- def shortlog(self):
- import commands
- GITPREFIX = self.getGITPREFIX()
- logtxt = commands.getoutput(GITPREFIX \
- + ' log --relative-date --max-count=6 | cat')
- log_items = logtxt.split('\ncommit ')
- if (log_items[0] == ''):
- log_items.pop(0)
- if (log_items[0].startswith('commit ')):
- log_items[0] = log_items[0][7:]
- shortlog = list()
- for li in log_items:
- logobj = dict()
- lines = li.splitlines()
- if len(lines) < 3: continue
- logobj['hash'] = lines[0].strip()
- logobj['shorthash'] = lines[0].strip()[:5]
- logobj['author'] = lines[1][8:]
- logobj['date'] = lines[2][8:]
- if len(lines) > 4:
- logobj['description'] = lines[4][4:]
- else:
- logobj['description'] = '(none)'
- # here we truncate commit comments for shortlogs
- logobj['shortdescription'] = logobj['description'][:128]
- shortlog.append(logobj)
- return shortlog
-
-class Tree(models.Model):
- repo = models.ForeignKey(Repository)
- mode = models.CharField("file mode/permissions", blank=False,max_length=4)
- path = models.CharField("relative path from repo base", max_length=512)
- id = models.CharField("hash", max_length=40,blank=False,primary_key=True)
- name = models.CharField("name of dir", max_length=128,blank=False)
- type = 'tree'
-
- class Admin:
- list_display = ['path','name','repo', 'id']
- ordering = ['repo','path']
- list_filter = ['repo','path']
-
- def __str__(self):
- return self.name
- def get_absolute_url(self):
- return "/code/%s/tree/%s/" % (self.repo.slug, self.hash)
- def get_admin_url(self):
- return "%s/code/tree/%s/" % (ADMIN_URL, self.id)
-
- def update(self):
- import commands
- if (not self.id): return
-
- GITPREFIX = self.repo.getGITPREFIX()
-
- self.id = self.id.strip()
- tree_ls = commands.getoutput(GITPREFIX + ' ls-tree --full-name ' \
- + self.id)
- tree_objs = list()
- blob_objs = list()
- for line in tree_ls.splitlines():
- l = line.split()
- if len(l) < 4:
- continue
- if l[1] == 'tree':
- t = Tree(id=l[2])
- t.path = ' '.join(l[3:])
- if self.path and self.path != '/':
- t.path = self.path + '/' + t.path
- t.name = t.path
- tree_objs.append(t)
- if l[1] == 'blob':
- b = Blob(id=l[2])
- b.path = ' '.join(l[3:])
- if self.path and self.path != '/':
- b.path = self.path + '/' + b.path
- b.name=b.path
- blob_objs.append(b)
- self.tree_objs = tree_objs
- self.blob_objs = blob_objs
- self.all_objs = tree_objs + blob_objs
-
-def tree_from_str(s):
- s = s.split();
- if len(s) != 4: return
- return Tree(mode=s[0],id=s[2],name=s[3])
-
-class Blob(models.Model):
- repo = models.ForeignKey(Repository)
- mode = models.CharField("file mode/permissions", blank=False,max_length=4)
- path = models.CharField("relative path from repo base", max_length=512)
- id = models.CharField("hash", max_length=40,blank=False,primary_key=True)
- name = models.CharField("name of dir", max_length=128,blank=False)
- size = models.IntegerField("filesize in byte", max_length=128,blank=False)
- contents = models.TextField("ASCII contents of the file")
- type='blob'
-
- class Admin:
- list_filter = ['repo','path']
- list_display = ['name','path','id','size','repo']
- search_fields = ['contents']
- ordering = ['repo','path','name']
- def __str__(self):
- return self.name
- def get_absolute_url(self):
- return "/code/%s/blob/%s/" % (self.repo.slug, self.hash)
- def get_admin_url(self):
- return "%s/code/blob/%s/" % (ADMIN_URL, self.id)
-
- def update(self):
- import commands
- if (not self.id) or (not self.repo): return
-
- GITPREFIX = self.repo.getGITPREFIX()
-
- self.id = self.id.strip()
- self.contents = commands.getoutput(GITPREFIX + ' cat-file -p ' \
- + self.id)
- self.size = commands.getoutput(GITPREFIX + ' cat-file -s ' + self.id)
- return
-
-def blob_from_str(s):
- s = s.split();
- if len(s) != 4: return
- return Blob(mode=s[0],id=s[2],name=s[3])
-
-class Commit(models.Model):
- repo = models.ForeignKey(Repository)
- id = models.CharField("hash", max_length=40,blank=False,primary_key=True)
- rawdiff = models.TextField("ASCII contents of full commit diff")
- commit_date = models.DateField("Date of commit to repository")
- author_date = models.DateField("Date commit was writen/created")
- author = models.CharField("Name of commit author", max_length=96)
- author_email = models.CharField("Email address of commit author", \
- max_length=196)
- committer = models.CharField("Name of committer", max_length=96)
- committer_email = models.CharField("Email address of committer", \
- max_length=196)
- comment = models.TextField("Notes on the commit")
- parenthash = models.CharField("parent's hash", max_length=40)
- #TODO: parent = models.ForeignKey()
- treehash = models.CharField("tree object's hash", max_length=40)
- tree = models.ForeignKey(Tree)
- type='commit'
-
- class Admin:
- list_filter = ['repo']
- list_display = ['id', 'commit_date', 'author', 'repo']
- ordering = ['repo','commit_date','author_date','author']
- def __str__(self):
- return self.id
- def get_absolute_url(self):
- return "/code/%s/commit/%s/" % (self.repo.slug, self.hash)
- def get_admin_url(self):
- return "%s/code/commit/%s/" % (ADMIN_URL, self.id)
-
- def update(self):
- import commands,time
- if (not self.id) or (not self.repo): return
-
- GITPREFIX = self.repo.getGITPREFIX()
-
- self.id = self.id.strip()
- raw = commands.getoutput(GITPREFIX + ' cat-file -p ' + self.id)
-
- raw = raw.splitlines()
- if len(raw) < 3: return
- self.treehash = raw[0].split()[-1].strip()
- if not raw[1].startswith('parent'):
- raw.insert(1, 'parent ')
- self.parenthash = raw[1][6:].strip()
- if raw[2].startswith('author'):
- self.author = raw[2].split()[1]
- self.author_date = time.ctime(int(raw[2].split()[-2]))
- elif raw[3].startswith('author'):
- self.author = raw[3].split()[1]
- self.author_date = time.ctime(int(raw[3].split()[-2]))
- elif raw[4].startswith('author'):
- self.author = raw[4].split()[1]
- self.author_date = time.ctime(int(raw[4].split()[-2]))
- else: return
- self.committer = raw[3].split()[1]
- self.committer_date = time.ctime(int(raw[3].split()[-2]))
- self.rawdiff = commands.getoutput(GITPREFIX + ' diff ' \
- + self.parenthash + ' ' + self.id + ' | cat')
- if len(raw) > 4:
- for l in raw[4:]:
- self.comment += str(l) + '\n'
- else:
- self.comment = '(none)'
- return
-
-from django.contrib import admin
-
-admin.site.register(Repository)
-admin.site.register(Tree)
-admin.site.register(Blob)
-admin.site.register(Commit)
-
diff --git a/bn_django/git_browse/settings.py.example b/bn_django/git_browse/settings.py.example
deleted file mode 100644
index 87b957d..0000000
--- a/bn_django/git_browse/settings.py.example
+++ /dev/null
@@ -1,2 +0,0 @@
-# fill path to the git command
-GITCOMMAND = '/usr/local/bin/git'
diff --git a/bn_django/git_browse/templates/git_browse/base.html b/bn_django/git_browse/templates/git_browse/base.html
deleted file mode 100644
index 611d11d..0000000
--- a/bn_django/git_browse/templates/git_browse/base.html
+++ /dev/null
@@ -1,37 +0,0 @@
-{% extends "base.html" %}
-
-{% block stylesheets %}
-{{ block.super }}
-<link rel="STYLESHEET" type="text/css" href="/static/style/git_browse.css" />
-{% endblock %}
-
-{% block path %}
-{{ block.super }}
-<a href="/code">code</a>
-{% if object %}
- &raquo; <a href="/code/{{ object.slug }}/">{{ object.name }}</a>
- [<a href="/code/{{ object.slug }}/tree/">browse</a>,
- <a href="/code/{{ object.slug }}/log/">log</a>]
-{% endif %}
-{% endblock %}
-
-{% block title %}
-{% if object %}
-{{ object.name }}
-{% endif %}
-{% endblock %}
-
-{% block content %}
-{% if object %}
- {% block gitbrowse %}
- {% endblock %}
- <br />
- <span class="righty">
- <a href="/code/{{ object.slug }}/tree/">browse tree</a> - <a href="/code/{{ object.slug }}/log">full log</a>
- </span>
- <br />
-{% else %}
-<p>No such repository!</p>
-{% endif %}
-
-{% endblock %}
diff --git a/bn_django/git_browse/templates/git_browse/blob.html b/bn_django/git_browse/templates/git_browse/blob.html
deleted file mode 100644
index 853c034..0000000
--- a/bn_django/git_browse/templates/git_browse/blob.html
+++ /dev/null
@@ -1,18 +0,0 @@
-{% extends "git_browse/base.html" %}
-
-{% block gitbrowse %} {% if contents %}
- <h3>Blob sha1 hash</h3>
- {{ hash }}<br />
- <h3>Size</h3>
- {{ size|filesizeformat }}<br />
- <h3>Raw contents</h3>
- {% if pretty_contents %}
- <pre class="large">{{ pretty_diff }}</pre>
- {% else %}
- {% if contents %}
- <pre class="large">{{ contents|escape|wordwrap:80 }}</pre>
- {% else %}No contents{% endif %}
- {% endif %}
-{% else %}
- <h3>No such object: {{ hash }}</h3>
-{% endif %} {% endblock %}
diff --git a/bn_django/git_browse/templates/git_browse/commit.html b/bn_django/git_browse/templates/git_browse/commit.html
deleted file mode 100644
index b586eb8..0000000
--- a/bn_django/git_browse/templates/git_browse/commit.html
+++ /dev/null
@@ -1,36 +0,0 @@
-{% extends "git_browse/base.html" %}
-{% block stylesheets %}{{ block.super }}
-<link rel="STYLESHEET" type="text/css" href="/static/style/pygments-default.css" />
-{% endblock %}
-
-{% block gitbrowse %} {% if commit %}
- <h3>Commit sha1 hash</h3>
- <span class="hash">{{ commit.id }}</span><br />
- <h3>Parent sha1 hash</h3>
- {% if commit.parenthash %}
- <a href="/code/{{object.slug}}/commit/{{ commit.parenthash }}/">
- <span class="hash">{{ commit.parenthash }}</span></a>
- {% else %}No parent... root commit?{% endif %}
- <h3>Tree sha1 hash</h3>
- {% if commit.treehash %}
- <a href="/code/{{object.slug}}/tree/{{ commit.treehash }}/">
- <span class="hash">{{ commit.treehash }}</span></a>
- {% else %}No tree hash?{% endif %}
- <h3>Author</h3>
- {{ commit.author }}<br />
- <h3>Author Date</h3>
- {{ commit.author_date }}<br />
- <h3>Committer</h3>
- {{ commit.committer }}<br />
- <h3>Committer Date</h3>
- {{ commit.committer_date }}<br />
- {% if commit.pretty_diff %}
- <pre class="large">{{ commit.pretty_diff }}</pre>
- {% else %}
- {% if commit.rawdiff %}
- <pre class="large">{{ commit.rawdiff|escape|wordwrap:80 }}</pre>
- {% else %}No diff{% endif %}
- {% endif %}
-{% else %}
- <h3>No such object: {{ hash }}</h3>
-{% endif %} {% endblock %}
diff --git a/bn_django/git_browse/templates/git_browse/full_log.html b/bn_django/git_browse/templates/git_browse/full_log.html
deleted file mode 100644
index 913a3c4..0000000
--- a/bn_django/git_browse/templates/git_browse/full_log.html
+++ /dev/null
@@ -1,17 +0,0 @@
-{% extends "git_browse/base.html" %}
-
-{% block gitbrowse %}
-{% if log_objs %}
- <h3>Full Log</h3><br />
- {% for item in log_objs %}
- <hr>
- <b>Hash: </b>
- <a href="/code/{{object.slug}}/commit/{{ item.hash }}/">
- <span class="hash">{{ item.hash }}</span></a>
- <br /><b>Author: </b>{{ item.author }}
- <br /><b>Date: </b>{{ item.date }}
- <br /><b>Comment: </b>
- <pre class="large">{{ item.comment|escape|wordwrap:80 }}</pre>
- {% endfor %}
-{% endif %}
-{% endblock %}
diff --git a/bn_django/git_browse/templates/git_browse/heads_table b/bn_django/git_browse/templates/git_browse/heads_table
deleted file mode 100644
index 5840db0..0000000
--- a/bn_django/git_browse/templates/git_browse/heads_table
+++ /dev/null
@@ -1,23 +0,0 @@
-{% if heads %}
-<table class="gitbrowser">
-{% for h in heads.iteritems %}
-<tr>
- <td class="head">
- <a href="/code/{{object.slug}}/commit/{{ h.1 }}" class="subtle">
- {{ h.0 }}</a></td>
- <td class="links">
- <a href="/code/{{object.slug}}/commit/{{ h.1 }}">commit</a> |
- <a href="/code/{{object.slug}}/commit/{{ h.1 }}/zip"> zip </a></td>
- <td class="hash">
- {% if tags %}{% for t in tags.iteritems %}
- {% ifequal h.1 t.1 %}
- <a href="/code/{{object.slug}}/tag/{{ t.1 }}/" class="tag">
- [{{ t.0 }}]</a>
- {% endifequal %}{% endfor %}{% endif %}
- <a href="/code/{{object.slug}}/obj/{{ h.1 }}" class="subtle">
- {{ h.1 }}</a>
- </td></tr>
-{% endfor %}
-</table>
-{% else %}No heads!{% endif %}
-
diff --git a/bn_django/git_browse/templates/git_browse/obj.html b/bn_django/git_browse/templates/git_browse/obj.html
deleted file mode 100644
index 669091b..0000000
--- a/bn_django/git_browse/templates/git_browse/obj.html
+++ /dev/null
@@ -1,16 +0,0 @@
-{% extends "git_browse/base.html" %}
-
-{% block gitbrowse %}
- {% if contents %}
- <h3>Object sha1 hash</h3>
- {{ hash }}<br />
- <h3>Size</h3>
- {{ size|filesizeformat }}<br />
- <h3>Type</h3>
- "{{ type }}"
- <h3>Raw Description</h3>
- <pre class="large">{{ contents }}</pre>
- {% else %}
- <h3>No such object: {{ hash }}</h3>
- {% endif %}
-{% endblock %}
diff --git a/bn_django/git_browse/templates/git_browse/repository_info.html b/bn_django/git_browse/templates/git_browse/repository_info.html
deleted file mode 100644
index f529c84..0000000
--- a/bn_django/git_browse/templates/git_browse/repository_info.html
+++ /dev/null
@@ -1,14 +0,0 @@
-{% extends "git_browse/base.html" %}
-
-{% block gitbrowse %}
-{{ object.description }}
-<h3>Shortlog (<a href="/code/{{object.slug}}/log/">full log</a>) (<a href="#"><strike>last commit</strike></a>)</h3>
-{% include "git_browse/shortlog_table" %}
-<h3>Heads (<a href="/code/{{object.slug}}/tree/">browse</a>)</h3>
-{% include "git_browse/heads_table" %}
-<h3>Tags (<a href="/code/{{object.slug}}/tree/">browse</a>)</h3>
-{% include "git_browse/tags_table" %}
-<h3>Filelist (<a href="/code/{{object.slug}}/tree/">browse tree</a>)</h3>
-{% if filelist %} <pre class="large">{{ filelist }}</pre>
-{% else %}No files!{% endif %}
-{% endblock %}
diff --git a/bn_django/git_browse/templates/git_browse/repository_list.html b/bn_django/git_browse/templates/git_browse/repository_list.html
deleted file mode 100644
index e409c74..0000000
--- a/bn_django/git_browse/templates/git_browse/repository_list.html
+++ /dev/null
@@ -1,50 +0,0 @@
-{% extends "git_browse/base.html" %}
-{# {% load markup %} #}
-
-{% block path %}code{% endblock %}
-{% block title %}Code Repositories{% endblock %}
-
-{% block content %}
-<div class="notice">
-Until this is better developed I would recommend trying <a href="http://git.bnewbold.net/">gitweb</a>.
-</div>
-<div class="notice">
-If you aren't familiar with git these repositories won't make much sense and will be frustrating!
-</div>
-{% if object_list %}
-{% for item in object_list %}
- <div class="righty"><br />
- <a href="{{ item.slug }}/tree/">browse</a> -
- <a href="{{ item.slug }}/log/">changelog</a>
- </div>
- <h3><a href="{{ item.slug }}/">{{ item.name }}</a> (aka {{ item.slug }})</h3>
- {{ item.description }}
-{% endfor %}
-{% else %}
-<p>No repositories have been set up yet.</p>
-{% endif %}
-
-
-{% if is_paginated %}
-{% if has_previous %}
-<a href="./?page={{ previous }}">&laquo; previous</a> |
-{% endif %}
-{% if has_next %}
-<a href="./?page={{ next }}">next &raquo;</a>
-{% endif %}
-{% endif %}
-
-<!--
-{% if not user.is_anonymous %}
-<p>
- <a href="{{admin_url}}/photos/gallery/add/">Create a new gallery.</a>
-</p>
-{% else %}
-<p>
- <a href="/accounts/login/?next={{ request.path }}">
- Login</a> to create a new gallery.
-</p>
-{% endif %}
--->
-
-{% endblock %}
diff --git a/bn_django/git_browse/templates/git_browse/repository_raw_output.html b/bn_django/git_browse/templates/git_browse/repository_raw_output.html
deleted file mode 100644
index ee1c8e0..0000000
--- a/bn_django/git_browse/templates/git_browse/repository_raw_output.html
+++ /dev/null
@@ -1,8 +0,0 @@
-{% extends "git_browse/base.html" %}
-
-{% block content %}
- {% if raw_content %}
- <br />
- <pre> {{ raw_content }} </pre>
- {% endif %}
-{% endblock %}
diff --git a/bn_django/git_browse/templates/git_browse/shortlog_table b/bn_django/git_browse/templates/git_browse/shortlog_table
deleted file mode 100644
index 8a223ec..0000000
--- a/bn_django/git_browse/templates/git_browse/shortlog_table
+++ /dev/null
@@ -1,29 +0,0 @@
-{% if shortlog %}
-<table class="gitbrowser">
-{% for l in shortlog %}
-<tr>
- <td class="date">
- {{ l.date }}</td>
- <td class="author">
- {{ l.author }}</td>
- <td class="description">
- <a href="/code/{{object.slug}}/commit/{{ l.hash }}/" class="description">
- {{ l.description|truncatewords:10 }}</a></td>
- <td class="shorthash">
- {% if heads %}{% for h in heads.iteritems %}
- {% ifequal h.1 l.hash %}
- <a href="/code/{{object.slug}}/head/{{ h.1 }}/" class="head">
- [{{ h.0 }}]</a>
- {% endifequal %}
- {% endfor %}{% endif %}
- {% if tags %}{% for t in tags.iteritems %}
- {% ifequal l.hash t.1 %}
- <a href="/code/{{object.slug}}/tag/{{ t.1 }}/" class="tag">
- [{{ t.0 }}]</a>
- {% endifequal %}{% endfor %}{% endif %}
-
- <a href="/code/{{object.slug}}/commit/{{ l.hash }}" class="subtle">
- <span class="hash">{{ l.shorthash }}</span></a>...</td></tr>
-{% endfor %}
-</table>
-{% else %}No shortlog!{% endif %}
diff --git a/bn_django/git_browse/templates/git_browse/tags_table b/bn_django/git_browse/templates/git_browse/tags_table
deleted file mode 100644
index 7df504a..0000000
--- a/bn_django/git_browse/templates/git_browse/tags_table
+++ /dev/null
@@ -1,23 +0,0 @@
-{% if tags %}
-<table class="gitbrowser">
-{% for t in tags.iteritems %}
-<tr>
- <td class="tag">
- <a href="/code/{{object.slug}}/tag/{{ h.1 }}" class="subtle">
- {{ t.0 }}</a></td>
- <td class="links">
- <a href="/code/{{object.slug}}/tag/{{ t.1 }}">tag</a> |
- <a href="/code/{{object.slug}}/commit/{{ t.1 }}">commit</a> |
- <a href="/code/{{object.slug}}/commit/{{ t.1 }}/zip"> zip </a></td>
- <td class="hash">
- {% for h in heads.iteritems %}
- {% ifequal h.1 t.1 %}
- <a href="/code/{{object.slug}}/head/{{ h.1 }}/" class="head">
- [{{ h.0 }}]</a>
- {% endifequal %}
- {% endfor %}
- <a href="/code/{{object.slug}}/obj/{{ t.1 }}" class="subtle">
- <span class="hash">{{ t.1 }}</span></a></td></tr>
-{% endfor %}
-</table>
-{% else %}No tags!{% endif %}
diff --git a/bn_django/git_browse/templates/git_browse/tree.html b/bn_django/git_browse/templates/git_browse/tree.html
deleted file mode 100644
index b177af8..0000000
--- a/bn_django/git_browse/templates/git_browse/tree.html
+++ /dev/null
@@ -1,11 +0,0 @@
-{% extends "git_browse/base.html" %}
-
-{% block gitbrowse %}
-
- <h3>Tree sha1 hash:</h3>
- <span class="hash">{{ hash }}</span>
- <h3>Shortlog:</h3>
- {% include "git_browse/shortlog_table" %}
- <h3>Directory listing:</h3>
- {% include "git_browse/tree_table" %}
-{% endblock %}
diff --git a/bn_django/git_browse/templates/git_browse/tree_table b/bn_django/git_browse/templates/git_browse/tree_table
deleted file mode 100644
index ce10c10..0000000
--- a/bn_django/git_browse/templates/git_browse/tree_table
+++ /dev/null
@@ -1,32 +0,0 @@
-{% if all_objs %}
-<table class="gitbrowser">
- {% for o in all_objs %}
- <tr> <td class="objtype">
- {{o.type}}</td>
- <td class="filemode">
- {{ o.mode }} </td>
- <td class="filename">
- {% ifequal o.type 'blob' %}
- <a href='/code/{{ object.slug }}/blob/{{ o.id }}/' class="blob">
- {{o.name}}</a>
- </td><td type="links">
- <a href='/code/{{object.slug}}/tree/{{ o.id }}/'>log</a>
- </td>
- {% else %} {% ifequal o.type 'tree' %}
- <a href='/code/{{object.slug}}/tree/{{ o.id }}/' class="tree">
- {{o.name}}/</a>
- </td><td type="links">
- <a href='/code/{{object.slug}}/tree/{{ o.id }}/'>browse</a> |
- <a href='/code/{{object.slug}}/tree/{{ o.id }}/zip/'>zip</a>
- </td>
- {% else %}
- <a href='/code/{{object.slug}}/obj/{{ o.id }}/' class="blob">
- {{o.name}}</a>
- </td><td type="links">
- </td>
- {% endifequal %}{% endifequal %}
- </tr>
- {% endfor %}
-</table>
-{% else %}No contents!
-{% endif %}
diff --git a/bn_django/git_browse/urls.py b/bn_django/git_browse/urls.py
deleted file mode 100644
index b608027..0000000
--- a/bn_django/git_browse/urls.py
+++ /dev/null
@@ -1,48 +0,0 @@
-from django.conf.urls.defaults import *
-from django.conf import settings
-
-from models import *
-
-try:
- GITBROWSE_BASE = settings.GITBROWSE_BASE.strip('/')
-except AttributeError:
- GITBROWSE_BASE='/home'
-
-try:
- ADMIN_URL = settings.ADMIN_URL
-except AttributeError:
- ADMIN_URL='/admin'
-if ADMIN_URL[-1] == '/':
- ADMIN_URL=ADMIN_URL[:-1]
-
-info_dict = { 'extra_context': { 'admin_url': ADMIN_URL,
- } }
-
-urlpatterns = patterns('django.views.generic.list_detail',
- (r'^$', 'object_list',
- dict(info_dict, queryset=Repository.objects.all(),
- allow_empty= True)),
-# (r'^(?P<object_id>\d+)/$', 'object_detail',
-# dict(info_dict, queryset=Gallery.objects.all())),
-# (r'^detail/(?P<object_id>\d+)/$', 'object_detail',
-# dict(info_dict, queryset=Photo.objects.all())),
-)
-
-urlpatterns += patterns('bn_django.git_browse.views',
- (r'^(?P<repo>[\w\-\_]*)/$', 'repo_info',),
- (r'^(?P<repo>[\w\-\_]*)/branches/$', 'view_branches',),
- (r'^(?P<repo>[\w\-\_]*)/log/$', 'view_log',),
- (r'^(?P<repo>[\w\-\_]*)/obj/(?P<hash>[0-9a-z]{40})/$', 'view_obj',),
- (r'^(?P<repo>[\w\-\_]*)/commit/(?P<hash>[0-9a-z]{40})/$', 'view_commit',),
- #(r'^(?P<repo>[\w\-\_]*)/commit/$', 'view_commit',),
- (r'^(?P<repo>[\w\-\_]*)/commit/(?P<hash>[0-9a-z]{40})/zip/$', 'zip',),
- #TODO: head and tag views
- (r'^(?P<repo>[\w\-\_]*)/tag/(?P<hash>[\w\-\_]+)/$', 'view_commit',),
- (r'^(?P<repo>[\w\-\_]*)/tag/(?P<hash>[0-9a-z]{40})/zip/$', 'zip',),
- (r'^(?P<repo>[\w\-\_]*)/head/(?P<hash>[\w\-\_]+)/$', 'view_commit',),
- (r'^(?P<repo>[\w\-\_]*)/head/(?P<hash>[0-9a-z]{40})/zip/$', 'zip',),
- (r'^(?P<repo>[\w\-\_]*)/blob/(?P<hash>[0-9a-z]{40})/$', 'view_blob',),
- (r'^(?P<repo>[\w\-\_]*)/tree/$', 'view_tree',),
- (r'^(?P<repo>[\w\-\_]*)/tree/(?P<hash>[0-9a-z]{40})/$', 'view_tree',),
- (r'^(?P<repo>[\w\-\_]*)/tree/(?P<hash>[0-9a-z]{40})/zip/$', 'zip',),
-)
diff --git a/bn_django/git_browse/views.py b/bn_django/git_browse/views.py
deleted file mode 100644
index 23b0191..0000000
--- a/bn_django/git_browse/views.py
+++ /dev/null
@@ -1,167 +0,0 @@
-import settings
-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
-
-import os, commands
-
-from models import *
-
-try:
- GITCOMMAND = settings.GITCOMMAND
-except AttributeError:
- GITCOMMAND='git'
-
-
-# Create your views here.
-
-def repo_info(request, repo,branch=None):
- therepo = get_object_or_404(Repository, slug=repo)
- (GITPREFIX, heads, tags) = therepo.scan()
-
- branches = commands.getoutput(GITPREFIX + ' branch')
- filelist = commands.getoutput(GITPREFIX + ' ls-files')
- shortlog = therepo.shortlog()
-
- return render_to_response('git_browse/repository_info.html', \
- dict(object=therepo, \
- filelist=filelist, \
- tags=tags, \
- heads=heads, \
- shortlog=shortlog,))
-
-def view_tree(request, repo, hash=None,branch=None):
- therepo = get_object_or_404(Repository, slug=repo)
- (GITPREFIX, heads, tags) = therepo.scan()
-
- if(hash == None):
- head_ref = commands.getoutput('cd ' + therepo.path + '; cat HEAD')
- head_ref = head_ref.split()[1]
- hash = commands.getoutput('cd ' + therepo.path + '; cat ' + head_ref)
-
- tree_ls = commands.getoutput(GITPREFIX + ' ls-tree ' + hash)
- tree_objs = list()
- blob_objs = list()
- for line in tree_ls.splitlines():
- l = line.split()
- if len(l) < 4:
- continue
- if l[1] == 'tree':
- t = Tree(id=l[2])
- t.path = ' '.join(l[3:])
- #if self.path and self.path != '/':
- # t.path = self.path + '/' + t.path
- t.name = t.path
- t.type = 'tree'
- tree_objs.append(t)
- if l[1] == 'blob':
- i = Blob(id=l[2])
- i.path = ' '.join(l[3:])
- #if self.path and self.path != '/':
- # i.path = self.path + '/' + i.path
- i.name=i.path
- i.type = 'blob'
- blob_objs.append(i)
-
- return render_to_response('git_browse/tree.html',
- dict(object=therepo,
- blob_objs=blob_objs,
- tree_objs=tree_objs,
- hash=hash,
- all_objs=tree_objs+blob_objs,))
-
-def view_log(request, repo, hash=None):
- therepo = get_object_or_404(Repository, slug=repo)
- (GITPREFIX, heads, tags) = therepo.scan()
-
- logtxt = commands.getoutput(GITPREFIX + ' log | cat')
- log_items = logtxt.split('\ncommit ')
- if (log_items[0] == ''):
- log_items.pop(0)
- if (log_items[0].startswith('commit ')):
- log_items[0] = log_items[0][7:]
- log_objs = list()
- for li in log_items:
- logobj = dict()
- lines = li.splitlines()
- if len(lines) < 3: continue
- logobj['hash'] = lines[0]
- logobj['author'] = lines[1][8:]
- logobj['date'] = lines[2][8:]
- logobj['comment'] = ''
- for l in lines[4:]:
- if l.startswith(' '):
- logobj['comment'] += l[4:] + '\n'
- log_objs.append(logobj)
-
- return render_to_response('git_browse/full_log.html',
- dict(object=therepo,
- log_objs=log_objs,))
-
-def view_blob(request, repo, hash):
- therepo = get_object_or_404(Repository, slug=repo)
- (GITPREFIX, heads, tags) = therepo.scan()
- b = Blob(id=hash,repo=therepo)
- b.update()
- try:
- from pygments import highlight
- from pygments.lexers import guess_lexer
- from pygments.formatters import HtmlFormatter
- b.pretty_contents = highlight(b.contents, guess_lexer(b.contents), HtmlFormatter())
- except:
- b.pretty_contents = None
-
- return render_to_response('git_browse/blob.html',
- dict(object=therepo,
- heads=heads,
- tags=tags,
- hash=b.id,
- size=b.size,
- contents=b.contents,
- pretty_contents=b.pretty_contents))
-
-def view_commit(request, repo, hash):
- therepo = get_object_or_404(Repository, slug=repo)
- (GITPREFIX, heads, tags) = therepo.scan()
- c = Commit(id=hash,repo=therepo)
- c.update()
-
- try:
- from pygments import highlight
- from pygments.lexers import DiffLexer
- from pygments.formatters import HtmlFormatter
- c.pretty_diff = highlight(c.rawdiff, DiffLexer(), HtmlFormatter())
- except: pass
-
- return render_to_response('git_browse/commit.html',
- dict(object=therepo, heads=heads, tags=tags,
- commit=c))
-
-def view_obj(request, repo, hash, branch=None):
- therepo = get_object_or_404(Repository, slug=repo)
- (GITPREFIX, heads, tags) = therepo.scan()
-
- obj_type = commands.getoutput(GITPREFIX + ' cat-file -t ' + hash)
- obj_contents = commands.getoutput(GITPREFIX + ' cat-file -p ' + hash)
- obj_size = commands.getoutput(GITPREFIX + ' cat-file -s ' + hash)
-
- return render_to_response('git_browse/obj.html',
- dict(object=therepo,
- hash=hash,
- type=obj_type,
- size=float(obj_size),
- contents=obj_contents))
-
-def zip(request, repo, hash):
- therepo = get_object_or_404(Repository, slug=repo)
- (GITPREFIX, heads, tags) = therepo.scan()
- t = Tree(id=hash,repo=therepo)
- t.update()
-
- hr = HttpResponse(mimetype="application/zip")
- hr['Content-Disposition'] = 'filename=%s.zip' % t.id
- archive = commands.getoutput(GITPREFIX + \
- ' archive --format=zip ' + hash + ' | cat')
- hr.write(archive)
- return hr
diff --git a/bn_django/git_wiki/__init__.py b/bn_django/git_wiki/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/bn_django/git_wiki/__init__.py
+++ /dev/null
diff --git a/bn_django/git_wiki/admin.py b/bn_django/git_wiki/admin.py
deleted file mode 100644
index 76839f7..0000000
--- a/bn_django/git_wiki/admin.py
+++ /dev/null
@@ -1,7 +0,0 @@
-from bn_django.git_wiki.models import Tree, Item, Commit
-from django.contrib import admin
-
-admin.site.register(Tree)
-admin.site.register(Item)
-admin.site.register(Commit)
-
diff --git a/bn_django/git_wiki/latex_directive.py b/bn_django/git_wiki/latex_directive.py
deleted file mode 100644
index 823cc6a..0000000
--- a/bn_django/git_wiki/latex_directive.py
+++ /dev/null
@@ -1,129 +0,0 @@
-"""
-Implement latex directive.
-
-"""
-import os
-import shutil
-import sha
-import tempfile
-import subprocess
-
-from docutils import nodes
-from docutils.parsers.rst.directives import register_directive, flag
-from docutils.parsers.rst.roles import register_canonical_role
-
-from settings import *
-
-dorawtexstuff = False
-
-def latex_math(tex,centerize=False):
- """ Process `tex` and produce image nodes. """
- if not dorawtexstuff:
- image_names = latex_snippet_to_png(tex)
- the_nodes = []
- alt = tex
- styleclasses = ("equation",)
- if tex[:2] =='$$':
- centerize=True
- if centerize:
- styleclasses += ("centered-equ",)
- for pageno, name in enumerate(image_names):
- the_nodes.append(nodes.image(uri=name, alt=alt,
- classes=styleclasses,))
- alt = ''
- return the_nodes
- else:
- return [nodes.raw(tex,tex,format='latex')]
-
-def latex_directive(name, arguments, options, content, lineno,
- content_offset, block_text, state, state_machine):
- """ Latex directive. """
- tex = '\n'.join(content)
- return latex_math(tex)
-latex_directive.content = True
-
-
-def latex_role(role, rawtext, text, lineno, inliner,
- options={}, content=[]):
- """ Latex role. """
- i = rawtext.find('`')
- tex = rawtext[i+1:-1]
- return latex_math(tex,), []
-
-def register():
- register_directive('latex', latex_directive)
- register_canonical_role('latex', latex_role)
- register_canonical_role('m', latex_role)
-
-def call_command_in_dir(app, args, targetdir):
-
- cwd = os.getcwd()
- try:
- os.chdir(targetdir)
- #print args
- #print ' '.join(args)
- p = subprocess.Popen(app + ' ' + ' '.join(args), shell=True)
- sts = os.waitpid(p.pid, 0)
-
- # FIXME -- should we raise an exception of status is non-zero?
-
- finally:
- # Restore working directory
- os.chdir(cwd)
-
-latex_template = r'''
-\documentclass[12pt]{article}
-\pagestyle{empty}
-%(prologue)s
-\begin{document}
-%(raw)s
-\end{document}
-'''
-max_pages = 10
-MAX_RUN_TIME = 5 # seconds
-latex_name_template = 'latex2png_%s'
-latex = "latex"
-dvipng = "dvipng"
-latex_args = ("--interaction=nonstopmode", "%s.tex")
-dvipng_args = ("-q", "-bgTransparent", "-Ttight", "--noghostscript", "-l%s" % max_pages, "%s.dvi")
-
-def latex_snippet_to_png(inputtex, prologue=''):
- """ Convert a latex snippet into a png. """
- import shutil
-
- tex = latex_template % { 'raw': inputtex, 'prologue': prologue }
- namebase = latex_name_template % sha.new(tex).hexdigest()
- dst = namebase + '%d.png'
-
- tmpdir = tempfile.mkdtemp()
- try:
- data = open("%s/%s.tex" % (tmpdir, namebase), "w")
- data.write(tex)
- data.close()
- args = list(latex_args)
- args[-1] = args[-1] % namebase
- res = call_command_in_dir(latex, args, tmpdir)
- if not res is None:
- # FIXME need to return some sort of error
- return []
- args = list(dvipng_args)
- args[-1] = args[-1] % namebase
- res = call_command_in_dir(dvipng, args, tmpdir)
- if not res is None:
- # FIXME need to return some sort of error
- return []
-
- page = 1
- pagenames = []
- while os.access("%s/%s%d.png" % (tmpdir, namebase, page), os.R_OK):
- pagename = dst % page
- shutil.copyfile("%s/%s%d.png" % (tmpdir, namebase, page),
- EQU_FOLDER + pagename)
- page += 1
- pagenames.append(EQU_PREFIX + pagename)
- finally:
- # FIXME do some tidy up here
- pass
- shutil.rmtree(tmpdir)
- return pagenames
-
diff --git a/bn_django/git_wiki/models.py b/bn_django/git_wiki/models.py
deleted file mode 100644
index 87bfa55..0000000
--- a/bn_django/git_wiki/models.py
+++ /dev/null
@@ -1,269 +0,0 @@
-from django.db import models
-from settings import *
-from django.conf import settings
-
-try:
- ADMIN_URL = settings.ADMIN_URL
-except AttributeError:
- ADMIN_URL='/admin'
-if ADMIN_URL[-1] == '/':
- ADMIN_URL=ADMIN_URL[:-1]
-
-class Tree(models.Model):
- mode = models.CharField("file mode/permissions", blank=False,max_length=4)
- path = models.CharField("relative path from repo base", max_length=512)
- id = models.CharField("hash", max_length=40,blank=False,primary_key=True)
- name = models.CharField("name of dir", max_length=128,blank=False)
- type = 'tree'
- def slug(self):
- #TODO: secure this
- return ''.join(self.path.replace('"','').replace("'","").strip().lower().split())
-
- class Admin:
- list_display = ['name', 'id', 'mode']
- ordering = ['path','name']
-
- def __str__(self):
- return self.name
- def get_absolute_url(self):
- return "/k/%s/" % self.slug()
- def get_admin_url(self):
- return "%s/k/%s/" % (ADMIN_URL, self.id)
-
- def update(self):
- import commands
- if (not self.id): return
-
- self.id = self.id.strip()
- tree_ls = commands.getoutput(GITPREFIX + ' ls-tree --full-name ' \
- + self.id)
- tree_objs = list()
- blob_objs = list()
- for line in tree_ls.splitlines():
- l = line.split()
- if len(l) < 4:
- continue
- if l[1] == 'tree':
- t = Tree(id=l[2])
- t.path = ' '.join(l[3:])
- if self.path and self.path != '/':
- t.path = self.path + '/' + t.path
- t.name = t.path
- tree_objs.append(t)
- if l[1] == 'blob':
- i = Item(id=l[2])
- i.path = ' '.join(l[3:])
- if self.path and self.path != '/':
- i.path = self.path + '/' + i.path
- i.name=i.path
- blob_objs.append(i)
- self.tree_objs = tree_objs
- self.blob_objs = blob_objs
- self.all_objs = tree_objs + blob_objs
- self.save()
-
-
-class Item(models.Model):
- mode = models.CharField("file mode/permissions", blank=False,max_length=4)
- path = models.CharField("relative path from repo base", max_length=512)
- id = models.CharField("hash", max_length=40,blank=False,primary_key=True)
- name = models.CharField("name of dir", max_length=128,blank=False)
- size = models.IntegerField("filesize in byte", max_length=128,blank=False)
- contents = models.TextField("ASCII contents of the file")
- type='blob'
- def slug(self):
- #TODO: secure this
- return ''.join(self.name.replace('"','').replace("'","").strip().lower().split())
-
- class Admin:
- list_display = ['name', 'id', 'size']
- search_fields = ['contents']
- ordering = ['name']
- def __str__(self):
- return self.name
- def get_absolute_url(self):
- return "/k/%s/" % self.slug()
- def get_admin_url(self):
- return "%s/k/%s/" % (ADMIN_URL, self.id)
-
- def isfig(self):
- if self.name.find('.') != -1:
- return True
- else:
- return False
-
- def update(self):
- import commands
- if (not self.id): return
-
- self.id = self.id.strip()
- self.contents = commands.getoutput(GITPREFIX + ' cat-file -p ' \
- + self.id)
- self.size = commands.getoutput(GITPREFIX + ' cat-file -s ' + self.id)
- if not self.isfig():
- self.save()
-
- def getfile(self):
- import commands
- if (not self.id): return
- return open(str(GITWIKI_DIR + '/objects/' + self.id[:2] + '/' + self.id[2:]),'r')
-
-class Commit(models.Model):
- id = models.CharField("hash", max_length=40,blank=False,primary_key=True)
- rawdiff = models.TextField("ASCII contents of full commit diff")
- commit_date = models.DateField("Date of commit to repository")
- author_date = models.DateField("Date commit was writen/created")
- author = models.CharField("Name of commit author", max_length=96)
- author_email = models.CharField("Email address of commit author",\
- max_length=196)
- committer = models.CharField("Name of committer", max_length=96)
- committer_email = models.CharField("Email address of committer", \
- max_length=196)
- comment = models.TextField("Notes on the commit")
- parenthash = models.CharField("parent's hash", max_length=40)
- #TODO: parent = models.ForeignKey()
- treehash = models.CharField("tree object's hash", max_length=40)
- tree = models.ForeignKey(Tree)
- type='commit'
-
- class Admin:
- ordering = ['commit_date','author_date','author']
- list_display = ['id', 'commit_date', 'author']
- def __str__(self):
- return self.id
- def get_absolute_url(self):
- return "/k/commit/%s/" % (self.id)
- def get_admin_url(self):
- return "%s/k/commit/%s/" % (ADMIN_URL, self.id)
-
- def update(self):
- import commands,time
- if (not self.id): return
-
- self.id = self.id.strip()
- raw = commands.getoutput(GITPREFIX + ' cat-file -p ' + self.id)
- self.rawdiff = commands.getoutput(GITPREFIX + ' diff ' + self.id \
- +' | cat')
-
- raw = raw.splitlines()
- if len(raw) < 3: return
- self.treehash = raw[0].split()[-1].strip()
- if raw[1].startswith('parent'):
- self.parenthash = raw[1][6:].strip()
- raw.pop(1)
- # Sometimes there are multiple parents; this ignores all but the
- # first
- while raw[1].startswith('parent'):
- raw.pop(1)
- self.author = raw[1].split()[1]
- self.author_date = time.ctime(int(raw[1].split()[-2]))
- self.committer = raw[2].split()[1]
- self.committer_date = time.ctime(int(raw[2].split()[-2]))
- self.rawdiff = commands.getoutput(GITPREFIX + ' diff ' \
- + self.parenthash + ' ' + self.id + ' | cat')
- if len(raw) > 3:
- for l in raw[3:]:
- self.comment += str(l) + '\n'
- else:
- self.comment = '(none)'
-
-def fromslug(reqslug):
- import commands
-
- if reqslug == '' or reqslug == '/':
- f = open(GITWIKI_DIR + '/HEAD','r')
- head = f.readline().strip().split()[1]
- f.close()
- f = open(GITWIKI_DIR + '/'+head,'r')
- hash = f.readline().strip()
- f.close()
- ret = Tree(id=hash)
- ret.path='/'
- ret.name='/'
- ret.reqslug = '/'
- return ret
-
- reqslug = ''.join(reqslug.replace('"','').replace("'","").strip().lower().split())
- if reqslug[-1] == '/':
- reqslug=reqslug[:-1]
- itemtxt = commands.getoutput(GITPREFIX \
- + ' ls-tree -t -r HEAD')
- if not itemtxt:
- return None
- hash, path, type = None, None, None
- for l in itemtxt.splitlines():
- words = l.split()
- if len(words) < 4:
- continue
- ftype = words[1]
- fhash = words[2]
- fpath = ' '.join(words[3:])
- if fpath[-1] == '/':
- fpath=fpath[:-1]
- if ''.join(fpath.replace('"','').replace("'","").strip().lower().split()) == reqslug:
- hash = fhash
- path = fpath
- type = ftype
- break;
- if (not hash) or (not type) or (not path):
- return None
- if type == 'blob':
- ret = Item(id=hash)
- elif type == 'tree':
- ret = Tree(id=hash)
- ret.path=path
- ret.name=path
- ret.reqslug = reqslug
- return ret
-
-def reposcan():
- import os
- heads = dict()
- 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_DIR + '/refs/tags/'):
- f = open(GITWIKI_DIR + '/refs/tags/' + t,'r')
- tags[t.strip()] = f.readline().strip()
- f.close()
- return (heads, tags)
-
-def newest_items():
- num = Item.objects.count()
- min = num-6
- if min < 0:
- min = 0
- return Item.objects.all()[min:num]
-
-def shortlog(hash=None,tree=None):
- import commands
-
- if tree:
- hash=tree.id
- logtxt = commands.getoutput(GITPREFIX \
- + ' log --relative-date --max-count=6 | cat')
- log_items = logtxt.split('\ncommit ')
- if (log_items[0] == ''):
- log_items.pop(0)
- if (log_items[0].startswith('commit ')):
- log_items[0] = log_items[0][7:]
- shortlog = list()
- for li in log_items:
- logobj = dict()
- lines = li.splitlines()
- if len(lines) < 3: continue
- logobj['hash'] = lines[0].strip()
- logobj['shorthash'] = lines[0].strip()[:5]
- logobj['author'] = lines[1][8:]
- logobj['date'] = lines[2][8:]
- if len(lines) > 4:
- logobj['description'] = lines[4][4:]
- else:
- logobj['description'] = '(none)'
- # here we truncate commit comments for shortlogs
- logobj['shortdescription'] = logobj['description'][:128]
- shortlog.append(logobj)
- return shortlog
-
diff --git a/bn_django/git_wiki/settings.py.example b/bn_django/git_wiki/settings.py.example
deleted file mode 100644
index 8257277..0000000
--- a/bn_django/git_wiki/settings.py.example
+++ /dev/null
@@ -1,17 +0,0 @@
-
-# full path to directory holding the wiki repository (or sys links to
-# the repositories)
-GITWIKI_BASE = '/home/bnewbold/knowledge/'
-
-EQU_FOLDER = '/home/bnewbold/bn-project/static/latex2png/'
-EQU_PREFIX = '/static/latex2png/'
-
-# leave this blank (NO WHITE SPACE) unless you're using a bare repo
-GITWIKI_NAME = ''
-
-# fill path to the git command
-GITCOMMAND = '/usr/local/bin/git'
-
-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/base.html b/bn_django/git_wiki/templates/git_wiki/base.html
deleted file mode 100644
index 532fde3..0000000
--- a/bn_django/git_wiki/templates/git_wiki/base.html
+++ /dev/null
@@ -1,22 +0,0 @@
-{% extends "base.html" %}
-
-{% block stylesheets %}
-{{ block.super }}
-<link rel="STYLESHEET" type="text/css" href="/static/style/git_wiki.css" />
-{% endblock %}
-
-{% block path %}
-{{ block.super }}
-<a href="/knowledge">knowledge</a>
-{% endblock %}
-
-{% block title %}
-{% if item %}
-{{ item.title }}
-{% endif %}
-{% endblock %}
-
-{% block content %}
- {% block gitwiki %}
- {% endblock %}
-{% endblock %}
diff --git a/bn_django/git_wiki/templates/git_wiki/commit.html b/bn_django/git_wiki/templates/git_wiki/commit.html
deleted file mode 100644
index e99d553..0000000
--- a/bn_django/git_wiki/templates/git_wiki/commit.html
+++ /dev/null
@@ -1,39 +0,0 @@
-{% extends "git_wiki/base.html" %}
-
-{% block stylesheets %}{{ block.super }}
-<link rel="STYLESHEET" type="text/css" href="/static/style/pygments-default.css" />
-{% endblock %}
-
-{% block title %}Commit: {{ commit.committer_date}}
-{% endblock %}
-{% block gitwiki %} {% if commit %}
- <b>Commit sha1 hash: </b>
- <span class="hash">{{ commit.id }}</span><br />
- <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 %}
- <br />
- <b>Tree sha1 hash: </b>
- {% if commit.treehash %}
- <span class="hash">{{ commit.treehash }}</span>
- {% else %}No tree hash?{% endif %}
- <br /><b>Author: </b>
- {{ commit.author }}<br />
- <b>Author Date: </b>
- {{ commit.author_date }}<br />
- <b>Committer: </b>
- {{ commit.committer }}<br />
- <b>Committer Date: </b>
- {{ commit.committer_date }}<br />
- {% if commit.pretty_diff %}
- <pre class="large">{{ commit.pretty_diff|safe}}</pre>
- {% else %}
- {% if commit.rawdiff %}
- <pre class="large">{{ commit.rawdiff }}</pre>
- {% else %}No difference?{% endif %}
- {% endif %}
-{% else %}
- <h3>No such object: {{ hash }}</h3>
-{% endif %} {% endblock %}
diff --git a/bn_django/git_wiki/templates/git_wiki/frontpage.html b/bn_django/git_wiki/templates/git_wiki/frontpage.html
deleted file mode 100644
index 0c8d245..0000000
--- a/bn_django/git_wiki/templates/git_wiki/frontpage.html
+++ /dev/null
@@ -1,35 +0,0 @@
-{% extends "git_wiki/base.html" %}
-
-{% block title %}Knowledge Repository{% endblock %}
-
-{% block right_stuff %}
-<br />
-Get some knowledge: <br />
- &nbsp; - <a href="http://wikipedia.org"> wikipedia</a><br />
- &nbsp; - <a href="http://archive.org"> internet archive</a><br />
- &nbsp; - <a href="http://mathworld.com"> mathworld</a>
-{% endblock %}
-
-{% block content %}
-<div class="notice">
-<center><b>This site is under active development!</b></center>
-<p />There are undoubtedly bugs, errors, aesthetic travesties, ommissions, etc.
-If you're curious you can track my work in the <a href="/code">code</a> section.
-</div>
-
-<div class="right_stuff">
-For more recent content see the <a href="/timeline/">timeline</a>
-</div>
-<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" %}
-<h3>Latest comments</h3>
-{% if latest_comments %}
-{% include "newcomments_table" %}
-{% else %}
-None yet!
-{% endif %}
-
-{% endblock %}
diff --git a/bn_django/git_wiki/templates/git_wiki/item.html b/bn_django/git_wiki/templates/git_wiki/item.html
deleted file mode 100644
index cf49753..0000000
--- a/bn_django/git_wiki/templates/git_wiki/item.html
+++ /dev/null
@@ -1,55 +0,0 @@
-{% extends "git_wiki/base.html" %}
-
-{% block stylesheets %}
-{{ block.super }}
-<link rel="STYLESHEET" type="text/css" href="/static/style/docutils.css" />
-{% endblock %}
-
-{% block right_stuff %}{{block.super}}
-<b>Item name:</b>
- <span class="hash">{{ item.name }}</span><br />
-<b>Item hash:</b>
- <span class="hash">{{ item.id }}</span><br />
-<br /><b>
-View as <a href="/k/{{ item.slug }}/pdf/">pdf</a>,<br />
-or as <a href="/k/{{ item.slug }}/latex/">LaTeX</a>,<br />
-or see the <a href="/k/{{ item.slug }}/raw/">raw source</a>.<br />
-<br />
-Browse the <a href="/k/{{ item.slug }}/log">changelog</a>
-</b>
-{% endblock %}
-
-{% block path %}{{ block.super }} &raquo; <a href="/k/{{ item.slug }}/">
- {{ item.path }}</a>{% endblock %}
-
-{% comment %} Needed the extra .title css info... {% endcomment %}
-{% block title %}<h1 class="title"> {% if doc.title %}{{ doc.title }}{% else %}[Unititled Document]{% endif %}</h1>{% endblock %}
-
-{% block subtitle %}{% if doc.subtitle %}{{doc.subtitle}}{% endif %}{% endblock %}
-
-{% block gitwiki %}
-&nbsp;
-{{ doc.fragment|safe }}
- <br />
-{% endblock %}
-
-{% comment %}
-BROKEN, comments need char type primary keys
-{% 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 true %}
-{% else %}
-{% free_comment_form for git_wiki.item item.id with is_public true %}
-{% endif %}
-<br />
-{% get_comment_list for git_wiki.item item.id as comments %}
-{% get_free_comment_list for git_wiki.item item.id as free_comments %}
-{% include "comment_list" %}
-</div>
-{% endblock %}
-{% endcomment %}
diff --git a/bn_django/git_wiki/templates/git_wiki/newitems_table b/bn_django/git_wiki/templates/git_wiki/newitems_table
deleted file mode 100644
index d8682be..0000000
--- a/bn_django/git_wiki/templates/git_wiki/newitems_table
+++ /dev/null
@@ -1,36 +0,0 @@
-{% if newitems %}
-<table class="listing">
- {% for i in newitems reversed %}
- <tr> <td class="filename">
- {% ifequal i.type 'blob' %}
- {% if i.isfig %}
- <a href='/k/{{ i.slug }}' class="item">
- {{i.path}}</a>
- </td><td class="links">
- <a href='/k/{{ i.slug }}'>download</a>
- {% else %}
- <a href='/k/{{ i.slug }}' class="item">
- {{i.path}}</a>
- </td><td class="links">
- <a href='/k/{{ i.slug }}/pdf/'>pdf</a>&nbsp;
- <a href='/k/{{ i.slug }}/latex/'>latex</a>&nbsp;
- <a href='/k/{{ i.slug }}/raw/'>raw</a>
- {% endif %}
- </td>
- {% else %} {% ifequal i.type 'tree' %}
- <a href='/k/{{ i.slug }}/' class="tree">
- {{i.path}}/</a>
- </td><td class="links">
- <a href='/k/{{ i.slug }}/'>browse</a>
- </td>
- {% else %}
- <a href='/k/{{ i.slug }}/' class="item">
- {{i.name}}</a>
- </td><td class="links">
- </td>
- {% endifequal %}{% endifequal %}
- </tr>
- {% endfor %}
-</table>
-{% else %}No new items!
-{% endif %}
diff --git a/bn_django/git_wiki/templates/git_wiki/shortlog_table b/bn_django/git_wiki/templates/git_wiki/shortlog_table
deleted file mode 100644
index 95aac57..0000000
--- a/bn_django/git_wiki/templates/git_wiki/shortlog_table
+++ /dev/null
@@ -1,27 +0,0 @@
-{% if shortlog %}
-<table class="gitbrowser">
-{% for l in shortlog %}
-<tr>
- <td class="date">
- {{ l.date }}</td>
- <td class="author">
- {{ l.author|striptags }}</td>
- <td class="description">
- <a href="/k/commit/{{ l.hash }}/" class="description">
- {{ l.description|escape|truncatewords:10 }}</a></td>
- <td class="shorthash">
- {% if heads %}{% for h in heads.iteritems %}
- {% ifequal h.1 l.hash %}
- <span class="head">[{{ h.0 }}]</span>
- {% endifequal %}
- {% endfor %}{% endif %}
- {% if tags %}{% for t in tags.iteritems %}
- {% ifequal l.hash t.1 %}
- <span class="tag">[{{ t.0 }}]</span>
- {% endifequal %}{% endfor %}{% endif %}
-
- <a href="/k/commit/{{ l.hash }}" class="subtle">
- <span class="hash">{{ l.shorthash }}</span></a>...</td></tr>
-{% endfor %}
-</table>
-{% else %}No shortlog!{% endif %}
diff --git a/bn_django/git_wiki/templates/git_wiki/tree.html b/bn_django/git_wiki/templates/git_wiki/tree.html
deleted file mode 100644
index 08f6e35..0000000
--- a/bn_django/git_wiki/templates/git_wiki/tree.html
+++ /dev/null
@@ -1,15 +0,0 @@
-{% extends "git_wiki/base.html" %}
-
-{% block path %}{{ block.super }} &raquo; <a href="/k/{{ tree.path }}/">
- {{ tree.path }}</a>{% endblock %}
-
-{% block title %}Knowledge Category: {{ tree.path }}{% endblock %}
-
-{% block gitwiki %}
- <h3>Directory listing:</h3>
- {% include "git_wiki/tree_table" %}
- <h3>Tree sha1 hash:</h3>
- <span class="hash">{{ tree.id }}</span>
- <h3>Shortlog:</h3>
- {% include "git_wiki/shortlog_table" %}
-{% endblock %}
diff --git a/bn_django/git_wiki/templates/git_wiki/tree_table b/bn_django/git_wiki/templates/git_wiki/tree_table
deleted file mode 100644
index 36bc3a6..0000000
--- a/bn_django/git_wiki/templates/git_wiki/tree_table
+++ /dev/null
@@ -1,38 +0,0 @@
-{% if tree.all_objs %}
-<table class="gitbrowser">
- {% for o in tree.all_objs %}
- <tr> <td class="objtype">
- {{o.type}}</td>
- <td class="filename">
- {% ifequal o.type 'blob' %}
- {% if o.isfig %}
- <a href='/k/{{ o.slug }}' class="item">
- {{o.path}}</a>
- </td><td class="links">
- <a href='/k/{{ o.slug }}/download/'>download</a>
- {% else %}
- <a href='/k/{{ o.slug }}/' class="item">
- {{o.path}}</a>
- </td><td class="links">
- <a href='/k/{{ o.slug }}/pdf/'>pdf</a>&nbsp;
- <a href='/k/{{ o.slug }}/latex/'>latex</a>&nbsp;
- <a href='/k/{{ o.slug }}/raw/'>raw</a>
- {% endif %}
- </td>
- {% else %} {% ifequal o.type 'tree' %}
- <a href='/k/{{ o.slug }}/' class="tree">
- {{o.path}}/</a>
- </td><td class="links">
- <a href='/k/{{ o.slug }}/'>browse</a>
- </td>
- {% else %}
- <a href='/k/{{ o.slug }}' class="item">
- {{o.name}}</a>
- </td><td class="links">
- </td>
- {% endifequal %}{% endifequal %}
- </tr>
- {% endfor %}
-</table>
-{% else %}No contents!
-{% endif %}
diff --git a/bn_django/git_wiki/urls.py b/bn_django/git_wiki/urls.py
deleted file mode 100644
index 22f36a3..0000000
--- a/bn_django/git_wiki/urls.py
+++ /dev/null
@@ -1,35 +0,0 @@
-from django.conf.urls.defaults import *
-from django.conf import settings
-
-from models import *
-
-try:
- ADMIN_URL = settings.ADMIN_URL
-except AttributeError:
- ADMIN_URL='/admin'
-if ADMIN_URL[-1] == '/':
- ADMIN_URL=ADMIN_URL[:-1]
-
-info_dict = { 'extra_context': { 'admin_url': ADMIN_URL,
- } }
-
-urlpatterns = patterns('bn_django.git_wiki.views',
- (r'^(?P<hash>[0-9a-z]{40})/$', 'olditem',),
- (r'^commit/(?P<hash>[0-9a-z]{40})/$', 'view_commit',),
- (r'^(?P<reqslug>[\w\-\_\/]*)/log/$', 'tree',),
- (r'^(?P<reqslug>[\w\-\_\/]*)/edit/$', 'tree',),
- (r'^(?P<reqslug>[\w\-\_\/]*)/pdf/$', 'pdfitem',),
- (r'^(?P<reqslug>[\w\-\_\/]*)/raw/$', 'rawitem',),
- (r'^(?P<reqslug>[\w\-\_\/]*)/latex/$', 'latexitem',),
- (r'^(?P<reqslug>[\w\-\_\/]*\.png/?)$', 'figure',),
- (r'^(?P<reqslug>[\w\-\_\/]*\.gif/?)$', 'figure',),
- (r'^(?P<reqslug>[\w\-\_\/]*\.jpg/?)$', 'figure',),
- (r'^(?P<reqslug>[\w\-\_\/]*\.jpeg/?)$', 'figure',),
- (r'^(?P<reqslug>[\w\-\_\/]*\.svg/?)$', 'figure',),
- (r'^(?P<reqslug>[\w\-\_\/]*\.png)/download/$', 'figure',{'download':True}),
- (r'^(?P<reqslug>[\w\-\_\/]*\.gif)/download/$', 'figure',{'download':True}),
- (r'^(?P<reqslug>[\w\-\_\/]*\.jpg)/download/$', 'figure',{'download':True}),
- (r'^(?P<reqslug>[\w\-\_\/]*\.jpeg)/download/$','figure',{'download':True}),
- (r'^(?P<reqslug>[\w\-\_\/]*\.svg)/download/$', 'figure',{'download':True}),
- (r'^(?P<reqslug>[\w\-\_\/]*)$', 'tree',),
-)
diff --git a/bn_django/git_wiki/views.py b/bn_django/git_wiki/views.py
deleted file mode 100644
index f16ea84..0000000
--- a/bn_django/git_wiki/views.py
+++ /dev/null
@@ -1,234 +0,0 @@
-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, HttpResponseServerError
-
-import os, commands
-
-from models import *
-from settings import *
-from django.contrib.comments.models import Comment
-
-# 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]
- return render_to_response('git_wiki/frontpage.html', \
- dict(shortlog=shortlog(), tree=t,
- latest_comments=lc,
- newitems=newest_items()))
-
-def tree(request, reqslug, tree=None):
- if not tree:
- t = fromslug(reqslug)
- if not t:
- raise Http404
- if t.type == 'blob':
- return item(request, reqslug, blob=t)
- else:
- t = tree
-
- t.update()
- (heads,tags) = reposcan()
- return render_to_response('git_wiki/tree.html',
- dict(shortlog=shortlog(tree=t), tree=t,
- heads=heads,tags=tags))
-
-def item(request, reqslug, blob=None):
- if not blob:
- i = fromslug(reqslug)
- if not i:
- raise Http404
- if i.type == 'tree':
- return tree(request, reqslug)
- else:
- i = blob
- i.update()
-
- try:
- from docutils.core import publish_parts,Publisher
- import latex_directive
- latex_directive.dorawtexstuff = False
- latex_directive.register()
- 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,user=request.user))
-
-def latexitem(request, reqslug, blob=None):
- if not blob:
- i = fromslug(reqslug)
- if not i:
- raise Http404
- if i.type == 'tree':
- return tree(request, reqslug)
- else:
- i = blob
- i.update()
-
- try:
- from docutils.core import publish_parts,Publisher
- import latex_directive
- latex_directive.dorawtexstuff = True
- latex_directive.register()
- except ImportError:
- if settings.DEBUG:
- raise HttpResponseServerError(request)
- else:
- docutils_settings = getattr(settings, "GITWIKI_REST_SETTINGS",
- {'format':'latex'})
- parts = publish_parts(source=i.contents, writer_name="latex", settings_overrides=docutils_settings)
- hr = HttpResponse(mimetype="text/plain")
- hr['Content-Disposition'] = 'filename=%s.tex' % reqslug
- hr.write(parts['whole'].replace('{\$}','$'))
- #hr.write(parts['whole'])
- return hr
-
-def pdfitem(request, reqslug, blob=None):
- if not blob:
- i = fromslug(reqslug)
- if not i:
- raise Http404
- if i.type == 'tree':
- return tree(request, reqslug)
- else:
- i = blob
- i.update()
-
- try:
- from docutils.core import publish_parts,Publisher
- import latex_directive
- latex_directive.dorawtexstuff = True
- latex_directive.register()
- import tempfile,re,os,shutil
- except ImportError:
- if settings.DEBUG:
- raise HttpResponseServerError(request)
- else:
- docutils_settings = getattr(settings, "GITWIKI_REST_SETTINGS",
- {'format':'latex'})
- parts = publish_parts(source=i.contents, writer_name="latex", settings_overrides=docutils_settings)
- tmpdir = tempfile.mkdtemp()
- pre = i.slug().split('/')
- for fig in re.findall('\\includegraphics.*\{(.+)\}', parts['whole']):
- try:
- if len(pre) > 1:
- fig_blob = fromslug("%s/%s" % ('/'.join(pre[:-1])),fig)
- else:
- fig_blob = fromslug(fig)
- fig_blob.update()
- # if might have to create subdirectories for figures
- fig_pre = fig.split('/')
- if len(fig_pre) > 1:
- os.mkdir("%s/%s" % (tmpdir,'/'.join(fig_pre[:-1])))
- fig_file = file(str("%s/%s" % (tmpdir,fig)),'wb')
- fig_file.write(fig_blob.contents)
- fig_file.close()
- except:
- parts['whole'].replace(fig,'')
- hr = HttpResponse(mimetype="application/pdf")
- #hr = HttpResponse()
- hr['Content-Disposition'] = 'filename=%s.pdf' % reqslug
- write_tex,pdf = os.popen2('rubber-pipe -qqq -d --into %s' % tmpdir)
- write_tex.write(parts['whole'].replace('{\$}','$'))
- write_tex.flush()
- write_tex.close()
- #hr.write(parts['whole'])
- #pdf.flush()
- for l in pdf.readlines():
- hr.write(l)
- try:
- pdff = open("%s/rubtmp0.pdf" % tmpdir,'r')
- for l in pdff.readlines():
- hr.write(l)
- pdff.close()
- except:
- pass
- pdf.close()
- shutil.rmtree(tmpdir)
- return hr
-
-def rawitem(request, reqslug, blob=None):
- if reqslug.endswith('/'):
- reqslug=reqslug[:-1]
- if not blob:
- i = fromslug(reqslug)
- if not i:
- raise Http404
- if i.type == 'tree':
- return tree(request, reqslug)
- else:
- i = blob
- i.update()
- slug = i.slug()
- r = HttpResponse(mimetype="text/plain")
- r['Content-Disposition'] = 'filename=%s.txt' % reqslug
- r.write(i.contents)
- return r
-
-def figure(request, reqslug, blob=None, download=False):
- if reqslug.endswith('/'):
- reqslug=reqslug[:-1]
- if not blob:
- i = fromslug(reqslug)
- if not i:
- l = reqslug.split('/')
- if l[-2] == 'fig':
- l = l[:-3] + l[-2:]
- else:
- l = l[:-2] + l[-1:]
- i = fromslug('/'.join(l))
- if not i:
- raise Http404
- if i.type == 'tree':
- return tree(request, reqslug)
- else:
- i = blob
- mime = "image/image"
- slug = i.slug()
- i.update()
- if slug.endswith('.jpg') or slug.endswith('.jpeg'):
- mime = "image/jpeg"
- elif slug.endswith('.png'):
- mime = "image/jpeg"
- elif slug.endswith('.gif'):
- mime = "image/jpeg"
- elif slug.endswith('.svg'):
- mime = "image/svg+xml"
- r = HttpResponse(mimetype=mime)
- if download:
- r['Content-Disposition'] = 'attachment; filename=%s' % reqslug
- else:
- r['Content-Disposition'] = 'filename=%s' % reqslug
- f = i.getfile()
- t = f.readlines()
- r.write(i.contents)
- return r
-
-def olditem(request, hash):
- i = get_object_or_404(Item, id=hash)
- i.update()
- return render_to_response('git_browse/olditem.html',
- dict(item=i))
-
-def view_commit(request, hash):
- (heads, tags) = reposcan()
- c = Commit(id=hash)
- c.update()
- try:
- from pygments import highlight
- from pygments.lexers import DiffLexer
- from pygments.formatters import HtmlFormatter
- c.pretty_diff = highlight(c.rawdiff, DiffLexer(), HtmlFormatter())
- except: pass
-
- return render_to_response('git_wiki/commit.html',
- dict(heads=heads, tags=tags,
- commit=c))
diff --git a/bn_django/photos/models.py b/bn_django/photos/models.py
index dcef1fc..346e19d 100644
--- a/bn_django/photos/models.py
+++ b/bn_django/photos/models.py
@@ -14,12 +14,7 @@ try:
except AttributeError:
STOCKPHOTO_BASE='photos'
-try:
- STOCKPHOTO_URL = settings.STOCKPHOTO_URL
-except AttributeError:
- STOCKPHOTO_URL='/photos'
-if STOCKPHOTO_URL[-1] == '/':
- STOCKPHOTO_URL=STOCKPHOTO_URL[:-1]
+STOCKPHOTO_URL='http://media.bnewbold.net/hosted-photos'
try:
ADMIN_URL = settings.ADMIN_URL
@@ -59,7 +54,7 @@ class Gallery(models.Model):
def __str__(self):
return self.title
def get_absolute_url(self):
- return "%s/%s/" % (STOCKPHOTO_URL, self.slug)
+ return "%s/%s/" % (STOCKPHOTO_BASE, self.slug)
def get_admin_url(self):
return "%s/photos/gallery/%d/" % (ADMIN_URL, self.id)
def was_published_today(self):
@@ -121,7 +116,7 @@ class Photo(models.Model):
#os.unlink(self.fullpath())
def get_absolute_url(self):
- return "%s/detail/%d/" % (STOCKPHOTO_URL, self.id)
+ return "%s/detail/%d/" % (STOCKPHOTO_BASE, self.id)
def get_admin_url(self):
return "%s/photos/photos/%d/" % (ADMIN_URL, self.id)
@@ -137,12 +132,7 @@ class Photo(models.Model):
"""URL to the thumbnail
"""
photobase = self.image.name[len(STOCKPHOTO_BASE)+1:]
- if settings.MEDIA_URL.endswith('/'):
- return settings.MEDIA_URL + STOCKPHOTO_BASE + \
- "/cache/thumbs/" + photobase
- return settings.MEDIA_URL + '/' + STOCKPHOTO_BASE + \
- "/cache/thumbs/" + photobase
-
+ return STOCKPHOTO_URL + "/cache/thumbs/" + photobase
def disppath(self):
photobase = self.image.name[len(STOCKPHOTO_BASE)+1:]
@@ -151,11 +141,7 @@ class Photo(models.Model):
def dispurl(self):
photobase = self.image.name[len(STOCKPHOTO_BASE)+1:]
- if settings.MEDIA_URL.endswith('/'):
- return settings.MEDIA_URL + STOCKPHOTO_BASE + "/cache/" \
- + photobase
- return settings.MEDIA_URL + '/' + STOCKPHOTO_BASE + \
- "/cache/" + photobase
+ return STOCKPHOTO_URL + "/cache/" + photobase
def fullpath(self):
if self.image.name.startswith(os.path.sep):
@@ -163,14 +149,7 @@ class Photo(models.Model):
return os.path.join(settings.MEDIA_ROOT, self.image.name)
def fullurl(self):
- if self.image.name.startswith(os.path.sep):
- # Shouldn't happen anymore
- return (settings.MEDIA_URL +
- self.image.name[len(settings.MEDIA_ROOT):])
- else:
- if settings.MEDIA_URL.endswith('/'):
- return settings.MEDIA_URL + self.image.name
- return settings.MEDIA_URL + '/' + self.image.name
+ return STOCKPHOTO_URL + '/' + self.image.name
def next(self):
diff --git a/bn_django/templates/comments/form.html b/bn_django/templates/comments/form.html
index 39626f0..e69de29 100644
--- a/bn_django/templates/comments/form.html
+++ b/bn_django/templates/comments/form.html
@@ -1,22 +0,0 @@
-{% load comments i18n %}
-<form action="{% comment_form_target %}" method="post">
-<table>
-{% if object.get_absolute_url %} <input type="hidden" name="next" value="{{ object.get_absolute_url }}" />{% endif %}
- {% for field in form %} {% if field.is_hidden %} {{ field }} {% else %}
- {% ifequal field.name "honeypot" %}
- <span style="display:none;">{{ field.label_tag }}{{ field }}</span>
- {% else %}
-<tr><td class="comment_field_name">
- <span {% if field.errors %} class="error"{% endif %}>
- {% if field.errors %}{{ field.errors }}{% endif %}
- {{ field.label_tag }}
- </span></td><td>{{ field }}
- {% ifequal field.name "name" %} <i>(required)</i> {% else %}{% ifequal field.name "email" %} <i>(required)</i>{% endifequal %}{% endifequal %}
-</td></tr> {% endifequal %} {% endif %} {% endfor %}
-<tr><td class="comment_field_name"></td><td>
- <input type="submit" name="preview" class="submit-preview" value="{% trans "Preview" %}" />
- <input type="submit" name="post" class="submit-post" value="{% trans "Post" %}" />
- <i>(no HTML or other markup)</i>
-</td></tr>
-</table>
-</form>
diff --git a/bn_django/templates/frontpage.html b/bn_django/templates/frontpage.html
index 78b5d48..e0fc19c 100644
--- a/bn_django/templates/frontpage.html
+++ b/bn_django/templates/frontpage.html
@@ -56,19 +56,6 @@ Other sites: <br />
<br/><br />None yet!
{% endif %}
<br />
-<h2 class="ruled">Knowledge!</h2>
-{% if shortlog %}
-{% include "git_wiki/shortlog_table" %}
-{% else %}
-None yet!
-{% endif %}
-<br />
-<h2 class="ruled">Comments!</h2>
-{% if latest_comments %}
-{% include "newcomments_table" %}
-{% else %}
-None yet!
-{% endif %}
<br /><br />
{% endblock %}