-
Notifications
You must be signed in to change notification settings - Fork 1
/
embed.php
196 lines (183 loc) · 4.93 KB
/
embed.php
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?php
$zoom = $_GET['zoom'] ?? '1';
$re = $_GET['region'] ?? '';
$sy = $_GET['sy'] ?? '';
$ey = $_GET['ey'] ?? '';
$pe = $_GET['id'] ?? '';
$gr = $_GET['gid'] ?? '';
$faves = $_GET['faves'] ?? '';
$frag = $_GET['frag'] ?? '';
if (!empty($re)){
$datastring[] = 'region='.$re;
$querystring[] = 'region='.$re;
}
if (!empty($sy)){
$datastring[] = 'sy='.$sy;
$querystring[] = 'sy='.$sy;
}
if (!empty($ey)){
$datastring[] = 'ey='.$ey;
$querystring[] = 'ey='.$ey;
}
if (!empty($pe)){
$datastring[] = 'id='.$pe;
$querystring[] = 'pid='.$pe;
}
if (!empty($gr)){
$datastring[] = 'gid='.$gr;
$querystring[] = 'gid='.$gr;
}
if (!empty($faves)){
$datastring[] = 'faves='.$faves;
$querystring[] = 'faves='.$faves;
}
if (!empty($frag)){
$datastring[] = 'frag='.$frag;
$querystring[] = 'frag='.$frag;
}
include '../core/inc.php';
include 'db/cognizdb.php';
include 'db/cognizqueries.php';
include 'regions.php';
if($re != ''){
$area = $regions[$re];
}
else {
$area = 'All regions';
}
if($sy){
if($sy > 0){
$sd = $sy;
}
if($ey > 0){
$sd .= '-'.$ey.'';
}
else {$sd .= ' to present';}
}
$json = 'https://www.coreymwamba.co.uk/resources/rhizome/rhizome-json.php?'.join('&',$datastring);
/*$qu = join('&',$querystring);
if($qu){
$qjson = file_get_contents('https://www.coreymwamba.co.uk/resources/rhizome/embed?'.$qu);
$dq = json_decode($qjson,true);
$graph = $dq[0]["@graph"][0];
}
*/
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>RHIZOME embed</title>
<style>
@font-face {
font-family: 'Muli';
src: url('https://www.coreymwamba.co.uk/styles/fonts/muli.woff') format('woff');
font-display: fallback;
font-weight: 100;
}
* {margin: 0; padding:0}
body {
font-size: 100%;
width: 100vw;
height: 100vh;
box-sizing: border-box;
margin:1em auto;
padding:0;
font-family: "Muli", sans-serif;
}
a:link, a:visited {color: blue; font-weight: 700}
a:hover {color: orange; text-decoration: none; cursor: pointer}
.links line {
stroke: #999;
stroke-opacity: 0.6;
}
.nodes circle {
stroke: #fff;
stroke-width: 1.5px;
}
.node:hover {
cursor: pointer;
}
svg#rhizome {
overflow: hidden;
width: 100%; height: 100%;
-moz-transform: scale(<?php echo $zoom; ?>);
-o-transform: scale(<?php echo $zoom; ?>);
transform: scale(<?php echo $zoom; ?>);
zoom: <?php echo $zoom; ?>;
}
#metadata ul{
list-style: none;
}
span#credit {font-size: 7px; position: absolute; top: 0px; left: 0px; width: 300px; z-index: 800}
iframe {display: block; width: 90%; height: 30em; border: 1px solid #bbb; margin-top: 1em }
main {font-size: 100%}
</style>
</head>
<body>
<?php
if (isset($datastring)){
echo '<main>';
if (empty($frag)){
echo '<span id="credit"><a href="https://www.coreymwamba.co.uk/resources/rhizome?'.join('&',$datastring).'" target="_blank">RHIZOME by Corey Mwamba and Tom Ward</a></span>';
}
echo '<svg id="rhizome" data-query="'.join('&',$datastring).'"></svg>'."\n";
echo '<script src="https://www.coreymwamba.co.uk/resources/rhizome/d3.min.js"></script>'."\n";
echo '<script src="https://www.coreymwamba.co.uk/resources/rhizome/rhizome-2.js"></script>'."\n";
echo '</main>';
}
else {
?>
<link href="https://www.coreymwamba.co.uk/resources/style.css" rel="stylesheet" />
<main>
<h1>RHIZOME embed endpoint</h1>
<p>This is a simple embed endpoint for RHIZOME data. Use this endpoint with parameters to produce a page that can be used in an HTML <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe">iframe</a>.</p>
<h2>example</h2>
<p>Preview a chart for <a href="https://www.coreymwamba.co.uk/resources/rhizome/embed?id=rachel-musson-1acf7057&zoom=2" target="queryres">Rachel Musson</a></dd>
<dt>HTML</dt>
<dd><code><iframe src="https://www.coreymwamba.co.uk/resources/rhizome/embed?id=rachel-musson-1acf7057&zoom=2"></iframe></code></dd>
<iframe name="queryres">The preview will appear here.</iframe>
</main>
<aside>
<dl>
<dt>GET Parameters</dt>
<dd>
<dl>
<dt>zoom (1...10)</dt>
<dd>initial zoom level of network graph</dd>
<dt>name (string)</dt>
<dd>a general search for a person or group. Cannot be used with other parameters.</dd>
<dt>id (id)</dt><dd>person ID. Cannot be used with other parameters.</dd>
<dt>gid (id)</dt><dd>group ID. Cannot be used with other parameters.</dd>
<dt>region (code)</dt>
<dd>filter groups by geographical region.<dd>
<dt>sy (year)</dt>
<dd>year group was formed</dd>
<dt>ey (year)</dt>
<dd>year group was disbanded</dd>
<dt>faves (checksum)</dt>
<dd>checksum generated by Pick and Mix generator</dd>
</dl>
</dd>
</dl>
</aside>
<?php
include '../menu.html';
}
?>
<script>
function displayMus(id){
var nameInput = document.getElementById("sr");
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if (this.readyState==4 && this.status==200){
nameInput.innerHTML = this.responseText;
}
}
xhr.open("GET","https://www.coreymwamba.co.uk/resources/rhizome/groupsearch.php?k="+encodeURIComponent(id));
xhr.send();
}
</script>
</body>
</html>