-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaspect
139 lines (114 loc) · 4.81 KB
/
aspect
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF
xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
xmlns:rdfs='http://www.w3.org/2000/01/rdf-schema#'
xmlns:rdfe='http://redfoot.net/3.0/rdf#'
xmlns:template='http://redfoot.net/3.0/template#'
xmlns:kid='http://redfoot.net/3.0/kid#'
xmlns:aspect="http://redfoot.net/3.0/aspect#"
xmlns:code="http://redfoot.net/3.0/code#"
>
<rdfe:Namespace rdf:about="#">
<rdfs:label>Aspect</rdfs:label>
<rdfs:comment>The Redfoot aspect namespace.</rdfs:comment>
</rdfe:Namespace>
<!-- TODO: add type property and change rdf:type Server:Page etc to aspect:type Server:Page etc -->
<!-- TODO: add aspect:Item once we have done aspect:type -->
<!-- But then again, it might be nice to go the quoting route -->
<rdf:Property rdf:ID="item">
<rdfs:label>item</rdfs:label>
<rdfs:comment></rdfs:comment>
<rdfs:domain rdf:resource="#Content"/>
<rdfs:range rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource"/>
</rdf:Property>
<rdf:Property rdf:ID="location">
<rdfs:label>location</rdfs:label>
<rdfs:comment></rdfs:comment>
<rdfs:domain rdf:resource="#Content"/>
<rdfs:range rdf:resource="http://www.w3.org/2000/01/rdf-schema#Literal"/>
</rdf:Property>
<rdfs:Class rdf:ID="Aspect">
<rdfs:label>Aspect</rdfs:label>
<rdfs:comment>An aspect is a set of functionality that is intented to be added to a site.</rdfs:comment>
<rdfs:subClassOf rdf:resource="#Resource"/>
<template:content>
<kid:PagePartHandler rdf:ID="AspectPagePartHandler">
<rdfs:label>Aspect Page Part Handler</rdfs:label>
<kid:template rdf:datatype="http://redfoot.net/3.0/server#Kid">
<![CDATA[
<div xmlns:kid="http://purl.org/kid/ns#" kid:strip="">
<?python
install = URIRef("http://redfoot.net/3.0/aspect#install")
action = request.parameters.get("action")
aspect = request.parameters.get("aspect")
if action=="install" and aspect:
print "installing:", aspect
if allow(install):
print "running:", install
redfoot.execute(install, aspect=URIRef(aspect), base=request.host)
?>
<form kid:if="allow(install)" method="POST" action="" style="display: inline">
<input type="hidden" name="aspect" value="${request.uri.abstract()}"/>
<input type="submit" name="action" value="install"/>
</form>
</div>
]]>
</kid:template>
</kid:PagePartHandler>
</template:content>
</rdfs:Class>
<code:Code rdf:ID="install">
<rdfs:label>Aspect</rdfs:label>
<code:python rdf:datatype="http://www.w3.org/2001/XMLSchema#string">
<![CDATA[
# input:
# aspect -- uri of aspect to install
# base -- xml:base at which to install aspect
site = base # TODO: calc site from base
ASPECT = redfoot.namespace("http://redfoot.net/3.0/aspect#")
TEMPLATE = redfoot.namespace("http://redfoot.net/3.0/template#")
SERVER = redfoot.namespace("http://redfoot.net/3.0/server#")
_logger = redfoot.getLogger(__uri__)
_logger.info("aspect: %s" % aspect)
cid = redfoot.context_id(aspect, context_id="context")
_logger.info("cid: %s" % cid)
redfoot.check(cid)
label = redfoot.label(aspect) or aspect
from urllib import quote
frag = quote(label.lower().replace(" ", "_"))
context = redfoot.get_context(URIRef("%s/%s#aspect" % (base, frag)), creator=__uri__)
context.remove((None, None, None))
context_label = Literal("%s (%s)" % (label, redfoot.label(site) or site))
context.set((context.identifier, RDFS.label, context_label))
for item in redfoot.objects(aspect, ASPECT.item):
if (item, RDF.type, SERVER.Site) in redfoot:
for p, o in redfoot.predicate_objects(item):
context.add((site, p, o))
location = redfoot.value(item, ASPECT.location)
if location:
uri = URIRef(location, base=base)
if (item, RDF.type, TEMPLATE.Section) in redfoot:
context.add((site, TEMPLATE.section, uri))
for p, o in redfoot.predicate_objects(item):
context.add((uri, p, o))
]]>
</code:python>
</code:Code>
<aspect:Aspect rdf:about="bookmark#aspect"/>
<aspect:Aspect rdf:about="browse#aspect"/>
<aspect:Aspect rdf:about="comment#aspect"/>
<aspect:Aspect rdf:about="doap#aspect"/>
<aspect:Aspect rdf:about="editor#aspect"/>
<aspect:Aspect rdf:about="aspects/issues#aspect"/>
<aspect:Aspect rdf:about="aspects/contexts#aspect"/>
<aspect:Aspect rdf:about="aspects/edit_content#aspect"/>
<aspect:Aspect rdf:about="aspects/edit_head#aspect"/>
<aspect:Aspect rdf:about="aspects/generic#aspect"/>
<aspect:Aspect rdf:about="aspects/recipes#aspect"/>
<aspect:Aspect rdf:about="aspects/register#aspect"/>
<aspect:Aspect rdf:about="aspects/auth#aspect"/>
<aspect:Aspect rdf:about="aspects/auth_invite#aspect"/>
<aspect:Aspect rdf:about="aspects/blog#aspect"/>
<aspect:Aspect rdf:about="aspects/documents#aspect"/>
<!-- <aspect:Aspect rdf:about="aspects/items#aspect"/>-->
</rdf:RDF>