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
@@ -0,0 +1,34 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _parseSeq = _interopRequireDefault(require("../../schema/parseSeq"));
|
9
|
+
|
10
|
+
var _Seq = _interopRequireDefault(require("../../schema/Seq"));
|
11
|
+
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
+
|
14
|
+
function createSeq(schema, obj, ctx) {
|
15
|
+
const seq = new _Seq.default(schema);
|
16
|
+
|
17
|
+
if (obj && obj[Symbol.iterator]) {
|
18
|
+
for (const it of obj) {
|
19
|
+
const v = schema.createNode(it, ctx.wrapScalars, null, ctx);
|
20
|
+
seq.items.push(v);
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
return seq;
|
25
|
+
}
|
26
|
+
|
27
|
+
var _default = {
|
28
|
+
createNode: createSeq,
|
29
|
+
default: true,
|
30
|
+
nodeClass: _Seq.default,
|
31
|
+
tag: 'tag:yaml.org,2002:seq',
|
32
|
+
resolve: _parseSeq.default
|
33
|
+
};
|
34
|
+
exports.default = _default;
|
@@ -0,0 +1,40 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = exports.resolveString = void 0;
|
7
|
+
|
8
|
+
var _stringify = require("../../stringify");
|
9
|
+
|
10
|
+
var _options = require("../options");
|
11
|
+
|
12
|
+
const resolveString = (doc, node) => {
|
13
|
+
// on error, will return { str: string, errors: Error[] }
|
14
|
+
const res = node.strValue;
|
15
|
+
if (!res) return '';
|
16
|
+
if (typeof res === 'string') return res;
|
17
|
+
res.errors.forEach(error => {
|
18
|
+
if (!error.source) error.source = node;
|
19
|
+
doc.errors.push(error);
|
20
|
+
});
|
21
|
+
return res.str;
|
22
|
+
};
|
23
|
+
|
24
|
+
exports.resolveString = resolveString;
|
25
|
+
var _default = {
|
26
|
+
identify: value => typeof value === 'string',
|
27
|
+
default: true,
|
28
|
+
tag: 'tag:yaml.org,2002:str',
|
29
|
+
resolve: resolveString,
|
30
|
+
|
31
|
+
stringify(item, ctx, onComment, onChompKeep) {
|
32
|
+
ctx = Object.assign({
|
33
|
+
actualString: true
|
34
|
+
}, ctx);
|
35
|
+
return (0, _stringify.stringifyString)(item, ctx, onComment, onChompKeep);
|
36
|
+
},
|
37
|
+
|
38
|
+
options: _options.strOptions
|
39
|
+
};
|
40
|
+
exports.default = _default;
|
@@ -0,0 +1,62 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.tags = exports.schemas = void 0;
|
7
|
+
|
8
|
+
var _core = _interopRequireWildcard(require("./core"));
|
9
|
+
|
10
|
+
var _failsafe = _interopRequireDefault(require("./failsafe"));
|
11
|
+
|
12
|
+
var _json = _interopRequireDefault(require("./json"));
|
13
|
+
|
14
|
+
var _yaml = _interopRequireDefault(require("./yaml-1.1"));
|
15
|
+
|
16
|
+
var _map = _interopRequireDefault(require("./failsafe/map"));
|
17
|
+
|
18
|
+
var _seq = _interopRequireDefault(require("./failsafe/seq"));
|
19
|
+
|
20
|
+
var _binary = _interopRequireDefault(require("./yaml-1.1/binary"));
|
21
|
+
|
22
|
+
var _omap = _interopRequireDefault(require("./yaml-1.1/omap"));
|
23
|
+
|
24
|
+
var _pairs = _interopRequireDefault(require("./yaml-1.1/pairs"));
|
25
|
+
|
26
|
+
var _set = _interopRequireDefault(require("./yaml-1.1/set"));
|
27
|
+
|
28
|
+
var _timestamp = require("./yaml-1.1/timestamp");
|
29
|
+
|
30
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
31
|
+
|
32
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
33
|
+
|
34
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
35
|
+
|
36
|
+
const schemas = {
|
37
|
+
core: _core.default,
|
38
|
+
failsafe: _failsafe.default,
|
39
|
+
json: _json.default,
|
40
|
+
yaml11: _yaml.default
|
41
|
+
};
|
42
|
+
exports.schemas = schemas;
|
43
|
+
const tags = {
|
44
|
+
binary: _binary.default,
|
45
|
+
bool: _core.boolObj,
|
46
|
+
float: _core.floatObj,
|
47
|
+
floatExp: _core.expObj,
|
48
|
+
floatNaN: _core.nanObj,
|
49
|
+
floatTime: _timestamp.floatTime,
|
50
|
+
int: _core.intObj,
|
51
|
+
intHex: _core.hexObj,
|
52
|
+
intOct: _core.octObj,
|
53
|
+
intTime: _timestamp.intTime,
|
54
|
+
map: _map.default,
|
55
|
+
null: _core.nullObj,
|
56
|
+
omap: _omap.default,
|
57
|
+
pairs: _pairs.default,
|
58
|
+
seq: _seq.default,
|
59
|
+
set: _set.default,
|
60
|
+
timestamp: _timestamp.timestamp
|
61
|
+
};
|
62
|
+
exports.tags = tags;
|
@@ -0,0 +1,60 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _map = _interopRequireDefault(require("./failsafe/map"));
|
9
|
+
|
10
|
+
var _seq = _interopRequireDefault(require("./failsafe/seq"));
|
11
|
+
|
12
|
+
var _Scalar = _interopRequireDefault(require("../schema/Scalar"));
|
13
|
+
|
14
|
+
var _string = require("./failsafe/string");
|
15
|
+
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
|
+
|
18
|
+
const schema = [_map.default, _seq.default, {
|
19
|
+
identify: value => typeof value === 'string',
|
20
|
+
default: true,
|
21
|
+
tag: 'tag:yaml.org,2002:str',
|
22
|
+
resolve: _string.resolveString,
|
23
|
+
stringify: value => JSON.stringify(value)
|
24
|
+
}, {
|
25
|
+
identify: value => value == null,
|
26
|
+
createNode: (schema, value, ctx) => ctx.wrapScalars ? new _Scalar.default(null) : null,
|
27
|
+
default: true,
|
28
|
+
tag: 'tag:yaml.org,2002:null',
|
29
|
+
test: /^null$/,
|
30
|
+
resolve: () => null,
|
31
|
+
stringify: value => JSON.stringify(value)
|
32
|
+
}, {
|
33
|
+
identify: value => typeof value === 'boolean',
|
34
|
+
default: true,
|
35
|
+
tag: 'tag:yaml.org,2002:bool',
|
36
|
+
test: /^true|false$/,
|
37
|
+
resolve: str => str === 'true',
|
38
|
+
stringify: value => JSON.stringify(value)
|
39
|
+
}, {
|
40
|
+
identify: value => typeof value === 'number',
|
41
|
+
default: true,
|
42
|
+
tag: 'tag:yaml.org,2002:int',
|
43
|
+
test: /^-?(?:0|[1-9][0-9]*)$/,
|
44
|
+
resolve: str => parseInt(str, 10),
|
45
|
+
stringify: value => JSON.stringify(value)
|
46
|
+
}, {
|
47
|
+
identify: value => typeof value === 'number',
|
48
|
+
default: true,
|
49
|
+
tag: 'tag:yaml.org,2002:float',
|
50
|
+
test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,
|
51
|
+
resolve: str => parseFloat(str),
|
52
|
+
stringify: value => JSON.stringify(value)
|
53
|
+
}];
|
54
|
+
|
55
|
+
schema.scalarFallback = str => {
|
56
|
+
throw new SyntaxError(`Unresolved plain scalar ${JSON.stringify(str)}`);
|
57
|
+
};
|
58
|
+
|
59
|
+
var _default = schema;
|
60
|
+
exports.default = _default;
|
@@ -0,0 +1,35 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.strOptions = exports.nullOptions = exports.boolOptions = exports.binaryOptions = void 0;
|
7
|
+
|
8
|
+
var _constants = require("../constants");
|
9
|
+
|
10
|
+
const binaryOptions = {
|
11
|
+
defaultType: _constants.Type.BLOCK_LITERAL,
|
12
|
+
lineWidth: 76
|
13
|
+
};
|
14
|
+
exports.binaryOptions = binaryOptions;
|
15
|
+
const boolOptions = {
|
16
|
+
trueStr: 'true',
|
17
|
+
falseStr: 'false'
|
18
|
+
};
|
19
|
+
exports.boolOptions = boolOptions;
|
20
|
+
const nullOptions = {
|
21
|
+
nullStr: 'null'
|
22
|
+
};
|
23
|
+
exports.nullOptions = nullOptions;
|
24
|
+
const strOptions = {
|
25
|
+
defaultType: _constants.Type.PLAIN,
|
26
|
+
doubleQuoted: {
|
27
|
+
jsonEncoding: false,
|
28
|
+
minMultiLineLength: 40
|
29
|
+
},
|
30
|
+
fold: {
|
31
|
+
lineWidth: 80,
|
32
|
+
minContentWidth: 20
|
33
|
+
}
|
34
|
+
};
|
35
|
+
exports.strOptions = strOptions;
|
@@ -0,0 +1,97 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _constants = require("../../constants");
|
9
|
+
|
10
|
+
var _errors = require("../../errors");
|
11
|
+
|
12
|
+
var _stringify = require("../../stringify");
|
13
|
+
|
14
|
+
var _string = require("../failsafe/string");
|
15
|
+
|
16
|
+
var _options = require("../options");
|
17
|
+
|
18
|
+
/* global atob, btoa, Buffer */
|
19
|
+
var _default = {
|
20
|
+
identify: value => value instanceof Uint8Array,
|
21
|
+
// Buffer inherits from Uint8Array
|
22
|
+
default: false,
|
23
|
+
tag: 'tag:yaml.org,2002:binary',
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Returns a Buffer in node and an Uint8Array in browsers
|
27
|
+
*
|
28
|
+
* To use the resulting buffer as an image, you'll want to do something like:
|
29
|
+
*
|
30
|
+
* const blob = new Blob([buffer], { type: 'image/jpeg' })
|
31
|
+
* document.querySelector('#photo').src = URL.createObjectURL(blob)
|
32
|
+
*/
|
33
|
+
resolve: (doc, node) => {
|
34
|
+
const src = (0, _string.resolveString)(doc, node);
|
35
|
+
|
36
|
+
if (typeof Buffer === 'function') {
|
37
|
+
return Buffer.from(src, 'base64');
|
38
|
+
} else if (typeof atob === 'function') {
|
39
|
+
// On IE 11, atob() can't handle newlines
|
40
|
+
const str = atob(src.replace(/[\n\r]/g, ''));
|
41
|
+
const buffer = new Uint8Array(str.length);
|
42
|
+
|
43
|
+
for (let i = 0; i < str.length; ++i) buffer[i] = str.charCodeAt(i);
|
44
|
+
|
45
|
+
return buffer;
|
46
|
+
} else {
|
47
|
+
const msg = 'This environment does not support reading binary tags; either Buffer or atob is required';
|
48
|
+
doc.errors.push(new _errors.YAMLReferenceError(node, msg));
|
49
|
+
return null;
|
50
|
+
}
|
51
|
+
},
|
52
|
+
options: _options.binaryOptions,
|
53
|
+
stringify: ({
|
54
|
+
comment,
|
55
|
+
type,
|
56
|
+
value
|
57
|
+
}, ctx, onComment, onChompKeep) => {
|
58
|
+
let src;
|
59
|
+
|
60
|
+
if (typeof Buffer === 'function') {
|
61
|
+
src = value instanceof Buffer ? value.toString('base64') : Buffer.from(value.buffer).toString('base64');
|
62
|
+
} else if (typeof btoa === 'function') {
|
63
|
+
let s = '';
|
64
|
+
|
65
|
+
for (let i = 0; i < value.length; ++i) s += String.fromCharCode(value[i]);
|
66
|
+
|
67
|
+
src = btoa(s);
|
68
|
+
} else {
|
69
|
+
throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required');
|
70
|
+
}
|
71
|
+
|
72
|
+
if (!type) type = _options.binaryOptions.defaultType;
|
73
|
+
|
74
|
+
if (type === _constants.Type.QUOTE_DOUBLE) {
|
75
|
+
value = src;
|
76
|
+
} else {
|
77
|
+
const {
|
78
|
+
lineWidth
|
79
|
+
} = _options.binaryOptions;
|
80
|
+
const n = Math.ceil(src.length / lineWidth);
|
81
|
+
const lines = new Array(n);
|
82
|
+
|
83
|
+
for (let i = 0, o = 0; i < n; ++i, o += lineWidth) {
|
84
|
+
lines[i] = src.substr(o, lineWidth);
|
85
|
+
}
|
86
|
+
|
87
|
+
value = lines.join(type === _constants.Type.BLOCK_LITERAL ? '\n' : ' ');
|
88
|
+
}
|
89
|
+
|
90
|
+
return (0, _stringify.stringifyString)({
|
91
|
+
comment,
|
92
|
+
type,
|
93
|
+
value
|
94
|
+
}, ctx, onComment, onChompKeep);
|
95
|
+
}
|
96
|
+
};
|
97
|
+
exports.default = _default;
|
@@ -0,0 +1,131 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _Scalar = _interopRequireDefault(require("../../schema/Scalar"));
|
9
|
+
|
10
|
+
var _stringify = require("../../stringify");
|
11
|
+
|
12
|
+
var _failsafe = _interopRequireDefault(require("../failsafe"));
|
13
|
+
|
14
|
+
var _options = require("../options");
|
15
|
+
|
16
|
+
var _binary = _interopRequireDefault(require("./binary"));
|
17
|
+
|
18
|
+
var _omap = _interopRequireDefault(require("./omap"));
|
19
|
+
|
20
|
+
var _pairs = _interopRequireDefault(require("./pairs"));
|
21
|
+
|
22
|
+
var _set = _interopRequireDefault(require("./set"));
|
23
|
+
|
24
|
+
var _timestamp = require("./timestamp");
|
25
|
+
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
27
|
+
|
28
|
+
const boolStringify = ({
|
29
|
+
value
|
30
|
+
}) => value ? _options.boolOptions.trueStr : _options.boolOptions.falseStr;
|
31
|
+
|
32
|
+
var _default = _failsafe.default.concat([{
|
33
|
+
identify: value => value == null,
|
34
|
+
createNode: (schema, value, ctx) => ctx.wrapScalars ? new _Scalar.default(null) : null,
|
35
|
+
default: true,
|
36
|
+
tag: 'tag:yaml.org,2002:null',
|
37
|
+
test: /^(?:~|[Nn]ull|NULL)?$/,
|
38
|
+
resolve: () => null,
|
39
|
+
options: _options.nullOptions,
|
40
|
+
stringify: () => _options.nullOptions.nullStr
|
41
|
+
}, {
|
42
|
+
identify: value => typeof value === 'boolean',
|
43
|
+
default: true,
|
44
|
+
tag: 'tag:yaml.org,2002:bool',
|
45
|
+
test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
|
46
|
+
resolve: () => true,
|
47
|
+
options: _options.boolOptions,
|
48
|
+
stringify: boolStringify
|
49
|
+
}, {
|
50
|
+
identify: value => typeof value === 'boolean',
|
51
|
+
default: true,
|
52
|
+
tag: 'tag:yaml.org,2002:bool',
|
53
|
+
test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/i,
|
54
|
+
resolve: () => false,
|
55
|
+
options: _options.boolOptions,
|
56
|
+
stringify: boolStringify
|
57
|
+
}, {
|
58
|
+
identify: value => typeof value === 'number',
|
59
|
+
default: true,
|
60
|
+
tag: 'tag:yaml.org,2002:int',
|
61
|
+
format: 'BIN',
|
62
|
+
test: /^0b([0-1_]+)$/,
|
63
|
+
resolve: (str, bin) => parseInt(bin.replace(/_/g, ''), 2),
|
64
|
+
stringify: ({
|
65
|
+
value
|
66
|
+
}) => '0b' + value.toString(2)
|
67
|
+
}, {
|
68
|
+
identify: value => typeof value === 'number',
|
69
|
+
default: true,
|
70
|
+
tag: 'tag:yaml.org,2002:int',
|
71
|
+
format: 'OCT',
|
72
|
+
test: /^[-+]?0([0-7_]+)$/,
|
73
|
+
resolve: (str, oct) => parseInt(oct.replace(/_/g, ''), 8),
|
74
|
+
stringify: ({
|
75
|
+
value
|
76
|
+
}) => (value < 0 ? '-0' : '0') + value.toString(8)
|
77
|
+
}, {
|
78
|
+
identify: value => typeof value === 'number',
|
79
|
+
default: true,
|
80
|
+
tag: 'tag:yaml.org,2002:int',
|
81
|
+
test: /^[-+]?[0-9][0-9_]*$/,
|
82
|
+
resolve: str => parseInt(str.replace(/_/g, ''), 10),
|
83
|
+
stringify: _stringify.stringifyNumber
|
84
|
+
}, {
|
85
|
+
identify: value => typeof value === 'number',
|
86
|
+
default: true,
|
87
|
+
tag: 'tag:yaml.org,2002:int',
|
88
|
+
format: 'HEX',
|
89
|
+
test: /^0x([0-9a-fA-F_]+)$/,
|
90
|
+
resolve: (str, hex) => parseInt(hex.replace(/_/g, ''), 16),
|
91
|
+
stringify: ({
|
92
|
+
value
|
93
|
+
}) => (value < 0 ? '-0x' : '0x') + value.toString(16)
|
94
|
+
}, {
|
95
|
+
identify: value => typeof value === 'number',
|
96
|
+
default: true,
|
97
|
+
tag: 'tag:yaml.org,2002:float',
|
98
|
+
test: /^(?:[-+]?\.inf|(\.nan))$/i,
|
99
|
+
resolve: (str, nan) => nan ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
|
100
|
+
stringify: _stringify.stringifyNumber
|
101
|
+
}, {
|
102
|
+
identify: value => typeof value === 'number',
|
103
|
+
default: true,
|
104
|
+
tag: 'tag:yaml.org,2002:float',
|
105
|
+
format: 'EXP',
|
106
|
+
test: /^[-+]?([0-9][0-9_]*)?(\.[0-9_]*)?[eE][-+]?[0-9]+$/,
|
107
|
+
resolve: str => parseFloat(str.replace(/_/g, '')),
|
108
|
+
stringify: ({
|
109
|
+
value
|
110
|
+
}) => Number(value).toExponential()
|
111
|
+
}, {
|
112
|
+
identify: value => typeof value === 'number',
|
113
|
+
default: true,
|
114
|
+
tag: 'tag:yaml.org,2002:float',
|
115
|
+
test: /^[-+]?(?:[0-9][0-9_]*)?\.([0-9_]*)$/,
|
116
|
+
|
117
|
+
resolve(str, frac) {
|
118
|
+
const node = new _Scalar.default(parseFloat(str.replace(/_/g, '')));
|
119
|
+
|
120
|
+
if (frac) {
|
121
|
+
const f = frac.replace(/_/g, '');
|
122
|
+
if (f[f.length - 1] === '0') node.minFractionDigits = f.length;
|
123
|
+
}
|
124
|
+
|
125
|
+
return node;
|
126
|
+
},
|
127
|
+
|
128
|
+
stringify: _stringify.stringifyNumber
|
129
|
+
}], _binary.default, _omap.default, _pairs.default, _set.default, _timestamp.intTime, _timestamp.floatTime, _timestamp.timestamp);
|
130
|
+
|
131
|
+
exports.default = _default;
|