This repository has been archived by the owner on Dec 27, 2022. It is now read-only.
/
graph.html
154 lines (152 loc) · 5.33 KB
/
graph.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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="/assets/styles.css">
<link rel="stylesheet" href="/assets/syntax.css">
</head>
<body class="page">
<nav>
<h1><a href="/">Unwalled.Garden</a></h1>
<ul>
<li>Docs
<ul>
<li><a href="/docs/how-does-it-work">How it works</a></li>
<li><a href="/docs/dat-primer">The Dat protocol</a></li>
<li><a href="/docs/examples/one">Example 1</a></li>
</ul>
</li>
</ul>
<ul>
<li>APIs
<ul>
<li><a href="/docs/api/bookmarks">Bookmarks</a></li>
<li><a href="/docs/api/graph">Graph</a></li>
<li><a href="/docs/api/posts">Posts</a></li>
<li><a href="/docs/api/profiles">Profiles</a></li>
<li><a href="/docs/api/reactions">Reactions</a></li>
<li><a href="/docs/api/search">Search</a></li>
</ul>
</li>
</ul>
<ul>
<li>Site types
<ul>
<li><a href="/application">Application</a></li>
<li><a href="/module">Module</a></li>
<li><a href="/person">Person</a></li>
<li><a href="/website">Website</a></li>
</ul>
</li>
</ul>
<ul>
<li>JSON types
<ul>
<li><a href="/bookmark">Bookmark</a></li>
<li><a href="/comment">Comment</a></li>
<li><a href="/follows">Follows</a></li>
<li><a href="/post">Post</a></li>
<li><a href="/reaction">Reaction</a></li>
<li><a href="/recommendation">Recommendation</a></li>
</ul>
</li>
</ul>
<ul>
<li>Links
<ul>
<li><a href="https://github.com/beakerbrowser/unwalled.garden">Github Repo</a></li>
<li><a href="https://beakerbrowser.com">Beaker Browser</a></li>
<li><a href="https://dat.foundation">Dat protocol</a></li>
</ul>
</li>
</ul>
</nav>
<main><h2>Graph API</h2><div class="notice">Status: DRAFT. Part of the upcoming <a href="https://beakerbrowser.com">Beaker Browser</a> 0.9 release.</div>
<p>Read and modify social relationships between sites.</p>
<hr>
<pre><code class="language-js"><span class="hljs-keyword">import</span> {graph} <span class="hljs-keyword">from</span> <span class="hljs-string">'dat://unwalled.garden/index.js'</span>
<span class="hljs-comment">// read</span>
<span class="hljs-keyword">await</span> graph.query({
<span class="hljs-attr">filters</span>: {authors},
offset,
limit,
reverse
})
<span class="hljs-keyword">await</span> graph.listFollowers(siteUrl, opts)
<span class="hljs-keyword">await</span> graph.listFollows(siteUrl, opts)
<span class="hljs-keyword">await</span> graph.isAFollowingB(siteUrlA, siteUrlB)
<span class="hljs-comment">// write</span>
<span class="hljs-keyword">await</span> graph.follow(siteUrl)
<span class="hljs-keyword">await</span> graph.unfollow(siteUrl)
</code></pre>
<hr>
<h3><code>Site</code></h3>
<p>The values returned by graph functions will fit the following object shape:</p>
<ul>
<li><var>url</var> <code>string</code></li>
<li><var>title</var> <code>string</code></li>
<li><var>description</var> <code>string</code></li>
<li><var>type</var> <code>string[]</code></li>
</ul>
<hr>
<h3><code>graph.listFollowers(siteUrl, opts)</code></h3>
<p>List the sites known to follow the given URL. (Will only include sites which have been crawled by the local user.)</p>
<ul>
<li><var>siteUrl</var> <code>string</code> <small>The URL of the site to get followers of.</small></li>
<li><var>opts</var> <code>Object</code>
<ul>
<li><var>filters</var> <code>Object</code>
<ul>
<li><var>followedBy</var> <code>string</code> <small>Filters the results to sites which are followed by this URL.</small></li>
</ul>
</li>
<li><var>offset</var> <code>number</code></li>
<li><var>limit</var> <code>number</code></li>
</ul>
</li>
<li>Returns <code>Promise<Site[]></code></li>
</ul>
<hr>
<h3><code>graph.listFollows(siteUrl, opts)</code></h3>
<p>List the sites followed by the given URL.</p>
<ul>
<li><var>siteUrl</var> <code>string</code> <small>The URL of the site to get follows of.</small></li>
<li><var>opts</var> <code>Object</code>
<ul>
<li><var>filters</var> <code>Object</code>
<ul>
<li><var>followedBy</var> <code>string</code> <small>Filters the results to sites which are followed by this URL.</small></li>
</ul>
</li>
<li><var>offset</var> <code>number</code></li>
<li><var>limit</var> <code>number</code></li>
</ul>
</li>
<li>Returns <code>Promise<Site[]></code></li>
</ul>
<hr>
<h3><code>graph.isAFollowingB(siteUrlA, siteUrlB)</code></h3>
<p>Checks whether one site follows the other.</p>
<ul>
<li><var>siteUrlA</var> <code>string</code> <small>The URL of the site which will have its “follows” queried.</small></li>
<li><var>siteUrlB</var> <code>string</code> <small>The URL of the site which will be looked for in the “follows.”</small></li>
<li>Returns <code>Promise<boolean></code></li>
</ul>
<hr>
<h3><code>graph.follow(siteUrl)</code></h3>
<p>Add a follow to the current user’s site.</p>
<ul>
<li><var>siteUrl</var> <code>string</code> <small>The URL of the site to follow.</small></li>
<li>Returns <code>Promise<void></code></li>
</ul>
<hr>
<h3><code>graph.unfollow(siteUrl)</code></h3>
<p>Remove a follow from the current user’s site.</p>
<ul>
<li><var>siteUrl</var> <code>string</code> <small>The URL of the site to unfollow.</small></li>
<li>Returns <code>Promise<void></code></li>
</ul>
</main>
</body>
<script type="module" src="/assets/admin.js"></script>
</html>