git ssb

0+

Josiah / ssb-tags



Commit 0a61f73856a935cde1353f9eed9dc9f27928802f

Public tags

Josiah Witt committed on 12/17/2017, 7:01:45 PM

Files changed

.gitignoreadded
README.mdadded
index.jsadded
package-lock.jsonadded
package.jsonadded
.gitignoreView
@@ -1,0 +1,1 @@
1 +node_modules
README.mdView
@@ -1,0 +1,7 @@
1 +# sbot-tags
2 +
3 +[scuttlebot](http://scuttlebutt.nz/) plugin for indexing reduced "tags" state.
4 +
5 +## License
6 +
7 +MIT
index.jsView
@@ -1,0 +1,48 @@
1 +var FlumeReduce = require('flumeview-reduce')
2 +var ref = require('ssb-ref')
3 +
4 +exports.name = 'sbot-tags'
5 +exports.version = require('./package.json').version
6 +exports.manifest = {
7 + stream: 'source',
8 + get: 'async'
9 +}
10 +
11 +exports.init = function (ssb, config) {
12 + return ssb._flumeUse('tags', FlumeReduce('test', reduce, map))
13 +
14 + function reduce (result, item) {
15 + if (!result) result = {}
16 + if (!result.tags) result.tags = {}
17 + var tags = result.tags
18 +
19 + if (item) {
20 + var { author, tag, message, tagged, timestamp } = item
21 + if (!tags[author]) tags[author] = {}
22 + if (!tags[author][tag]) tags[author][tag] = {}
23 + if (!tags[author][tag][message] || timestamp > tags[author][tag][message].timestamp) {
24 + tags[author][tag][message] = { timestamp, tagged }
25 + }
26 + }
27 +
28 + return result
29 + }
30 +
31 + function map (msg) {
32 + // unbox private message
33 + if (msg.value.content === 'string') {
34 + // unbox private message (requires ssb-private plugin)
35 + msg = ssb.private.unbox(msg)
36 + }
37 +
38 + if (msg.value.content && msg.value.content.type === 'tag' && ref.isLink(msg.value.content.message)) {
39 + return {
40 + tag: msg.key,
41 + author: msg.value.author,
42 + message: msg.value.content.message,
43 + tagged: msg.value.content.tagged,
44 + timestamp: msg.value.timestamp
45 + }
46 + }
47 + }
48 +}
package-lock.jsonView
@@ -1,0 +1,92 @@
1 +{
2 + "name": "sbot-tags",
3 + "version": "0.1.0",
4 + "lockfileVersion": 1,
5 + "requires": true,
6 + "dependencies": {
7 + "async-single": {
8 + "version": "1.0.5",
9 + "resolved": "https://registry.npmjs.org/async-single/-/async-single-1.0.5.tgz",
10 + "integrity": "sha1-El3QneldPqMKN4rb7QIQkhebA8k="
11 + },
12 + "atomic-file": {
13 + "version": "1.1.4",
14 + "resolved": "https://registry.npmjs.org/atomic-file/-/atomic-file-1.1.4.tgz",
15 + "integrity": "sha1-ZhUuOfzosrDH5fJi4KGl06s6q1E="
16 + },
17 + "deep-equal": {
18 + "version": "1.0.1",
19 + "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz",
20 + "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU="
21 + },
22 + "flumecodec": {
23 + "version": "0.0.0",
24 + "resolved": "https://registry.npmjs.org/flumecodec/-/flumecodec-0.0.0.tgz",
25 + "integrity": "sha1-Ns4Gq+Lg4BxE3WnyoWUwWiMgZJs=",
26 + "requires": {
27 + "level-codec": "6.2.0"
28 + }
29 + },
30 + "flumeview-reduce": {
31 + "version": "1.3.10",
32 + "resolved": "https://registry.npmjs.org/flumeview-reduce/-/flumeview-reduce-1.3.10.tgz",
33 + "integrity": "sha1-7fJBtZDbg2zoI1uV5W6QzBrNqCc=",
34 + "requires": {
35 + "async-single": "1.0.5",
36 + "atomic-file": "1.1.4",
37 + "deep-equal": "1.0.1",
38 + "flumecodec": "0.0.0",
39 + "obv": "0.0.0",
40 + "pull-notify": "0.1.1",
41 + "pull-stream": "3.6.1"
42 + }
43 + },
44 + "ip": {
45 + "version": "1.1.5",
46 + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz",
47 + "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo="
48 + },
49 + "is-valid-domain": {
50 + "version": "0.0.5",
51 + "resolved": "https://registry.npmjs.org/is-valid-domain/-/is-valid-domain-0.0.5.tgz",
52 + "integrity": "sha1-SOcDGfy0MAkjbpazf5hDiJzntRM="
53 + },
54 + "level-codec": {
55 + "version": "6.2.0",
56 + "resolved": "https://registry.npmjs.org/level-codec/-/level-codec-6.2.0.tgz",
57 + "integrity": "sha1-pLUkS7akwvcj1oodZOmAxTYn2dQ="
58 + },
59 + "obv": {
60 + "version": "0.0.0",
61 + "resolved": "https://registry.npmjs.org/obv/-/obv-0.0.0.tgz",
62 + "integrity": "sha1-7eq4Ro+R1BkzYu1/kdC5bdOaecE="
63 + },
64 + "pull-notify": {
65 + "version": "0.1.1",
66 + "resolved": "https://registry.npmjs.org/pull-notify/-/pull-notify-0.1.1.tgz",
67 + "integrity": "sha1-b4b/ldJwuJw+vyVbYDG3Ay3JnMo=",
68 + "requires": {
69 + "pull-pushable": "2.1.1"
70 + }
71 + },
72 + "pull-pushable": {
73 + "version": "2.1.1",
74 + "resolved": "https://registry.npmjs.org/pull-pushable/-/pull-pushable-2.1.1.tgz",
75 + "integrity": "sha1-hmZqu+P1QC8ffq0D7v1pt4Xspbg="
76 + },
77 + "pull-stream": {
78 + "version": "3.6.1",
79 + "resolved": "https://registry.npmjs.org/pull-stream/-/pull-stream-3.6.1.tgz",
80 + "integrity": "sha1-xcKuSlEkbv7rzGXAQSo9clqSzgA="
81 + },
82 + "ssb-ref": {
83 + "version": "2.9.0",
84 + "resolved": "https://registry.npmjs.org/ssb-ref/-/ssb-ref-2.9.0.tgz",
85 + "integrity": "sha1-OkN5v0WSO9ipiJaHpMot2YcOCmw=",
86 + "requires": {
87 + "ip": "1.1.5",
88 + "is-valid-domain": "0.0.5"
89 + }
90 + }
91 + }
92 +}
package.jsonView
@@ -1,0 +1,18 @@
1 +{
2 + "name": "sbot-tags",
3 + "description": "scuttlebot plugin for getting reduced 'tags' state",
4 + "version": "0.1.0",
5 + "homepage": "https://github.com/wittjosiah/sbot-tags",
6 + "repository": {
7 + "type": "git",
8 + "url": "git://github.com/wittjosiah/sbot-tags.git"
9 + },
10 + "dependencies": {
11 + "flumeview-reduce": "^1.3.9",
12 + "ssb-ref": "^2.7.1"
13 + },
14 + "devDependencies": {},
15 + "scripts": {},
16 + "author": "Josiah Witt",
17 + "license": "MIT"
18 +}

Built with git-ssb-web