hieraviz 0.2.0 → 0.2.1

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: b4eaf9279a8b9ffdd555aa1d48fcf395a648b5e2
4
- data.tar.gz: 3325be3798ce496aea8ce0f99e1c58348ef72805
3
+ metadata.gz: c92243305adbd29684586595b9756031dbab5890
4
+ data.tar.gz: 92149f89aebee317256c51b143613111431730ab
5
5
  SHA512:
6
- metadata.gz: 1365f4a1804d57eae53a2ea56fa47a8a0be87eb605a98e575ba075dc76a68ca398c5e33125a5dcc73e9a9f95fa8dc6c30b1a38fb98270cc6e248c66f67941f77
7
- data.tar.gz: f46e79ebd53ade534fad598bf09ce5584b41e6ff943ff65fca029fffc9089e1ea9a9d0598994a87f4c6bad2b87f7a5a2f00878757d6b361c0ec25507200e8907
6
+ metadata.gz: 2910ecf14f76df96f33f1b211bcfe315a6ba2acec195a2375c7cc95a6f3a7a02230e8703256e79d673069178cfaaa7cd19190a86660a9a23420136984bca0852
7
+ data.tar.gz: 868f5226fc033dc439515f4b3f81182f6a40068ae17da91fec87a67296384d0789d29b4e70b23176581578069e34abd6a44f71750599640ed829488ed173ad26
data/CHANGELOG.md CHANGED
@@ -1,7 +1,10 @@
1
1
  Hieraviz Changelog
2
2
  ========================
3
3
 
4
- ### v0.2.0 - 2014-03-03
4
+ ### v0.2.1 - 2016-04-04
5
+ - replaced sinatra-flash (weird license, no debian package) with rack-flash3
6
+
7
+ ### v0.2.0 - 2016-03-03
5
8
  - fix button display on firefox
6
9
  - fixes on http simple auth
7
10
  - various refactoring
data/README.md CHANGED
@@ -23,7 +23,25 @@ Install it from Rubygens:
23
23
 
24
24
  Development
25
25
  --------------
26
- Launch it with `shotgun` or `rackup`.
26
+
27
+ Make sure you have ruby installed (version 2.1.5 from jessie works fine, or use rvm).
28
+
29
+ gem install bundler
30
+ git clone https://github.com/Gandi/hieraviz.git
31
+ cd hieraviz
32
+ bundle install --path vendor
33
+ cp config/hieraviz.default.yml config/hieraviz.yml
34
+ # edit the config file
35
+ bundle exec shotgun
36
+ # or
37
+ bundle exec rackup
38
+
39
+
40
+ Production
41
+ ----------------
42
+
43
+ gem install thin
44
+ thin -s 1 -C config.yml -R config.ru start
27
45
 
28
46
  Contributing
29
47
  ----------------
data/app/apiv1.rb CHANGED
@@ -14,6 +14,7 @@ module HieravizApp
14
14
 
15
15
  configure do
16
16
  set :session_secret, settings.configdata['session_seed']
17
+ set :protection, :origin_whitelist => ['http://web.example.com']
17
18
  enable :sessions
18
19
  end
19
20
 
@@ -52,6 +53,11 @@ module HieravizApp
52
53
  def get_facts(base, node)
53
54
  Hieraviz::Facts.new(settings.configdata['tmpdir'], base, node, username)
54
55
  end
56
+ def cors_headers()
57
+ headers 'Access-Control-Allow-Origin' => '*'
58
+ headers 'Access-Control-Allow-Headers' => 'Authorization,Accepts,Content-Type,X-CSRF-Token,X-Requested-With,X-AUTH'
59
+ headers 'Access-Control-Allow-Methods' => 'GET,POST,PUT,DELETE,OPTIONS'
60
+ end
55
61
  end
56
62
 
57
63
  get %r{^/?([-_\.a-zA-Z0-9]+)?/nodes} do |base|
@@ -109,6 +115,7 @@ module HieravizApp
109
115
 
110
116
  get %r{^/?([-_\.a-zA-Z0-9]+)?/farms} do |base|
111
117
  check_authorization
118
+ cors_headers
112
119
  hieracles_config = prepare_config(base)
113
120
  json Hieracles::Registry.farms_counted(hieracles_config, base)
114
121
  end
@@ -137,8 +144,14 @@ module HieravizApp
137
144
  json res
138
145
  end
139
146
 
147
+ options %r{^/.*/$} do
148
+ cors_headers
149
+ halt 200
150
+ end
151
+
140
152
  get %r{^/?([-_\.a-zA-Z0-9]+)?/farm/([-_\.a-zA-Z0-9]+)$} do |base, farm|
141
- check_authorization
153
+ # check_authorization
154
+ cors_headers
142
155
  hieracles_config = prepare_config(base)
143
156
  nodes = Hieracles::Registry.nodes_data(hieracles_config, base).each_with_object({}) do |(key, val), acc|
144
157
  acc[key] = val if val['farm'] == farm
@@ -452,10 +452,6 @@ input {
452
452
  background-color: #4d4;
453
453
  color: #000;
454
454
  }
455
- .flash.warning {
456
- background-color: #d63;
457
- color: #fff;
458
- }
459
455
  .flash.fatal {
460
456
  background-color: #a20;
461
457
  color: #fff;
@@ -51,19 +51,19 @@ ready( () => {
51
51
  var Farm = {
52
52
  show: function(el) {
53
53
  addClass(meat, 'wait');
54
- farm = el.dataset.item;
55
- fetch('/v1/' + base + '/farm/' + farm, auth_header()).
54
+ focused = el.dataset.item;
55
+ fetch('/v1/' + base + '/farm/' + focused, auth_header()).
56
56
  then(res => res.json()).
57
57
  then(j => {
58
58
  if (j.error !== undefined) {
59
59
  show_error(meat, j['error']);
60
60
  } else {
61
- build_list(meat, farm, j);
61
+ build_list(meat, focused, j);
62
62
  Array.prototype.forEach.call(farms, (item, i) => {
63
63
  removeClass(item, 'focus');
64
64
  });
65
65
  addClass(el, 'focus');
66
- update_footer('/v1/' + base + '/farm/' + farm);
66
+ update_footer('/v1/' + base + '/farm/' + focused);
67
67
  }
68
68
  removeClass(meat, 'wait');
69
69
  });
@@ -0,0 +1,5 @@
1
+ <% if flash.has?(:fatal) %>
2
+ <div class="flash fatal"><%= flash[:fatal] %></div>
3
+ <% elsif flash.has?(:info) %>
4
+ <div class="flash info"><%= flash[:info] %></div>
5
+ <% end %>
@@ -23,7 +23,7 @@
23
23
  <%= erb :_head, :layout => false %>
24
24
  </div>
25
25
  <div class="content">
26
- <%= styled_flash %>
26
+ <%= erb :_flash, :layout => false %>
27
27
  <%= yield %>
28
28
  </div>
29
29
  <div class="foot">
data/app/web.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'sinatra/content_for'
2
- require 'sinatra/flash'
3
2
 
4
3
  require 'better_errors'
4
+ require 'rack-flash'
5
5
  require 'dotenv'
6
6
  require 'oauth2'
7
7
 
@@ -14,7 +14,7 @@ module HieravizApp
14
14
  # the unique web endpoints management
15
15
  class Web < Common
16
16
  helpers Sinatra::ContentFor
17
- register Sinatra::Flash
17
+ use Rack::Flash
18
18
 
19
19
  configure do
20
20
  set :session_secret, settings.configdata['session_seed']
@@ -113,7 +113,7 @@ module HieravizApp
113
113
  access_token = settings.oauth.access_token(request, params[:code])
114
114
  session[:access_token] = access_token.token
115
115
  settings.store.set access_token.token, settings.oauth.user_info(access_token.token)
116
- flash['info'] = 'Successfully authenticated with the server'
116
+ flash[:info] = 'Successfully authenticated with the server'
117
117
  redirect '/'
118
118
  end
119
119
 
data/config.ru CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'sinatra'
3
+
3
4
  require File.expand_path '../app/main.rb', __FILE__
4
5
 
5
6
  run Rack::URLMap.new('/' => HieravizApp::Web,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hieraviz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - mose
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-03 00:00:00.000000000 Z
11
+ date: 2016-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: sinatra-flash
84
+ name: rack-flash3
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -276,6 +276,7 @@ files:
276
276
  - app/public/js/modules.js
277
277
  - app/public/js/nodes.js
278
278
  - app/public/js/resources.js
279
+ - app/views/_flash.erb
279
280
  - app/views/_foot.erb
280
281
  - app/views/_head.erb
281
282
  - app/views/_layout.erb