oneis 1.0.4-java → 1.1.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/new_plugin.rb +17 -17
- data/lib/plugin.rb +12 -1
- data/lib/plugin_tool.rb +8 -1
- data/lib/server.rb +14 -0
- data/lib/version.txt +1 -1
- data/oneis.gemspec +2 -2
- metadata +2 -2
data/lib/new_plugin.rb
CHANGED
@@ -16,37 +16,39 @@ module PluginTool
|
|
16
16
|
rbytes = Java::byte[20].new
|
17
17
|
random.nextBytes(rbytes)
|
18
18
|
install_secret = String.from_java_bytes(rbytes).unpack('H*').join
|
19
|
+
plugin_url_fragment = plugin_name.gsub('_','-')
|
19
20
|
File.open("#{plugin_name}/plugin.json",'w') do |file|
|
20
21
|
file.write(<<__E)
|
21
22
|
{
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
"pluginName": "#{plugin_name}",
|
24
|
+
"pluginAuthor": "TODO Your Company",
|
25
|
+
"pluginVersion": 1,
|
26
|
+
"displayName": "#{plugin_name.split('_').map {|e| e.capitalize} .join(' ')}",
|
27
|
+
"displayDescription": "TODO Longer description of plugin",
|
28
|
+
"installSecret": "#{install_secret}",
|
29
|
+
"apiVersion": 2,
|
30
|
+
"load": [
|
31
|
+
"js/#{plugin_name}.js"
|
32
|
+
],
|
33
|
+
"respond": ["/do/#{plugin_url_fragment}"]
|
31
34
|
}
|
32
35
|
__E
|
33
36
|
end
|
34
37
|
File.open("#{plugin_name}/js/#{plugin_name}.js",'w') do |file|
|
35
38
|
file.write(<<__E)
|
36
39
|
|
37
|
-
var #{plugin_name} = O.plugin("#{plugin_name}"
|
38
|
-
});
|
40
|
+
var #{plugin_name} = O.plugin("#{plugin_name}");
|
39
41
|
|
40
|
-
(function() {
|
42
|
+
(function(P) {
|
41
43
|
|
42
|
-
|
44
|
+
P.respond("GET", "/do/#{plugin_url_fragment}/example", [
|
43
45
|
], function(E) {
|
44
46
|
E.render({
|
45
47
|
pageTitle: "Example page"
|
46
48
|
});
|
47
49
|
});
|
48
50
|
|
49
|
-
})();
|
51
|
+
})(#{plugin_name});
|
50
52
|
|
51
53
|
__E
|
52
54
|
end
|
@@ -77,12 +79,10 @@ Plugin #{plugin_name} has been created. Run
|
|
77
79
|
|
78
80
|
to upload it to the server, then visit
|
79
81
|
|
80
|
-
https://<HOSTNAME>/do/#{
|
82
|
+
https://<HOSTNAME>/do/#{plugin_url_fragment}/example
|
81
83
|
|
82
84
|
to see a sample page.
|
83
85
|
|
84
|
-
Add additional hook handlers in the js/#{plugin_name}.js file.
|
85
|
-
|
86
86
|
See http://docs.oneis.co.uk/dev/plugin for more information.
|
87
87
|
|
88
88
|
__E
|
data/lib/plugin.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
module PluginTool
|
3
3
|
|
4
4
|
class Plugin
|
5
|
+
DEFAULT_PLUGIN_LOAD_PRIORITY = 9999999
|
6
|
+
|
5
7
|
def initialize(name, options)
|
6
8
|
@name = name
|
7
9
|
@options = options
|
@@ -20,9 +22,17 @@ module PluginTool
|
|
20
22
|
@plugin_dir = @name
|
21
23
|
end_on_error "logic error" unless @plugin_dir =~ /\A[a-zA-Z0-9_-]+\z/
|
22
24
|
@loaded_plugin_id = nil
|
23
|
-
puts "Plugin: #{@plugin_dir}"
|
24
25
|
end
|
25
26
|
|
27
|
+
def plugin_load_priority
|
28
|
+
pj = File.open("#{@plugin_dir}/plugin.json") { |f| JSON.parse(f.read) }
|
29
|
+
pj['loadPriority'] || DEFAULT_PLUGIN_LOAD_PRIORITY
|
30
|
+
end
|
31
|
+
|
32
|
+
def print_banner
|
33
|
+
puts "Plugin: #{@plugin_dir}"
|
34
|
+
end
|
35
|
+
|
26
36
|
def setup_for_server
|
27
37
|
# Delete any legacy registration file for this plugin
|
28
38
|
registration_file = "registration.#{@plugin_dir}.yaml"
|
@@ -152,6 +162,7 @@ module PluginTool
|
|
152
162
|
puts "\n\n#{@name}: Didn't apply changes on server\n\n"
|
153
163
|
PluginTool.beep
|
154
164
|
end
|
165
|
+
PluginTool.push_delayed_apply(@name) if r[:requires_delayed_apply]
|
155
166
|
end
|
156
167
|
end
|
157
168
|
PluginTool.finish_with_connection
|
data/lib/plugin_tool.rb
CHANGED
@@ -101,11 +101,17 @@ if plugin_names.empty?
|
|
101
101
|
plugin_names = all_plugins
|
102
102
|
end
|
103
103
|
|
104
|
-
# Make plugin objects
|
104
|
+
# Make plugin objects, start them, sort by order the server will load them
|
105
105
|
plugins = plugin_names.map do |name|
|
106
106
|
PluginTool::Plugin.new(name, options)
|
107
107
|
end
|
108
108
|
plugins.each { |p| p.start }
|
109
|
+
plugins.sort! do |a,b|
|
110
|
+
pri_a = a.plugin_load_priority
|
111
|
+
pri_b = b.plugin_load_priority
|
112
|
+
(pri_a == pri_b) ? (a.name <=> b.name) : (pri_a <=> pri_b)
|
113
|
+
end
|
114
|
+
plugins.each { |p| p.print_banner }
|
109
115
|
|
110
116
|
# Special handling for some commands
|
111
117
|
case PLUGIN_TOOL_COMMAND
|
@@ -151,6 +157,7 @@ first_run = true
|
|
151
157
|
while(true)
|
152
158
|
puts "Scanning plugin files..."
|
153
159
|
plugins.each { |p| p.develop_scan_and_upload(first_run) }
|
160
|
+
PluginTool.do_delayed_apply
|
154
161
|
puts "Waiting for changes..."
|
155
162
|
if first_run
|
156
163
|
puts " Any changes you make to your local copy of the plugin will be automatically"
|
data/lib/server.rb
CHANGED
@@ -128,4 +128,18 @@ EOF
|
|
128
128
|
r
|
129
129
|
end
|
130
130
|
|
131
|
+
# Delayed apply support
|
132
|
+
@@delayed_apply_queue = []
|
133
|
+
def self.push_delayed_apply(name)
|
134
|
+
@@delayed_apply_queue.push(name)
|
135
|
+
end
|
136
|
+
def self.do_delayed_apply
|
137
|
+
return if @@delayed_apply_queue.empty?
|
138
|
+
puts "Updating server..."
|
139
|
+
self.post_yaml("/api/development_plugin_loader/delayed_apply", {"plugins" => @@delayed_apply_queue.join(',')})
|
140
|
+
self.finish_with_connection
|
141
|
+
puts "Updated."
|
142
|
+
@@delayed_apply_queue = []
|
143
|
+
end
|
144
|
+
|
131
145
|
end
|
data/lib/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
ef06a9244e
|
data/oneis.gemspec
CHANGED
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
|
|
3
3
|
files = Dir.glob("#{root_dir}/**/*.*").map { |x| x[root_dir.length + 1, x.length]}
|
4
4
|
|
5
5
|
s.name = 'oneis'
|
6
|
-
s.version = '1.0
|
7
|
-
s.date = '
|
6
|
+
s.version = '1.1.0'
|
7
|
+
s.date = '2014-10-03'
|
8
8
|
s.summary = "ONEIS Tools"
|
9
9
|
s.description = "ONEIS Developer Tools"
|
10
10
|
s.authors = ["ONEIS"]
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: oneis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0
|
5
|
+
version: 1.1.0
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- ONEIS
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date:
|
13
|
+
date: 2014-10-03 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: jruby-openssl
|