-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathindex.html
419 lines (370 loc) · 15 KB
/
index.html
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="X-XRDS-Location"
content="//{{ host }}/.well-known/host-meta.xrds" />
<script type="text/javascript" src="/static/demo.js"></script>
<script type="text/javascript" src="/oauth_dropins_static/util.js"></script>
<title>Granary</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" type="text/css" href="/oauth_dropins_static/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="/oauth_dropins_static/style.css" />
<link rel="stylesheet" type="text/css" href="/oauth_dropins_static/util.css" />
<link rel="stylesheet" type="text/css" href="/static/style.css" />
</head>
<body>
<!-- highlight fragments -->
<style type="text/css">
#contact, #privacy {
transition: background-color 2s;
}
</style>
<script type="text/javascript">
function onHashChange() {
var id = location.href.match(/#(.+)$/);
if (id) {
var elem = document.getElementById(id[1]);
if (elem) {
elem.style.backgroundColor = "#FFFFAA";
}
}
}
window.addEventListener('hashchange', onHashChange);
document.addEventListener('DOMContentLoaded', onHashChange);
function update_and_maybe_submit() {
update_form();
maybe_submit();
}
window.onload = update_and_maybe_submit;
function spinner(visibility) {
elems = document.getElementsByClassName('spinner');
for (i = 0; i < elems.length; i++) {
elems[i].style.visibility = visibility;
}
}
</script>
<main class="tp-main">
<div class="container">
<h1>
<img id="logo" src="/static/granary_logo_512.png" width="128px" />
granary<br>
<small>The social web translator</small>
</h1>
<p class="lead">
Fetches and converts data between
<a href="https://indiewebcamp.com/silo">social networks</a>, HTML and JSON with <a href="http://microformats.org/wiki/microformats2">microformats2</a>, <a href="http://activitystrea.ms/">ActivityStreams</a> 1 and 2 (including <a href="https://activitypub.rocks/">ActivityPub</a>), <a href="http://atomenabled.org/">Atom</a>, <a href="http://www.rssboard.org/rss-specification">RSS</a>, <a href="https://jsonfeed.org/">JSON Feed</a>, and more.
</p>
<p class="lead">
Try it below! Also <a href="https://granary.readthedocs.io/">see the docs</a> and <a href="https://github.com/snarfed/granary">source code</a>.
</p>
<!--
-- oauth login buttons
-->
<br id="logins" />
<div class="login">
<div class="row">
{{ flickr_html|safe }}
{{ github_html|safe }}
{{ mastodon_html|safe }}
{{ pixelfed_html|safe }}
<div class="col-lg-2 col-sm-4 col-xs-6">
<form method="get" action="#logins">
<input type="image" class="shadow" title="Nostr" id="nostr"
src="/static/nostr_button.png" height="50" />
<input name="site" type="hidden" value="nostr" />
</form></div>
<div class="col-lg-2 col-sm-4 col-xs-6">
<form method="get" action="#logins">
<input type="image" class="shadow" title="Bluesky" id="bluesky"
src="/oauth_dropins_static/bluesky_logotype.png" height="50"
style="background-color: #EEEEEE" />
<input name="site" type="hidden" value="bluesky" />
</form></div>
<div class="col-lg-2 col-sm-4 col-xs-6">
<form method="get" action="#logins">
<input type="image" class="shadow" title="ActivityStreams"
src="/static/activitystreams_logotype_2x.png" height="50" />
<input name="input" type="hidden" value="activitystreams" />
</form></div>
<div class="col-lg-2 col-sm-4 col-xs-6">
<form method="get" action="#logins">
<input type="image" class="shadow" title="Microformats2" height="50"
src="/static/microformats_2x.png"
style="background-color: #EEEEEE; padding: 5px" />
<input name="input" type="hidden" value="mf2-json" />
</form></div>
<div class="col-lg-2 col-sm-4 col-xs-6">
<form method="get" action="#logins">
<input type="image" class="shadow" title="JSON Feed"
src="/static/jsonfeed_button.png" height="50" />
<input name="input" type="hidden" value="jsonfeed" />
</form></div>
<div class="col-lg-2 col-sm-4 col-xs-6">
<form method="get" action="#logins">
<input type="image" class="shadow" title="HTML" id="html"
src="/static/html_button_2x.png" height="50" />
<input name="input" type="hidden" value="html" />
</form></div>
<div class="col-lg-2 col-sm-4 col-xs-6">
<form method="get" action="#logins">
<input type="image" class="shadow" title="Atom" id="atom"
src="/static/atom_button.png" height="50" style="background-color: #EEEEEE" />
<input name="input" type="hidden" value="atom" />
</form></div>
<div class="col-lg-2 col-sm-4 col-xs-6">
<form method="get" action="#logins">
<input type="image" class="shadow" title="RSS" id="rss"
src="/static/rss_button.png" height="50" />
<input name="input" type="hidden" value="rss" />
</form></div>
</div>
</div>
<!--
-- interactive for
8000
m
-->
{% if access_token or access_token_key or access_token_secret or input or site
or declined or error or failure %}
<div class="row">
<p class="lead"><em>
<span style="color: red">
{% if declined or error %}
Please accept the prompt to try the demo.
{% endif %}
{% if failure %}
Error: {{ failure }}</span>
{% endif %}
</span>
{% if entity %}
<span style="color: green">
Authenticated as {{ entity.user_display_name() }} on {{ entity.site_name() }}.</span>
{% endif %}
</em></p>
</div>
{% if entity or site %}
<form id="demo-form" action="/demo" method="get" target="results"
onsubmit="spinner('visible')">
<input type="hidden" id="site" name="site" value="{{ site }}" />
<input type="hidden" name="cache" value="false" />
<p><code>
<label>/ {{ site }} </label>
{% if site in ('mastodon', 'pixelfed') %}
<input type="hidden" id="instance" name="instance" value="{{ entity.instance() }}" />
{% endif %}
{% if site == 'nostr' %}
<label>/ </label>
<input id="relay" name="relay" type="relay" class="form-control"
value="relay.nos.social" placeholder="relay" size="19" required />
{% endif %}
{% if site != 'github' %}
<label>/ </label>
<input id="user_id" name="user_id" type="text" class="form-control"
{% if site == 'instagram' %}
placeholder="username" size="12" required
{% else %}{% if site in ('mastodon', 'pixelfed') %}
value="{{ entity.user_id() }}" placeholder="user id" size="19" required
{% else %}
{% set name = 'handle' if site == 'bluesky' else 'user npub' if site == 'nostr' else 'username' %}
placeholder="{{ name }} ({% if site == 'bluesky' %}required{% else %}optional{% endif %})" size="22"
{% endif %}
{% endif %} />
<label> / </label>
{% endif %}
{% if site == 'facebook' %}
<label> @self </label>
<input type="hidden" id="group_id" name="group_id" value="@self" />
{% elif site != 'github' %}
<select id="group_id" name="group_id" onchange="update_form()">
{% if site != 'instagram' %}
<option value="@all">@all</option>
{% endif %}
<option value="@self">@self</option>
<option value="@friends">@friends</option>
{% if site in ('mastodon', 'pixelfed', 'reddit') %}
<option value="@search">@search</option>
{% endif %}
</select>
<input id="list" name="list" type="text" class="form-control"
placeholder="list name" size="12" />
{% endif %}
<label>/ @app </label>
<span id="activity_id_span">
<label for="activity_id"> / </label>
<input id="activity_id" name="activity_id" type="text" class="form-control"
placeholder="activity id (optional)"
size="{% if site == 'bluesky' %} 32 {% else %} 22 {% endif %}" />
</span>
?
<span id="search_query_span">
<label for="search_query">search_query =</label>
<input id="search_query" name="search_query" type="text" class="form-control"
placeholder="search query" size="12" />
&
</span>
<label for="format">format =</label>
<select id="format" name="format">
<option value="as1" {% if output == 'as1' %} selected {% endif %}>as1</option>
<option value="as1-xml" {% if output == 'as1-xml' %} selected {% endif %}>as1-xml</option>
<option value="as2" {% if output == 'as2' %} selected {% endif %}>as2</option>
<option value="atom" {% if output == 'atom' %} selected {% endif %}>atom</option>
<option value="bluesky" {% if output == 'bluesky' %} selected {% endif %}>bluesky</option>
<option value="html" {% if output == 'html' %} selected {% endif %}>html</option>
<option value="jsonfeed" {% if output == 'jsonfeed' %} selected {% endif %}>jsonfeed</option>
<option value="mf2-json" {% if output == 'mf2-json' %} selected {% endif %}>mf2-json</option>
<option value="nostr" {% if output == 'nostr' %} selected {% endif %}>nostr</option>
<option value="rss" {% if output == 'rss' %} selected {% endif %}>rss</option>
</select>
{% if site not in ('github', 'nostr') %}
<br>
{% endif %}
{% if access_token %}
<label for="access_token">& access_token =</label>
<input id="access_token" name="access_token" type="text" size="10"
class="form-control" value="{{ access_token }}" />
{% endif %}
{% if access_token_key and access_token_secret %}
<label for="access_token_key">& access_token_key =</label>
<input id="access_token_key" name="access_token_key" type="text" size="10"
class="form-control" value="{{ access_token_key }}" />
<label for="access_token_secret">& access_token
8000
_secret =</label>
<input id="access_token_secret" name="access_token_secret" type="text" size="10"
class="form-control" value="{{ access_token_secret }}" />
{% endif %}
{% if refresh_token %}
<label for="refresh_token">& refresh_token =</label>
<input id="refresh_token" name="refresh_token" type="text" size="10"
class="form-control" value="{{ refresh_token }}" />
{% endif %}
{% if site == 'bluesky' %}
<label for="app_password">&
<a href="https://github.com/bluesky-social/atproto-ecosystem/blob/main/app-passwords.md"
title="In the Bluesky app or web site, Settings => App passwords">
app_password</a>
=</label>
</a>
<input id="app_password" name="app_password" type="text" size="30"
class="form-control" value="{{ app_password }}"
placeholder="(optional for some requests)"/>
{% endif %}
{% if site == 'instagram' %}
<nobr>
<label for="cookie">& cookie =</label>
<input id="cookie" name="cookie" type="text" class="form-control"
placeholder="sessionid cookie (for @friends)" size="31" />
</nobr>
{% endif %}
</code>
<input type="hidden" name="cache" value="false" />
<input type="hidden" name="interactive" value="true" />
<br>
<button type="submit" class="btn btn-default"
onclick="render_demo_request()">GET</button>
<img id="demo-spinner" class="spinner" src="/static/spinner.gif" width="30" />
</p>
</form>
{% endif %}
{% if input %}
<form id="url-form" action="/url" method="get" target="results"
onsubmit="spinner('visible')">
<p><code>
<label>/ url ? input = </label>
<select id="input" name="input">
<option {% if input == "activitystreams" %} selected {% endif %}
value="as2">as2</option>
<option value="as1">as1</option>
<option {% if input == "atom" %} selected {% endif %}
value="atom">atom</option>
<option {% if input == "html" %} selected {% endif %}
value="html">html</option>
<option {% if input == "mf2-json" %} selected {% endif %}
value="mf2-json">mf2-json</option>
<option {% if input == "jsonfeed" %} selected {% endif %}
value="jsonfeed">jsonfeed</option>
<option {% if input == "rss" %} selected {% endif %}
value="rss">rss</option>
<option {% if input == "bluesky" %} selected {% endif %}
value="bluesky">bluesky</option>
</select>
<label>& output = </label>
<select id="output" name="output">
<option {% if output == "as1" %} selected {% endif %} value="as1">as1</option>
<option {% if output == "as1-xml" %} selected {% endif %} value="as1-xml">as1-xml</option>
<option {% if output == "as2" %} selected {% endif %} value="as2">as2</option>
<option {% if output == "atom" %} selected {% endif %} value="atom">atom</option>
<option {% if output == "bluesky" %} selected {% endif %} value="bluesky">bluesky</option>
<option {% if output == "html" %} selected {% endif %} value="html">html</option>
<option {% if output == "jsonfeed" %} selected {% endif %} value="jsonfeed">jsonfeed</option>
<option {% if output == "mf2-json" %} selected {% endif %} value="mf2-json">mf2-json</option>
<option {% if output == "nostr" %} selected {% endif %} value="nostr">nostr</option>
<option {% if output == "rss" %} selected {% endif %} value="rss">rss</option>
</select>
<label>& url = </label>
<input id="url" name="url" type="url" required class="form-control"
placeholder="http://example.com/post.html" size="30" value="{{ url }}" />
<input type="hidden" name="plaintext" value="true" />
<input type="hidden" name="cache" value="false" />
<input type="hidden" name="interactive" value="true" />
<button type="submit" class="btn btn-default"
onclick="render_url_request()">GET</button>
</code>
<img id="url-spinner" class="spinner" src="/static/spinner.gif" width="30" />
</p>
</form>
{% endif %}
<div id="results">
<p><code id="request"></code></p>
<iframe name="results" onload="spinner('hidden')" onerror="spinner('hidden')">
</iframe>
</div>
{% else %}
<!--
-- not showing interactive form
-->
<div class="container">
<p class="lead">
The <a href="https://granary.readthedocs.io/">library</a> also includes:
</p>
<div class="col-lg-2 col-sm-4 col-xs-6">
<a href="https://granary.readthedocs.io/en/latest/source/granary.html#module-granary.twitter">
<img class="shadow" src="/oauth_dropins_static/twitter_2x.png" height="50" />
</a>
</form>
</div>
<div class="row">
<div class="col-lg-2 col-sm-4 col-xs-6">
<a href="https://granary.readthedocs.io/en/latest/source/granary.html#module-granary.facebook">
5333
;
<img class="shadow" src="/oauth_dropins_static/facebook_2x.png" height="50" />
</a>
</div>
<div class="col-lg-2 col-sm-4 col-xs-6">
<a href="https://granary.readthedocs.io/en/latest/source/granary.html#module-granary.instagram">
<img class="shadow" src="/oauth_dropins_static/instagram_2x.png" height="50"
style="background-color: #EEEEEE; padding: 5px; padding-top: 8px; padding-bottom: 2px" />
</a>
</div>
<div class="col-lg-2 col-sm-4 col-xs-6">
<a href="https://granary.readthedocs.io/en/latest/source/granary.html#module-granary.meetup">
<img class="shadow" src="/oauth_dropins_static/meetup_2x.png" height="50"
style="background-color: #EEEEEE; padding: 10px" />
</a>
</div>
<div class="col-lg-2 col-sm-4 col-xs-6">
<a href="https://granary.readthedocs.io/en/latest/source/granary.html#module-granary.reddit">
<img class="shadow" src="/oauth_dropins_static/reddit_2x.png" height="50"
style="background-color: #CEE3F8; padding: 10px;" />
</a>
</div>
</div>
</div>
{% endif %}
<div class="row">
<p id="privacy" class="lead">This app does not store or use any data, yours or
anyone else's. It only reformats data and passes it through in response to your
own HTTP requests.
<a id="contact" href="https://github.com/snarfed/granary/issues">Questions?</a></p>
</div>
</div>
</main>
</body>
</html>