magent 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/magent-web +15 -0
- data/lib/magent_web.rb +18 -5
- data/lib/magent_web/app.rb +13 -2
- data/lib/magent_web/mongo_helper.rb +11 -1
- data/lib/magent_web/views/index.haml +1 -1
- data/lib/magent_web/views/layout.haml +1 -1
- data/lib/magent_web/views/queues/failed.haml +4 -4
- data/lib/magent_web/views/queues/show.haml +4 -4
- data/magent.gemspec +2 -2
- data/public/javascripts/{application.js → magent_web.js} +0 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.2
|
data/bin/magent-web
CHANGED
@@ -4,6 +4,21 @@ $:.unshift << File.expand_path("../../lib", __FILE__)
|
|
4
4
|
require 'magent'
|
5
5
|
require 'magent_web'
|
6
6
|
require 'launchy'
|
7
|
+
require 'fileutils'
|
8
|
+
|
9
|
+
if ARGV[0] == "--install"
|
10
|
+
base_path = File.expand_path("../../", __FILE__)
|
11
|
+
|
12
|
+
if File.exist?("public/javascripts/") && File.exist?("public/stylesheets/")
|
13
|
+
FileUtils.cp_r("#{base_path}/public/javascripts/", "public/")
|
14
|
+
FileUtils.cp_r("#{base_path}/public/stylesheets/", "public/")
|
15
|
+
else
|
16
|
+
raise ArgumentError, "public/javascripts and public/stylesheets do not exist"
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
exit 0
|
21
|
+
end
|
7
22
|
|
8
23
|
Thread.start do
|
9
24
|
sleep 2.5
|
data/lib/magent_web.rb
CHANGED
@@ -12,13 +12,8 @@ require 'net/http'
|
|
12
12
|
require 'uri'
|
13
13
|
require 'cgi'
|
14
14
|
|
15
|
-
require 'magent_web/mongo_helper'
|
16
|
-
require 'magent_web/app'
|
17
|
-
|
18
15
|
module MagentWeb
|
19
16
|
def self.app
|
20
|
-
MagentWeb.connect
|
21
|
-
|
22
17
|
MagentWeb::App
|
23
18
|
end
|
24
19
|
|
@@ -38,5 +33,23 @@ module MagentWeb
|
|
38
33
|
raise ArgumentError, "/etc/magent.yml, ./config/magent.yml or ./magent.yml were not found"
|
39
34
|
end
|
40
35
|
end
|
36
|
+
|
37
|
+
def self.config_path
|
38
|
+
Dir.home+"/.magent_webrc"
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.config
|
42
|
+
@config ||= YAML.load_file(self.config_path)
|
43
|
+
end
|
41
44
|
end
|
42
45
|
|
46
|
+
if !File.exist?(MagentWeb.config_path)
|
47
|
+
File.open(MagentWeb.config_path, "w") do |f|
|
48
|
+
f.write YAML.dump("username" => "admin", "password" => "admin", "enable_auth" => true)
|
49
|
+
end
|
50
|
+
|
51
|
+
$stdout.puts "Created #{MagentWeb.config_path} with username=admin password=admin"
|
52
|
+
end
|
53
|
+
|
54
|
+
require 'magent_web/mongo_helper'
|
55
|
+
require 'magent_web/app'
|
data/lib/magent_web/app.rb
CHANGED
@@ -2,6 +2,17 @@ module MagentWeb
|
|
2
2
|
class App < Sinatra::Base
|
3
3
|
include MagentWeb::MongoHelper
|
4
4
|
|
5
|
+
if MagentWeb.config["enable_auth"]
|
6
|
+
use Rack::Auth::Basic, "Restricted Area" do |username, password|
|
7
|
+
[username, password] == [MagentWeb.config["username"], MagentWeb.config["password"]]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(*args)
|
12
|
+
MagentWeb.connect
|
13
|
+
super(*args)
|
14
|
+
end
|
15
|
+
|
5
16
|
helpers do
|
6
17
|
include Rack::Utils
|
7
18
|
alias_method :h, :escape_html
|
@@ -59,13 +70,13 @@ module MagentWeb
|
|
59
70
|
doc = @errors_queue.find({:_id => params[:id]}).next_document
|
60
71
|
channel.enqueue_error(doc)
|
61
72
|
|
62
|
-
redirect "
|
73
|
+
redirect "#{queue_path(params[:queue_id])}/failed"
|
63
74
|
end
|
64
75
|
|
65
76
|
get "/queues/:queue_id/delete/:id" do
|
66
77
|
@errors_queue = @database.collection(params[:queue_id]+".errors")
|
67
78
|
@errors_queue.remove(:_id => params[:id])
|
68
|
-
redirect "
|
79
|
+
redirect "#{queue_path(params[:queue_id])}/failed"
|
69
80
|
end
|
70
81
|
|
71
82
|
private
|
@@ -55,7 +55,11 @@ module MagentWeb
|
|
55
55
|
if v.nil? && quote
|
56
56
|
"null"
|
57
57
|
elsif v.kind_of?(Hash)
|
58
|
-
|
58
|
+
buffer = ""
|
59
|
+
v.each do |k,v|
|
60
|
+
buffer << "#{k.inspect}: #{v.inspect} <br />"
|
61
|
+
end
|
62
|
+
buffer
|
59
63
|
elsif v.kind_of?(Array)
|
60
64
|
v.map{|e| e.nil? ? "null" : e }.join("<br />")
|
61
65
|
elsif v.kind_of?(Time)
|
@@ -80,5 +84,11 @@ module MagentWeb
|
|
80
84
|
def channel_name_for(queue_id)
|
81
85
|
queue_id.to_s.match("magent\.([^\.]+)")[1]
|
82
86
|
end
|
87
|
+
|
88
|
+
def queue_path(queue)
|
89
|
+
queue = queue.name if !queue.kind_of?(String)
|
90
|
+
|
91
|
+
"#{ENV["MAGENT_WEB_PATH"]}/queues/#{queue}"
|
92
|
+
end
|
83
93
|
end
|
84
94
|
end
|
@@ -19,18 +19,18 @@
|
|
19
19
|
%div(data-role="navbar" data-iconpos="bottom")
|
20
20
|
%ul
|
21
21
|
%li
|
22
|
-
%a(href="
|
22
|
+
%a(href="#{queue_path(@queue)}/retry/#{document["_id"]}" data-icon="refresh")
|
23
23
|
Retry
|
24
24
|
%li
|
25
|
-
%a(href="
|
25
|
+
%a(href="#{queue_path(@queue)}/delete/#{document["_id"]}" data-icon="delete" data-theme="e")
|
26
26
|
Delete
|
27
27
|
|
28
28
|
|
29
29
|
%div(data-role="footer")
|
30
30
|
-if skip > 0
|
31
|
-
%a(href="
|
31
|
+
%a(href="#{queue_path(@queue)}/failed?skip=#{params[:skip].to_i-25}")
|
32
32
|
Previous
|
33
33
|
-if count >= 25
|
34
|
-
%a(href="
|
34
|
+
%a(href="#{queue_path(@queue)}/failed?skip=#{params[:skip].to_i+25}")
|
35
35
|
Next
|
36
36
|
|
@@ -8,10 +8,10 @@
|
|
8
8
|
%div{:"data-role" => "navbar"}
|
9
9
|
%ul
|
10
10
|
%li
|
11
|
-
%a(href="
|
11
|
+
%a(href="#{queue_path(@queue)}/failed" data-icon="alert")
|
12
12
|
Failed
|
13
13
|
%li
|
14
|
-
%a(href="
|
14
|
+
%a(href="#{queue_path(@queue)}/stats" data-icon="grid")
|
15
15
|
Stats
|
16
16
|
|
17
17
|
|
@@ -29,8 +29,8 @@
|
|
29
29
|
|
30
30
|
%div(data-role="footer")
|
31
31
|
-if skip > 0
|
32
|
-
%a(href="
|
32
|
+
%a(href="#{queue_path(@queue)}?skip=#{params[:skip].to_i-25}")
|
33
33
|
Previous
|
34
34
|
-if count >= 25
|
35
|
-
%a(href="
|
35
|
+
%a(href="#{queue_path(@queue)}?skip=#{params[:skip].to_i+25}")
|
36
36
|
Next
|
data/magent.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{magent}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["David A. Cuadrado"]
|
@@ -63,8 +63,8 @@ Gem::Specification.new do |s|
|
|
63
63
|
"lib/magent_web/views/status.haml",
|
64
64
|
"lib/tasks/magent.rake",
|
65
65
|
"magent.gemspec",
|
66
|
-
"public/javascripts/application.js",
|
67
66
|
"public/javascripts/jquery.mobile-1.0b1pre.min.js",
|
67
|
+
"public/javascripts/magent_web.js",
|
68
68
|
"public/stylesheets/highlight.css",
|
69
69
|
"public/stylesheets/images/ajax-loader.png",
|
70
70
|
"public/stylesheets/images/icon-search-black.png",
|
File without changes
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 6
|
8
|
-
-
|
9
|
-
version: 0.6.
|
8
|
+
- 2
|
9
|
+
version: 0.6.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- David A. Cuadrado
|
@@ -210,8 +210,8 @@ files:
|
|
210
210
|
- lib/magent_web/views/status.haml
|
211
211
|
- lib/tasks/magent.rake
|
212
212
|
- magent.gemspec
|
213
|
-
- public/javascripts/application.js
|
214
213
|
- public/javascripts/jquery.mobile-1.0b1pre.min.js
|
214
|
+
- public/javascripts/magent_web.js
|
215
215
|
- public/stylesheets/highlight.css
|
216
216
|
- public/stylesheets/images/ajax-loader.png
|
217
217
|
- public/stylesheets/images/icon-search-black.png
|