├── js ├── jquery.js ├── index-node.js ├── index.js ├── app │ ├── options.js │ ├── util.js │ ├── printer.js │ ├── twinejson.js │ ├── treebuilder.js │ └── converter.js └── lib │ ├── FileSaver.js │ └── requirejs │ └── requirejs.js ├── test ├── stories │ └── castle.xml └── tests.js ├── .gitignore ├── .travis.yml ├── format.js ├── package.json ├── LICENSE ├── storyFormat.html ├── gulpfile.js ├── README.md ├── icon.svg ├── dist ├── icon.svg ├── storyFormat.html ├── escaped │ └── storyFormat.html └── format.js └── index.html /js/jquery.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/stories/castle.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .npm-debug.log -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "6.1" 4 | install: 5 | - npm install 6 | - mocha 7 | - gulp -------------------------------------------------------------------------------- /format.js: -------------------------------------------------------------------------------- 1 | window.storyFormat({ 2 | "name":"TwineJson", 3 | "version":"0.1.3", 4 | "author":"Cauli Tomaz", 5 | "description":"Export your story to JSON", 6 | "image":"icon.svg", 7 | "url":"https://github.com/cauli/TwineJson", 8 | "license":"MIT License", 9 | "proofing":false, 10 | "source":"@@include('./dist/escaped/storyFormat.html')" 11 | }); -------------------------------------------------------------------------------- /js/index-node.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * TwineJson 3 | * 4 | * Based on Entweedle by Michael McCollum 5 | * Copyright(c) 2015 Páprica Comunicação http://papricacomunicacao.com.br 6 | * Copyright(c) 2015-2016 Cauli Tomaz https://cau.li 7 | * MIT Licensed 8 | * 9 | * https://github.com/cauli/TwineJson 10 | */ 11 | 'use strict'; 12 | 13 | if (typeof define !== 'function') { 14 | var define = require('amdefine')(module); 15 | } 16 | 17 | requirejs.config({ 18 | "baseUrl": "js/lib", 19 | "paths": { 20 | "app": "app", 21 | "jquery": "//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min" 22 | } 23 | }); 24 | 25 | // Load the main app module to start the app 26 | requirejs(["app/twinejson"]); -------------------------------------------------------------------------------- /js/index.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * TwineJson 3 | * 4 | * Based on Entweedle by Michael McCollum 5 | * Copyright(c) 2015 Páprica Comunicação http://papricacomunicacao.com.br 6 | * Copyright(c) 2015-2016 Cauli Tomaz https://cau.li 7 | * MIT Licensed 8 | * 9 | * https://github.com/cauli/TwineJson 10 | */ 11 | 'use strict'; 12 | 13 | if (typeof define !== 'function') { 14 | var define = require('amdefine')(module); 15 | } 16 | 17 | 18 | jQuery(document).ready(function() { 19 | requirejs.config({ 20 | "baseUrl": "js/lib", 21 | "paths": { 22 | "app": "../app", 23 | "jquery": "//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min" 24 | } 25 | }); 26 | 27 | // Load the main app module to start the app 28 | requirejs(["../app/twinejson"]); 29 | }); -------------------------------------------------------------------------------- /js/app/options.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * TwineJson 3 | * 4 | * Based on Entweedle by Michael McCollum 5 | * Copyright(c) 2015 Páprica Comunicação http://papricacomunicacao.com.br 6 | * Copyright(c) 2015-2016 Cauli Tomaz https://cau.li 7 | * MIT Licensed 8 | * 9 | * https://github.com/cauli/TwineJson 10 | */ 11 | 12 | /** 13 | * TwineJson options for exporting 14 | * 15 | * @return {} 16 | */ 17 | 18 | define(function () { 19 | return { 20 | // Export unknown properties inside {{property}}{{/property}} tags 21 | 'exportCustomProperties':true, 22 | // Exclude these properties from CustomProperties Export. 23 | // Expected input: ['property1','property2','...','propertyN']; 24 | 'customPropertiesToIgnore':['pid','name','tags','content','childrenNames','children'], 25 | // Save as a .json file 26 | 'saveAsFile':true 27 | } 28 | }); 29 | -------------------------------------------------------------------------------- /js/app/util.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * TwineJson 3 | * 4 | * Based on Entweedle by Michael McCollum 5 | * Copyright(c) 2015 Páprica Comunicação http://papricacomunicacao.com.br 6 | * Copyright(c) 2015-2016 Cauli Tomaz https://cau.li 7 | * MIT Licensed 8 | * 9 | * https://github.com/cauli/TwineJson 10 | */ 11 | 12 | 13 | define( 14 | function () { 15 | return { 16 | // Removes "" and "{carriage return}" from an array 17 | cleanArray: function(arr) { 18 | if(arr[0] == "") 19 | { 20 | arr.splice(0,1); 21 | } 22 | 23 | if(arr[arr.length-1] == "") 24 | { 25 | arr.splice(arr.length-1,1); 26 | } 27 | 28 | // <= 1 because carriage returns counts as one character 29 | for(var i = arr.length-1; i >= 0; i--) 30 | { 31 | if(arr[i].match(/^[\r\n ]+$/)) 32 | { 33 | arr.splice(i,1); 34 | } 35 | } 36 | 37 | return arr; 38 | } 39 | } 40 | }); 41 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "TwineJson", 3 | "description": "Free utility format to export your story into JSON format. Based on Entweedle by Michael McCollum", 4 | "version": "0.1.3", 5 | "author": "Cauli Tomaz", 6 | "license": "MIT", 7 | "main": "format.js", 8 | "devDependencies": { 9 | "amdefine": "^1.0.0", 10 | "chai": "^3.5.0", 11 | "gulp": "^3.9.1", 12 | "gulp-clean": "^0.3.2", 13 | "gulp-debug": "^2.1.2", 14 | "gulp-file-includer": "^1.0.0", 15 | "gulp-js-escape": "^1.0.1", 16 | "gulp-jslint": "^1.0.1", 17 | "gulp-minify-html": "^1.0.6", 18 | "gulp-shell": "^0.5.2", 19 | "gulp-uglify": "^1.5.4", 20 | "mocha": "^2.5.3", 21 | "requirejs": "^2.2.0", 22 | "run-sequence": "^1.2.2" 23 | }, 24 | "scripts": { 25 | "test": "mocha" 26 | }, 27 | "repository": { 28 | "type": "git", 29 | "url": "https://github.com/cauli/TwineJson" 30 | }, 31 | "keywords": [ 32 | "node" 33 | ], 34 | "dependencies": { 35 | "es6-shim": "latest", 36 | "jquery": "latest" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Cauli Tomaz and Páprica Comunicação 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /js/app/printer.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * TwineJson 3 | * 4 | * Based on Entweedle by Michael McCollum 5 | * Copyright(c) 2015 Páprica Comunicação http://papricacomunicacao.com.br 6 | * Copyright(c) 2015-2016 Cauli Tomaz https://cau.li 7 | * MIT Licensed 8 | * 9 | * https://github.com/cauli/TwineJson 10 | */ 11 | 12 | /** 13 | * Pretty printer for JSON 14 | * 15 | * @return {} 16 | */ 17 | 18 | define( 19 | [], 20 | function () { 21 | 22 | return { 23 | syntaxHighlight : function(json, jqEl) { 24 | json = json.replace(/&/g, '&').replace(//g, '>'); 25 | return jqEl.html(json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) { 26 | var cls = 'number'; 27 | if (/^"/.test(match)) { 28 | if (/:$/.test(match)) { 29 | cls = 'key'; 30 | } else { 31 | cls = 'string'; 32 | } 33 | } else if (/true|false/.test(match)) { 34 | cls = 'boolean'; 35 | } else if (/null/.test(match)) { 36 | cls = 'null'; 37 | } 38 | return '' + match + ''; 39 | })); 40 | } 41 | } 42 | }); 43 | -------------------------------------------------------------------------------- /storyFormat.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |82 |83 | 84 |
86 |87 |