mapexplorer-rails 1.0.0.pre.alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c8dbad4b829760587e41d9f421eec65970e36ad0
4
+ data.tar.gz: 7dfad63a4cbdd04e2255e918e22c7e03551efc42
5
+ SHA512:
6
+ metadata.gz: 60941726ef993e82589fb13ed53b132508fa565e84bd6d0ba65f9b6dc39efbd4d5388b714f327e0c507270f850e6459871fb0ae6733302ed4f176f8e86d376c5
7
+ data.tar.gz: 1837b2dcbb1493981c0adeda58161bf04e828b5c61a421644cc30607abd80654b176334bbbfcbde109791f034ac1213c496fb3d3478e5322bc9c0b068064c576
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2016 adrien
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # Mapexplorer::Rails
2
+ Exposes a simple view helper that displays a Map Explorer.
3
+
4
+ ## Usage
5
+ ```erb
6
+ <%= mapexplorer(application_url: 'http://localhost:3333', map_id: '00583e40-2a91-497b-83bb-ab82ea143324') %>
7
+
8
+ <%= mapexplorer(chainscript: my_chainscript_array) %>
9
+ ```
10
+
11
+ ## Installation
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'mapexplorer-rails'
16
+ ```
17
+
18
+ And then execute:
19
+ ```bash
20
+ $ bundle
21
+ ```
22
+
23
+ Or install it yourself as:
24
+ ```bash
25
+ $ gem install mapexplorer-rails
26
+ ```
27
+
28
+ ## Contributing
29
+ Contribution directions go here.
30
+
31
+ ## License
32
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Mapexplorer::Rails'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ require 'bundler/gem_tasks'
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'lib'
31
+ t.libs << 'test'
32
+ t.pattern = 'test/**/*_test.rb'
33
+ t.verbose = false
34
+ end
35
+
36
+
37
+ task default: :test
File without changes
@@ -0,0 +1,66 @@
1
+ //= require jquery
2
+ //= require turbolinks
3
+ //= require d3
4
+ //= require jsrender
5
+ //= require dist/mapexplorer-core
6
+
7
+ document.addEventListener('turbolinks:load', function() {
8
+
9
+ var segmentTemplate = $.templates("#segment-template");
10
+
11
+ $('.mapexplorer').each(function() {
12
+ var map = $(this);
13
+ var helpers = {
14
+ json: function(val) {
15
+ return JSON.stringify(val, undefined, 2);
16
+ },
17
+ merklePathTree: function(merklePath) {
18
+ setTimeout(function(){
19
+ var tree = new mapexplorerCore.MerklePathTree(map.find('.merkle-path-tree')[0]);
20
+ tree.display(merklePath);
21
+ });
22
+ return '<div class="merkle-path-tree"></div>';
23
+ },
24
+ argsFmt: function(args) {
25
+ return args.map(function(arg) {
26
+ return JSON.stringify(args, undefined, 2);;
27
+ }).join(', ');
28
+ }
29
+ };
30
+
31
+ var builder = new mapexplorerCore.ChainTreeBuilder(this);
32
+
33
+ builder.build({
34
+ id: map.data('mapId'),
35
+ applicationUrl: map.data('applicationUrl'),
36
+ chainscript: map.data('chainscript')
37
+ }, {
38
+ onclick: function(d, onHide) {
39
+ var segment = d.data;
40
+
41
+ var refresh = function() {
42
+ map.find('.segment').html(segmentTemplate.render({ segment: segment }, helpers));
43
+
44
+ map.find('.nav-link').on('click', function() {
45
+ segment.currentSection = $(this).data('target');
46
+ refresh();
47
+ });
48
+
49
+ map.find('a.close').on('click', function(){
50
+ map.find('.segment').html(null);
51
+ onHide();
52
+ return false;
53
+ });
54
+ };
55
+
56
+ segment.show = function(target) {
57
+ return this.currentSection === target;
58
+ };
59
+
60
+ segment.currentSection = 'state';
61
+ refresh();
62
+ },
63
+ onTag: function(){}
64
+ });
65
+ });
66
+ });
@@ -0,0 +1,128 @@
1
+ /*
2
+ *= require assets/stylesheets/mapexplorer-core
3
+ */
4
+
5
+ $brand-primary: #EC714A !default;
6
+
7
+ .segment-container {
8
+
9
+ color: white;
10
+
11
+ .title {
12
+ background: #2E2E2E;
13
+ padding: 10px 100px;
14
+ }
15
+
16
+ .title md-icon {
17
+ color: white;
18
+ }
19
+
20
+ h1 {
21
+ margin-top: 0;
22
+ font-family: Gibson-SemiBold, 'Montserrat', sans-serif;
23
+ font-weight: 600;
24
+ font-size: 11px;
25
+ color: #CCCCCC;
26
+ text-transform: uppercase;
27
+ }
28
+
29
+ h2 {
30
+ margin-bottom: 0;
31
+ font-family: Gibson-Light, 'Montserrat', sans-serif;
32
+ font-weight: 300;
33
+ font-size: 18px;
34
+ color: #FFFFFF;
35
+ text-transform: none;
36
+ }
37
+
38
+ .body {
39
+ background: #3E3E3E;
40
+ padding: 0 100px;
41
+ max-height: 400px;
42
+ }
43
+
44
+ .content {
45
+ overflow-y: scroll;
46
+ }
47
+
48
+ li {
49
+ cursor: pointer;
50
+ font-family: 'Gibson-Regular', 'Montserrat', sans-serif;
51
+ font-size: 15px;
52
+ color: #CCCCCC;
53
+ margin: 20px 0;
54
+ width: 100px;
55
+ }
56
+
57
+ ul {
58
+ padding-left: 0;
59
+ padding-right: 5px;
60
+ list-style: none;
61
+ }
62
+
63
+ .ace_editor {
64
+ width: 100%;
65
+ }
66
+
67
+ .ace-tm .ace_gutter, .ace_scroller {
68
+ padding-top: 20px;
69
+ }
70
+
71
+ li.active {
72
+ color: $brand-primary;
73
+ border-bottom: 2px solid $brand-primary;
74
+ }
75
+
76
+ li {
77
+ outline: 0;
78
+ }
79
+
80
+ h4 {
81
+ font-family: Gibson-SemiBold, 'Montserrat', sans-serif;
82
+ font-weight: 600;
83
+ font-size: 11px;
84
+ color: #ADADAD;
85
+ text-transform: uppercase;
86
+ margin-bottom: 0;
87
+ }
88
+
89
+ p {
90
+ font-family: RationalTWText-Light, 'Roboto Mono', monospace;
91
+ font-size: 14px;
92
+ color: white;
93
+ margin-top: 0;
94
+ }
95
+
96
+ a {
97
+ font-family: 'Gibson-Regular', 'Montserrat', sans-serif;
98
+ font-size: 15px;
99
+ color: $brand-primary;
100
+ display: block;
101
+ }
102
+
103
+ a.close {
104
+ color: white;
105
+ text-decoration: none;
106
+ font-size: 24px;
107
+ }
108
+
109
+ .flex-row, .flex-column {
110
+ display: flex;
111
+ }
112
+
113
+ .flex-row {
114
+ flex-direction: horizontal;
115
+ }
116
+
117
+ .flex-column {
118
+ flex-direction: vertical;
119
+ }
120
+
121
+ .flex-grow {
122
+ flex-grow: 1;
123
+ }
124
+
125
+ .flex {
126
+ flex: 1;
127
+ }
128
+ }
@@ -0,0 +1,5 @@
1
+ module MapexplorerHelper
2
+ def mapexplorer(application_url: nil, map_id: nil, chainscript: nil)
3
+ render 'mapexplorer', { application_url: application_url, map_id: map_id, chainscript: chainscript }
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ <div class="mapexplorer" data-application-url=<%= application_url %> data-map-id=<%= map_id %> data-chainscript=<%= chainscript %>>
2
+ <%= render 'segment.jsr' %>
3
+ <div class="segment">
4
+ </div>
5
+ <svg>
6
+ <marker id="triangle" viewBox="0 0 10 10" refX="0" refY="5" markerUnits="strokeWidth"
7
+ markerWidth="4" markerHeight="3" orient="auto">
8
+ <path fill="#CCCCCC" d="M 0 0 L 10 5 L 0 10 z"/>
9
+ </marker>
10
+ </svg>
11
+ </div>
@@ -0,0 +1,75 @@
1
+ <script id="segment-template" type="text/x-jsrender">
2
+ <div class="segment-container">
3
+ <div class="title flex-row">
4
+ <div>
5
+ <h1>Segment</h1>
6
+ <h2>{{: segment.meta.linkHash }}</h2>
7
+ </div>
8
+ <span class="flex"></span>
9
+ <a href="#" class="close">&times;</a>
10
+ </div>
11
+ <div class="body flex-row">
12
+ <div class="menu">
13
+ <ul>
14
+ <li class={{: (segment.show('state') ? 'active ' : '') + 'nav-link' }} data-target="state">State</li>
15
+ <li class={{: (segment.show('link') ? 'active ' : '') + 'nav-link' }} data-target="link">Link</li>
16
+ <li class={{: (segment.show('evidence') ? 'active ' : '') + 'nav-link' }} data-target="evidence">Evidence</li>
17
+ <li class={{: (segment.show('json') ? 'active ' : '') + 'nav-link' }} data-target="json">JSON</li>
18
+ </ul>
19
+ </div>
20
+ <div class="content flex-grow">
21
+ {{if segment.show('state')}}
22
+ <pre>{{:~json(segment.link.state)}}</pre>
23
+ {{/if}}
24
+ {{if segment.show('link')}}
25
+ <div class="link">
26
+ <h4>Map ID</h4>
27
+ <p>{{: segment.link.meta.mapId}}</p>
28
+
29
+ <h4>Agent Hash</h4>
30
+ <p>{{: segment.link.meta.agentHash}}</p>
31
+
32
+ <h4>State Hash</h4>
33
+ <p>{{: segment.link.meta.stateHash}}</p>
34
+
35
+ <h4>Previous Link hash</h4>
36
+ <p>{{: segment.link.meta.prevLinkHash}}</p>
37
+
38
+ <h4>Action</h4>
39
+ <p>{{: segment.link.meta.action }}({{:~argsFmt(segment.link.meta.arguments)}})</p>
40
+ </div>
41
+ {{/if}}
42
+ {{if segment.show('evidence')}}
43
+ <div class="flex-row">
44
+ <div class="info">
45
+ <h4>State</h4>
46
+ <p>{{: segment.meta.evidence.state }}</p>
47
+ {{if segment.show('evidence')}}
48
+ <h4>Bitcoin Transaction</h4>
49
+ <p>
50
+ {{if segment.meta.evidence.transactions}}
51
+ <a target="_blank"
52
+ href={{: "https://blockchain.info/tx/" + segment.meta.evidence.transactions['bitcoin:main'] }}>View
53
+ transaction on Blockchain.info</a>
54
+ {{/if}}
55
+ </p>
56
+
57
+ <h4>Merkle root</h4>
58
+ <p>{{: segment.meta.evidence.merkleRoot }}</p>
59
+ {{/if}}
60
+ </div>
61
+ {{if segment.meta.evidence.state === 'COMPLETE'}}
62
+ <div class="merkle-path">
63
+ <h4>Merkle Path</h4>
64
+ {{:~merklePathTree(segment.meta.evidence.merklePath)}}
65
+ </div>
66
+ {{/if}}
67
+ </div>
68
+ {{/if}}
69
+ {{if segment.show('json')}}
70
+ <pre>{{:~json(segment)}}</pre>
71
+ {{/if}}
72
+ </div>
73
+ </div>
74
+ </div>
75
+ </script>
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ Rails.application.routes.draw do
2
+ end
@@ -0,0 +1,9 @@
1
+ module Mapexplorer
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ require 'jquery-rails'
5
+ require 'turbolinks'
6
+ require 'sass-rails'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module Mapexplorer
2
+ module Rails
3
+ VERSION = '1.0.0-alpha'
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require "mapexplorer/rails/engine"
2
+
3
+ module Mapexplorer
4
+ module Rails
5
+ # Your code goes here...
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :mapexplorer_rails do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mapexplorer-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.pre.alpha
5
+ platform: ruby
6
+ authors:
7
+ - adrien
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-11-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.0.0
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 5.0.0.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 5.0.0
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 5.0.0.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: turbolinks
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 5.0.0
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 5.0.0.1
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: 5.0.0
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 5.0.0.1
53
+ - !ruby/object:Gem::Dependency
54
+ name: jquery-rails
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '4.2'
60
+ type: :runtime
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '4.2'
67
+ - !ruby/object:Gem::Dependency
68
+ name: sass-rails
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '5.0'
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 5.0.0
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '5.0'
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 5.0.0
87
+ - !ruby/object:Gem::Dependency
88
+ name: sqlite3
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ type: :development
95
+ prerelease: false
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ description: Rails Engine that provides an Action View helper thats displays a Map
102
+ Explorer
103
+ email:
104
+ - adrien@stratumn.com
105
+ executables: []
106
+ extensions: []
107
+ extra_rdoc_files: []
108
+ files:
109
+ - MIT-LICENSE
110
+ - README.md
111
+ - Rakefile
112
+ - app/assets/config/mapexplorer_rails_manifest.js
113
+ - app/assets/javascripts/mapexplorer-rails.js
114
+ - app/assets/stylesheets/mapexplorer-rails.scss
115
+ - app/helpers/mapexplorer_helper.rb
116
+ - app/views/application/_mapexplorer.html.erb
117
+ - app/views/application/_segment.jsr.html
118
+ - config/routes.rb
119
+ - lib/mapexplorer/rails.rb
120
+ - lib/mapexplorer/rails/engine.rb
121
+ - lib/mapexplorer/rails/version.rb
122
+ - lib/tasks/mapexplorer/rails_tasks.rake
123
+ homepage: https://github.com/stratumn/mapexplorer-rails
124
+ licenses:
125
+ - MIT
126
+ metadata: {}
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">"
139
+ - !ruby/object:Gem::Version
140
+ version: 1.3.1
141
+ requirements: []
142
+ rubyforge_project:
143
+ rubygems_version: 2.5.2
144
+ signing_key:
145
+ specification_version: 4
146
+ summary: Rails Engine to display a Map Explorer
147
+ test_files: []