Compare commits

...

No commits in common. "e04705e16128714ed0b3fd01b2320850183c17cd" and "3cb8bacb31e250d7d228335c92bf138727c91a6f" have entirely different histories.

6 changed files with 80 additions and 31 deletions

View File

@ -44,6 +44,7 @@ class AppWeb(object):
ceil=math.ceil,
statusstr=lambda x: str(x).split(".")[-1])
self.node = NodesWeb(self)
self.classes = ClassWeb(self)
def render(self, template, **kwargs):
"""
@ -55,25 +56,13 @@ class AppWeb(object):
"""
Return a dict containing variables expected to be on every page
"""
#s = self.session()
# all tags / albums with photos visible under the current auth context
# tagq = s.query(Tag).join(TagItem).join(PhotoSet)
# if not auth():
# tagq = tagq.filter(PhotoSet.status == PhotoStatus.public)
# tagq = tagq.filter(Tag.is_album == False).order_by(Tag.name).all() # pragma: manual auth
# albumq = s.query(Tag).join(TagItem).join(PhotoSet)
# if not auth():
# albumq = albumq.filter(PhotoSet.status == PhotoStatus.public)
# albumq = albumq.filter(Tag.is_album == True).order_by(Tag.name).all() # pragma: manual auth
ret = {
"all_tags": [], #tagq,
"all_albums": [], #albumq,
"path": cherrypy.request.path_info,
"auth": True or auth()
}
#s.close()
with self.nodes.db.transaction() as c:
ret = {
"classes": c.root.classes,
# "all_albums": [],
"path": cherrypy.request.path_info,
"auth": True or auth()
}
return ret
@cherrypy.expose
@ -84,6 +73,7 @@ class AppWeb(object):
obj = c.root.nodes[fqdn] if fqdn in c.root.nodes else NObject(fqdn, body)
obj.body = body
c.root.nodes[fqdn] = obj
raise cherrypy.HTTPRedirect("node/{}".format(fqdn), 302)
with self.nodes.db.transaction() as c:
yield self.render("node_edit.html", node=c.root.nodes.get(node, None))
@ -133,6 +123,24 @@ class NodesWeb(object):
yield self.render("node.html", node=c.root.nodes[node])
@cherrypy.popargs("cls")
class ClassWeb(object):
def __init__(self, root):
self.root = root
self.nodes = root.nodes
self.render = root.render
@cherrypy.expose
def index(self, cls):
# with self.nodes.db.transaction() as c:
yield self.render("classes.html")
@cherrypy.expose
def op(self, cls, op=None, name=None):
# with self.nodes.db.transaction() as c:
yield self.render("classes.html")
def main():
import argparse
import signal

View File

@ -2,6 +2,7 @@ import ZODB
import ZODB.FileStorage
import persistent
import persistent.list
import persistent.mapping
import BTrees.OOBTree
@ -9,12 +10,16 @@ def plist():
return persistent.list.PersistentList()
def pmap():
return persistent.mapping.PersistentMapping()
class NObject(persistent.Persistent):
def __init__(self, fqdn, body):
self.fqdn = fqdn
self.parents = plist()
self.classes = plist()
self.classes = pmap()
self.body = body
@ -27,7 +32,7 @@ class NClass(persistent.Persistent):
class NClassAttachment(persistent.Persistent):
def __init__(self, cls, conf):
self.cls = persistent.list.PersistentList()
self.cls = cls
self.conf = conf
@ -39,6 +44,8 @@ class NodeOps(object):
with self.db.transaction() as c:
if "nodes" not in c.root():
c.root.nodes = BTrees.OOBTree.BTree()
if "classes" not in c.root():
c.root.classes = persistent.list.PersistentList()
# def add_photoset(self, photoset):
# """

22
templates/classes.html Normal file
View File

@ -0,0 +1,22 @@
{% extends "page.html" %}
{% block title %}All classes{% endblock %}
{% block subtitle %}<a href="/node_edit">Add</a>{% endblock %}
{% block buttons %}{% endblock %}
{% block body %}
<div class="classes-all">
{% for node in classes %}
<div class="class">
<h2>{{ node.fqdn }}</h2>
<p>
<a href="/node/{{ node.fqdn }}">view</a> <a href="/node_edit?node={{ node.fqdn }}">edit</a>
</p>
<pre>
{{ node.body }}
</pre>
</div>
{% endfor %}
</div>
{% endblock %}

View File

@ -3,26 +3,37 @@
{% block subtitle %}placehoolder{% endblock %}
{% block buttons %}
<form action="/tag/{{ tag.uuid }}/op" method="post">
{% if tag.is_album %}<input type="submit" class="secondary-button pure-button" name="op" value="Demote to tag" />{% else %}
<input type="submit" class="secondary-button pure-button" name="op" value="Promote to album" />{% endif %}
<!--<form action="/node/{{ node.fqdn }}/op" method="post">
<input type="submit" class="secondary-button pure-button" name="op" value="Make all public" />
<input type="submit" class="secondary-button pure-button" name="op" value="Make all private" />
<input type="submit" class="secondary-button pure-button" name="op" value="Delete tag" />
</form>
</form>-->
<a href="//node/{{ node.fqdn }}/attach"><button class="secondary-button pure-button">Attach class</button></a>
{% endblock %}
{% block body %}
<div class="nodes-single">
<div class="node">
<h2>{{ node.name }}</h2>
<p>
<div class="node_info">
<h2>{{ node.name }}</h2>
<p>
</p>
<pre>
</p>
<pre>
{{ node.body }}
</pre>
</pre>
</div>
<div class="node-classes">
<h2>Classes</h2>
<div class="class-list">
{% for class in node.classes %}
<div class="class">
{{ class.cls.name }}
</div>
{% endfor %}
</div>
</div>
</div>
</div>

View File

@ -3,7 +3,7 @@
{% block subtitle %}{% if node %}Editing "{{ node.fqdn }}"{% else %}New item{% endif %}{% endblock %}
{% block buttons %}
{% if node is defined %}<a href="/nodes/{{ image.uuid }}"><button class="secondary-button pure-button">Back</button></a>{% endif %}
{% if node is defined %}<a href="/nodes/{{ node.fqdn }}"><button class="secondary-button pure-button">Back</button></a>{% endif %}
{% endblock %}
{% block body %}

View File

@ -15,6 +15,7 @@
<ul class="pure-menu-list">
<li class="pure-menu-item"><a href="/" class="pure-menu-link">Nodes</a></li>
<li class="pure-menu-item"><a href="/objects" class="pure-menu-link">Objects</a></li>
<li class="pure-menu-item"><a href="/classes" class="pure-menu-link">Classes</a></li>
<li class="pure-menu-item"><a href="/lookup" class="pure-menu-link">Lookup</a></li>
<li class="pure-menu-heading">Albums</li>
{% for tag in all_albums %}