diff --git a/vulcanize/.gitignore b/vulcanize/.gitignore deleted file mode 100644 index 9b1dab5..0000000 --- a/vulcanize/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -test/vulcanized.html -test/vulcanized.js -test/index-vulcanized.html -node_modules diff --git a/vulcanize/README.md b/vulcanize/README.md deleted file mode 100644 index 2939bc8..0000000 --- a/vulcanize/README.md +++ /dev/null @@ -1,110 +0,0 @@ -# Vulcan - -### Concatenate a set of Web Components into one file - ->Named for the [Vulcanization](http://en.wikipedia.org/wiki/Vulcanization) process that turns polymers into more durable -materials. - -## Getting Started -- Install the node dependencies with `npm install` - - Depends on [cheerio](https://github.com/MatthewMueller/cheerio) and [nopt](https://github.com/isaacs/nopt) -- Give a main input html file with the `--input` or `-i` flags and output file name with the `--output` or `-o` flags. - - Example: `node vulcan.js -i index.html -o build.html` - - Defaults to `vulcanized.html` -- URL paths are adjusted for the new output location automatically (execpt ones set in Javascript) - -## Example - -Say we have three html files: `index.html`, `x-app.html`, and `x-dep.html`. - -index.html: - -```html - - - -``` - -app.html: - -```html - - - - - -``` - -x-dep.html: - -```html - - - - -``` - -Running vulcan on `index.html`, and specifying `build.html` as the output: - - node vulcan.js -i index.html -o build.html - -Will result in `build.html` that appears as so: - -```html - - - - - - - - - - -``` - -## Content Security Policy -[Content Security Policy](http://en.wikipedia.org/wiki/Content_Security_Policy), or CSP, is a Javascript security model -that aims to prevent XSS and other attacks. In so doing, it prohibits the use of inline scripts. - -To help automate the use of Polymer element registration with CSP, the `--csp` flag to vulcan will remove all scripts -from the HTML Imports and place their contents into an output javascript file. - -Using the previous example, the output from `node vulcan.js --csp -i index.html -o build.html` will be - -build.html: -```html - - - - - - - - - -``` - -build.js: -```js -Polymer('x-dep'); -Polymer('x-app'); -``` diff --git a/vulcanize/bin/vulcanize b/vulcanize/bin/vulcanize deleted file mode 100755 index 3014daf..0000000 --- a/vulcanize/bin/vulcanize +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env node -var path = require('path'); -var nopt = require('nopt'); -var vulcan = require('../lib/vulcan.js'); - -var options = nopt( - { - 'output': path, - 'verbose': Boolean, - 'csp': Boolean, - 'inline': Boolean - }, - { - 'o': ['--output'], - 'v': ['--verbose'] - } -); - -options.input = path.resolve(options.argv.remain[0]); - -if (!options.input) { - console.error('No input file given!'); - process.exit(1); -} - -var DEFAULT_OUTPUT = 'vulcanized.html'; -if (!options.output) { - console.warn('Default output to vulcanized.html' + (options.csp ? ' and vulcanized.js' : '') + ' in the input directory.'); - options.output = path.resolve(path.dirname(options.input), DEFAULT_OUTPUT); -} - -options.outputDir = path.dirname(options.output); - -vulcan.setOptions(options); -vulcan.processDocument(); diff --git a/vulcanize/lib/vulcan.js b/vulcanize/lib/vulcan.js deleted file mode 100644 index 0799db6..0000000 --- a/vulcanize/lib/vulcan.js +++ /dev/null @@ -1,229 +0,0 @@ -var fs = require('fs'); -var path = require('path'); -var cheerio = require('cheerio'); -var nopt = require('nopt'); -var EOL = require('os').EOL; - -var ABS_URL = /(^data:)|(^http[s]?:)|(^\/)/; -var ELEMENTS = 'polymer-element'; -var IMPORTS = 'link[rel="import"][href]'; -var POLYMER = 'script[src $= "polymer.js"], script[src $= "polymer.min.js"]'; -var SCRIPT_SRC = /'; - } - return out; - }); -} - -function handleMainDocument() { - var $ = readDocument(options.input); - var dir = path.dirname(options.input); - // find the position of the last import's nextSibling - var import_pos = $(IMPORTS).last().next(); - processImports($, dir); - var output = import_buffer.join(EOL); - - // strip scripts into a separate file - if (options.csp) { - if (options.verbose) { - console.log('Separating scripts into separate file'); - } - var scripts = []; - var scripts_after_polymer = []; - var tempoutput = cheerio.load(output); - - tempoutput('script').each(function() { - var src = this.attr('src'); - if (src) { - // external script - if (!ABS_URL.test(src)) { - scripts.push(fs.readFileSync(src, 'utf8')); - } else { - // put an absolute path script after polymer.js in main document - scripts_after_polymer.push(this.html()); - } - } else { - // inline script - scripts.push(this.text()); - } - }).remove(); - output = tempoutput.html(); - // join scripts with ';' to prevent breakages due to EOF semicolon insertion - var script_name = path.basename(options.output, '.html') + '.js'; - fs.writeFileSync(script_name, scripts.join(';' + EOL), 'utf8'); - scripts_after_polymer.push(''); - findScriptLocation($).append(EOL + scripts_after_polymer.join(EOL) + EOL); - } - - insertImport($, import_pos, imports_before_polymer.join(EOL) + EOL); - insertInlinedImports($, import_pos, output); - var outhtml = $.html(); - if (!options.csp && options.inline) { - outhtml = inlineScripts(outhtml); - } - fs.writeFileSync(options.output, outhtml, 'utf8'); -} - -exports.processDocument = handleMainDocument; -exports.setOptions = setOptions; diff --git a/vulcanize/package.json b/vulcanize/package.json deleted file mode 100644 index fec8bfa..0000000 --- a/vulcanize/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "vulcanize", - "version": "0.0.1", - "description": "Process Web Components into one output file", - "main": "lib", - "bin": { - "vulcanize": "bin/vulcanize" - }, - "dependencies": { - "cheerio": "~0.12.1", - "nopt": "~2.1.1" - }, - "devDependencies": {}, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "Daniel Freedman", - "license": "BSD", - "directories": { - "test": "test" - }, - "keywords": [ - "web components", - "polymer" - ] -} diff --git a/vulcanize/test/import-test.css b/vulcanize/test/import-test.css deleted file mode 100644 index 74bd1c3..0000000 --- a/vulcanize/test/import-test.css +++ /dev/null @@ -1,5 +0,0 @@ -@host { - * { - background: orange; - } -} diff --git a/vulcanize/test/import-test.html b/vulcanize/test/import-test.html deleted file mode 100644 index 06ca514..0000000 --- a/vulcanize/test/import-test.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - diff --git a/vulcanize/test/index.html b/vulcanize/test/index.html deleted file mode 100644 index 62f46d9..0000000 --- a/vulcanize/test/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - Vulcanizer Test - - - - - Hello Import! - - diff --git a/vulcanize/viz.html b/vulcanize/viz.html deleted file mode 100644 index f406bea..0000000 --- a/vulcanize/viz.html +++ /dev/null @@ -1,180 +0,0 @@ - - - - - - - - -
-
-
x-message.shadowRoot.x-decorate.shadowRoot - -
-
-
-
-
-      <x-turbin></x-turbin>
-        <x-filigree>
-          <content>           </content>
-        </x-filigree>
-      <x-clogs></x-clogs>
-
-
-
-
- -
-
x-message.shadowRoot.x-decorate - -
-
-
-  <x-decorate>
-    <content>
-
-
-                   
-
-
-    </content>
-  </x-decorate>
-
- -
-
x-message - -
-
-<x-message>
-
-
-
-
-                   Hello World
-
-
-
-
-</x-message>
- -
-
-
- Drag to rotate, then or -
-
-
-
- - - -