| author | rougeronj |
| Fri, 24 Apr 2015 18:01:45 +0200 | |
| changeset 431 | 1387779706e5 |
| parent 403 | 96781c1a8bbe |
| child 439 | 741fd2028c99 |
| permissions | -rw-r--r-- |
| 249 | 1 |
# Renkan - Client configuration |
2 |
||
|
398
57f8d344fde9
Correct button shift on hover that appeared after paperjs v 0.9.15
ymh <ymh.work@gmail.com>
parents:
265
diff
changeset
|
3 |
Renkan is a tool to simply build oriented graphs by creating nodes and drag'n'droping links, |
|
57f8d344fde9
Correct button shift on hover that appeared after paperjs v 0.9.15
ymh <ymh.work@gmail.com>
parents:
265
diff
changeset
|
4 |
pictures and html elements from web pages. Each node can have title, description, uri/url, color, |
| 249 | 5 |
image and specific size. Each node can have title, uri/url and color. |
6 |
||
7 |
||
8 |
## Embedding Renkan in a web page |
|
9 |
||
10 |
Whatever configuration you have, you need to import those javascript files **in that order**... |
|
11 |
||
12 |
<script src="[...]/jquery.min.js"></script> |
|
13 |
<script src="[...]/jquery.mousewheel.min.js"></script> |
|
14 |
<script src="[...]/underscore-min.js"></script> |
|
15 |
<script src="[...]/backbone.js"></script> |
|
16 |
<script src="[...]/backbone-relational.js"></script> |
|
17 |
<script src="[...]/paper.js"></script> |
|
18 |
<script src="[...]/renkan.js"></script> |
|
19 |
||
20 |
... and the renkan css file : |
|
21 |
||
22 |
<link rel="stylesheet" href="[...]/renkan.css" /> |
|
23 |
||
24 |
Finally, add the div in you DOM : |
|
25 |
||
26 |
<div id="renkan"></div> |
|
27 |
||
28 |
Your Renkan should be displayed. Now let's see more specifically the 2 displays possibilities : in body 100% or in a div with set width and height. |
|
29 |
||
| 251 | 30 |
N.B. : renkan.js is the concatenation of those js files : header.js main.js models.js defaults.js i18n.js paper-renderer.js full-json.js ldtjson-bin.js list-bin.js wikipedia-bin.js. |
|
398
57f8d344fde9
Correct button shift on hover that appeared after paperjs v 0.9.15
ymh <ymh.work@gmail.com>
parents:
265
diff
changeset
|
31 |
It is built with the script available in sbin/build/compil.sh. |
| 249 | 32 |
|
33 |
### In body 100% |
|
34 |
||
35 |
Nothing to add, the html is very simple : |
|
36 |
||
37 |
<body> |
|
38 |
<div id="renkan"></div> |
|
39 |
</body> |
|
40 |
||
41 |
||
42 |
### In a div |
|
43 |
||
|
398
57f8d344fde9
Correct button shift on hover that appeared after paperjs v 0.9.15
ymh <ymh.work@gmail.com>
parents:
265
diff
changeset
|
44 |
The renkan div has the css attributes position:absolute/top:0/left:0/bottom:0/right:0, |
| 250 | 45 |
so the parent div has to be in position:relative and define width and height. Here is a simple example including css and partial html : |
| 249 | 46 |
|
47 |
<head> |
|
48 |
<style type="text/css"> |
|
49 |
body{ |
|
50 |
margin: 0 auto; |
|
51 |
width: 960px; |
|
52 |
} |
|
53 |
.header, .footer { |
|
54 |
font-size: 14px; |
|
55 |
height: 40px; |
|
56 |
padding-top: 10px; |
|
57 |
} |
|
58 |
.rnk-container{ |
|
59 |
height: 500px; |
|
60 |
position: relative; |
|
61 |
width: 700px; |
|
62 |
} |
|
63 |
</style> |
|
64 |
</head> |
|
65 |
<body> |
|
66 |
<div class="header"> |
|
67 |
This is a header |
|
68 |
</div> |
|
69 |
<div class="rnk-container"> |
|
70 |
<div id="renkan"></div> |
|
71 |
</div> |
|
72 |
<div class="footer"> |
|
73 |
This is a footer |
|
74 |
</div> |
|
75 |
</body> |
|
76 |
||
77 |
||
78 |
## Embedding a read only Renkan |
|
79 |
||
80 |
To embed a read only Renkan, just add this script tag : |
|
81 |
||
82 |
<script type="text/javascript"> |
|
83 |
var _renkan; |
|
84 |
$(function() { |
|
85 |
_renkan = new Rkns.Renkan({ |
|
86 |
editor_mode: false, |
|
87 |
show_bins: false, |
|
88 |
}); |
|
89 |
Rkns.jsonIO(_renkan, { |
|
90 |
url: "any_local_or_jsonp_url" |
|
91 |
}); |
|
92 |
}); |
|
93 |
</script> |
|
94 |
||
95 |
||
96 |
||
97 |
## Embedding a writable Renkan |
|
98 |
||
99 |
### Simple mode : no bins on the left, just the canvas |
|
100 |
||
|
398
57f8d344fde9
Correct button shift on hover that appeared after paperjs v 0.9.15
ymh <ymh.work@gmail.com>
parents:
265
diff
changeset
|
101 |
To embed a simple writable Renkan, just add this script tag. In the client folder, "data/simple-persist.php" makes a very simple persistent url. |
| 249 | 102 |
The persistent url is supposed to give the json data on GET request at page load, and save datas at PUT request sent by the browser : |
103 |
||
104 |
<script type="text/javascript"> |
|
105 |
var _renkan; |
|
106 |
$(function() { |
|
107 |
_renkan = new Rkns.Renkan({ |
|
108 |
show_bins: false |
|
109 |
}); |
|
110 |
Rkns.jsonIO(_renkan, { |
|
111 |
url: "url_of_a_persistent_connection" |
|
112 |
}); |
|
113 |
}); |
|
114 |
</script> |
|
115 |
||
116 |
||
| 251 | 117 |
## Search and bins |
118 |
||
119 |
On the right of your renkan interface, you can add some search engine and data bins. |
|
120 |
||
|
398
57f8d344fde9
Correct button shift on hover that appeared after paperjs v 0.9.15
ymh <ymh.work@gmail.com>
parents:
265
diff
changeset
|
121 |
Search engine can be the current [IRI's Lignes de temps platform](http://ldt.iri.centrepompidou.fr/) and wikipedia in any available language. |
| 251 | 122 |
Here is an example of configuration : |
123 |
||
124 |
_renkan = new Rkns.Renkan({ |
|
125 |
search: [ |
|
126 |
{ |
|
127 |
type: "Ldt" |
|
128 |
}, |
|
129 |
{ |
|
130 |
type: "Wikipedia", |
|
131 |
lang: "fr" |
|
132 |
}, |
|
133 |
{ |
|
134 |
type: "Wikipedia", |
|
135 |
lang: "ja" |
|
136 |
} |
|
137 |
] |
|
138 |
}); |
|
139 |
Rkns.jsonIO(_renkan, { |
|
140 |
url: "data/simple-persist.php" |
|
141 |
}); |
|
142 |
||
143 |
You can also define data bins : annotations loaded from IRI's Lignes de temps projects, and any resources which can be drag and dropped into the renkan. |
|
144 |
Resources can be simple texts, links or objects with title, description, url and image. Here is an example of configuration : |
|
145 |
||
146 |
_renkan = new Rkns.Renkan({ |
|
147 |
search: [ |
|
148 |
... |
|
149 |
], |
|
150 |
bins: [ |
|
151 |
{ |
|
152 |
title: "To be or not to be on Lignes de Temps", |
|
153 |
type: "Ldt", |
|
154 |
ldt_type: "Project", |
|
155 |
project_id: "6af4019c-8283-11e2-9678-00145ea4a2be", |
|
156 |
ldt_platform: "http://ldt.iri.centrepompidou.fr/" |
|
157 |
}, |
|
158 |
{ |
|
159 |
type: "ResourceList", |
|
160 |
title: "Ressources", |
|
161 |
list: [ |
|
162 |
{ |
|
163 |
url: "http://www.google.com/", |
|
164 |
title: "Google", |
|
165 |
description: "Search engine", |
|
166 |
image: "http://www.google.fr/images/srpr/logo4w.png" |
|
167 |
}, |
|
168 |
"Polemic Tweet http://www.polemictweet.com", |
|
169 |
"Twitter http://www.twitter.com/" |
|
170 |
] |
|
171 |
} |
|
172 |
] |
|
173 |
}); |
|
174 |
Rkns.jsonIO(_renkan, { |
|
175 |
url: "data/simple-persist.php" |
|
176 |
}); |
|
| 249 | 177 |
|
| 253 | 178 |
If you embed the renkan in a div, the renkan container css should have overflow:hidden in order to hide bins when the user wants to. |
| 249 | 179 |
|
| 251 | 180 |
## More configuration |
181 |
||
182 |
You can configure several things : |
|
183 |
* the language of your interface, english (default) or french |
|
184 |
* you can fill your nodes with black color instead of transparent. |
|
185 |
* thanks to an external file, you can define properties for links between node. |
|
186 |
||
187 |
||
188 |
_renkan = new Rkns.Renkan({ |
|
189 |
... |
|
190 |
property_files: [ "data/properties.json" ], |
|
191 |
node_fill_color: true, |
|
192 |
language: "fr" |
|
193 |
}); |
|
194 |
||
195 |
Here is an example of properties file : |
|
| 249 | 196 |
|
| 251 | 197 |
[ |
198 |
{ |
|
199 |
"label": "Dublin Core Metadata", |
|
200 |
"base-uri": "http://purl.org/dc/elements/1.1/", |
|
201 |
"properties": [ |
|
202 |
{ |
|
203 |
"uri": "creator", |
|
204 |
"label": "created by" |
|
205 |
}, { |
|
206 |
"uri": "date", |
|
207 |
"label": "has date" |
|
208 |
}, { |
|
209 |
"uri": "subject", |
|
210 |
"label": "has subject" |
|
211 |
} |
|
212 |
] |
|
213 |
}, { |
|
214 |
"label": "SKOS Semantic relations", |
|
215 |
"base-uri": "http://www.w3.org/2004/02/skos/core#", |
|
216 |
"properties": [ |
|
217 |
{ |
|
218 |
"uri": "broader", |
|
219 |
"label": "has broader" |
|
220 |
}, { |
|
221 |
"uri": "narrower", |
|
222 |
"label": "has narrower" |
|
223 |
}, { |
|
224 |
"uri": "related", |
|
225 |
"label": "has related" |
|
226 |
} |
|
227 |
] |
|
228 |
} |
|
229 |
] |
|
| 249 | 230 |
|
231 |
||
232 |
||
| 251 | 233 |
Finally, here is an example of full configuration : |
| 249 | 234 |
|
| 251 | 235 |
<script type="text/javascript"> |
236 |
var _renkan; |
|
237 |
$(function() { |
|
238 |
_renkan = new Rkns.Renkan({ |
|
239 |
search: [ |
|
240 |
{ |
|
241 |
type: "Ldt" |
|
242 |
}, |
|
243 |
{ |
|
244 |
type: "Wikipedia", |
|
245 |
lang: "fr" |
|
246 |
}, |
|
247 |
{ |
|
248 |
type: "Wikipedia", |
|
249 |
lang: "ja" |
|
250 |
} |
|
251 |
], |
|
252 |
bins: [ |
|
253 |
{ |
|
254 |
title: "Projet Lignes de Temps", |
|
255 |
type: "Ldt", |
|
256 |
ldt_type: "Project", |
|
257 |
project_id: "6af4019c-8283-11e2-9678-00145ea4a2be", |
|
258 |
ldt_platform: "http://ldt.iri.centrepompidou.fr/" |
|
259 |
}, |
|
260 |
{ |
|
261 |
type: "ResourceList", |
|
262 |
title: "Ressources", |
|
263 |
list: [ |
|
264 |
{ |
|
265 |
url: "http://www.google.com/", |
|
266 |
title: "Google", |
|
267 |
description: "Search engine", |
|
268 |
image: "http://www.google.fr/images/srpr/logo4w.png" |
|
269 |
}, |
|
270 |
"Polemic Tweet http://www.polemictweet.com", |
|
271 |
"Twitter http://www.twitter.com/" |
|
272 |
] |
|
273 |
} |
|
274 |
], |
|
275 |
property_files: [ "data/properties.json" ], |
|
276 |
node_fill_color: false, |
|
277 |
language: "fr" |
|
278 |
}); |
|
279 |
Rkns.jsonIO(_renkan, { |
|
280 |
url: "data/simple-persist.php" |
|
281 |
}); |
|
282 |
}); |
|
| 253 | 283 |
</script> |
284 |
||
|
264
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
285 |
|
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
286 |
## Drop management |
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
287 |
|
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
288 |
You can override, partially or totally, the function that handle the drop event from an other web page. |
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
289 |
The current function catches drops from google results page, tweets, links, images and other things like svg paths. |
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
290 |
If you want to override totally the handler function, you can define a **drop\_handler** function that receives a \_data object |
|
398
57f8d344fde9
Correct button shift on hover that appeared after paperjs v 0.9.15
ymh <ymh.work@gmail.com>
parents:
265
diff
changeset
|
291 |
and returns a node object. A node object has title, description, image and uri properties. The \_data object is received from the |
|
264
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
292 |
browser's drop event. Here is an example of drop\_handler function : |
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
293 |
|
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
294 |
_renkan = new Rkns.Renkan({ |
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
295 |
... |
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
296 |
drop_handler: function(_data){ |
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
297 |
var newNode = {}; |
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
298 |
newNode.title = "Overridden title"; |
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
299 |
newNode.description = "Overridden description " + _data["text/plain"]; |
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
300 |
return newNode; |
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
301 |
} |
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
302 |
}); |
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
303 |
|
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
304 |
|
|
398
57f8d344fde9
Correct button shift on hover that appeared after paperjs v 0.9.15
ymh <ymh.work@gmail.com>
parents:
265
diff
changeset
|
305 |
You can also define a **drop\_enhancer** function that receives the already formed node object and \_data object. This function has to |
|
264
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
306 |
return the overriden node object. Here is an example of drop\_enhancer function : |
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
307 |
|
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
308 |
_renkan = new Rkns.Renkan({ |
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
309 |
... |
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
310 |
drop_enhancer: function(newNode, _data){ |
| 265 | 311 |
newNode.title = "Prefixed title : " + newNode.title; |
|
264
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
312 |
return newNode; |
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
313 |
} |
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
314 |
}); |
|
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
315 |
|
|
431
1387779706e5
update README file to reference the task available in grunt
rougeronj
parents:
403
diff
changeset
|
316 |
## Dev |
|
264
cc1b3aa8cada
drop handler and enhancer functions, and read me explains this.
cavaliet
parents:
253
diff
changeset
|
317 |
|
|
431
1387779706e5
update README file to reference the task available in grunt
rougeronj
parents:
403
diff
changeset
|
318 |
We offer a environment to develop without having to build all the project manually after each change. We define few grunt task to help us |
|
1387779706e5
update README file to reference the task available in grunt
rougeronj
parents:
403
diff
changeset
|
319 |
making it easier. You can launch them by running './node_modules/.bin/grunt task'. |
|
1387779706e5
update README file to reference the task available in grunt
rougeronj
parents:
403
diff
changeset
|
320 |
* 'dev': will build th project but let the temporary file like templates.js to let us test the application through the test files |
|
1387779706e5
update README file to reference the task available in grunt
rougeronj
parents:
403
diff
changeset
|
321 |
(see 'Tests' part below). Then it will launch a small testing server and watch the modifications of the js/css/html to build the project |
|
1387779706e5
update README file to reference the task available in grunt
rougeronj
parents:
403
diff
changeset
|
322 |
again in case of any change. |
|
1387779706e5
update README file to reference the task available in grunt
rougeronj
parents:
403
diff
changeset
|
323 |
|
|
1387779706e5
update README file to reference the task available in grunt
rougeronj
parents:
403
diff
changeset
|
324 |
Tasks for production : |
|
1387779706e5
update README file to reference the task available in grunt
rougeronj
parents:
403
diff
changeset
|
325 |
* 'default': will build the project and clean the temporary files (like templates.js) used during development and building. |
|
1387779706e5
update README file to reference the task available in grunt
rougeronj
parents:
403
diff
changeset
|
326 |
* 'copy-server': will copy the built project to the server side. |
|
1387779706e5
update README file to reference the task available in grunt
rougeronj
parents:
403
diff
changeset
|
327 |
|
| 253 | 328 |
## Tests |
329 |
||
330 |
Because of a simple php file enabling persistent connection, you can not test the writables examples by only opening them in your browser. |
|
331 |
A url like file:///path/to/folder/test-writable-\*.html will not work. |
|
332 |
You need to run a localhost server that executes php and go to a url like http://localhost/renkan/test/test-writable-\*.html. |
|
333 |
||
334 |
For read only examples, it appears that for security reasons urls like file:///path/to/folder/test-readonly-\*.html only work on Firefox. |
|
335 |
To see those examples with other browsers, you also need to run a localhost server and go to a url like http://localhost/renkan/test/test-readonly-\*.html. |