haplo 2.4.2-java → 2.5.2-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/haplo.gemspec +2 -2
- data/lib/CertificateBundle.pem +1114 -1852
- data/lib/haplo-templates.jar +0 -0
- data/lib/i18n_extract_text.rb +46 -0
- data/lib/manifest.rb +1 -1
- data/lib/packing.rb +4 -1
- data/lib/plugin.rb +26 -5
- data/lib/plugin_tool.rb +18 -3
- data/lib/run.rb +1 -0
- data/lib/server.rb +1 -0
- data/lib/usage.txt +8 -0
- data/lib/version.txt +1 -1
- metadata +3 -2
data/lib/haplo-templates.jar
CHANGED
Binary file
|
@@ -0,0 +1,46 @@
|
|
1
|
+
|
2
|
+
module PluginTool
|
3
|
+
|
4
|
+
def self.i18n_extract_text(plugins)
|
5
|
+
text = {}
|
6
|
+
|
7
|
+
# Get text from templates. This is exact, because each template is parsed.
|
8
|
+
parser_config = TemplateParserConfiguration.new
|
9
|
+
plugins.each do |plugin|
|
10
|
+
Dir.glob("#{plugin.plugin_dir}/template/**/*.hsvt").sort.each do |template|
|
11
|
+
template = Java::OrgHaploTemplateHtml::Parser.new(File.read(template), "extract", parser_config).parse()
|
12
|
+
template.extractTranslatedStrings().each do |string|
|
13
|
+
text[string] = string
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Get text from JS files, which isn't exact, because it just relies on convention and hopes for the best.
|
19
|
+
plugins.each do |plugin|
|
20
|
+
Dir.glob("#{plugin.plugin_dir}/js/**/*.js").sort.each do |js_file|
|
21
|
+
js = File.read(js_file)
|
22
|
+
[/\bi\['([^']+)'\]/, /\bi\["([^"]+)"\]/].each do |regexp|
|
23
|
+
js.scan(regexp) do
|
24
|
+
text[$1] = $1
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Last, add in any of the default locale's text, so where text is looked up by symbol, the translation is included.
|
31
|
+
plugins.each do |plugin|
|
32
|
+
['global','local'].each do |scope|
|
33
|
+
maybe_strings = "#{plugin.plugin_dir}/i18n/#{scope}/#{plugin.default_locale_id}.template.json"
|
34
|
+
if File.exist?(maybe_strings)
|
35
|
+
strings = JSON.parse(File.read(maybe_strings))
|
36
|
+
strings.each do |k,v|
|
37
|
+
text[k] = v
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
puts JSON.pretty_generate(text)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
data/lib/manifest.rb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
module PluginTool
|
9
9
|
|
10
|
-
PLUGIN_ACCEPTABLE_FILENAME = /\A(js|static|template|test|file)\/([A-Za-z0-9_\.-]+\/)*[A-Za-z0-9_\.-]+\.[A-Za-z0-9]+\z/
|
10
|
+
PLUGIN_ACCEPTABLE_FILENAME = /\A(js|static|template|test|file|i18n)\/([A-Za-z0-9_\.-]+\/)*[A-Za-z0-9_\.-]+\.[A-Za-z0-9]+\z/
|
11
11
|
PLUGIN_ACCEPTABLE_FILENAME_EXCEPTIONS = ['plugin.json', 'requirements.schema', 'global.js', 'certificates-temp-http-api.pem', 'developer.json', 'readme.txt']
|
12
12
|
def self.plugin_filename_allowed?(filename)
|
13
13
|
(filename =~ PLUGIN_ACCEPTABLE_FILENAME) || (PLUGIN_ACCEPTABLE_FILENAME_EXCEPTIONS.include?(filename))
|
data/lib/packing.rb
CHANGED
@@ -50,7 +50,10 @@ module PluginTool
|
|
50
50
|
end
|
51
51
|
# Minimise file?
|
52
52
|
unless filename =~ /\A(js|test)\//
|
53
|
-
|
53
|
+
# Is this file explicitly excluded from minimisation?
|
54
|
+
unless plugin.exclude_files_from_minimisation.include?(filename)
|
55
|
+
data = minimiser.process(data, filename)
|
56
|
+
end
|
54
57
|
end
|
55
58
|
hash = Digest::SHA256.hexdigest(data)
|
56
59
|
# Make sure output directory exists, write file
|
data/lib/plugin.rb
CHANGED
@@ -29,6 +29,11 @@ module PluginTool
|
|
29
29
|
attr_accessor :depend
|
30
30
|
attr_accessor :loaded_plugin_id
|
31
31
|
|
32
|
+
def default_locale_id
|
33
|
+
# TODO: Other default locales
|
34
|
+
'en'
|
35
|
+
end
|
36
|
+
|
32
37
|
# ---------------------------------------------------------------------------------------------------------
|
33
38
|
|
34
39
|
@@pending_apply = []
|
@@ -97,6 +102,17 @@ module PluginTool
|
|
97
102
|
end
|
98
103
|
end
|
99
104
|
|
105
|
+
def exclude_files_from_minimisation
|
106
|
+
@exclude_files_from_minimisation ||= begin
|
107
|
+
# developer.json file might specify files which should skip minimisation when packing
|
108
|
+
if developer_json['excludeFromMinimisation'].kind_of?(Array)
|
109
|
+
developer_json['excludeFromMinimisation']
|
110
|
+
else
|
111
|
+
[]
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
100
116
|
# ---------------------------------------------------------------------------------------------------------
|
101
117
|
|
102
118
|
def command(cmd, errors)
|
@@ -175,11 +191,16 @@ module PluginTool
|
|
175
191
|
hash = action
|
176
192
|
# Minimise file before uploading?
|
177
193
|
if @options.minimiser != nil && filename =~ /\A(static|template)\//
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
194
|
+
# Is this file explicitly excluded from minimisation?
|
195
|
+
unless exclude_files_from_minimisation.include?(filename)
|
196
|
+
size_before = data.length
|
197
|
+
data = @options.minimiser.process(data, filename)
|
198
|
+
size_after = data.length
|
199
|
+
hash = Digest::SHA256.hexdigest(data)
|
200
|
+
puts " minimisation: #{size_before} -> #{size_after} (#{(size_after * 100) / size_before}%)"
|
201
|
+
else
|
202
|
+
puts " minimisation: skipped by developer.json, unmodified file uploaded"
|
203
|
+
end
|
183
204
|
end
|
184
205
|
r = PluginTool.post_with_json_response("/api/development-plugin-loader/put-file/#{@loaded_plugin_id}", params, {:file => [filename, data]})
|
185
206
|
if r["result"] == 'success'
|
data/lib/plugin_tool.rb
CHANGED
@@ -17,7 +17,7 @@ end
|
|
17
17
|
PluginTool.try_load_custom
|
18
18
|
|
19
19
|
WORKSPACE_FILE = 'workspace.json'
|
20
|
-
LOCAL_ONLY_COMMANDS = {"license-key" => true, "pack" => true, "check" => true, "new" => true, "list" => true}
|
20
|
+
LOCAL_ONLY_COMMANDS = {"license-key" => true, "pack" => true, "check" => true, "new" => true, "list" => true, "extract-text" => true}
|
21
21
|
NO_DEPENDENCY_COMMANDS = {"reset-db" => true}.merge(LOCAL_ONLY_COMMANDS)
|
22
22
|
NO_DEPENDENCY_COMMANDS.delete('list')
|
23
23
|
PLUGIN_SEARCH_PATH = ['.']
|
@@ -144,7 +144,7 @@ unless LOCAL_ONLY_COMMANDS[PLUGIN_TOOL_COMMAND]
|
|
144
144
|
PluginTool.setup_auth(options)
|
145
145
|
PluginTool.check_for_certificate_file
|
146
146
|
application_info = PluginTool.get_application_info
|
147
|
-
puts "Remote application name: #{(application_info["name"]||'').to_s.strip.gsub(/\s+/,' ')}"
|
147
|
+
STDERR.puts "Remote application name: #{(application_info["name"]||'').to_s.strip.gsub(/\s+/,' ')}"
|
148
148
|
end
|
149
149
|
|
150
150
|
if PLUGIN_TOOL_COMMAND == 'devtools'
|
@@ -171,6 +171,18 @@ if PLUGIN_TOOL_COMMAND == 'template-debugging'
|
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
174
|
+
if PLUGIN_TOOL_COMMAND == 'i18n-debugging'
|
175
|
+
disable = (ARGV[0] == 'disable')
|
176
|
+
puts disable ? "Disabling i18n debugging..." : "Enabling i18n debugging..."
|
177
|
+
if 'OK' == PluginTool.post("/api/development-plugin-loader/i18n-debugging?enable=#{disable ? '0' : '1'}")
|
178
|
+
puts "Done"
|
179
|
+
exit 0
|
180
|
+
else
|
181
|
+
puts "Error updating server"
|
182
|
+
exit 1
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
174
186
|
# If the user didn't requested a plugin, try to use the application info to select the root plugin
|
175
187
|
if requested_plugins.empty? && application_info
|
176
188
|
application_root_plugin = application_info["config"]["applicationRootPlugin"]
|
@@ -291,7 +303,7 @@ if PLUGIN_TOOL_COMMAND == 'list'
|
|
291
303
|
exit 0
|
292
304
|
end
|
293
305
|
|
294
|
-
puts "#{plugins.length} plugin#{plugins.length != 1 ? 's' : ''}"
|
306
|
+
STDERR.puts "#{plugins.length} plugin#{plugins.length != 1 ? 's' : ''}"
|
295
307
|
|
296
308
|
# Custom behaviour for this repo?
|
297
309
|
PluginTool.custom_behaviour.start(plugins, PLUGIN_TOOL_COMMAND, options, LOCAL_ONLY_COMMANDS[PLUGIN_TOOL_COMMAND])
|
@@ -304,6 +316,9 @@ when 'pack'
|
|
304
316
|
when 'check'
|
305
317
|
PluginTool.check_plugins(plugins)
|
306
318
|
exit 0
|
319
|
+
when 'extract-text'
|
320
|
+
PluginTool.i18n_extract_text(plugins)
|
321
|
+
exit 0
|
307
322
|
end
|
308
323
|
|
309
324
|
# Set up local plugin objects against server
|
data/lib/run.rb
CHANGED
@@ -70,4 +70,5 @@ require "#{PLUGIN_TOOL_ROOT_DIR}/lib/watchers.rb"
|
|
70
70
|
require "#{PLUGIN_TOOL_ROOT_DIR}/lib/minimise.rb"
|
71
71
|
require "#{PLUGIN_TOOL_ROOT_DIR}/lib/check.rb"
|
72
72
|
require "#{PLUGIN_TOOL_ROOT_DIR}/lib/custom.rb"
|
73
|
+
require "#{PLUGIN_TOOL_ROOT_DIR}/lib/i18n_extract_text.rb"
|
73
74
|
require "#{PLUGIN_TOOL_ROOT_DIR}/lib/plugin_tool.rb"
|
data/lib/server.rb
CHANGED
data/lib/usage.txt
CHANGED
@@ -68,6 +68,10 @@ Commands:
|
|
68
68
|
Enable or disable template debugging, including adding comments in generated HTML
|
69
69
|
to indicate which templates were used.
|
70
70
|
|
71
|
+
i18n-debugging [disable]
|
72
|
+
Enable or disable internationalisation debugging, including indicating which text
|
73
|
+
in the user interface is translated.
|
74
|
+
|
71
75
|
auth [SERVER]
|
72
76
|
Authorise with server. SERVER can optionally include a non-default port number.
|
73
77
|
|
@@ -93,6 +97,10 @@ Commands:
|
|
93
97
|
check
|
94
98
|
Perform checks on the plugin as a quick test before it's submitted for review.
|
95
99
|
|
100
|
+
extract-text
|
101
|
+
Extract translatable text from templates, and attempt to extract text from JavaScript
|
102
|
+
files, and output a JSON data structure suitable for translation.
|
103
|
+
|
96
104
|
license-key <application-id>
|
97
105
|
Generate a license key to allow plugin installation by a client. The numeric
|
98
106
|
application ID is displayed during plugin installation.
|
data/lib/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
8864920
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haplo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.2
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Haplo Services
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Development tools for developing Haplo plugins, see https://haplo.org
|
14
14
|
email: client.services@haplo-services.com
|
@@ -27,6 +27,7 @@ files:
|
|
27
27
|
- lib/haplo-templates.jar
|
28
28
|
- lib/hmac.rb
|
29
29
|
- lib/hsvt_parser_config.rb
|
30
|
+
- lib/i18n_extract_text.rb
|
30
31
|
- lib/js.jar
|
31
32
|
- lib/js_min.js
|
32
33
|
- lib/js_syntax_test.js
|