zold 0.9.11 → 0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 76a4eedb7d10def207298c7f125a6c9fbe392bec
4
- data.tar.gz: 04f8e073cea64e11e7989d1c943a629295e45425
3
+ metadata.gz: 8a814090449cd1c18d0ecbe1829aff24ea56faec
4
+ data.tar.gz: 3c123ae97703d66da02fadb2504c1e880da5c1a0
5
5
  SHA512:
6
- metadata.gz: b70bdc247fa5230a8a6709578d603f1e7a87f8b3a758abc663dc5cf603136f49f8049a1df90fb709c728cf8a9d8b4ca9fcedbc9b0e15ee209ec2556cffe996be
7
- data.tar.gz: 9dbfe9ece397a9ef7a6ee65e771ac560fe4aacc2ceb1ac77d291bb53b0d263ddc4349ae45e00ecc8c47564dab15f304a639e6440828325a7cded1a2e7de4db52
6
+ metadata.gz: 34da8c63b94f5fa6227c8ad1b432f444647d1ce6482d4b5bab48b127072976c0f956131ed660330653b2135ba343e17604d8693ad759a299ce9b693d5b01bf4f
7
+ data.tar.gz: c6a8bb7d55f2f2171cded95ad75c5b43877cbd77ff95f321979ff54d860a322cc269c3e2081f8f1874a112e1b8363b42095434092c4b38e04571cd4b403bc15c
data/Procfile CHANGED
@@ -1 +1 @@
1
- web: LC_ALL=UTF-8 ./bin/zold node --no-colors --verbose --trace --bind-port=$PORT --port=80 --host=b1.zold.io --threads=0 --standalone --invoice=JKFq17yipfjLtX@0000000000000000 --never-reboot
1
+ web: LC_ALL=UTF-8 ./bin/zold node --no-colors --verbose --trace --bind-port=$PORT --port=80 --host=b1.zold.io --threads=0 --invoice=JKFq17yipfjLtX@0000000000000000 --never-reboot
data/html/map.html ADDED
@@ -0,0 +1,128 @@
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ (The MIT License)
4
+
5
+ Copyright (c) 2018 Yegor Bugayenko
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the 'Software'), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
24
+ -->
25
+ <!DOCTYPE html>
26
+ <html>
27
+ <head>
28
+ <meta charset="utf-8"/>
29
+ <title>Zold nodes map</title>
30
+ <meta name="description" content="Full map of visible Zold nodes"/>
31
+ <meta name="keywords" content="zerocracy, management, robotocracy, meritocracy"/>
32
+ <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
33
+ <link rel="shortcut icon" href="https://www.zold.io/logo.png"/>
34
+ <script src="https://maps.google.com/maps/api/js">
35
+ // Should be empty
36
+ </script>
37
+ <script src="https://code.jquery.com/jquery-3.3.1.min.js">
38
+ // Should be empty
39
+ </script>
40
+ <style>
41
+ * { box-sizing: border-box; margin: 0; padding: 0; font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; }
42
+ html { height: 100% }
43
+ body { height: 100%; }
44
+ #container { width: 100%; height: 100% }
45
+ #map { width: 80%; height: 100%; display: inline-block; }
46
+ #nodes { width: 20%; height: 100%; background-color: #f5f5f5; float: right; padding: 1em; }
47
+ #logo { position: absolute; bottom: 1em; right: 1em; width: 48px; height: 48px; }
48
+ #remotes { margin-top: 1em; }
49
+ #remotes li { list-style: none; }
50
+ </style>
51
+ <script>
52
+ function init() {
53
+ var options = {
54
+ center: new google.maps.LatLng(55.751244, 37.618423),
55
+ mapTypeId: google.maps.MapTypeId.ROADMAP,
56
+ zoom: 3
57
+ };
58
+ var remotes = {};
59
+ var map = new google.maps.Map(document.getElementById("map"), options);
60
+ $.getJSON('/', function(data) {
61
+ $('#header').html(
62
+ 'Version: ' + data['version'] + '<br/>' +
63
+ 'Host: ' + data['score']['host'] + ':' + data['score']['port'] + '<br/>' +
64
+ 'Score: ' + data['score']['value'] + '<br/>' +
65
+ 'Wallets: ' + data['wallets']
66
+ );
67
+ });
68
+ window.setInterval(function() {
69
+ $.getJSON('/remotes', function(data) { remotes = data['all']; });
70
+ }, 10000);
71
+ window.setInterval(function() {
72
+ $('#remotes li').each(function (li) {
73
+ found = $.grep(remotes, function (r, i) { return r['host'] + ':' + r['port'] == li.attr('data-coords'); });
74
+ if (!found.length) {
75
+ li.remove();
76
+ }
77
+ });
78
+ }, 10000);
79
+ window.setInterval(function() {
80
+ $.each(remotes, function (idx, remote) {
81
+ var host = remote['host'], port = remote['port'];
82
+ var coords = host + ':' + port;
83
+ var items = $('#remotes li[data-coords="' + coords + '"]');
84
+ if (items.length) {
85
+ var li = items.first();
86
+ $.getJSON('http://' + coords + '/', function(data) {
87
+ coords + ': ' + data['score']['value'] + '/' + data['wallets'] + ' (' + li.html(data['version'] + ')');
88
+ })
89
+ .done(function() { li.css('color', 'darkgreen'); })
90
+ .fail(function() { li.css('color', 'red'); });
91
+ var ip = host;
92
+ if (!ip.match(/[0-9\.]+/)) {
93
+ $.get('http://api.konvert.me/forward-dns/' + host, function(data) {
94
+ ip = data
95
+ });
96
+ }
97
+ $.getJSON('http://ip-api.com/json/' + ip, function(data) {
98
+ new google.maps.Marker({
99
+ position: { lat: data['lat'], lng: data['lon'] },
100
+ map: map,
101
+ title: coords
102
+ });
103
+ });
104
+ } else {
105
+ $('#remotes').append('<li data-coords="' + coords + '">' + coords + '</li>')
106
+ }
107
+ });
108
+ }, 1000);
109
+ };
110
+ </script>
111
+ </head>
112
+ <body onload="init();">
113
+ <div id="container">
114
+ <div id="map">
115
+ <!-- Empty on start -->
116
+ </div>
117
+ <div id="nodes">
118
+ <div id="header">
119
+ <!-- Empty on start -->
120
+ </div>
121
+ <ul id="remotes">
122
+ <!-- Empty on start -->
123
+ </ul>
124
+ </div>
125
+ <img id="logo" src="https://www.zold.io/logo.svg"/>
126
+ </div>
127
+ </body>
128
+ </html>
@@ -96,6 +96,7 @@ module Zold
96
96
  Zold::Front.set(
97
97
  :entrance, Entrance.new(wallets, remotes, copies, address, log: @log)
98
98
  )
99
+ Zold::Front.set(:root, Dir.pwd)
99
100
  Zold::Front.set(:port, opts['bind-port'])
100
101
  Zold::Front.set(:reboot, !opts['never-rebootw'])
101
102
  invoice = opts[:invoice]
@@ -74,6 +74,7 @@ module Zold
74
74
  headers['Cache-Control'] = 'no-cache'
75
75
  headers['Connection'] = 'close'
76
76
  headers['X-Zold-Version'] = VERSION
77
+ headers['Access-Control-Allow-Origin'] = '*'
77
78
  end
78
79
 
79
80
  get '/robots.txt' do
@@ -143,6 +144,11 @@ module Zold
143
144
  )
144
145
  end
145
146
 
147
+ get %r{/(?<page>.+\.html)} do
148
+ content_type 'text/html'
149
+ File.read(File.join(settings.root, "html/#{params[:page]}"))
150
+ end
151
+
146
152
  not_found do
147
153
  status 404
148
154
  content_type 'text/plain'
data/lib/zold/version.rb CHANGED
@@ -23,5 +23,5 @@
23
23
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
24
24
  # License:: MIT
25
25
  module Zold
26
- VERSION = '0.9.11'.freeze
26
+ VERSION = '0.10'.freeze
27
27
  end
@@ -22,7 +22,6 @@ require 'tmpdir'
22
22
  require 'webmock/minitest'
23
23
  require_relative '../../lib/zold/log'
24
24
  require_relative '../../lib/zold/http'
25
- require_relative '../../lib/zold/commands/node'
26
25
 
27
26
  # Fake node.
28
27
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -43,6 +42,7 @@ class FakeNode
43
42
  begin
44
43
  Thread.current.abort_on_exception = true
45
44
  home = File.join(dir, 'node-home')
45
+ require_relative '../../lib/zold/commands/node'
46
46
  Zold::Node.new(log: @log).run(
47
47
  [
48
48
  '--standalone',
@@ -55,7 +55,7 @@ class FakeNode
55
55
  ]
56
56
  )
57
57
  rescue StandardError => e
58
- @log.error(e.message + "\n" + e.backtrace.join("\n"))
58
+ @log.error(e.message + "\n" + e.backtrace.join("\n\t"))
59
59
  end
60
60
  end
61
61
  home = URI("http://localhost:#{port}/")
@@ -35,6 +35,7 @@ class FrontTest < Minitest::Test
35
35
  '200' => [
36
36
  '/robots.txt',
37
37
  '/',
38
+ '/map.html',
38
39
  '/remotes'
39
40
  ],
40
41
  '404' => [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.11
4
+ version: '0.10'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
@@ -290,6 +290,7 @@ files:
290
290
  - fixtures/scripts/calculate-scores.sh
291
291
  - fixtures/scripts/print-helps.sh
292
292
  - fixtures/scripts/push-and-pull.sh
293
+ - html/map.html
293
294
  - lib/zold.rb
294
295
  - lib/zold/amount.rb
295
296
  - lib/zold/commands/args.rb