diff --git a/books/views.py b/books/views.py
index f94b32e..27d88ac 100644
--- a/books/views.py
+++ b/books/views.py
@@ -1,46 +1,5 @@
-from django.shortcuts import render
from . import models
-from django.template import loader
-
-import functools
-
-def rerender(funky):
- @functools.wraps(funky)
- def wrap(req,*args,**kwargs):
- with open('main/utils/navs') as b:
- navs=parsecat(b,4)
- namednavs=[{'id':blah[0], 'link':blah[1], 'text':blah[2], 'align':int(blah[3])} for blah in navs['']]
- out=funky(*args,**kwargs)
- temp=loader.get_template('main/nav.html')
- out['nav']=temp.render({"navs":namednavs},None)
- return render(req, 'main/temp.html', out)
- return wrap
-
-def parsecat(file,n):
- if not isinstance(file,str):
- # Assume open handle
- stuff=file.read()
- else:
- with open(f'main/pages/{file}') as b:
- stuff=b.read()
- cats=stuff.split('\n\n')
- out={}
- head=''
- out['']=[]
- for cat in cats:
- if ':' in cat[:cat.index('\n')]:
- # We have a category name
- head,cat=cat.split('\n',1)
- head=head[:-1]
- out[head]=[]
- else: head=''
- for line in cat.split('\n'):
- lin=line.split(',',n-1)
- pad=n-len(lin)
- lin.extend(['']*pad)
- out[head].append(lin)
- if out['']==[]: del(out[''])
- return out
+from rakka.utils import rerender
@rerender
def index():
diff --git a/main/views.py b/main/views.py
index 2d5fed1..a2283af 100644
--- a/main/views.py
+++ b/main/views.py
@@ -1,50 +1,10 @@
-from django.shortcuts import render
from django.http import HttpResponse
-from django.template import loader
import random as ra
import asyncio
from . import mdl
from .models import Page,Contact,Update
-import functools
-
-def rerender(funky):
- @functools.wraps(funky)
- def wrap(req,*args,**kwargs):
- with open('main/utils/navs') as b:
- navs=parsecat(b,4)
- namednavs=[{'id':blah[0], 'link':blah[1], 'text':blah[2], 'align':int(blah[3])} for blah in navs['']]
- out=funky(*args,**kwargs)
- temp=loader.get_template('main/nav.html')
- out['nav']=temp.render({"navs":namednavs},None)
- return render(req, 'main/temp.html', out)
- return wrap
-
-def parsecat(file,n):
- if not isinstance(file,str):
- # Assume open handle
- stuff=file.read()
- else:
- with open(f'main/pages/{file}') as b:
- stuff=b.read()
- cats=stuff.split('\n\n')
- out={}
- head=''
- out['']=[]
- for cat in cats:
- if ':' in cat[:cat.index('\n')]:
- # We have a category name
- head,cat=cat.split('\n',1)
- head=head[:-1]
- out[head]=[]
- else: head=''
- for line in cat.split('\n'):
- lin=line.split(',',n-1)
- pad=n-len(lin)
- lin.extend(['']*pad)
- out[head].append(lin)
- if out['']==[]: del(out[''])
- return out
+from rakka.utils import rerender,parsecat
@rerender
def index():
@@ -56,7 +16,7 @@ def index():
stuff=stuff.format(ra.choice(ids))
return {'title':'Home','content':stuff,'date':'2021/12/15'}
-def lii(obj):
+def lii(obj): # This will get moved to a template shortly
name=obj.name
if obj.url: name=f"{name}"
if obj.comment: name=f"{name} ({obj.comment})"
@@ -99,7 +59,7 @@ def songs():
@rerender
def nerdshope():
- return {'title':'Nerds\' Hope','content':"Store stuff. TODO. Will include inventory and budget. FB
Address is 21 Kensington St, Glenorchy
Off dates 2022:Dunno yet.
NYE party 31st Dec.",'date':'2021/12/24'}
+ return {'title':"Nerds' Hope",'content':"Store stuff. TODO. Will include inventory and budget. FB
Address is 21 Kensington St, Glenorchy
Off dates 2022: 25th Feb, 4th March, 6th May, 17th June, 24th June",'date':'2022/02/09'}
def teapot(req):
return HttpResponse("You're probably missing the joke.",status=418)
diff --git a/rakka/urls.py b/rakka/urls.py
index c477c82..d70dc31 100644
--- a/rakka/urls.py
+++ b/rakka/urls.py
@@ -20,5 +20,6 @@ from . import views
urlpatterns = [
path('admin/', admin.site.urls),
path('books/',include('books.urls')),
+ path('comment/',include('comment.urls')),
path('', include('main.urls')),
]
diff --git a/rakka/utils.py b/rakka/utils.py
new file mode 100644
index 0000000..dc8b173
--- /dev/null
+++ b/rakka/utils.py
@@ -0,0 +1,41 @@
+from django.shortcuts import render
+from django.template import loader
+import functools
+
+def rerender(funky):
+ @functools.wraps(funky)
+ def wrap(req,*args,**kwargs):
+ with open('main/utils/navs') as b:
+ navs=parsecat(b,4)
+ namednavs=[{'id':blah[0], 'link':blah[1], 'text':blah[2], 'align':int(blah[3])} for blah in navs['']]
+ out=funky(*args,**kwargs)
+ temp=loader.get_template('main/nav.html')
+ out['nav']=temp.render({"navs":namednavs},None)
+ return render(req, 'main/temp.html', out)
+ return wrap
+
+def parsecat(file,n):
+ if not isinstance(file,str):
+ # Assume open handle
+ stuff=file.read()
+ else:
+ with open(f'main/pages/{file}') as b:
+ stuff=b.read()
+ cats=stuff.split('\n\n')
+ out={}
+ head=''
+ out['']=[]
+ for cat in cats:
+ if ':' in cat[:cat.index('\n')]:
+ # We have a category name
+ head,cat=cat.split('\n',1)
+ head=head[:-1]
+ out[head]=[]
+ else: head=''
+ for line in cat.split('\n'):
+ lin=line.split(',',n-1)
+ pad=n-len(lin)
+ lin.extend(['']*pad)
+ out[head].append(lin)
+ if out['']==[]: del(out[''])
+ return out
\ No newline at end of file