blob: 72c88d1c128707e1a807d6f2a61998d386219851 (
plain)
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
|
;; index.cljs.hl - The gnunet-web website
;; Copyright (C) 2013,2014 David Barksdale <amatus@amatus.name>
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
(page "index.html"
(:require [amatus.code :as code]
[gnunet-web.core :as core]
[gnunet-web.hostlist :as hostlist]
[gnunet-web.service :as service]
[gnunet-web.transport :as transport]))
(set! *print-fn* #(.log js/console %))
(defn peer-id-short
[peer]
(.substr (code/base32-crockford peer) 0 4))
(def topology-worker (service/start-worker "topology"
"js/gnunet-daemon-topology.js"))
(def fs-worker (service/start-worker "fs" "js/gnunet-service-fs.js"))
(defc my-id [])
(transport/monitor (fn [message] (reset! my-id (:public-key message))))
(defc peers {})
(transport/monitor-peers (fn [message]
(swap! peers
#(-> %
(assoc-in [(:peer message) :transport-state]
(:state message))
(assoc-in [(:peer message) :address]
(:address message))
(assoc-in [(:peer message) :plugin]
(:plugin message))))))
(core/monitor-peers (fn [message]
(if (not (= 6 (:state message)))
(swap! peers assoc-in [(:peer message) :core-state]
(:state message)))))
(hostlist/fetch-and-process!)
(defelem ui-button
[attr kids]
((div :class "ui button") attr kids))
(html
(head
(link :rel "stylesheet" :type "text/css" :href "css/semantic.min.css")
(script :src "js/semantic.min.js"))
(body
(div :class "ui header"
:title (cell= (code/base32-crockford my-id))
(text "My Peer ID: ~(peer-id-short my-id)\u2026"))
(table :class "ui table segment"
(thead
(tr
(th :text "Peer ID")
(th :text "Transport State")
(th :text "Core State")
(th :text "Address")))
(tbody
(loop-tpl :bindings [[peer info] peers]
(tr
(td :width "25%"
:title (cell= (code/base32-crockford peer))
(text "~(peer-id-short peer)\u2026"))
(td :width "25%"
:text (cell= (transport/state->string
(:transport-state info))))
(td :width "25%"
:text (cell= (core/state->string
(:core-state info))))
(td :width "25%"
:text (cell= (transport/addr->string
(:address info))))))))
(div :class "ui active inline loader")))
;; vim: set expandtab ts=2 sw=2 filetype=clojure :
|