trusty-cms 4.1.1 → 4.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -3
- data/Gemfile.lock +107 -107
- data/README.md +1 -1
- data/Rakefile +7 -7
- data/app/assets/javascripts/admin/assets.js +1 -1
- data/app/assets/javascripts/rad_social/rad_ajax_form.js +3 -0
- data/app/assets/javascripts/rad_social/rad_email.js +0 -1
- data/app/assets/javascripts/rad_social/rad_email_form.js +2 -7
- data/app/assets/stylesheets/admin/partials/_forms.scss +1 -1
- data/app/assets/stylesheets/rad_social/rad_screen.scss +0 -4
- data/app/controllers/admin/assets_controller.rb +21 -31
- data/app/controllers/admin/configuration_controller.rb +9 -11
- data/app/controllers/admin/extensions_controller.rb +3 -3
- data/app/controllers/admin/layouts_controller.rb +3 -4
- data/app/controllers/admin/page_attachments_controller.rb +5 -5
- data/app/controllers/admin/page_fields_controller.rb +3 -4
- data/app/controllers/admin/page_parts_controller.rb +4 -5
- data/app/controllers/admin/pages_controller.rb +55 -56
- data/app/controllers/admin/references_controller.rb +1 -1
- data/app/controllers/admin/resource_controller.rb +132 -130
- data/app/controllers/admin/sites_controller.rb +4 -4
- data/app/controllers/admin/snippets_controller.rb +3 -4
- data/app/controllers/admin/users_controller.rb +16 -16
- data/app/controllers/application_controller.rb +47 -48
- data/app/controllers/site_controller.rb +51 -48
- data/app/controllers/social_mailer_controller.rb +12 -22
- data/app/helpers/admin/configuration_helper.rb +19 -20
- data/app/helpers/admin/layouts_helper.rb +0 -1
- data/app/helpers/admin/node_helper.rb +27 -24
- data/app/helpers/admin/pages_helper.rb +2 -2
- data/app/helpers/admin/preferences_helper.rb +0 -1
- data/app/helpers/admin/references_helper.rb +9 -10
- data/app/helpers/admin/regions_helper.rb +3 -3
- data/app/helpers/application_helper.rb +32 -33
- data/app/helpers/rad_social_helper.rb +8 -11
- data/app/helpers/scoped_helper.rb +1 -3
- data/app/helpers/sites_helper.rb +4 -4
- data/app/mailers/devise_mailer.rb +3 -4
- data/app/mailers/rad_social_mailer.rb +8 -8
- data/app/models/asset.rb +62 -63
- data/app/models/asset_type.rb +38 -39
- data/app/models/deprecated_tags.rb +3 -4
- data/app/models/file_not_found_page.rb +1 -3
- data/app/models/haml_filter.rb +1 -1
- data/app/models/layout.rb +4 -5
- data/app/models/legacy_user.rb +2 -2
- data/app/models/menu_renderer.rb +16 -18
- data/app/models/page.rb +96 -93
- data/app/models/page_attachment.rb +1 -2
- data/app/models/page_context.rb +11 -12
- data/app/models/page_part.rb +3 -4
- data/app/models/rails_page.rb +10 -12
- data/app/models/site.rb +22 -21
- data/app/models/snippet.rb +6 -8
- data/app/models/snippet_finder.rb +3 -3
- data/app/models/snippet_tags.rb +4 -4
- data/app/models/standard_tags.rb +258 -252
- data/app/models/status.rb +8 -8
- data/app/models/trusty_cms/config.rb +25 -25
- data/app/models/trusty_cms/page_response_cache_director.rb +2 -3
- data/app/models/user.rb +15 -14
- data/app/models/user_action_observer.rb +3 -3
- data/app/views/admin/assets/edit.html.haml +3 -9
- data/app/views/admin/assets/new.html.haml +0 -3
- data/app/views/admin/assets/remove.html.haml +1 -1
- data/app/views/admin/layouts/remove.html.haml +3 -2
- data/app/views/admin/page_parts/_page_part.html.haml +1 -1
- data/app/views/admin/snippets/remove.html.haml +3 -2
- data/app/views/rad_social_mailer/social_mail_form.html.haml +1 -3
- data/app/views/widget/_email_form.html.haml +0 -5
- data/bin/rails +4 -4
- data/bin/trusty_cms +3 -5
- data/config.ru +1 -1
- data/config/application.rb +14 -15
- data/config/boot.rb +1 -2
- data/config/environment.rb +1 -1
- data/config/environments/production.rb +0 -1
- data/config/environments/test.rb +1 -2
- data/config/initializers/devise.rb +1 -1
- data/config/initializers/kraken.rb +2 -2
- data/config/initializers/tmp.rb +1 -1
- data/config/initializers/trusty_cms_config.rb +48 -48
- data/config/locales/en.yml +5 -4
- data/config/routes.rb +6 -7
- data/lib/active_record_extensions/active_record_extensions.rb +1 -2
- data/lib/annotatable.rb +3 -5
- data/lib/configuration_extensions/configuration_extensions.rb +1 -1
- data/lib/inheritable_class_attributes.rb +13 -9
- data/lib/login_system.rb +73 -73
- data/lib/method_observer.rb +13 -12
- data/lib/ostruct.rb +7 -10
- data/lib/simpleton.rb +0 -4
- data/lib/string_extensions/string_extensions.rb +3 -3
- data/lib/symbol_extensions/symbol_extensions.rb +1 -1
- data/lib/tasks/database.rake +28 -28
- data/lib/tasks/extensions.rake +18 -18
- data/lib/tasks/framework.rake +68 -68
- data/lib/tasks/radiant_config.rake +4 -4
- data/lib/tasks/snippets_extension_tasks.rake +11 -11
- data/lib/tasks/translate.rake +14 -14
- data/lib/tasks/upgrade_to_devise.rake +1 -1
- data/lib/translation_support.rb +22 -22
- data/lib/trusty_cms.rb +2 -2
- data/lib/trusty_cms/admin_ui.rb +19 -16
- data/lib/trusty_cms/admin_ui/region_partials.rb +4 -3
- data/lib/trusty_cms/admin_ui/region_set.rb +4 -5
- data/lib/trusty_cms/available_locales.rb +2 -4
- data/lib/trusty_cms/config/definition.rb +11 -8
- data/lib/trusty_cms/engine.rb +13 -14
- data/lib/trusty_cms/extension.rb +14 -16
- data/lib/trusty_cms/extension_loader.rb +6 -6
- data/lib/trusty_cms/extension_migrator.rb +42 -41
- data/lib/trusty_cms/extension_path.rb +20 -19
- data/lib/trusty_cms/initializer.rb +5 -8
- data/lib/trusty_cms/pagination/controller.rb +7 -10
- data/lib/trusty_cms/pagination/link_renderer.rb +2 -2
- data/lib/trusty_cms/resource_responses.rb +3 -3
- data/lib/trusty_cms/setup.rb +130 -132
- data/lib/trusty_cms/taggable.rb +19 -22
- data/lib/trusty_cms/task_support.rb +9 -6
- data/package.json +1 -1
- data/public/dispatch.fcgi +1 -1
- data/public/dispatch.rb +2 -2
- data/script/extension +1 -1
- data/script/rails +2 -2
- data/spec/dummy/package.json +1 -1
- data/spec/dummy/yarn.lock +3 -3
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/core.js +126 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/index.js +4 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/map.js +56 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/seq.js +43 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/string.js +28 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/index.js +36 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/json.js +76 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/options.js +23 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/binary.js +87 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/index.js +157 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/omap.js +142 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/pairs.js +81 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/set.js +114 -0
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/timestamp.js +97 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/core.js +114 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/index.js +17 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/map.js +37 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/seq.js +34 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/string.js +40 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/index.js +62 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/json.js +60 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/options.js +35 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/binary.js +97 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/index.js +131 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/omap.js +105 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/pairs.js +80 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/set.js +91 -0
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/timestamp.js +93 -0
- data/trusty_cms.gemspec +25 -25
- data/vendor/extensions/clipped-extension/lib/clipped_admin_ui.rb +1 -1
- data/yarn.lock +7 -7
- metadata +7609 -105
- data/app/assets/javascripts/rad_social/captcha.js +0 -42
- data/app/views/admin/assets/refresh.html.haml +0 -14
data/lib/trusty_cms/taggable.rb
CHANGED
@@ -13,20 +13,21 @@ module TrustyCms::Taggable
|
|
13
13
|
end
|
14
14
|
class << new_base
|
15
15
|
def default_url_options
|
16
|
-
{:
|
16
|
+
{ controller: 'site', action: 'show_page', only_path: true }
|
17
17
|
end
|
18
18
|
end
|
19
|
-
new_base.tag_descriptions.merge!
|
19
|
+
new_base.tag_descriptions.merge! tag_descriptions
|
20
20
|
end
|
21
21
|
|
22
22
|
protected
|
23
|
-
def params
|
24
|
-
@params ||= request.parameters unless request.nil?
|
25
|
-
end
|
26
23
|
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
def params
|
25
|
+
@params ||= request.parameters unless request.nil?
|
26
|
+
end
|
27
|
+
|
28
|
+
def request_uri
|
29
|
+
@request_url ||= request.request_uri unless request.nil?
|
30
|
+
end
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
@@ -44,11 +45,11 @@ module TrustyCms::Taggable
|
|
44
45
|
Util.tags_in_array(methods)
|
45
46
|
end
|
46
47
|
|
47
|
-
def tag_descriptions(hash=nil)
|
48
|
+
def tag_descriptions(hash = nil)
|
48
49
|
self.class.tag_descriptions hash
|
49
50
|
end
|
50
51
|
|
51
|
-
def warn_of_tag_deprecation(tag_name, options={})
|
52
|
+
def warn_of_tag_deprecation(tag_name, options = {})
|
52
53
|
message = "Deprecated radius tag <r:#{tag_name}>"
|
53
54
|
message << " will be removed or significantly changed in trusty #{options[:deadline]}." if options[:deadline]
|
54
55
|
message << " Please use <r:#{options[:substitute]}> instead." if options[:substitute]
|
@@ -57,12 +58,12 @@ module TrustyCms::Taggable
|
|
57
58
|
|
58
59
|
module ClassMethods
|
59
60
|
def inherited(subclass)
|
60
|
-
subclass.tag_descriptions.reverse_merge!
|
61
|
+
subclass.tag_descriptions.reverse_merge! tag_descriptions
|
61
62
|
super
|
62
63
|
end
|
63
64
|
|
64
65
|
def tag_descriptions(hash = nil)
|
65
|
-
TrustyCms::Taggable.tag_descriptions[
|
66
|
+
TrustyCms::Taggable.tag_descriptions[name] ||= (hash || {})
|
66
67
|
end
|
67
68
|
|
68
69
|
def desc(text)
|
@@ -71,13 +72,13 @@ module TrustyCms::Taggable
|
|
71
72
|
end
|
72
73
|
|
73
74
|
def tag(name, &block)
|
74
|
-
|
75
|
+
tag_descriptions[name] = TrustyCms::Taggable.last_description if TrustyCms::Taggable.last_description
|
75
76
|
TrustyCms::Taggable.last_description = nil
|
76
77
|
define_method("tag:#{name}", &block)
|
77
78
|
end
|
78
79
|
|
79
80
|
def tags
|
80
|
-
Util.tags_in_array(
|
81
|
+
Util.tags_in_array(instance_methods)
|
81
82
|
end
|
82
83
|
|
83
84
|
# Define a tag while also deprecating it. Normal usage:
|
@@ -98,7 +99,7 @@ module TrustyCms::Taggable
|
|
98
99
|
# raise TagError "..."
|
99
100
|
# end
|
100
101
|
#
|
101
|
-
def deprecated_tag(name, options={}, &dblock)
|
102
|
+
def deprecated_tag(name, options = {}, &dblock)
|
102
103
|
TrustyCms::Taggable.tag_deprecations[name] = options.dup
|
103
104
|
if dblock
|
104
105
|
tag(name) do |tag|
|
@@ -121,18 +122,14 @@ module TrustyCms::Taggable
|
|
121
122
|
|
122
123
|
def self.strip_leading_whitespace(text)
|
123
124
|
text = text.dup
|
124
|
-
text.gsub!("\t",
|
125
|
+
text.gsub!("\t", ' ')
|
125
126
|
lines = text.split("\n")
|
126
127
|
leading = lines.map do |line|
|
127
128
|
unless line =~ /^\s*$/
|
128
|
-
|
129
|
-
else
|
130
|
-
nil
|
129
|
+
line.match(/^(\s*)/)[0].length
|
131
130
|
end
|
132
131
|
end.compact.min
|
133
|
-
lines.inject([]) {|ary, line| ary << line.sub(/^[ ]{#{leading}}/,
|
132
|
+
lines.inject([]) { |ary, line| ary << line.sub(/^[ ]{#{leading}}/, '') }.join("\n")
|
134
133
|
end
|
135
|
-
|
136
134
|
end
|
137
|
-
|
138
135
|
end
|
@@ -8,15 +8,17 @@ module TrustyCms
|
|
8
8
|
ActiveRecord::Base.establish_connection(env_connection)
|
9
9
|
end
|
10
10
|
end
|
11
|
+
|
11
12
|
def config_export(path = "#{Rails.root}/config/trusty_config.yml")
|
12
|
-
|
13
|
+
establish_connection
|
13
14
|
FileUtils.mkdir_p(File.dirname(path))
|
14
|
-
if File.open(File.expand_path(path), 'w') { |f| YAML.dump(TrustyCms::Config.to_hash.to_yaml,f) }
|
15
|
+
if File.open(File.expand_path(path), 'w') { |f| YAML.dump(TrustyCms::Config.to_hash.to_yaml, f) }
|
15
16
|
puts "TrustyCms::Config saved to #{path}"
|
16
17
|
end
|
17
18
|
end
|
19
|
+
|
18
20
|
def config_import(path = "#{Rails.root}/config/trusty_config.yml", clear = nil)
|
19
|
-
|
21
|
+
establish_connection
|
20
22
|
if File.exist?(path)
|
21
23
|
begin
|
22
24
|
TrustyCms::Config.transaction do
|
@@ -40,12 +42,13 @@ module TrustyCms
|
|
40
42
|
# Write the combined content of files in dir into cache_file in the same dir.
|
41
43
|
#
|
42
44
|
def cache_files(dir, files, cache_file)
|
43
|
-
cache_content = files.collect
|
44
|
-
File.read(File.join(dir, f))
|
45
|
+
cache_content = files.collect do |f|
|
46
|
+
File.read(File.join(dir, f))
|
47
|
+
end .join("\n\n")
|
45
48
|
|
46
49
|
cache_path = File.join(dir, cache_file)
|
47
50
|
File.delete(cache_path) if File.exists?(cache_path)
|
48
|
-
File.open(cache_path,
|
51
|
+
File.open(cache_path, 'w+') { |f| f.write(cache_content) }
|
49
52
|
end
|
50
53
|
|
51
54
|
# Reads through the layout file and returns an array of JS filenames
|
data/package.json
CHANGED
data/public/dispatch.fcgi
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
# # Custom log path, normal GC behavior.
|
19
19
|
# RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log'
|
20
20
|
#
|
21
|
-
require File.dirname(__FILE__) +
|
21
|
+
require File.dirname(__FILE__) + '/../config/environment'
|
22
22
|
require 'fcgi_handler'
|
23
23
|
|
24
24
|
RailsFCGIHandler.process!
|
data/public/dispatch.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
#!/home/rails/bin/ruby
|
2
2
|
|
3
|
-
require File.dirname(__FILE__) +
|
3
|
+
require File.dirname(__FILE__) + '/../config/environment' unless defined?(Rails.root)
|
4
4
|
|
5
5
|
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
|
6
6
|
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
|
7
|
-
require
|
7
|
+
require 'dispatcher'
|
8
8
|
|
9
9
|
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
|
10
10
|
Dispatcher.dispatch
|
data/script/extension
CHANGED
data/script/rails
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
3
|
|
4
|
-
APP_PATH = File.expand_path('
|
5
|
-
require File.expand_path('
|
4
|
+
APP_PATH = File.expand_path('../config/application', __dir__)
|
5
|
+
require File.expand_path('../config/boot', __dir__)
|
6
6
|
require 'rails/commands'
|
data/spec/dummy/package.json
CHANGED
data/spec/dummy/yarn.lock
CHANGED
@@ -12,6 +12,6 @@ jquery-ujs@^1.2.2:
|
|
12
12
|
dependencies:
|
13
13
|
jquery ">=1.8.0"
|
14
14
|
|
15
|
-
jquery@>=1.8.0, jquery@^3.
|
16
|
-
version "3.
|
17
|
-
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.
|
15
|
+
jquery@>=1.8.0, jquery@^3.5.0:
|
16
|
+
version "3.5.0"
|
17
|
+
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.5.0.tgz#9980b97d9e4194611c36530e7dc46a58d7340fc9"
|
@@ -0,0 +1,126 @@
|
|
1
|
+
import Scalar from '../schema/Scalar';
|
2
|
+
import { stringifyNumber } from '../stringify';
|
3
|
+
import failsafe from './failsafe';
|
4
|
+
import { boolOptions, nullOptions } from './options';
|
5
|
+
export var nullObj = {
|
6
|
+
identify: function identify(value) {
|
7
|
+
return value == null;
|
8
|
+
},
|
9
|
+
createNode: function createNode(schema, value, ctx) {
|
10
|
+
return ctx.wrapScalars ? new Scalar(null) : null;
|
11
|
+
},
|
12
|
+
default: true,
|
13
|
+
tag: 'tag:yaml.org,2002:null',
|
14
|
+
test: /^(?:~|[Nn]ull|NULL)?$/,
|
15
|
+
resolve: function resolve() {
|
16
|
+
return null;
|
17
|
+
},
|
18
|
+
options: nullOptions,
|
19
|
+
stringify: function stringify() {
|
20
|
+
return nullOptions.nullStr;
|
21
|
+
}
|
22
|
+
};
|
23
|
+
export var boolObj = {
|
24
|
+
identify: function identify(value) {
|
25
|
+
return typeof value === 'boolean';
|
26
|
+
},
|
27
|
+
default: true,
|
28
|
+
tag: 'tag:yaml.org,2002:bool',
|
29
|
+
test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
|
30
|
+
resolve: function resolve(str) {
|
31
|
+
return str[0] === 't' || str[0] === 'T';
|
32
|
+
},
|
33
|
+
options: boolOptions,
|
34
|
+
stringify: function stringify(_ref) {
|
35
|
+
var value = _ref.value;
|
36
|
+
return value ? boolOptions.trueStr : boolOptions.falseStr;
|
37
|
+
}
|
38
|
+
};
|
39
|
+
export var octObj = {
|
40
|
+
identify: function identify(value) {
|
41
|
+
return typeof value === 'number';
|
42
|
+
},
|
43
|
+
default: true,
|
44
|
+
tag: 'tag:yaml.org,2002:int',
|
45
|
+
format: 'OCT',
|
46
|
+
test: /^0o([0-7]+)$/,
|
47
|
+
resolve: function resolve(str, oct) {
|
48
|
+
return parseInt(oct, 8);
|
49
|
+
},
|
50
|
+
stringify: function stringify(_ref2) {
|
51
|
+
var value = _ref2.value;
|
52
|
+
return '0o' + value.toString(8);
|
53
|
+
}
|
54
|
+
};
|
55
|
+
export var intObj = {
|
56
|
+
identify: function identify(value) {
|
57
|
+
return typeof value === 'number';
|
58
|
+
},
|
59
|
+
default: true,
|
60
|
+
tag: 'tag:yaml.org,2002:int',
|
61
|
+
test: /^[-+]?[0-9]+$/,
|
62
|
+
resolve: function resolve(str) {
|
63
|
+
return parseInt(str, 10);
|
64
|
+
},
|
65
|
+
stringify: stringifyNumber
|
66
|
+
};
|
67
|
+
export var hexObj = {
|
68
|
+
identify: function identify(value) {
|
69
|
+
return typeof value === 'number';
|
70
|
+
},
|
71
|
+
default: true,
|
72
|
+
tag: 'tag:yaml.org,2002:int',
|
73
|
+
format: 'HEX',
|
74
|
+
test: /^0x([0-9a-fA-F]+)$/,
|
75
|
+
resolve: function resolve(str, hex) {
|
76
|
+
return parseInt(hex, 16);
|
77
|
+
},
|
78
|
+
stringify: function stringify(_ref3) {
|
79
|
+
var value = _ref3.value;
|
80
|
+
return '0x' + value.toString(16);
|
81
|
+
}
|
82
|
+
};
|
83
|
+
export var nanObj = {
|
84
|
+
identify: function identify(value) {
|
85
|
+
return typeof value === 'number';
|
86
|
+
},
|
87
|
+
default: true,
|
88
|
+
tag: 'tag:yaml.org,2002:float',
|
89
|
+
test: /^(?:[-+]?\.inf|(\.nan))$/i,
|
90
|
+
resolve: function resolve(str, nan) {
|
91
|
+
return nan ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY;
|
92
|
+
},
|
93
|
+
stringify: stringifyNumber
|
94
|
+
};
|
95
|
+
export var expObj = {
|
96
|
+
identify: function identify(value) {
|
97
|
+
return typeof value === 'number';
|
98
|
+
},
|
99
|
+
default: true,
|
100
|
+
tag: 'tag:yaml.org,2002:float',
|
101
|
+
format: 'EXP',
|
102
|
+
test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
|
103
|
+
resolve: function resolve(str) {
|
104
|
+
return parseFloat(str);
|
105
|
+
},
|
106
|
+
stringify: function stringify(_ref4) {
|
107
|
+
var value = _ref4.value;
|
108
|
+
return Number(value).toExponential();
|
109
|
+
}
|
110
|
+
};
|
111
|
+
export var floatObj = {
|
112
|
+
identify: function identify(value) {
|
113
|
+
return typeof value === 'number';
|
114
|
+
},
|
115
|
+
default: true,
|
116
|
+
tag: 'tag:yaml.org,2002:float',
|
117
|
+
test: /^[-+]?(?:\.([0-9]+)|[0-9]+\.([0-9]*))$/,
|
118
|
+
resolve: function resolve(str, frac1, frac2) {
|
119
|
+
var frac = frac1 || frac2;
|
120
|
+
var node = new Scalar(parseFloat(str));
|
121
|
+
if (frac && frac[frac.length - 1] === '0') node.minFractionDigits = frac.length;
|
122
|
+
return node;
|
123
|
+
},
|
124
|
+
stringify: stringifyNumber
|
125
|
+
};
|
126
|
+
export default failsafe.concat([nullObj, boolObj, octObj, intObj, hexObj, nanObj, expObj, floatObj]);
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
3
|
+
import YAMLMap from '../../schema/Map';
|
4
|
+
import parseMap from '../../schema/parseMap';
|
5
|
+
|
6
|
+
function createMap(schema, obj, ctx) {
|
7
|
+
var map = new YAMLMap(schema);
|
8
|
+
|
9
|
+
if (obj instanceof Map) {
|
10
|
+
var _iteratorNormalCompletion = true;
|
11
|
+
var _didIteratorError = false;
|
12
|
+
var _iteratorError = undefined;
|
13
|
+
|
14
|
+
try {
|
15
|
+
for (var _iterator = obj[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
16
|
+
var _step$value = _slicedToArray(_step.value, 2),
|
17
|
+
key = _step$value[0],
|
18
|
+
value = _step$value[1];
|
19
|
+
|
20
|
+
map.items.push(schema.createPair(key, value, ctx));
|
21
|
+
}
|
22
|
+
} catch (err) {
|
23
|
+
_didIteratorError = true;
|
24
|
+
_iteratorError = err;
|
25
|
+
} finally {
|
26
|
+
try {
|
27
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
28
|
+
_iterator.return();
|
29
|
+
}
|
30
|
+
} finally {
|
31
|
+
if (_didIteratorError) {
|
32
|
+
throw _iteratorError;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
} else if (obj && _typeof(obj) === 'object') {
|
37
|
+
for (var _i = 0, _Object$keys = Object.keys(obj); _i < _Object$keys.length; _i++) {
|
38
|
+
var _key = _Object$keys[_i];
|
39
|
+
map.items.push(schema.createPair(_key, obj[_key], ctx));
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
if (typeof schema.sortMapEntries === 'function') {
|
44
|
+
map.items.sort(schema.sortMapEntries);
|
45
|
+
}
|
46
|
+
|
47
|
+
return map;
|
48
|
+
}
|
49
|
+
|
50
|
+
export default {
|
51
|
+
createNode: createMap,
|
52
|
+
default: true,
|
53
|
+
nodeClass: YAMLMap,
|
54
|
+
tag: 'tag:yaml.org,2002:map',
|
55
|
+
resolve: parseMap
|
56
|
+
};
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import parseSeq from '../../schema/parseSeq';
|
2
|
+
import YAMLSeq from '../../schema/Seq';
|
3
|
+
|
4
|
+
function createSeq(schema, obj, ctx) {
|
5
|
+
var seq = new YAMLSeq(schema);
|
6
|
+
|
7
|
+
if (obj && obj[Symbol.iterator]) {
|
8
|
+
var _iteratorNormalCompletion = true;
|
9
|
+
var _didIteratorError = false;
|
10
|
+
var _iteratorError = undefined;
|
11
|
+
|
12
|
+
try {
|
13
|
+
for (var _iterator = obj[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
14
|
+
var it = _step.value;
|
15
|
+
var v = schema.createNode(it, ctx.wrapScalars, null, ctx);
|
16
|
+
seq.items.push(v);
|
17
|
+
}
|
18
|
+
} catch (err) {
|
19
|
+
_didIteratorError = true;
|
20
|
+
_iteratorError = err;
|
21
|
+
} finally {
|
22
|
+
try {
|
23
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
24
|
+
_iterator.return();
|
25
|
+
}
|
26
|
+
} finally {
|
27
|
+
if (_didIteratorError) {
|
28
|
+
throw _iteratorError;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
return seq;
|
35
|
+
}
|
36
|
+
|
37
|
+
export default {
|
38
|
+
createNode: createSeq,
|
39
|
+
default: true,
|
40
|
+
nodeClass: YAMLSeq,
|
41
|
+
tag: 'tag:yaml.org,2002:seq',
|
42
|
+
resolve: parseSeq
|
43
|
+
};
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { stringifyString } from '../../stringify';
|
2
|
+
import { strOptions } from '../options';
|
3
|
+
export var resolveString = function resolveString(doc, node) {
|
4
|
+
// on error, will return { str: string, errors: Error[] }
|
5
|
+
var res = node.strValue;
|
6
|
+
if (!res) return '';
|
7
|
+
if (typeof res === 'string') return res;
|
8
|
+
res.errors.forEach(function (error) {
|
9
|
+
if (!error.source) error.source = node;
|
10
|
+
doc.errors.push(error);
|
11
|
+
});
|
12
|
+
return res.str;
|
13
|
+
};
|
14
|
+
export default {
|
15
|
+
identify: function identify(value) {
|
16
|
+
return typeof value === 'string';
|
17
|
+
},
|
18
|
+
default: true,
|
19
|
+
tag: 'tag:yaml.org,2002:str',
|
20
|
+
resolve: resolveString,
|
21
|
+
stringify: function stringify(item, ctx, onComment, onChompKeep) {
|
22
|
+
ctx = Object.assign({
|
23
|
+
actualString: true
|
24
|
+
}, ctx);
|
25
|
+
return stringifyString(item, ctx, onComment, onChompKeep);
|
26
|
+
},
|
27
|
+
options: strOptions
|
28
|
+
};
|