trusty-cms 4.1.2 → 4.1.7
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 +104 -104
- 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/_content.scss +1 -2
- data/app/assets/stylesheets/rad_social/rad_screen.scss +0 -4
- data/app/controllers/admin/assets_controller.rb +22 -21
- 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 -0
- 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 +1 -0
- data/config/routes.rb +6 -6
- 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/public/dispatch.fcgi +1 -1
- data/public/dispatch.rb +2 -2
- data/script/extension +1 -1
- data/script/rails +2 -2
- 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 +24 -24
- data/yarn.lock +3 -3
- metadata +7602 -103
- data/app/assets/javascripts/rad_social/captcha.js +0 -42
@@ -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/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'
|
@@ -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
|
+
};
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import core, { nullObj, boolObj, octObj, intObj, hexObj, nanObj, expObj, floatObj } from './core';
|
2
|
+
import failsafe from './failsafe';
|
3
|
+
import json from './json';
|
4
|
+
import yaml11 from './yaml-1.1';
|
5
|
+
import map from './failsafe/map';
|
6
|
+
import seq from './failsafe/seq';
|
7
|
+
import binary from './yaml-1.1/binary';
|
8
|
+
import omap from './yaml-1.1/omap';
|
9
|
+
import pairs from './yaml-1.1/pairs';
|
10
|
+
import set from './yaml-1.1/set';
|
11
|
+
import { floatTime, intTime, timestamp } from './yaml-1.1/timestamp';
|
12
|
+
export var schemas = {
|
13
|
+
core: core,
|
14
|
+
failsafe: failsafe,
|
15
|
+
json: json,
|
16
|
+
yaml11: yaml11
|
17
|
+
};
|
18
|
+
export var tags = {
|
19
|
+
binary: binary,
|
20
|
+
bool: boolObj,
|
21
|
+
float: floatObj,
|
22
|
+
floatExp: expObj,
|
23
|
+
floatNaN: nanObj,
|
24
|
+
floatTime: floatTime,
|
25
|
+
int: intObj,
|
26
|
+
intHex: hexObj,
|
27
|
+
intOct: octObj,
|
28
|
+
intTime: intTime,
|
29
|
+
map: map,
|
30
|
+
null: nullObj,
|
31
|
+
omap: omap,
|
32
|
+
pairs: pairs,
|
33
|
+
seq: seq,
|
34
|
+
set: set,
|
35
|
+
timestamp: timestamp
|
36
|
+
};
|
@@ -0,0 +1,76 @@
|
|
1
|
+
import map from './failsafe/map';
|
2
|
+
import seq from './failsafe/seq';
|
3
|
+
import Scalar from '../schema/Scalar';
|
4
|
+
import { resolveString } from './failsafe/string';
|
5
|
+
var schema = [map, seq, {
|
6
|
+
identify: function identify(value) {
|
7
|
+
return typeof value === 'string';
|
8
|
+
},
|
9
|
+
default: true,
|
10
|
+
tag: 'tag:yaml.org,2002:str',
|
11
|
+
resolve: resolveString,
|
12
|
+
stringify: function stringify(value) {
|
13
|
+
return JSON.stringify(value);
|
14
|
+
}
|
15
|
+
}, {
|
16
|
+
identify: function identify(value) {
|
17
|
+
return value == null;
|
18
|
+
},
|
19
|
+
createNode: function createNode(schema, value, ctx) {
|
20
|
+
return ctx.wrapScalars ? new Scalar(null) : null;
|
21
|
+
},
|
22
|
+
default: true,
|
23
|
+
tag: 'tag:yaml.org,2002:null',
|
24
|
+
test: /^null$/,
|
25
|
+
resolve: function resolve() {
|
26
|
+
return null;
|
27
|
+
},
|
28
|
+
stringify: function stringify(value) {
|
29
|
+
return JSON.stringify(value);
|
30
|
+
}
|
31
|
+
}, {
|
32
|
+
identify: function identify(value) {
|
33
|
+
return typeof value === 'boolean';
|
34
|
+
},
|
35
|
+
default: true,
|
36
|
+
tag: 'tag:yaml.org,2002:bool',
|
37
|
+
test: /^true|false$/,
|
38
|
+
resolve: function resolve(str) {
|
39
|
+
return str === 'true';
|
40
|
+
},
|
41
|
+
stringify: function stringify(value) {
|
42
|
+
return JSON.stringify(value);
|
43
|
+
}
|
44
|
+
}, {
|
45
|
+
identify: function identify(value) {
|
46
|
+
return typeof value === 'number';
|
47
|
+
},
|
48
|
+
default: true,
|
49
|
+
tag: 'tag:yaml.org,2002:int',
|
50
|
+
test: /^-?(?:0|[1-9][0-9]*)$/,
|
51
|
+
resolve: function resolve(str) {
|
52
|
+
return parseInt(str, 10);
|
53
|
+
},
|
54
|
+
stringify: function stringify(value) {
|
55
|
+
return JSON.stringify(value);
|
56
|
+
}
|
57
|
+
}, {
|
58
|
+
identify: function identify(value) {
|
59
|
+
return typeof value === 'number';
|
60
|
+
},
|
61
|
+
default: true,
|
62
|
+
tag: 'tag:yaml.org,2002:float',
|
63
|
+
test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,
|
64
|
+
resolve: function resolve(str) {
|
65
|
+
return parseFloat(str);
|
66
|
+
},
|
67
|
+
stringify: function stringify(value) {
|
68
|
+
return JSON.stringify(value);
|
69
|
+
}
|
70
|
+
}];
|
71
|
+
|
72
|
+
schema.scalarFallback = function (str) {
|
73
|
+
throw new SyntaxError("Unresolved plain scalar ".concat(JSON.stringify(str)));
|
74
|
+
};
|
75
|
+
|
76
|
+
export default schema;
|