[svn r8034] Initial troggle checkin

This is a development site using Django 1.0
This commit is contained in:
julian 2008-10-26 22:04:06 +01:00
parent ec35f056e5
commit 8bccfd9ed8
29 changed files with 1366 additions and 0 deletions

0
troggle/__init__.py Normal file
View File

0
troggle/expo/__init__.py Normal file
View File

15
troggle/expo/admin.py Normal file
View File

@ -0,0 +1,15 @@
from troggle.expo.models import *
from django.contrib import admin
admin.site.register(Cave)
admin.site.register(Area)
admin.site.register(OtherCaveName)
admin.site.register(CaveAndEntrance)
admin.site.register(SurveyStation)
admin.site.register(Entrance)
admin.site.register(SurvexBlock)
admin.site.register(Expedition)
admin.site.register(Person)
admin.site.register(PersonExpedition)
admin.site.register(LogbookEntry)
admin.site.register(PersonTrip)

3
troggle/expo/models.py Normal file
View File

@ -0,0 +1,3 @@
from models_cave import *
from models_survex import *
from models_logbooks import *

153
troggle/expo/models_cave.py Normal file
View File

@ -0,0 +1,153 @@
from django.db import models
class Area(models.Model):
short_name = models.CharField(max_length=100)
name = models.CharField(max_length=200, blank=True, null=True)
description = models.TextField(blank=True,null=True)
parent = models.ForeignKey('Area', blank=True, null=True)
def __unicode__(self):
if self.parent:
return unicode(self.parent) + u" - " + unicode(self.short_name)
else:
return unicode(self.short_name)
def kat_area(self):
if self.short_name in ["1623", "1626"]:
return self.short_name
elif self.parent:
return self.parent.kat_area()
class CaveAndEntrance(models.Model):
cave = models.ForeignKey('Cave')
entrance = models.ForeignKey('Entrance')
entrance_letter = models.CharField(max_length=20,blank=True,null=True)
def __unicode__(self):
return unicode(self.cave) + unicode(self.entrance_letter)
class Cave(models.Model):
official_name = models.CharField(max_length=160)
area = models.ManyToManyField(Area, blank=True, null=True)
kataster_code = models.CharField(max_length=20,blank=True,null=True)
kataster_number = models.CharField(max_length=10,blank=True, null=True)
unofficial_number = models.CharField(max_length=30,blank=True, null=True)
entrances = models.ManyToManyField('Entrance', through='CaveAndEntrance')
explorers = models.TextField(blank=True,null=True)
underground_description = models.TextField(blank=True,null=True)
equipment = models.TextField(blank=True,null=True)
references = models.TextField(blank=True,null=True)
survey = models.TextField(blank=True,null=True)
kataster_status = models.TextField(blank=True,null=True)
underground_centre_line = models.TextField(blank=True,null=True)
notes = models.TextField(blank=True,null=True)
length = models.CharField(max_length=40,blank=True,null=True)
depth = models.CharField(max_length=40,blank=True,null=True)
extent = models.CharField(max_length=40,blank=True,null=True)
survex_file = models.CharField(max_length=100,blank=True,null=True)
def __unicode__(self):
if self.kataster_number:
if self.kat_area():
return self.kat_area() + u": " + self.kataster_number
else:
return unicode(l) + u": " + self.kataster_number
else:
if self.kat_area():
return self.kat_area() + u": " + self.unofficial_number
else:
return self.unofficial_number
def kat_area(self):
for a in self.area.all():
if a.kat_area():
return a.kat_area()
def entrances(self):
return CaveAndEntrance.objects.filter(cave=self)
def entrancelist(self):
rs = []
res = ""
for e in CaveAndEntrance.objects.filter(cave=self):
rs.append(e.entrance_letter)
rs.sort()
prevR = None
n = 0
for r in rs:
if prevR:
if chr(ord(prevR) + 1 ) == r:
prevR = r
n += 1
else:
if n == 0:
res += ", " + prevR
else:
res += "–" + prevR
else:
prevR = r
n = 0
res += r
if n == 0:
res += ", " + prevR
else:
res += "–" + prevR
return res
class OtherCaveName(models.Model):
name = models.CharField(max_length=160)
cave = models.ForeignKey(Cave)
def __unicode__(self):
return unicode(self.name)
class SurveyStation(models.Model):
name = models.CharField(max_length=200)
def __unicode__(self):
return unicode(self.name)
class Entrance(models.Model):
name = models.CharField(max_length=60, blank=True,null=True)
entrance_description = models.TextField(blank=True,null=True)
explorers = models.TextField(blank=True,null=True)
map_description = models.TextField(blank=True,null=True)
location_description = models.TextField(blank=True,null=True)
approach = models.TextField(blank=True,null=True)
underground_description = models.TextField(blank=True,null=True)
photo = models.TextField(blank=True,null=True)
MARKING_CHOICES = (
('P', 'Paint'),
('P?', 'Paint (?)'),
('T', 'Tag'),
('T?', 'Tag (?)'),
('R', 'Retagged'),
('S', 'Spit'),
('S?', 'Spit (?)'),
('U', 'Unmarked'),
('?', 'Unknown'))
marking = models.CharField(max_length=2, choices=MARKING_CHOICES)
marking_comment = models.TextField(blank=True,null=True)
FINDABLE_CHOICES = (
('?', 'To be confirmed ...'),
('S', 'Surveyed'),
('L', 'Lost'),
('R', 'Refindable'))
findability = models.CharField(max_length=1, choices=FINDABLE_CHOICES, blank=True, null=True)
findability_description = models.TextField(blank=True,null=True)
alt = models.TextField(blank=True, null=True)
northing = models.TextField(blank=True, null=True)
easting = models.TextField(blank=True, null=True)
tag_station = models.ForeignKey(SurveyStation, blank=True,null=True, related_name="tag_station")
exact_station = models.ForeignKey(SurveyStation, blank=True,null=True, related_name="exact_station")
other_station = models.ForeignKey(SurveyStation, blank=True,null=True, related_name="other_station")
other_description = models.TextField(blank=True,null=True)
bearings = models.TextField(blank=True,null=True)
def __unicode__(self):
a = CaveAndEntrance.objects.filter(entrance = self)
name = u''
if self.name:
name = unicode(self.name) + u' '
if len(a) == 1:
return name + unicode(a[0])
return name + unicode(a)
def marking_val(self):
for m in self.MARKING_CHOICES:
if m[0] == self.marking:
return m[1]
def findability_val(self):
for f in self.FINDABLE_CHOICES:
if f[0] == self.findability:
return f[1]

View File

@ -0,0 +1,79 @@
from django.db import models
from django.contrib import admin
class Expedition(models.Model):
year = models.CharField(max_length=20, unique=True)
name = models.CharField(max_length=100)
start_date = models.DateField(blank=True,null=True)
end_date = models.DateField(blank=True,null=True)
def __str__(self):
return self.year
def GetPersonExpedition(self, name):
if name == "Dour":
name = "Anthony Day"
personyears = PersonExpedition.objects.filter(expedition=self)
res = None
for personyear in personyears:
if name == "%s %s" % (personyear.person.first_name, personyear.person.last_name):
assert not res, "Ambiguous:" + name
res = personyear
if name == "%s %s" % (personyear.person.first_name, personyear.person.last_name[0]):
assert not res, "Ambiguous:" + name
res = personyear
if name == personyear.person.first_name:
assert not res, "Ambiguous:" + name
res = personyear
return res
class Person(models.Model):
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
is_guest = models.BooleanField()
is_vfho = models.BooleanField()
mug_shot = models.CharField(max_length=100, blank=True,null=True)
def __str__(self):
return "%s %s" % (self.first_name, self.last_name)
class PersonExpedition(models.Model):
expedition = models.ForeignKey(Expedition)
person = models.ForeignKey(Person)
from_date = models.DateField(blank=True,null=True)
to_date = models.DateField(blank=True,null=True)
nickname = models.CharField(max_length=100,blank=True,null=True)
def __str__(self):
return "%s: (%s)" % (self.person, self.expedition)
class LogbookEntry(models.Model):
date = models.DateField()
author = models.ForeignKey(PersonExpedition,blank=True,null=True)
title = models.CharField(max_length=100)
# this will be a foreign key
place = models.CharField(max_length=100,blank=True,null=True)
text = models.TextField()
#cavers = models.ManyToManyField(PersonYear)
#tu = models.CharField(max_length=50)
def __str__(self):
return "%s: (%s)" % (self.date, self.title)
class PersonTrip(models.Model):
personexpedition = models.ForeignKey(PersonExpedition)
place = models.CharField(max_length=100) # this will be a foreign key
date = models.DateField()
timeunderground = models.CharField(max_length=100)
logbookentry = models.ForeignKey(LogbookEntry)
#is_author = models.BooleanField()
def __str__(self):
return "%s %s (%s)" % (self.personexpedition, self.place, self.date)

View File

@ -0,0 +1,15 @@
from django.db import models
class SurvexBlock(models.Model):
name = models.CharField(max_length=100)
text = models.TextField()
notes_person = models.ManyToManyField('PersonTrip', related_name="notes")
pics_person = models.ManyToManyField('PersonTrip', related_name="pics")
tape_person = models.ManyToManyField('PersonTrip', related_name="tape")
insts_person = models.ManyToManyField('PersonTrip', related_name="insts")
begin_file = models.CharField(max_length=200)
begin_char = models.IntegerField()
end_file = models.CharField(max_length=200)
end_char = models.IntegerField()
def __unicode__(self):
return unicode(name)

View File

View File

@ -0,0 +1,51 @@
from django import template
from django.utils.html import conditional_escape
from django.template.defaultfilters import stringfilter
from django.utils.safestring import mark_safe
import re
register = template.Library()
regexes = []
regexes.append((re.compile(r"(;.*)$", re.IGNORECASE|re.MULTILINE),
r'<span class = "comment">\1</span>\n'))
regexes.append((re.compile(r"^(\s*)(\*include)(\s+)([^\s]*)(.svx)$", re.IGNORECASE|re.MULTILINE),
r'\1<span class = "command">\2</span>\3<a href="\4.index">\4\5</a>'))
regexes.append((re.compile(r"^(\s*)(\*include)(\s+)([^\s]*)$", re.IGNORECASE|re.MULTILINE),
r'\1<span class = "command">\2</span>\3<a href="\4.index">\4</a>'))
regexes.append((re.compile(r"^(\s*)(\*team\s+(?:notes|tape|insts|pics))(\s+)(.*)$", re.IGNORECASE|re.MULTILINE),
r'\1<span class = "command">\2</span>\3\4'))
regexes.append((re.compile(r"^(\s*)(\*(?:begin|end|copyright|date|entrance|equate|export|fix|prefix|require|SOLVE|title|truncate))(\s+)(.*)$", re.IGNORECASE|re.MULTILINE),
r'\1<span class = "command">\2</span>\3\4'))
regexes.append((re.compile(r"^(\s*)(\*calibrate\s+(?:TAPE|COMPASS|CLINO|COUNTER|DEPTH|DECLINATION|X|Y|Z)+)(\s+)(.*)$", re.IGNORECASE|re.MULTILINE),
r'\1<span class = "command">\2</span>\3\4'))
regexes.append((re.compile(r"^(\s*)(\*data\s+(?:DEFAULT|NORMAL|DIVING|CARTESIAN|TOPOFIL|CYLPOLAR|NOSURVEY|passage)(?:\s+station|\s+from|\s+to|\s+FROMDEPTH|\s+TODEPTH|\s+DEPTHCHANGE|\s+newline|\s+direction|\s+tape|\s+compass|\s+clino|\s+northing|\s+easting|\s+altitude|\s+length|\s+bearing|\s+gradient|\s+ignoreall|\sleft|\sright|\sup|\sdown)*)$", re.IGNORECASE|re.MULTILINE),
r'\1<span class = "command">\2</span>'))
regexes.append((re.compile(r"^(\s*)(\*default\s+(?:CALIBRATE|DATA|UNITS)+)(\s+)(.*)$", re.IGNORECASE|re.MULTILINE),
r'\1<span class = "command">\2</span>\3\4'))
regexes.append((re.compile(r"^(\s*)(\*flags\s+(?:DUPLICATE|SPLAY|SURFACE|not DUPLICATE|not SPLAY|not SURFACE))(\s+)(.*)$", re.IGNORECASE|re.MULTILINE),
r'\1<span class = "command">\2</span>\3\4'))
regexes.append((re.compile(r"^(\s*)(\*infer\s+(?:plumbs|equates|exports))(\s+)(.*)$", re.IGNORECASE|re.MULTILINE),
r'\1<span class = "command">\2</span>\3\4'))
regexes.append((re.compile(r"^(\s*)(\*instrument\s+(?:compass|clino|tape))(\s+)(.*)$", re.IGNORECASE|re.MULTILINE),
r'\1<span class = "command">\2</span>\3\4'))
regexes.append((re.compile(r"^(\s*)(\*instrument\s+(?:compass|clino|tape))(\s+)(.*)$", re.IGNORECASE|re.MULTILINE),
r'\1<span class = "command">\2</span>\3\4'))
regexes.append((re.compile(r"^(\s*)(\*sd\s+(?:TAPE|COMPASS|CLINO|COUNTER|DEPTH|DECLINATION|DX|DY|DZ))(\s+)(.*)$", re.IGNORECASE|re.MULTILINE),
r'\1<span class = "command">\2</span>\3\4'))
regexes.append((re.compile(r"^(\s*)(\*set\s+(?:BLANK|COMMENT|DECIMAL|EOL|KEYWORD|MINUS|NAMES|OMIT|PLUS|ROOT|SEPARATOR))(\s+)(.*)$", re.IGNORECASE|re.MULTILINE),
r'\1<span class = "command">\2</span>\3\4'))
regexes.append((re.compile(r"^(\s*)(\*units\s+(?:TAPE|LENGTH|COMPASS|BEARING|CLINO|GRADIENT|COUNTER|DEPTH|DECLINATION|X|Y|Z))(\s+)(.*)$", re.IGNORECASE|re.MULTILINE),
r'\1<span class = "command">\2</span>\3\4'))
regexes.append((re.compile(r"^(.*)$", re.IGNORECASE|re.MULTILINE),
r'<div>\1&nbsp;</div>\n'))
@register.filter()
@stringfilter
def survex_to_html(value, autoescape=None):
if autoescape:
value = conditional_escape(value)
for regex, sub in regexes:
print sub
value = regex.sub(sub, value)
return mark_safe(value)

View File

@ -0,0 +1,58 @@
from django import template
from django.utils.html import conditional_escape
from django.template.defaultfilters import stringfilter
from django.utils.safestring import mark_safe
import re
register = template.Library()
def wiki_list(line, listdepth):
l = ""
for d in listdepth:
l += d
mstar = re.match(l + "\*(.*)", line)
if mstar:
listdepth.append("\*")
return ("<ul>\n" + " " * len(listdepth) + "<li>%s</li>\n" % mstar.groups()[0], listdepth)
mhash = re.match(l + "#(.*)", line)
if mhash:
listdepth.append("#")
return ("<ol>\n" + " " * len(listdepth) + "<li>%s</li>\n" % mhash.groups()[0], listdepth)
mflat = re.match(l + "(.*)", line)
if mflat and listdepth:
return (" " * len(listdepth) + "<li>%s</li>\n" % mflat.groups()[0], listdepth)
if listdepth:
prev = listdepth.pop()
if prev == "\*":
t, l = wiki_list(line, listdepth)
return ("</ul>\n" + t, l)
if prev == "#":
t, l = wiki_list(line, listdepth)
return ("</ol>\n" + t, l)
return (line, listdepth)
@register.filter()
@stringfilter
def wiki_to_html(value, autoescape=None):
if autoescape:
value = conditional_escape(value)
#deescape doubly escaped characters
value = re.sub("&amp;(.*?);", r"&\1;", value, re.DOTALL)
#italics and bold
value = re.sub("&#39;&#39;&#39;&#39;([^']+)&#39;&#39;&#39;&#39;", r"<b><i>\1</i></b>", value, re.DOTALL)
value = re.sub("&#39;&#39;&#39;([^']+)&#39;&#39;&#39;", r"<b>\1</b>", value, re.DOTALL)
value = re.sub("&#39;&#39;([^']+)&#39;&#39;", r"<i>\1</i>", value, re.DOTALL)
#Make lists from lines starting with lists of [stars and hashes]
listdepth = []
outValue = ""
for line in value.split("\n"):
t, listdepth = wiki_list(line, listdepth)
outValue += t
for item in listdepth:
if item == "\*":
outValue += "</ul>\n"
elif item == "#":
outValue += "</ol>\n"
return mark_safe(outValue)
wiki_to_html.needs_autoescape = True

2
troggle/expo/views.py Normal file
View File

@ -0,0 +1,2 @@
from views_caves import *
from views_survex import *

View File

@ -0,0 +1,19 @@
from django.shortcuts import render_to_response
from troggle.expo.models import Cave, CaveAndEntrance
import troggle.settings as settings
def caveindex(request):
caves = Cave.objects.all()
return render_to_response('caveindex.html', {'caves': caves, 'settings': settings})
def cave(request, cave_id):
cave = Cave.objects.filter(kataster_number = cave_id)[0]
return render_to_response('cave.html', {'cave': cave, 'settings': settings})
def ent(request, cave_id, ent_letter):
cave = Cave.objects.filter(kataster_number = cave_id)[0]
cave_and_ent = CaveAndEntrance.objects.filter(cave = cave).filter(entrance_letter = ent_letter)[0]
return render_to_response('entrance.html', {'cave': cave,
'entrance': cave_and_ent.entrance,
'letter': cave_and_ent.entrance_letter,
'settings': settings})

View File

@ -0,0 +1,44 @@
from django.shortcuts import render_to_response
from django.http import HttpResponse, Http404
import re
import os
import troggle.settings as settings
def index(request, survex_file):
process(survex_file)
f = open(settings.SURVEX_DATA + survex_file + ".svx", "rb")
a = f.read()
return render_to_response('svxfile.html', {'settings': settings,
'has_3d': os.path.isfile(settings.SURVEX_DATA + survex_file + ".3d"),
'title': survex_file,
'text': unicode(a, "latin1")})
def svx(request, survex_file):
svx = open(settings.SURVEX_DATA + survex_file + ".svx", "rb")
return HttpResponse(svx, mimetype="text")
def threed(request, survex_file):
process(survex_file)
try:
threed = open(settings.SURVEX_DATA + survex_file + ".3d", "rb")
return HttpResponse(threed, mimetype="model/3d")
except:
log = open(settings.SURVEX_DATA + survex_file + ".log", "rb")
return HttpResponse(log, mimetype="text")
def log(request, survex_file):
process(survex_file)
log = open(settings.SURVEX_DATA + survex_file + ".log", "rb")
return HttpResponse(log, mimetype="text")
def err(request, survex_file):
process(survex_file)
err = open(settings.SURVEX_DATA + survex_file + ".err", "rb")
return HttpResponse(err, mimetype="text")
def process(survex_file):
cwd = os.getcwd()
os.chdir(os.path.split(settings.SURVEX_DATA + survex_file)[0])
os.system(settings.CAVERN + " --log " +settings.SURVEX_DATA + survex_file + ".svx")
os.chdir(cwd)

View File

@ -0,0 +1,10 @@
DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'undemocracy' # Or path to database file if using sqlite3.
DATABASE_USER = 'undemocracy' # Not used with sqlite3.
DATABASE_PASSWORD = 'aiGohsh5' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
SURVEX_DATA = ''
CAVERN = 'cavern'
EXPOWEB = ''

View File

@ -0,0 +1,10 @@
DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = './sqlite.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.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
SURVEX_DATA = 'c:\\loser\\'
CAVERN = '"C:\\Program Files\\Survex\\cavern"'
EXPOWEB = 'C:\\expoweb\\'

11
troggle/manage.py Normal file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
sys.exit(1)
if __name__ == "__main__":
execute_manager(settings)

View File

@ -0,0 +1,43 @@
.caption { font-size: 8pt; margin-bottom: 0pt; }
.centre { text-align: center; }
.plus2pt { font-size: 160%; }
body, td, center, ul, p, input { color: #000; font-family: sans-serif; }
a:link, a:visited { text-decoration: none; }
div.centre img { vertical-align: middle; }
h1 { text-align: center; font-size: 210%;
line-height: 100%; }
h2 { color: #009900; }
h3 { color: #2c105e; }
h4 { color: #0d664c; }
img.onright, div.onright { vertical-align: top; float: right;
margin-left: 10pt; margin-bottom: 10pt;
margin-right: 8pt; }
img.onleft, div.onleft { vertical-align: top; float: left;
margin-right: 10pt; margin-bottom: 10pt;
margin-left: 8pt; }
img.icon { vertical-align: middle; }
img.aligntop { vertical-align: top; }
table.imgtable { margin-left: auto; margin-right: auto; }
table.imgtable td { vertical-align: middle; text-align: center;
padding: 10px; }
/* "Traditional" table with borders.*/
table.trad { margin: 0pt; border: 1px solid #000;
border-color: #c0c0c0 #8d8d8d #8d8d8d #c0c0c0; }
table.bigfatborder { border-width: 6px; }
table.trad td, table.trad th { margin: 0pt; border: 1px solid #aaa;
border-color: #8d8d8d #c0c0c0 #c0c0c0 #8d8d8d; }
/* You are not expected to understand this. It is necessary. */
table.centre { margin-left: auto; margin-right: auto; }
table.centre td { text-align: left; }
h2#tophead { text-align: center; margin-bottom: -10pt; }
table#cavepage { width: 100%; font-size: 160%; }
table#cavepage th#kat_no { text-align: left; width: 25%; }
table#cavepage th#name { text-align: center; width: 50%; }
table#cavepage th#status { text-align: right; width: 25%; }
.command { color: #FF0000; }
.comment { color: #888888; font-style:italic;}

49
troggle/middleware.py Normal file
View File

@ -0,0 +1,49 @@
from django.conf import settings
from django import http
from django.core.urlresolvers import resolve
class SmartAppendSlashMiddleware(object):
"""
"SmartAppendSlash" middleware for taking care of URL rewriting.
This middleware appends a missing slash, if:
* the SMART_APPEND_SLASH setting is True
* the URL without the slash does not exist
* the URL with an appended slash does exist.
Otherwise it won't touch the URL.
"""
def process_request(self, request):
"""
Rewrite the URL based on settings.SMART_APPEND_SLASH
"""
# Check for a redirect based on settings.SMART_APPEND_SLASH
host = http.get_host(request)
old_url = [host, request.path]
new_url = old_url[:]
# Append a slash if SMART_APPEND_SLASH is set and the resulting URL
# resolves.
if settings.SMART_APPEND_SLASH and (not old_url[1].endswith('/')) and not _resolves(old_url[1]) and _resolves(old_url[1] + '/'):
new_url[1] = new_url[1] + '/'
if settings.DEBUG and request.method == 'POST':
raise RuntimeError, "You called this URL via POST, but the URL doesn't end in a slash and you have SMART_APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data. Change your form to point to %s%s (note the trailing slash), or set SMART_APPEND_SLASH=False in your Django settings." % (new_url[0], new_url[1])
if new_url != old_url:
# Redirect
if new_url[0]:
newurl = "%s://%s%s" % (request.is_secure() and 'https' or 'http', new_url[0], new_url[1])
else:
newurl = new_url[1]
if request.GET:
newurl += '?' + request.GET.urlencode()
return http.HttpResponsePermanentRedirect(newurl)
return None
def _resolves(url):
try:
resolve(url)
return True
except http.Http404:
return False

View File

272
troggle/parsers/cavetab.py Normal file
View File

@ -0,0 +1,272 @@
# -*- coding: utf-8 -*-
import settings
import expo.models as models
import csv
import time
import sqlite3
import re
import os
##format of CAVETAB2.CSV is
KatasterNumber = 0
KatStatusCode = 1
Entrances = 2
UnofficialNumber = 3
MultipleEntrances = 4
AutogenFile = 5
LinkFile = 6
LinkEntrance = 7
Name = 8
UnofficialName = 9
Comment = 10
Area = 11
Explorers = 12
UndergroundDescription = 13
Equipment = 14
QMList = 15
KatasterStatus = 16
References = 17
UndergroundCentreLine = 18
UndergroundDrawnSurvey = 19
SurvexFile = 20
Length = 21
Depth = 22
Extent = 23
Notes = 24
EntranceName = 25
TagPoint = 26
OtherPoint = 27
DescriptionOfOtherPoint = 28
ExactEntrance = 29
TypeOfFix = 30
GPSpreSA = 31
GPSpostSA = 32
Northing = 33
Easting = 34
Altitude = 35
Bearings = 36
Map = 37
Location = 38
Approach = 39
EntranceDescription = 40
PhotoOfLocation = 41
Marking = 42
MarkingComment = 43
Findability = 44
FindabilityComment = 45
cavetab = open(os.path.join(settings.EXPOWEB, "noinfo", "CAVETAB2.CSV"))
caveReader = csv.reader(cavetab)
caveReader.next() # Strip out column headers
def save(x): #There seems to be an intermitent problem with sqlite and Vista, this should fix it
try:
x.save()
except sqlite3.OperationalError:
print "Error"
time.sleep(1)
save(x)
def html_to_wiki(text):
if type(text) != str:
return text
text = unicode(text, "utf-8")
#Characters
#text = re.sub("&uuml;", u"\xfc", text)
#text = re.sub("&ouml;", u"\xf6", text)
#text = re.sub("&auml;", u"\xe4", text)
#text = re.sub("&deg;", u"\xb0", text)
#text = re.sub("&copy;", u"\xa9", text)
#text = re.sub("&amp;", u"\x26", text)
#text = re.sub("&szlig;", u"\xdf", text)
#text = re.sub("&szlig;", u"\xdf", text)
#text = re.sub("&lt;", u"<", text)
#text = re.sub("&gt;", u">", text)
#text = re.sub("&egrave;", u"\xe8", text)
#text = re.sub("&eacute;", u"\xe9", text)
#text = re.sub("&quote;", u'"', text)
#text = re.sub("&quot;", u'"', text)
#text = re.sub("&Ouml;", u'\xd6', text)
#text = re.sub("&times;", u'"', text)
#text = re.sub("&(.*);", "/1", text)
#if s:
# print s.groups()
#Lists
text = re.sub("^</p>(.*)", r"\1", text)
text = re.sub("(.*)<p>$", r"\1", text)
out = ""
lists = ""
while text:
mstar = re.match("^(.*?)<ul>\s*<li[^>]*>(.*?)</li>(.*)$", text, re.DOTALL)
munstar = re.match("^(\s*)</ul>(.*)$", text, re.DOTALL)
mhash = re.match("^(.*?)<ol>\s*<li[^>]*>(.*?)</li>(.*)$", text, re.DOTALL)
munhash = re.match("^(\s*)</ol>(.*)$", text, re.DOTALL)
mitem = re.match("^(\s*)<li[^>]*>(.*?)</li>(.*)$", text, re.DOTALL)
ms = [len(m.groups()[0]) for m in [mstar, munstar, mhash, munhash, mitem] if m]
def min_(i, l):
try:
v = i.groups()[0]
l.remove(len(v))
return len(v) < min(l, 1000000000)
except:
return False
if min_(mstar, ms):
lists += "*"
pre, val, post = mstar.groups()
out += pre + "\n" + lists + " " + val
text = post
elif min_(mhash, ms):
lists += "#"
pre, val, post = mhash.groups()
out += pre + "\n" + lists + " " + val
text = post
elif min_(mitem, ms):
pre, val, post = mitem.groups()
out += "\n" + lists + " " + val
text = post
elif min_(munstar, ms):
lists = lists[:-1]
text = munstar.groups()[1]
elif min_(munhash, ms):
lists.pop()
text = munhash.groups()[1]
else:
out += text
text = ""
text2 = out
while text2:
mtag = re.match("^(.*?)<(.*?)>(.*)$", text, re.DOTALL)
if mtag:
text2 = mtag.groups()[2]
print mtag.groups()[1]
else:
text2 = ""
return out
for katArea in ['1623', '1626']:
if not models.Area.objects.filter(short_name = katArea):
newArea = models.Area(short_name = katArea)
save(newArea)
area1626 = models.Area.objects.filter(short_name = '1626')[0]
area1623 = models.Area.objects.filter(short_name = '1623')[0]
counter=0
for line in caveReader :
if line[Area] == 'nonexistent':
continue
entranceLetters=[] #Used in caves that have mulitlple entrances, which are not described on seperate lines
if line[MultipleEntrances] == 'yes' or line[MultipleEntrances]=='':
args = {}
def addToArgs(CSVname, modelName):
if line[CSVname]:
args[modelName] = html_to_wiki(line[CSVname])
addToArgs(KatasterNumber, "kataster_number")
addToArgs(KatStatusCode, "kataster_code")
addToArgs(UnofficialNumber, "unofficial_number")
addToArgs(Name, "official_name")
addToArgs(Comment, "notes")
addToArgs(Explorers, "explorers")
addToArgs(UndergroundDescription, "underground_description")
addToArgs(Equipment, "equipment")
addToArgs(KatasterStatus, "kataster_status")
addToArgs(References, "references")
addToArgs(UndergroundCentreLine, "underground_centre_line")
addToArgs(UndergroundDrawnSurvey, "survey")
addToArgs(Length, "length")
addToArgs(Depth, "depth")
addToArgs(Extent, "extent")
addToArgs(SurvexFile, "survex_file")
addToArgs(Notes, "notes")
newCave = models.Cave(**args)
save(newCave)
if line[Area]:
if line[Area] == "1626":
newCave.area.add(area1626)
else:
area = models.Area.objects.filter(short_name = line[Area])
if area:
newArea = area[0]
else:
newArea = models.Area(short_name = line[Area], parent = area1623)
save(newArea)
newCave.area.add(newArea)
else:
newCave.area.add(area1623)
save(newCave)
if line[UnofficialName]:
newUnofficialName = models.OtherCaveName(cave = newCave, name = line[UnofficialName])
save(newUnofficialName)
if line[MultipleEntrances] == '' or \
line[MultipleEntrances] == 'entrance' or \
line[MultipleEntrances] == 'last entrance':
args = {}
def addToArgs(CSVname, modelName):
if line[CSVname]:
args[modelName] = html_to_wiki(line[CSVname])
def addToArgsViaDict(CSVname, modelName, dictionary):
if line[CSVname]:
args[modelName] = dictionary[html_to_wiki(line[CSVname])]
addToArgs(EntranceName, 'name')
addToArgs(Explorers, 'explorers')
addToArgs(Map, 'map_description')
addToArgs(Location, 'location_description')
addToArgs(Approach, 'approach')
addToArgs(EntranceDescription, 'entrance_description')
addToArgs(UndergroundDescription, 'underground_description')
addToArgs(PhotoOfLocation, 'photo')
addToArgsViaDict(Marking, 'marking', {"Paint": "P",
"Paint (?)": "P?",
"Tag": "T",
"Tag (?)": "T?",
"Retagged": "R",
"Retag": "R",
"Spit": "S",
"Spit (?)": "S?",
"Unmarked": "U",
"": "?",
})
addToArgs(MarkingComment, 'marking_comment')
addToArgsViaDict(Findability, 'findability', {"Surveyed": "S",
"Lost": "L",
"Refindable": "R",
"": "?",
"?": "?",
})
addToArgs(FindabilityComment, 'findability_description')
addToArgs(Easting, 'easting')
addToArgs(Northing, 'northing')
addToArgs(Altitude, 'alt')
addToArgs(DescriptionOfOtherPoint, 'other_description')
def addToArgsSurveyStation(CSVname, modelName):
if line[CSVname]:
surveyPoint = models.SurveyStation(name = line[CSVname])
save(surveyPoint)
args[modelName] = html_to_wiki(surveyPoint)
addToArgsSurveyStation(TagPoint, 'tag_station')
addToArgsSurveyStation(ExactEntrance, 'exact_station')
addToArgsSurveyStation(OtherPoint, 'other_station')
addToArgs(OtherPoint, 'other_description')
if line[GPSpreSA]:
addToArgsSurveyStation(GPSpreSA, 'other_station')
args['other_description'] = 'pre selective availability GPS'
if line[GPSpostSA]:
addToArgsSurveyStation(GPSpostSA, 'other_station')
args['other_description'] = 'post selective availability GPS'
addToArgs(Bearings, 'bearings')
newEntrance = models.Entrance(**args)
save(newEntrance)
if line[Entrances]:
entrance_letter = line[Entrances]
else:
entrance_letter = ''
newCaveAndEntrance = models.CaveAndEntrance(cave = newCave, entrance = newEntrance, entrance_letter = entrance_letter)
save(newCaveAndEntrance)

197
troggle/parsers/logbooks.py Normal file
View File

@ -0,0 +1,197 @@
#.-*- coding: utf-8 -*-
import settings
import expo.models as models
import csv
import sqlite3
import re
import os
import datetime
# Dave Johnson (Stonker) is hacked -- are there two of this DJ name
# Dave Collins (Scout) is hacked
# Letty ten Harkel has middle , tu = timeug or ""name removed
# the <span lang=""sv""> have been removed
# Dave Milne (Lummat)
# Ben van Millingen
# Rebecca Lawson (Becka)
persontab = open(os.path.join(settings.EXPOWEB, "noinfo", "folk.csv"))
personreader = csv.reader(persontab)
headers = personreader.next()
header = dict(zip(headers, range(len(headers))))
def LoadExpos():
models.Expedition.objects.all().delete()
y = models.Expedition(year = "2008", name = "CUCC expo2008")
y.save()
for year in headers[5:]:
y = models.Expedition(year = year, name = "CUCC expo%s" % y)
y.save()
def LoadPersons():
models.Person.objects.all().delete()
models.PersonExpedition.objects.all().delete()
expoers2008 = """Edvin Deadman,Kathryn Hopkins,Djuke Veldhuis,Becka Lawson,Julian Todd,Natalie Uomini,Aaron Curtis,Tony Rooke,Ollie Stevens,Frank Tully,Martin Jahnke,Mark Shinwell,Jess Stirrups,Nial Peters,Serena Povia,Olly Madge,Steve Jones,Pete Harley,Eeva Makiranta,Keith Curtis""".split(",")
expomissing = set(expoers2008)
for person in personreader:
name = person[header["Name"]]
name = re.sub("<.*?>", "", name)
lname = name.split()
if len(lname) >= 2:
firstname, lastname = lname[0], lname[1]
else:
firstname, lastname = lname[0], ""
print firstname, lastname
#assert lastname == person[header[""]], person
pObject = models.Person(first_name = firstname,
last_name = lastname,
is_guest = person[header["Guest"]] == "1",
is_vfho = person[header["VfHO member"]],
mug_shot = person[header["Mugshot"]])
pObject.save()
for year, attended in zip(headers, person)[5:]:
yo = models.Expedition.objects.filter(year = year)[0]
if attended == "1" or attended == "-1":
pyo = models.PersonExpedition(person = pObject, expedition = yo)
pyo.save()
if name in expoers2008:
print "2008:", name
expomissing.discard(name)
yo = models.Expedition.objects.filter(year = "2008")[0]
pyo = models.PersonExpedition(person = pObject, expedition = yo)
pyo.save()
print expomissing
for name in expomissing:
firstname, lastname = name.split()
pObject = models.Person(first_name = firstname,
last_name = lastname,
is_guest = name in ["Eeva Makiranta", "Kieth Curtis"],
is_vfho = False,
mug_shot = "")
pObject.save()
yo = models.Expedition.objects.filter(year = "2008")[0]
pyo = models.PersonExpedition(person = pObject, expedition = yo)
pyo.save()
#
# the logbook loading section
#
def GetTripPersons(trippeople, expedition):
res = [ ]
author = None
for tripperson in re.split(",|\+|&| and ", trippeople):
tripperson = tripperson.strip()
mul = re.match("<u>(.*?)</u>$", tripperson)
if mul:
tripperson = mul.group(1)
if tripperson and tripperson[0] != '*':
#assert tripperson in personyearmap, "'%s' << %s\n\n %s" % (tripperson, trippeople, personyearmap)
personyear = expedition.GetPersonExpedition(tripperson)
print personyear
res.append(personyear)
if mul:
author = personyear
if not author:
author = res[-1]
return res, author
def Parselogwikitxt(year, personyearmap, txt):
trippara = re.findall("===(.*?)===([\s\S]*?)(?====)", txt)
for triphead, triptext in trippara:
tripheadp = triphead.split("|")
assert len(tripheadp) == 3, tripheadp
tripdate, tripplace, trippeople = tripheadp
tripsplace = tripplace.split(" - ")
tripcave = tripsplace[0]
tul = re.findall("T/?U:?\s*(\d+(?:\.\d*)?|unknown)\s*(hrs|hours)?", triptext)
if tul:
#assert len(tul) <= 1, (triphead, triptext)
#assert tul[0][1] in ["hrs", "hours"], (triphead, triptext)
triptime = tul[0][0]
else:
triptime = ""
#assert tripcave == "Journey", (triphead, triptext)
assert re.match("\d\d\d\d-\d\d-\d\d", tripdate), tripdate
ldate = datetime.date(int(tripdate[:4]), int(tripdate[5:7]), int(tripdate[8:10]))
lbo = models.LogbookEntry(date = ldate, cave = tripcave, title = tripsplace[-1], text = triptext, tu = triptime)
lbo.save()
trippersons, author = GetTripPersons(trippeople, personyearmap)
for tripperson in trippersons:
lbo.cavers.add(tripperson)
# add the author
def Parseloghtmltxt(year, expedition, txt):
tripparas = re.findall("<hr\s*/>([\s\S]*?)(?=<hr)", txt)
for trippara in tripparas:
s = re.match('''(?x)\s*(?:<a\s+id="(.*?)"\s*/>)?
\s*<div\s+class="tripdate"\s*(?:id="(.*?)")?>(.*?)</div>
\s*<div\s+class="trippeople">(.*?)</div>
\s*<div\s+class="triptitle">(.*?)</div>
([\s\S]*?)
\s*(?:<div\s+class="timeug">(.*?)</div>)?
\s*$
''', trippara)
assert s, trippara
tripid, tripid1, tripdate, trippeople, triptitle, triptext, timeug = s.groups()
mdatestandard = re.match("(\d\d\d\d)-(\d\d)-(\d\d)", tripdate)
mdategoof = re.match("(\d\d?)/(\d)/(\d\d)", tripdate)
if mdatestandard:
year, month, day = int(mdatestandard.group(1)), int(mdatestandard.group(2)), int(mdatestandard.group(3))
elif mdategoof:
day, month, year = int(mdategoof.group(1)), int(mdategoof.group(2)), int(mdategoof.group(3)) + 2000
else:
assert False, tripdate
ldate = datetime.date(year, month, day)
#assert tripid[:-1] == "t" + tripdate, (tripid, tripdate)
trippersons, author = GetTripPersons(trippeople, expedition)
tripcave = ""
lbo = models.LogbookEntry(date = ldate, place = tripcave, title = triptitle, text = triptext, author=author)
lbo.save()
tu = timeug or ""
for tripperson in trippersons:
pto = models.PersonTrip(personexpedition = tripperson, place=tripcave, date=ldate, timeunderground=tu, logbookentry=lbo)
pto.save()
def LoadLogbooks():
models.LogbookEntry.objects.all().delete()
expowebbase = os.path.join(settings.EXPOWEB, "years") # this could be a url
yearlinks = [
# ("2008", "2008/logbook/2008logbook.txt"),
# ("2007", "2007/logbook/2007logbook.txt"),
# ("2005", "2005/logbook.html"),
("2004", "2004/logbook.html"),
# ("2003", "2003/logbook.html"),
]
for year, lloc in yearlinks:
expedition = models.Expedition.objects.filter(year = year)[0]
fin = open(os.path.join(expowebbase, lloc))
txt = fin.read()
fin.close()
#print personyearmap
if year >= "2007":
Parselogwikitxt(year, personyearmap, txt)
else:
Parseloghtmltxt(year, expedition, txt)
# command line run through the loading stages
LoadExpos()
LoadPersons()
LoadLogbooks()

31
troggle/parsers/survex.py Normal file
View File

@ -0,0 +1,31 @@
import settings
import expo.models as models
import re
import os
def readFile(filename):
for line in fileIterator(settings.SURVEX_DATA, filename):
print line
re_include_extension = re.compile(r"^\s*\*include\s+([^\s]*).svx$", re.IGNORECASE)
re_include_no_extension = re.compile(r"^\s*\*include\s+([^\s]*)$", re.IGNORECASE)
def fileIterator(directory, filename):
f = open(os.path.join(directory, filename + ".svx"), "rb")
for line in f.readlines():
include_extension = re_include_extension.match(line)
include_no_extension = re_include_no_extension.match(line)
def a(include):
link = re.split(r"/|\\", include)
print os.path.join(directory, *link[:-1]), link[-1]
return fileIterator(os.path.join(directory, *link[:-1]), link[-1])
if include_extension:
for b in a(include_extension.groups()[0]):
yield b
elif include_no_extension:
for b in a(include_no_extension.groups()[0]):
yield b
else:
yield line
readFile("all")

84
troggle/settings.py Normal file
View File

@ -0,0 +1,84 @@
from localsettings import *
# Django settings for troggle2 project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@domain.com'),
)
MANAGERS = ADMINS
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'Europe/London'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-uk'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = '/media-admin/'
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = 'http://127.0.0.1:8000/site_media/'
SVX_URL = 'http://127.0.0.1:8000/troggle/survex/'
# 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 = '/media-admin/'
APPEND_SLASH = False
SMART_APPEND_SLASH = True
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'a#vaeozn0)uz_9t_%v5n#tj)m+%ace6b_0(^fj!355qki*v)j2'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
'troggle.middleware.SmartAppendSlashMiddleware'
)
ROOT_URLCONF = 'troggle.urls'
TEMPLATE_DIRS = (
"templates"
# 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.
)
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.redirects',
'troggle.expo'
)

View File

@ -0,0 +1,12 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="{{ settings.MEDIA_URL }}/css/main2.css" />
<title>{% block title %}{% endblock %}</title>
</head>
<body>
{% block content %}{% endblock %}
{% block footer %}{% endblock %}
</body>
</html>

View File

@ -0,0 +1,76 @@
{% extends "base.html" %}
{% load wiki_markup %}
{% block title %}{{ cave.official_name|wiki_to_html }}{% endblock %}
{% block content %}
<table id="cavepage">
<tr>
<th id="kat_no">
{% if cave.kataster_number %}
{{ cave.kataster_number|wiki_to_html }}
{% if cave.entrancelist %}
- {{ cave.entrancelist|wiki_to_html }}
{% endif %}
{% if cave.unofficial_number %}
<br />({{ cave.unofficial_number|wiki_to_html }})
{% endif %}
{% endif %}
</th>
<th id="name">
{{ cave.official_name|wiki_to_html }}
</th>
<th id="status">
{{ cave.kataster_code|wiki_to_html }}
</th>
</tr>
</table>
{% if cave.entrances %}
<h2>Entrances</h2>
{% for ent in cave.entrances %}
<a href = "./{{ ent.entrance_letter|wiki_to_html }}">{{ ent.entrance_letter|wiki_to_html }}</a>
{% if ent.entrance.marking %}
Marking: {{ ent.entrance.marking_val|wiki_to_html }}
{% endif %}
<br>
{% endfor %}
{% endif %}
{% if cave.explorers %}
<h2>Explorers</h2>
{{ cave.explorers|wiki_to_html }}
{% endif %}
{% if cave.underground_description %}
<h2>Underground Description</h2>
{{ cave.underground_description|wiki_to_html }}
{% endif %}
{% if cave.equipment %}
<h2>Equipment</h2>
{{ cave.equipment|wiki_to_html }}
{% endif %}
{% if cave.references %}
<h2>References</h2>
{{ cave.references|wiki_to_html }}
{% endif %}
{% if cave.survey %}
<h2>Survey</h2>
{{ cave.survey|wiki_to_html }}
{% endif %}
{% if cave.kataster_status %}
<h2>Kataster_status</h2>
{{ cave.kataster_status|wiki_to_html }}
{% endif %}
{% if cave.underground_centre_line %}
<h2>Underground Centre Line</h2>
{{ cave.underground_centre_line|wiki_to_html }}
{% endif %}
{% if cave.survex_file %}
<h2>Survex File</h2>
{{ cave.survex_file|wiki_to_html }}
{% endif %}
{% if cave.notes %}
<h2>Notes</h2>
{{ cave.notes|wiki_to_html }}
{% endif %}
{% endblock %}

View File

@ -0,0 +1,10 @@
{% extends "base.html" %}
{% load wiki_markup %}
{% block title %}Cave Index{% endblock %}
{% block content %}
{% for cave in caves %}
<p>{{ cave }} <a href="./{{ cave.kataster_number }}/">{{ cave.official_name|wiki_to_html }}</a> </p>
{% endfor %}
{% endblock %}

View File

@ -0,0 +1,80 @@
{% extends "base.html" %}
{% load wiki_markup %}
{% block title %}{{ cave.official_name|wiki_to_html }} - {{ entrance_letter|wiki_to_html }}{% endblock %}
{% block content %}
<table id="cavepage">
<tr>
<th id="kat_no">
{% if cave.kataster_number %}
{{ cave.kataster_number|wiki_to_html }}{{ letter|wiki_to_html }}
{% if cave.unofficial_number %}
<br />({{ cave.unofficial_number|wiki_to_html }})
{% endif %}
{% endif %}
</th>
<th id="name">
{% if entrance.name %}
{{ entrance.name|wiki_to_html }}
{% else %}
Unnamed
{% endif %} - {{ cave.official_name|wiki_to_html }}
</th>
<th id="status">
{{ cave.kataster_code|wiki_to_html }}
</th>
</tr>
</table>
{% if entrance.entrance_description %}
<h2>Entrance Description</h2>
{{ entrance.entrance_description|wiki_to_html }}
{% endif %}
{% if entrance.explorers %}
<h2>Explorers</h2>
{{ entrance.explorers|wiki_to_html }}
{% endif %}
{% if entrance.map_description %}
<h2>Map</h2>
{{ entrance.map_description|wiki_to_html }}
{% endif %}
{% if entrance.explorers %}
<h2>Entrance Description</h2>
{{ entrance.entrance_description|wiki_to_html }}
{% endif %}
{% if entrance.location_description %}
<h2>Location Description</h2>
{{ entrance.location_description|wiki_to_html }}
{% endif %}
{% if entrance.approach %}
<h2>Approach</h2>
{{ entrance.approach|wiki_to_html }}
{% endif %}
{% if entrance.underground_description %}
<h2>Underground Description</h2>
{{ entrance.underground_description|wiki_to_html }}
{% endif %}
{% if entrance.photo %}
<h2>Photo</h2>
{{ entrance.photo|wiki_to_html }}
{% endif %}
{% if entrance.marking %}
<h2>Marking - {{ entrance.marking_val|wiki_to_html }}</h2>
{% if entrance.marking_comment %}
{{ entrance.marking_comment|wiki_to_html }}
{% endif %}
{% endif %}
{% if entrance.findability %}
<h2>Findability - {{ entrance.findability_val|wiki_to_html }}</h2>
{% if entrance.findability_description %}
{{ entrance.findability_description|wiki_to_html }}
{% endif %}
{% endif %}
{% if entrance.bearings %}
<h2>Bearings</h2>
{{ entrance.bearings|wiki_to_html }}
{% endif %}
{% endblock %}

View File

@ -0,0 +1,19 @@
{% extends "base.html" %}
{% load survex_markup %}
{% block title %}{{ title }}{% endblock %}
{% block content %}
<H1>{{ title }}</H1>
<div><a href="{{ settings.SVX_URL }}{{ title }}.svx">Download svx file</a></div>
{% if has_3d %}
<div><a href="{{ settings.SVX_URL }}{{ title }}.3d">Download 3d file</a></div>
<div><a href="{{ settings.SVX_URL }}{{ title }}.err">Download err file</a></div>
{% else %}
<div>Processing failed</div>
{% endif %}
<div><a href="{{ settings.SVX_URL }}{{ title }}.log">Download log file</a></div>
{{ text|survex_to_html }}
{% endblock %}

23
troggle/urls.py Normal file
View File

@ -0,0 +1,23 @@
from django.conf.urls.defaults import *
from expo.views import *
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Example:
(r'^troggle/cave/$', caveindex),
(r'^troggle/cave/(?P<cave_id>[^/]+)/$', cave),
(r'^troggle/cave/(?P<cave_id>[^/]+)/(?P<ent_letter>[^/]?)$', ent),
(r'^troggle/survex/(?P<survex_file>.*)\.index$', index),
(r'^troggle/survex/(?P<survex_file>.*)\.svx$', svx),
(r'^troggle/survex/(?P<survex_file>.*)\.3d$', threed),
(r'^troggle/survex/(?P<survex_file>.*)\.log$', log),
(r'^troggle/survex/(?P<survex_file>.*)\.err$', err),
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^admin/(.*)', admin.site.root),
(r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': 'c:/expodjango/troggle/media/'}),
)