summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/views_caves.py12
-rw-r--r--core/views_logbooks.py2
-rw-r--r--flatpages/views.py65
-rw-r--r--localsettingsubuntu.py7
-rw-r--r--templates/cavebase.html7
-rw-r--r--templates/caveindex.html6
-rw-r--r--templates/dataformat/flatfile.html2
-rw-r--r--templates/editflatpage.html10
-rw-r--r--templates/expobase.html13
-rw-r--r--templates/flatpage.html15
-rw-r--r--templates/menu.html12
-rw-r--r--templates/pagenotfound.html7
12 files changed, 103 insertions, 55 deletions
diff --git a/core/views_caves.py b/core/views_caves.py
index 4a79652..9fcf9b4 100644
--- a/core/views_caves.py
+++ b/core/views_caves.py
@@ -30,39 +30,39 @@ def caveindex(request):
def cave(request, cave_id='', offical_name=''):
cave=getCave(cave_id)
- if cave.non_public and not request.user.is_authenticated():
+ if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated():
return render_with_context(request,'nonpublic.html', {'instance': cave, 'cavepage': True})
else:
return render_with_context(request,'cave.html', {'cave': cave, 'cavepage': True})
def caveEntrance(request, slug):
cave = Cave.objects.get(slug = slug)
- if cave.non_public and not request.user.is_authenticated():
+ if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated():
return render_with_context(request,'nonpublic.html', {'instance': cave})
else:
return render_with_context(request,'cave_entrances.html', {'cave': cave})
def caveDescription(request, slug):
cave = Cave.objects.get(slug = slug)
- if cave.non_public and not request.user.is_authenticated():
+ if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated():
return render_with_context(request,'nonpublic.html', {'instance': cave})
else:
return render_with_context(request,'cave_uground_description.html', {'cave': cave})
def caveQMs(request, slug):
cave = Cave.objects.get(slug = slug)
- if cave.non_public and not request.user.is_authenticated():
+ if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated():
return render_with_context(request,'nonpublic.html', {'instance': cave})
else:
return render_with_context(request,'cave_qms.html', {'cave': cave})
def caveLogbook(request, slug):
cave = Cave.objects.get(slug = slug)
- if cave.non_public and not request.user.is_authenticated():
+ if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated():
return render_with_context(request,'nonpublic.html', {'instance': cave})
else:
return render_with_context(request,'cave_logbook.html', {'cave': cave})
def caveSlug(request, slug):
cave = Cave.objects.get(slug = slug)
- if cave.non_public and not request.user.is_authenticated():
+ if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated():
return render_with_context(request,'nonpublic.html', {'instance': cave})
else:
return render_with_context(request,'cave.html', {'cave': cave})
diff --git a/core/views_logbooks.py b/core/views_logbooks.py
index 2cf9163..0aee9c6 100644
--- a/core/views_logbooks.py
+++ b/core/views_logbooks.py
@@ -5,7 +5,7 @@ import troggle.settings as settings
import django.db.models
from troggle.parsers.logbooks import LoadLogbookForExpedition
from troggle.parsers.people import GetPersonExpeditionNameLookup
-#from troggle.core.forms import PersonForm, getTripForm, get_name
+from troggle.core.forms import getTripForm#, get_name, PersonForm
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, HttpResponse
from django.template import Context, loader
diff --git a/flatpages/views.py b/flatpages/views.py
index e9db223..f46488e 100644
--- a/flatpages/views.py
+++ b/flatpages/views.py
@@ -15,7 +15,6 @@ import os
import re
def flatpage(request, path):
- print "gggggg", path
try:
r = Redirect.objects.get(originalURL = path)
return HttpResponseRedirect(r.newURL) # Redirect after POST
@@ -36,6 +35,7 @@ def flatpage(request, path):
if path.startswith("noinfo") and settings.PUBLIC_SITE and not request.user.is_authenticated():
+ print "flat path noinfo", path
return HttpResponseRedirect(reverse("auth_login") + '?next=%s' % request.path)
if path.endswith("/") or path == "":
@@ -45,29 +45,34 @@ def flatpage(request, path):
except IOError:
try:
o = open(os.path.normpath(settings.EXPOWEB + path + "index.htm"), "rb")
- path = path + "index.html"
+ path = path + "index.htm"
except IOError:
- raise Http404
+ return render_with_context(request, 'pagenotfound.html', {'path': path})
else:
try:
o = open(os.path.normpath(settings.EXPOWEB + path), "rb")
except IOError:
- raise Http404
+ return render_with_context(request, 'pagenotfound.html', {'path': path})
if path.endswith(".htm") or path.endswith(".html"):
html = o.read()
- m = re.search(r"<head>(.*)</head>.*<body>(.*)</body>", html, re.DOTALL)
- mwithid = re.search(r'<head>(.*)</head>.*<body id="([^"]*)">(.*)</body>', html, re.DOTALL)
+ m = re.search(r"<head>(.*)</head>.*<body[^>]*>(.*)</body>", html, re.DOTALL + re.IGNORECASE)
if m:
head, body = m.groups()
- bodyid = None
- elif mwithid:
- head, bodyid, body = mwithid.groups()
else:
return HttpResponse(html + "Page could not be split into header and body")
+ m = re.search(r"<title>(.*)</title>", head, re.DOTALL + re.IGNORECASE)
+ if m:
+ title, = m.groups()
+ else:
+ title = ""
+ linksmatch = re.match('(.*)<ul id="links">', body, re.DOTALL + re.IGNORECASE)
+ if linksmatch:
+ body, = linksmatch.groups()
if re.search(r"iso-8859-1", html):
body = unicode(body, "iso-8859-1")
- return render_with_context(request, 'flatpage.html', {'editable': True, 'path': path, 'head': head, 'body': body, "bodyid": bodyid})
+ body.strip
+ return render_with_context(request, 'flatpage.html', {'editable': True, 'path': path, 'title': title, 'body': body, 'homepage': (path == "index.htm")})
else:
return HttpResponse(o.read(), mimetype=getmimetype(path))
@@ -100,28 +105,44 @@ def editflatpage(request, path):
try:
filepath = os.path.normpath(settings.EXPOWEB + path)
o = open(filepath, "r")
+ html = o.read()
+ m = re.search(r"<head>(.*)</head>.*<body[^>]*>(.*)</body>", html, re.DOTALL + re.IGNORECASE)
+ if m:
+ filefound = True
+ head, body = m.groups()
+ linksmatch = re.match('(.*)<ul\s+id="links">', body, re.DOTALL + re.IGNORECASE)
+ if linksmatch:
+ body, = linksmatch.groups()
+ if re.search(r"iso-8859-1", html):
+ body = unicode(body, "iso-8859-1")
+ else:
+ return HttpResponse("Page could not be split into header and body")
except IOError:
- raise Http404
- html = o.read()
- m = re.search(r"<head>(.*)</head>.*<body>(.*)</body>", html, re.DOTALL)
- if m:
- head, body = m.groups()
- if re.search(r"iso-8859-1", html):
- body = unicode(body, "iso-8859-1")
- else:
- return HttpResponse("Page could not be split into header and body")
+ filefound = False
+
+
if request.method == 'POST': # If the form has been submitted...
flatpageForm = FlatPageForm(request.POST) # A form bound to the POST data
if flatpageForm.is_valid():# Form valid therefore write file
f = open(filepath, "w")
template = loader.get_template('dataformat/flatfile.html')
- context = Context({'form': flatpageForm.cleaned_data, 'head': head})
+ context = Context({'form': flatpageForm.cleaned_data})
f.write(template.render(context))
f.close()
return HttpResponseRedirect(reverse('flatpage', args=[path])) # Redirect after POST
else:
- flatpageForm = FlatPageForm({"html": body})
+ if filefound:
+ m = re.search(r"<title>(.*)</title>", head, re.DOTALL + re.IGNORECASE)
+ if m:
+ title, = m.groups()
+ else:
+ title = ""
+ flatpageForm = FlatPageForm({"html": body, "title": title})
+ else:
+ flatpageForm = FlatPageForm()
return render_with_context(request, 'editflatpage.html', {'path': path, 'form': flatpageForm, })
class FlatPageForm(forms.Form):
- html = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 30}))
+ title = forms.CharField(widget=forms.TextInput(attrs={'size':'60'}))
+
+ html = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 20}))
diff --git a/localsettingsubuntu.py b/localsettingsubuntu.py
index d3457c7..0a1d5e8 100644
--- a/localsettingsubuntu.py
+++ b/localsettingsubuntu.py
@@ -1,9 +1,10 @@
+import sys
# link localsettings to this file for use on expo computer in austria
DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'troggle' # Or path to database file if using sqlite3.
-DATABASE_USER = 'troggler3' # Not used with sqlite3.
-DATABASE_PASSWORD = 'ggg' # Not used with sqlite3.
+DATABASE_USER = 'expo' # Not used with sqlite3.
+DATABASE_PASSWORD = 'gosser' # 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.
@@ -48,4 +49,4 @@ TEMPLATE_DIRS = (
# Don't forget to use absolute paths, not relative paths.
)
-LOGFILE = '/home/expo/expofiles/expoweb/parsing_log.txt'
+LOGFILE = '/home/expo/expofiles/troggle/parsing_log.txt'
diff --git a/templates/cavebase.html b/templates/cavebase.html
index 7e83151..a0ffd4d 100644
--- a/templates/cavebase.html
+++ b/templates/cavebase.html
@@ -16,11 +16,6 @@
</head>
<body>
{% block content %}{% endblock %}
-{% block menu %}
-<ul id="links">
-<li>Back to <a href="/index.htm">Expedition home page</a></li>
-<li>Back to <a href="http://cucc.survex.com/">CUCC home page</a></li>
-</ul>
-{% endblock %}
+{% include "menu.html" %}
</body>
</html>
diff --git a/templates/caveindex.html b/templates/caveindex.html
index 8f16e87..42322d3 100644
--- a/templates/caveindex.html
+++ b/templates/caveindex.html
@@ -10,7 +10,7 @@
<h3>Notable caves</h3>
<ul>
{% for cave in notablecaves %}
- <li> <a href="{{ cave.get_absolute_url }}">{% if cave.kataster_number %}{{ cave.kataster_number }}{% else %}{{cave.unofficial_number }}{%endif %} {{cave.official_name|safe}}</a> </li>
+ <li> <a href="{{ cave.url }}">{% if cave.kataster_number %}{{ cave.kataster_number }}{% else %}{{cave.unofficial_number }}{%endif %} {{cave.official_name|safe}}</a> </li>
{% endfor %}
</ul>
@@ -19,7 +19,7 @@
<ul class="searchable">
{% for cave in caves1623 %}
- <li> <a href="{{ cave.get_absolute_url }}">{% if cave.kataster_number %}{{ cave.kataster_number }}{% else %}{{cave.unofficial_number }}{%endif %} {{cave.official_name|safe}}</a> </li>
+ <li> <a href="{{ cave.url }}">{% if cave.kataster_number %}{{ cave.kataster_number }}{% else %}{{cave.unofficial_number }}{%endif %} {{cave.official_name|safe}}</a> </li>
{% endfor %}
</ul>
@@ -29,7 +29,7 @@
<ul class="searchable">
{% for cave in caves1626 %}
- <li> <a href="{{ cave.get_absolute_url }}">{% if cave.kataster_number %}{{ cave.kataster_number }}{% else %}{{cave.unofficial_number }}{%endif %} {{cave.official_name|safe}}</a> </li>
+ <li> <a href="{{ cave.url }}">{% if cave.kataster_number %}{{ cave.kataster_number }}{% else %}{{cave.unofficial_number }}{%endif %} {{cave.official_name|safe}}</a> </li>
{% endfor %}
</ul>
diff --git a/templates/dataformat/flatfile.html b/templates/dataformat/flatfile.html
index 1ddb7a5..07d03ca 100644
--- a/templates/dataformat/flatfile.html
+++ b/templates/dataformat/flatfile.html
@@ -1,7 +1,7 @@
{% autoescape off %}
<html>
<head>
-{{ head }}
+<title>{{ form.title }}</title>
</head>
<body>
{{ form.html }}
diff --git a/templates/editflatpage.html b/templates/editflatpage.html
index 85a5bcc..4768078 100644
--- a/templates/editflatpage.html
+++ b/templates/editflatpage.html
@@ -1,12 +1,14 @@
-{% extends "base.html" %}
+{% extends "expobase.html" %}
{% block title %}Edit {{ path }}{% endblock %}
-{% block head %}
+{% block extrahead %}
{% load csrffaker %}
<script src="{{ settings.TINY_MCE_MEDIA_URL }}tiny_mce.js" type="text/javascript"></script>
{% endblock %}
-{% block content %}
+{% block body %}
+<h1>Edit {{ path }}</h1>
<form action="" method="post">{% csrf_token %}
-{{form}}
+{{form.as_p}}
<p><input type="submit" value="Submit" /></p>
</form>
+{% include "menu.html" %}
{% endblock %}
diff --git a/templates/expobase.html b/templates/expobase.html
new file mode 100644
index 0000000..5cadb61
--- /dev/null
+++ b/templates/expobase.html
@@ -0,0 +1,13 @@
+{% autoescape off %}
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<title>{% block title %}{% endblock %}</title>
+<link rel="stylesheet" type="text/css" href="/css/main2.css" />
+{% block extrahead %}{% endblock %}
+</head>
+<body {% block bodyattrs %}{% endblock %}>
+{% block body %}{% endblock %}
+</body>
+</html>
+{% endautoescape %}
diff --git a/templates/flatpage.html b/templates/flatpage.html
index 04ff1f8..47863e3 100644
--- a/templates/flatpage.html
+++ b/templates/flatpage.html
@@ -1,10 +1,7 @@
-<html>
-<head>
-{{ head|safe }}
-</head>
-<body{% if bodyid %} id="{{ bodyid }}"{% endif %}>
+{% extends "expobase.html" %}
+{% block title %}{{ title }}{% endblock %}
+{% block bodyattrs %}{% if homepage %} id="homepage"{% endif %}{% endblock %}
+{% block body %}
{{ body|safe }}
-{% if editable %}<a href="{% url editflatpage path %}">Edit</a>{% endif %}
-<a href="/troggle">Troggle</a>
-</body>
-</html>
+{% if homepage %}{% if editable %}<a href="{% url editflatpage path %}">Edit</a>{% endif %}{%else %}{% include "menu.html" %}{% endif %}
+{% endblock %}
diff --git a/templates/menu.html b/templates/menu.html
new file mode 100644
index 0000000..65b8544
--- /dev/null
+++ b/templates/menu.html
@@ -0,0 +1,12 @@
+{% if not homepage %}
+<ul id="links">
+<li><a href="/index.htm">Home</a></li>
+<li><a href="/infodx.htm">Main Index</a></li>
+<li><a href="/troggle">Troggle</a></li>
+<li><a href="/areas.htm">Areas</a></li>
+<li><a href="/indxal.htm">Caves</a></li>
+<li><a href="/handbook/index.htm">Handbook</a></li>
+<li><a href="/pubs.htm">Reports</a></li>
+{% if editable %}<li><a href="{% url editflatpage path %}" class="editlink"><strong>Edit this page</strong></a></li>{% endif %}
+</ul>
+{% endif %}
diff --git a/templates/pagenotfound.html b/templates/pagenotfound.html
new file mode 100644
index 0000000..03569de
--- /dev/null
+++ b/templates/pagenotfound.html
@@ -0,0 +1,7 @@
+{% extends "expobase.html" %}
+{% block title %}Page not found {{ path }}{% endblock %}
+{% block body %}
+<h1>Page not found {{ path }}</h1>
+<a href="{%url editflatpage path %}">Create this page.</a>
+{% include "menu.html" %}
+{% endblock %}