├── src ├── README.md ├── config │ └── config.json ├── host.js ├── runtime │ ├── virtualModules │ │ └── HH-hyperhost.js │ ├── virtualServer.js │ └── staticServer.js ├── processing │ ├── io.js │ ├── flattener.js │ └── compiler.js └── util │ └── util.js ├── examples ├── virtual-backend-basic │ ├── package.json │ ├── index.html │ ├── README.md │ ├── HH-custom.js │ ├── exampleClient.js │ └── HH-server.js └── html5up-phantom-example │ ├── images │ ├── pic01.jpg │ ├── pic02.jpg │ ├── pic03.jpg │ ├── pic04.jpg │ ├── pic05.jpg │ ├── pic06.jpg │ ├── pic07.jpg │ ├── pic08.jpg │ ├── pic09.jpg │ ├── pic10.jpg │ ├── pic11.jpg │ ├── pic12.jpg │ ├── pic13.jpg │ ├── pic14.jpg │ ├── pic15.jpg │ └── logo.svg │ ├── assets │ ├── fonts │ │ ├── FontAwesome.otf │ │ ├── fontawesome-webfont.eot │ │ ├── fontawesome-webfont.ttf │ │ ├── fontawesome-webfont.woff │ │ └── fontawesome-webfont.woff2 │ ├── sass │ │ ├── layout │ │ │ ├── _main.scss │ │ │ ├── _wrapper.scss │ │ │ ├── _footer.scss │ │ │ ├── _header.scss │ │ │ └── _menu.scss │ │ ├── components │ │ │ ├── _section.scss │ │ │ ├── _box.scss │ │ │ ├── _icon.scss │ │ │ ├── _image.scss │ │ │ ├── _table.scss │ │ │ ├── _button.scss │ │ │ ├── _list.scss │ │ │ ├── _form.scss │ │ │ └── _tiles.scss │ │ ├── libs │ │ │ ├── _functions.scss │ │ │ ├── _vars.scss │ │ │ ├── _mixins.scss │ │ │ └── _skel.scss │ │ ├── base │ │ │ ├── _page.scss │ │ │ └── _typography.scss │ │ ├── ie9.scss │ │ ├── main.scss │ │ └── ie8.scss │ ├── css │ │ ├── ie9.css │ │ └── ie8.css │ └── js │ │ ├── ie │ │ ├── html5shiv.js │ │ └── respond.min.js │ │ ├── main.js │ │ ├── skel.min.js │ │ └── util.js │ ├── README.txt │ ├── generic.html │ ├── index.html │ ├── LICENSE.txt │ └── elements.html ├── dist └── client │ ├── client.html │ ├── client.css │ └── hyperclient.js ├── test └── test.html ├── LICENSE └── README.md /src/README.md: -------------------------------------------------------------------------------- 1 | ##To Build 2 | ``` 3 | browserify -t babelify src/host.js --standalone HyperHost -o dist/host/hyperhost.js 4 | ``` -------------------------------------------------------------------------------- /examples/virtual-backend-basic/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "NodejsStarterApp", 3 | "dependencies": { 4 | "browserify-fs": "" 5 | } 6 | } -------------------------------------------------------------------------------- /examples/html5up-phantom-example/images/pic01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-mullen/hyperhost/HEAD/examples/html5up-phantom-example/images/pic01.jpg -------------------------------------------------------------------------------- /examples/html5up-phantom-example/images/pic02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-mullen/hyperhost/HEAD/examples/html5up-phantom-example/images/pic02.jpg -------------------------------------------------------------------------------- /examples/html5up-phantom-example/images/pic03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-mullen/hyperhost/HEAD/examples/html5up-phantom-example/images/pic03.jpg -------------------------------------------------------------------------------- /examples/html5up-phantom-example/images/pic04.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-mullen/hyperhost/HEAD/examples/html5up-phantom-example/images/pic04.jpg -------------------------------------------------------------------------------- /examples/html5up-phantom-example/images/pic05.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-mullen/hyperhost/HEAD/examples/html5up-phantom-example/images/pic05.jpg -------------------------------------------------------------------------------- /examples/html5up-phantom-example/images/pic06.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-mullen/hyperhost/HEAD/examples/html5up-phantom-example/images/pic06.jpg -------------------------------------------------------------------------------- /examples/html5up-phantom-example/images/pic07.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-mullen/hyperhost/HEAD/examples/html5up-phantom-example/images/pic07.jpg -------------------------------------------------------------------------------- /examples/html5up-phantom-example/images/pic08.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-mullen/hyperhost/HEAD/examples/html5up-phantom-example/images/pic08.jpg -------------------------------------------------------------------------------- /examples/html5up-phantom-example/images/pic09.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-mullen/hyperhost/HEAD/examples/html5up-phantom-example/images/pic09.jpg -------------------------------------------------------------------------------- /examples/html5up-phantom-example/images/pic10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-mullen/hyperhost/HEAD/examples/html5up-phantom-example/images/pic10.jpg -------------------------------------------------------------------------------- /examples/html5up-phantom-example/images/pic11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-mullen/hyperhost/HEAD/examples/html5up-phantom-example/images/pic11.jpg -------------------------------------------------------------------------------- /examples/html5up-phantom-example/images/pic12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-mullen/hyperhost/HEAD/examples/html5up-phantom-example/images/pic12.jpg -------------------------------------------------------------------------------- /examples/html5up-phantom-example/images/pic13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-mullen/hyperhost/HEAD/examples/html5up-phantom-example/images/pic13.jpg -------------------------------------------------------------------------------- /examples/html5up-phantom-example/images/pic14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-mullen/hyperhost/HEAD/examples/html5up-phantom-example/images/pic14.jpg -------------------------------------------------------------------------------- /examples/html5up-phantom-example/images/pic15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-mullen/hyperhost/HEAD/examples/html5up-phantom-example/images/pic15.jpg -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-mullen/hyperhost/HEAD/examples/html5up-phantom-example/assets/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-mullen/hyperhost/HEAD/examples/html5up-phantom-example/assets/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-mullen/hyperhost/HEAD/examples/html5up-phantom-example/assets/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-mullen/hyperhost/HEAD/examples/html5up-phantom-example/assets/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/t-mullen/hyperhost/HEAD/examples/html5up-phantom-example/assets/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /examples/virtual-backend-basic/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |

Testing...

10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /examples/virtual-backend-basic/README.md: -------------------------------------------------------------------------------- 1 | ## Virtual Server Demo 2 | Drag and drop this folder into HyperHost. 3 | 4 | The client script will be hosted, then make a subsequent request to the virtual server. 5 | 6 | This demo demonstrates connecting to the virtual server, pulling from NPM, and how custom node modules can be built. 7 | -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/sass/layout/_main.scss: -------------------------------------------------------------------------------- 1 | /// 2 | /// Phantom by HTML5 UP 3 | /// html5up.net | @ajlkn 4 | /// Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | /// 6 | 7 | /* Main */ 8 | 9 | #main { 10 | @include padding(5em, 0, (-5em, 0, 3em, 0)); 11 | 12 | @include breakpoint(small) { 13 | @include padding(3em, 0, (-3em, 0, 3em, 0)); 14 | } 15 | } -------------------------------------------------------------------------------- /examples/virtual-backend-basic/HH-custom.js: -------------------------------------------------------------------------------- 1 | /* 2 | A HyperHost module built without browserify. 3 | */ 4 | 5 | HyperHost.modules['custom'] = (function () { 6 | module = {exports: {}} // This is just to make it look like node, you can return anything 7 | 8 | module.exports.someFunction = function () { 9 | console.log('whoa') 10 | return 'custom module is working!' 11 | } 12 | 13 | return module.exports // Return the exported module 14 | }()) 15 | -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/sass/components/_section.scss: -------------------------------------------------------------------------------- 1 | /// 2 | /// Phantom by HTML5 UP 3 | /// html5up.net | @ajlkn 4 | /// Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | /// 6 | 7 | /* Section/Article */ 8 | 9 | section, article { 10 | &.special { 11 | text-align: center; 12 | } 13 | } 14 | 15 | header { 16 | p { 17 | margin-top: _size(element-margin) * -0.5; 18 | } 19 | 20 | @include breakpoint(small) { 21 | p { 22 | margin-top: 0; 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /dist/client/client.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
10 |

Loading...

11 |

Host a new website!

12 |
13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/sass/layout/_wrapper.scss: -------------------------------------------------------------------------------- 1 | /// 2 | /// Phantom by HTML5 UP 3 | /// html5up.net | @ajlkn 4 | /// Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | /// 6 | 7 | /* Wrapper */ 8 | 9 | #wrapper { 10 | > * { 11 | > .inner { 12 | $gutter: _size(gutter); 13 | 14 | width: 100%; 15 | max-width: _size(inner); 16 | margin: 0 auto; 17 | padding: 0 $gutter; 18 | 19 | @include breakpoint(small) { 20 | $gutter: _size(gutter) * 0.5; 21 | 22 | padding: 0 $gutter; 23 | } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/sass/components/_box.scss: -------------------------------------------------------------------------------- 1 | /// 2 | /// Phantom by HTML5 UP 3 | /// html5up.net | @ajlkn 4 | /// Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | /// 6 | 7 | /* Box */ 8 | 9 | .box { 10 | border-radius: _size(border-radius); 11 | border: solid _size(border-width) _palette(border); 12 | margin-bottom: _size(element-margin); 13 | padding: 1.5em; 14 | 15 | > :last-child, 16 | > :last-child > :last-child, 17 | > :last-child > :last-child > :last-child { 18 | margin-bottom: 0; 19 | } 20 | 21 | &.alt { 22 | border: 0; 23 | border-radius: 0; 24 | padding: 0; 25 | } 26 | } -------------------------------------------------------------------------------- /examples/virtual-backend-basic/exampleClient.js: -------------------------------------------------------------------------------- 1 | /* 2 | Example client code for making requests to a virtual backend. 3 | A HyperRequest object is requested, then used to fetch data from the server. 4 | 5 | See HS-server.js to see how to create a server that can handle these requests. 6 | */ 7 | 8 | // Here is an example request 9 | var hyp = HyperRequest() // Create a new HyperRequest 10 | hyp.onload = function (response) { // Set the callback 11 | console.log(response) 12 | document.getElementById('output').innerHTML = JSON.stringify(response) 13 | } 14 | hyp.open('GET', '/') // Set the method and route 15 | hyp.send({ // Send arbitrary data to server 16 | message: 'hello', 17 | moreData: [12, 42, 21], 18 | evenMore: {} 19 | }) 20 | -------------------------------------------------------------------------------- /src/config/config.json: -------------------------------------------------------------------------------- 1 | { 2 | paths : { 3 | client : "https://rationalcoding.github.io/hyperhost/client.html?site=", 4 | wzrd : "https://tmullen-bcdn.herokuapp.com/debug-standalone/", 5 | crossOriginProxy : "https://crossorigin.me/" 6 | }, 7 | extensions : { 8 | text : ["js", "txt", "md", "py", "java"], 9 | font : ["eot", "woff", "woff2", "ttf", "svg", "sfnt", "otf"], 10 | image : ["png", "jpg", "jpeg", , "jpeg2000", "tif", "tiff", "gif", "bmp"], 11 | view : ["html", "css", "json"] 12 | }, 13 | peerJS : { 14 | host: "peerjs-server-tmullen.mybluemix.net", 15 | port: 443, 16 | path: "/server", 17 | secure: true 18 | }, 19 | warnings : { 20 | maxTreeSize : 40 21 | }, 22 | maxReconnectAttempts : 10 23 | } 24 | -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/css/ie9.css: -------------------------------------------------------------------------------- 1 | /* 2 | Phantom by HTML5 UP 3 | html5up.net | @ajlkn 4 | Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | */ 6 | 7 | /* Tiles */ 8 | 9 | .tiles:after { 10 | content: ''; 11 | display: block; 12 | clear: both; 13 | } 14 | 15 | .tiles article { 16 | float: left; 17 | } 18 | 19 | .tiles article > a { 20 | padding-top: 50%; 21 | margin-top: -1.75em; 22 | } 23 | 24 | body:not(.is-touch) .tiles article:hover > .image { 25 | -moz-transform: none; 26 | -webkit-transform: none; 27 | -ms-transform: none; 28 | transform: none; 29 | } 30 | 31 | /* Footer */ 32 | 33 | #footer > .inner section { 34 | float: left; 35 | } 36 | 37 | #footer > .inner .copyright { 38 | clear: both; 39 | padding-top: 4em; 40 | } -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/sass/libs/_functions.scss: -------------------------------------------------------------------------------- 1 | /// Gets a duration value. 2 | /// @param {string} $keys Key(s). 3 | /// @return {string} Value. 4 | @function _duration($keys...) { 5 | @return val($duration, $keys...); 6 | } 7 | 8 | /// Gets a font value. 9 | /// @param {string} $keys Key(s). 10 | /// @return {string} Value. 11 | @function _font($keys...) { 12 | @return val($font, $keys...); 13 | } 14 | 15 | /// Gets a misc value. 16 | /// @param {string} $keys Key(s). 17 | /// @return {string} Value. 18 | @function _misc($keys...) { 19 | @return val($misc, $keys...); 20 | } 21 | 22 | /// Gets a palette value. 23 | /// @param {string} $keys Key(s). 24 | /// @return {string} Value. 25 | @function _palette($keys...) { 26 | @return val($palette, $keys...); 27 | } 28 | 29 | /// Gets a size value. 30 | /// @param {string} $keys Key(s). 31 | /// @return {string} Value. 32 | @function _size($keys...) { 33 | @return val($size, $keys...); 34 | } -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/sass/base/_page.scss: -------------------------------------------------------------------------------- 1 | /// 2 | /// Phantom by HTML5 UP 3 | /// html5up.net | @ajlkn 4 | /// Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | /// 6 | 7 | /* Basic */ 8 | 9 | // MSIE: Required for IEMobile. 10 | @-ms-viewport { 11 | width: device-width; 12 | } 13 | 14 | // MSIE: Prevents scrollbar from overlapping content. 15 | body { 16 | -ms-overflow-style: scrollbar; 17 | } 18 | 19 | // Ensures page width is always >=320px. 20 | @include breakpoint(xsmall) { 21 | html, body { 22 | min-width: 320px; 23 | } 24 | } 25 | 26 | body { 27 | background: _palette(bg); 28 | 29 | // Prevents animation/transition "flicker" on page load. 30 | // Automatically added/removed by js/main.js. 31 | &.is-loading { 32 | *, *:before, *:after { 33 | @include vendor('animation', 'none !important'); 34 | @include vendor('transition', 'none !important'); 35 | } 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/sass/ie9.scss: -------------------------------------------------------------------------------- 1 | @import 'libs/vars'; 2 | @import 'libs/functions'; 3 | @import 'libs/mixins'; 4 | @import 'libs/skel'; 5 | 6 | /* 7 | Phantom by HTML5 UP 8 | html5up.net | @ajlkn 9 | Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 10 | */ 11 | 12 | /* Tiles */ 13 | 14 | .tiles { 15 | &:after { 16 | content: ''; 17 | display: block; 18 | clear: both; 19 | } 20 | 21 | article { 22 | float: left; 23 | 24 | > a { 25 | padding-top: 50%; 26 | margin-top: -1.75em; 27 | } 28 | 29 | body:not(.is-touch) & { 30 | &:hover { 31 | > .image { 32 | @include vendor('transform', 'none'); 33 | } 34 | } 35 | } 36 | } 37 | } 38 | 39 | /* Footer */ 40 | 41 | #footer { 42 | > .inner { 43 | section { 44 | float: left; 45 | } 46 | 47 | .copyright { 48 | clear: both; 49 | padding-top: (_size(element-margin) * 2); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /dist/client/client.css: -------------------------------------------------------------------------------- 1 | html { 2 | position: relative; 3 | background: white; 4 | height: 100%; 5 | } 6 | 7 | #HYPERHOST-dropzone { 8 | position: absolute; 9 | top: 30px; 10 | left: 30px; 11 | bottom: 30px; 12 | right: 30px; 13 | text-align: center; 14 | max-width: none; 15 | min-height: 80%; 16 | } 17 | 18 | #HYPERHOST-dropzone > div { 19 | pointer-events: none; 20 | position: relative; 21 | top: 50%; 22 | transform: translateY(-50%); 23 | font-family: Arial; 24 | } 25 | 26 | #HYPERHOST-dropzone a { 27 | text-decoration: none; 28 | color: black; 29 | cursor: pointer; 30 | pointer-events: all; 31 | } 32 | 33 | #HYPERHOST-dropzone h1 { 34 | font-size: 50px; 35 | } 36 | 37 | #HYPERHOST-dropzone p { 38 | font-size: 14px; 39 | } 40 | 41 | #HYPERHOST-viewframe { 42 | position: absolute; 43 | left: 0; 44 | top: 0; 45 | width: 100%; 46 | height: 100%; 47 | display: none; 48 | border: transparent 20px; 49 | background: white; 50 | } -------------------------------------------------------------------------------- /test/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2016 Thomas Mullen 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/sass/libs/_vars.scss: -------------------------------------------------------------------------------- 1 | // Misc. 2 | $misc: ( 3 | z-index-base: 10000 4 | ); 5 | 6 | // Duration. 7 | $duration: ( 8 | menu: 0.45s, 9 | transition: 0.2s 10 | ); 11 | 12 | // Size. 13 | $size: ( 14 | border-radius: 4px, 15 | border-width: 1px, 16 | element-height: 3em, 17 | element-margin: 2em, 18 | gutter: 2.5em, 19 | field-gutter: 2em, 20 | inner: 68em, 21 | menu: 22em 22 | ); 23 | 24 | // Font. 25 | $font: ( 26 | family: ('Source Sans Pro', Helvetica, sans-serif), 27 | family-fixed: ('Courier New', monospace), 28 | weight: 300, 29 | weight-bold: 900, 30 | weight-bold-alt: 700, 31 | letter-spacing: 0.35em, 32 | letter-spacing-alt: -0.035em 33 | ); 34 | 35 | // Palette. 36 | $palette: ( 37 | bg: #ffffff, 38 | bg-accent: #333333, 39 | bg-alt: #f6f6f6, 40 | fg: #585858, 41 | fg-accent: #ffffff, 42 | border: #c9c9c9, 43 | border-bg: rgba(144,144,144,0.075), 44 | accent1: #f2849e, 45 | accent2: #7ecaf6, 46 | accent3: #7bd0c1, 47 | accent4: #c75b9b, 48 | accent5: #ae85ca, 49 | accent6: #8499e7, 50 | ); -------------------------------------------------------------------------------- /examples/html5up-phantom-example/README.txt: -------------------------------------------------------------------------------- 1 | Try dragging and dropping this template by HTML5UP into HyperHost! 2 | 3 | Phantom by HTML5 UP 4 | html5up.net | @ajlkn 5 | Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 6 | 7 | 8 | This is Phantom, a simple design built around a grid of large, colorful, semi-interactive 9 | image tiles (of which you can have as many or as few as you like). Makes use of some 10 | SVG and animation techniques I've been experimenting with on that other project of mine 11 | you may have heard about (https://carrd.co), and includes a handy generic page for whatever. 12 | 13 | Demo images* courtesy of Unsplash, a radtastic collection of CC0 (public domain) images 14 | you can use for pretty much whatever. 15 | 16 | (* = not included) 17 | 18 | AJ 19 | aj@lkn.io | @ajlkn 20 | 21 | 22 | Credits: 23 | 24 | Demo Images: 25 | Unsplash (unsplash.com) 26 | 27 | Icons: 28 | Font Awesome (fortawesome.github.com/Font-Awesome) 29 | 30 | Other: 31 | jQuery (jquery.com) 32 | html5shiv.js (@afarkas @jdalton @jon_neal @rem) 33 | Misc. Sass functions (@HugoGiraudel) 34 | Respond.js (j.mp/respondjs) 35 | Skel (skel.io) 36 | -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/sass/components/_icon.scss: -------------------------------------------------------------------------------- 1 | /// 2 | /// Phantom by HTML5 UP 3 | /// html5up.net | @ajlkn 4 | /// Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | /// 6 | 7 | /* Icon */ 8 | 9 | .icon { 10 | @include icon; 11 | border-bottom: none; 12 | position: relative; 13 | 14 | > .label { 15 | display: none; 16 | } 17 | 18 | &.style1 { 19 | } 20 | 21 | &.style2 { 22 | @include vendor('transition', ( 23 | 'background-color #{_duration(transition)} ease-in-out', 24 | 'color #{_duration(transition)} ease-in-out', 25 | 'border-color #{_duration(transition)} ease-in-out' 26 | )); 27 | background-color: transparent; 28 | border: solid 1px _palette(border); 29 | border-radius: _size(border-radius); 30 | width: 2.65em; 31 | height: 2.65em; 32 | display: inline-block; 33 | text-align: center; 34 | line-height: 2.65em; 35 | color: inherit; 36 | 37 | &:before { 38 | font-size: 1.1em; 39 | } 40 | 41 | &:hover { 42 | color: _palette(accent1); 43 | border-color: _palette(accent1); 44 | } 45 | 46 | &:active { 47 | background-color: transparentize(_palette(accent1), 0.9); 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/sass/components/_image.scss: -------------------------------------------------------------------------------- 1 | /// 2 | /// Phantom by HTML5 UP 3 | /// html5up.net | @ajlkn 4 | /// Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | /// 6 | 7 | /* Image */ 8 | 9 | .image { 10 | border-radius: _size(border-radius); 11 | border: 0; 12 | display: inline-block; 13 | position: relative; 14 | 15 | img { 16 | border-radius: _size(border-radius); 17 | display: block; 18 | } 19 | 20 | &.left, 21 | &.right { 22 | max-width: 40%; 23 | 24 | img { 25 | width: 100%; 26 | } 27 | } 28 | 29 | &.left { 30 | float: left; 31 | padding: 0 1.5em 1em 0; 32 | top: 0.25em; 33 | } 34 | 35 | &.right { 36 | float: right; 37 | padding: 0 0 1em 1.5em; 38 | top: 0.25em; 39 | } 40 | 41 | &.fit { 42 | display: block; 43 | margin: 0 0 _size(element-margin) 0; 44 | width: 100%; 45 | 46 | img { 47 | width: 100%; 48 | } 49 | } 50 | 51 | &.main { 52 | display: block; 53 | margin: 0 0 (_size(element-margin) * 1.5) 0; 54 | width: 100%; 55 | 56 | img { 57 | width: 100%; 58 | } 59 | 60 | @include breakpoint(small) { 61 | margin: 0 0 _size(element-margin) 0; 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /examples/html5up-phantom-example/images/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 14 | 15 | -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/css/ie8.css: -------------------------------------------------------------------------------- 1 | /* 2 | Phantom by HTML5 UP 3 | html5up.net | @ajlkn 4 | Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | */ 6 | 7 | /* Form */ 8 | 9 | form .field { 10 | float: none !important; 11 | width: 100% !important; 12 | padding-left: 0 !important; 13 | } 14 | 15 | /* Button */ 16 | 17 | input[type="submit"], 18 | input[type="reset"], 19 | input[type="button"], 20 | button, 21 | .button { 22 | border: solid 2px #585858 !important; 23 | } 24 | 25 | input[type="submit"]:hover, 26 | input[type="reset"]:hover, 27 | input[type="button"]:hover, 28 | button:hover, 29 | .button:hover { 30 | border-color: #f2849e !important; 31 | } 32 | 33 | input[type="submit"].special, 34 | input[type="reset"].special, 35 | input[type="button"].special, 36 | button.special, 37 | .button.special { 38 | border: none !important; 39 | } 40 | 41 | /* Tiles */ 42 | 43 | .tiles article > .image:before, .tiles article > .image:after { 44 | display: none; 45 | } 46 | 47 | /* Header */ 48 | 49 | #header .logo .symbol { 50 | display: none; 51 | } 52 | 53 | #header nav ul li a[href="#menu"] { 54 | text-indent: 0; 55 | width: auto; 56 | font-size: 0.8em; 57 | } 58 | 59 | #header nav ul li a[href="#menu"]:before, #header nav ul li a[href="#menu"]:after { 60 | display: none; 61 | } 62 | 63 | /* Footer */ 64 | 65 | #footer > .inner section { 66 | width: 50%; 67 | margin-left: 3em; 68 | } 69 | 70 | #footer > .inner section:first-child { 71 | margin-left: 0; 72 | width: 40%; 73 | } -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/sass/main.scss: -------------------------------------------------------------------------------- 1 | @import 'libs/vars'; 2 | @import 'libs/functions'; 3 | @import 'libs/mixins'; 4 | @import 'libs/skel'; 5 | @import 'font-awesome.min.css'; 6 | @import url('http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,700,900'); 7 | 8 | /* 9 | Phantom by HTML5 UP 10 | html5up.net | @ajlkn 11 | Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 12 | */ 13 | 14 | @include skel-breakpoints(( 15 | xlarge: '(max-width: 1680px)', 16 | large: '(max-width: 1280px)', 17 | medium: '(max-width: 980px)', 18 | small: '(max-width: 736px)', 19 | xsmall: '(max-width: 480px)', 20 | xxsmall: '(max-width: 360px)' 21 | )); 22 | 23 | @include skel-layout(( 24 | reset: 'full', 25 | boxModel: 'border', 26 | grid: ( 27 | gutters: 2em 28 | ), 29 | breakpoints: ( 30 | medium: ( 31 | grid: ( 32 | gutters: 1.5em 33 | ) 34 | ), 35 | small: ( 36 | grid: ( 37 | gutters: 1em 38 | ) 39 | ) 40 | ) 41 | )); 42 | 43 | // Base. 44 | 45 | @import 'base/page'; 46 | @import 'base/typography'; 47 | 48 | // Component. 49 | 50 | @import 'components/section'; 51 | @import 'components/icon'; 52 | @import 'components/list'; 53 | @import 'components/form'; 54 | @import 'components/box'; 55 | @import 'components/image'; 56 | @import 'components/table'; 57 | @import 'components/button'; 58 | @import 'components/tiles'; 59 | 60 | // Layout. 61 | 62 | @import 'layout/header'; 63 | @import 'layout/menu'; 64 | @import 'layout/main'; 65 | @import 'layout/footer'; 66 | @import 'layout/wrapper'; -------------------------------------------------------------------------------- /src/host.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016 Thomas Mullen. All rights reserved. 3 | MIT License 4 | 5 | HyperHost v2.0 6 | Module to host websites over WebRTC. 7 | 8 | */ 9 | 10 | const IO = require('./processing/io.js'), 11 | Flattener = require('./processing/flattener.js'), 12 | Compiler = require('./processing/compiler.js'), 13 | 14 | StaticServer = require('./runtime/staticServer.js'), 15 | VirtualServer = require('./runtime/virtualServer.js') 16 | 17 | function Host () { 18 | 'use strict' 19 | 20 | this.io = new IO() 21 | 22 | let staticServer, 23 | virtualServer, 24 | _handlers = {} 25 | 26 | const flattener = new Flattener(), 27 | compiler = new Compiler(), 28 | 29 | _emit = function _emit (event, data) { 30 | var fn = _handlers[event] 31 | if (fn && typeof (fn) === 'function') { 32 | fn(data) 33 | } 34 | } 35 | 36 | /* 37 | Listen for an event. 38 | */ 39 | this.on = function on (event, handler) { 40 | _handlers[event] = handler 41 | } 42 | 43 | /* 44 | Launch the server. 45 | */ 46 | this.launch = function launch () { 47 | const flat = flattener.flatten(this.io.getContentTree()), 48 | views = compiler.compile(flat.views, flat.assets) 49 | 50 | staticServer = new StaticServer(views, !!flat.startScript) 51 | 52 | staticServer.on('ready', () => { 53 | _emit('ready', staticServer.clientURL) 54 | }) 55 | 56 | staticServer.launch() 57 | 58 | if (flat.startScript) { 59 | virtualServer = new VirtualServer(flat.startScript, flat.virtualModules, flat.jsonFiles) 60 | virtualServer.launch() 61 | } 62 | } 63 | } 64 | 65 | module.exports = Host 66 | -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/sass/ie8.scss: -------------------------------------------------------------------------------- 1 | @import 'libs/vars'; 2 | @import 'libs/functions'; 3 | @import 'libs/mixins'; 4 | @import 'libs/skel'; 5 | 6 | /* 7 | Phantom by HTML5 UP 8 | html5up.net | @ajlkn 9 | Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 10 | */ 11 | 12 | /* Form */ 13 | 14 | form { 15 | .field { 16 | float: none !important; 17 | width: 100% !important; 18 | padding-left: 0 !important; 19 | } 20 | } 21 | 22 | /* Button */ 23 | 24 | input[type="submit"], 25 | input[type="reset"], 26 | input[type="button"], 27 | button, 28 | .button { 29 | border: solid 2px _palette(fg) !important; 30 | 31 | &:hover { 32 | border-color: _palette(accent1) !important; 33 | } 34 | 35 | &.special { 36 | border: none !important; 37 | } 38 | } 39 | 40 | /* Tiles */ 41 | 42 | .tiles { 43 | article { 44 | > .image { 45 | &:before, &:after { 46 | display: none; 47 | } 48 | } 49 | } 50 | } 51 | 52 | /* Header */ 53 | 54 | #header { 55 | .logo { 56 | .symbol { 57 | display: none; 58 | } 59 | } 60 | 61 | nav { 62 | ul { 63 | li { 64 | a[href="#menu"] { 65 | text-indent: 0; 66 | width: auto; 67 | font-size: 0.8em; 68 | 69 | &:before, &:after { 70 | display: none; 71 | } 72 | } 73 | } 74 | } 75 | } 76 | } 77 | 78 | /* Footer */ 79 | 80 | #footer { 81 | > .inner { 82 | section { 83 | width: 50%; 84 | margin-left: 3em; 85 | 86 | &:first-child { 87 | margin-left: 0; 88 | width: 40%; 89 | } 90 | } 91 | } 92 | } -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/sass/components/_table.scss: -------------------------------------------------------------------------------- 1 | /// 2 | /// Phantom by HTML5 UP 3 | /// html5up.net | @ajlkn 4 | /// Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | /// 6 | 7 | /* Table */ 8 | 9 | .table-wrapper { 10 | -webkit-overflow-scrolling: touch; 11 | overflow-x: auto; 12 | } 13 | 14 | table { 15 | margin: 0 0 _size(element-margin) 0; 16 | width: 100%; 17 | 18 | tbody { 19 | tr { 20 | border: solid _size(border-width) _palette(border); 21 | border-left: 0; 22 | border-right: 0; 23 | 24 | &:nth-child(2n + 1) { 25 | background-color: _palette(border-bg); 26 | } 27 | } 28 | } 29 | 30 | td { 31 | padding: 0.75em 0.75em; 32 | } 33 | 34 | th { 35 | color: _palette(fg-bold); 36 | font-size: 0.9em; 37 | font-weight: _font(weight-bold); 38 | padding: 0 0.75em 0.75em 0.75em; 39 | text-align: left; 40 | } 41 | 42 | thead { 43 | border-bottom: solid (_size(border-width) * 2) _palette(border); 44 | } 45 | 46 | tfoot { 47 | border-top: solid (_size(border-width) * 2) _palette(border); 48 | } 49 | 50 | &.alt { 51 | border-collapse: separate; 52 | 53 | tbody { 54 | tr { 55 | td { 56 | border: solid _size(border-width) _palette(border); 57 | border-left-width: 0; 58 | border-top-width: 0; 59 | 60 | &:first-child { 61 | border-left-width: _size(border-width); 62 | } 63 | } 64 | 65 | &:first-child { 66 | td { 67 | border-top-width: _size(border-width); 68 | } 69 | } 70 | } 71 | } 72 | 73 | thead { 74 | border-bottom: 0; 75 | } 76 | 77 | tfoot { 78 | border-top: 0; 79 | } 80 | } 81 | } -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/sass/libs/_mixins.scss: -------------------------------------------------------------------------------- 1 | /// Makes an element's :before pseudoelement a FontAwesome icon. 2 | /// @param {string} $content Optional content value to use. 3 | /// @param {string} $where Optional pseudoelement to target (before or after). 4 | @mixin icon($content: false, $where: before) { 5 | 6 | text-decoration: none; 7 | 8 | &:#{$where} { 9 | 10 | @if $content { 11 | content: $content; 12 | } 13 | 14 | -moz-osx-font-smoothing: grayscale; 15 | -webkit-font-smoothing: antialiased; 16 | font-family: FontAwesome; 17 | font-style: normal; 18 | font-weight: normal; 19 | text-transform: none !important; 20 | 21 | } 22 | 23 | } 24 | 25 | /// Applies padding to an element, taking the current element-margin value into account. 26 | /// @param {mixed} $tb Top/bottom padding. 27 | /// @param {mixed} $lr Left/right padding. 28 | /// @param {list} $pad Optional extra padding (in the following order top, right, bottom, left) 29 | /// @param {bool} $important If true, adds !important. 30 | @mixin padding($tb, $lr, $pad: (0,0,0,0), $important: null) { 31 | 32 | @if $important { 33 | $important: '!important'; 34 | } 35 | 36 | padding: ($tb + nth($pad,1)) ($lr + nth($pad,2)) max(0.1em, $tb - _size(element-margin) + nth($pad,3)) ($lr + nth($pad,4)) #{$important}; 37 | 38 | } 39 | 40 | /// Encodes a SVG data URL so IE doesn't choke (via codepen.io/jakob-e/pen/YXXBrp). 41 | /// @param {string} $svg SVG data URL. 42 | /// @return {string} Encoded SVG data URL. 43 | @function svg-url($svg) { 44 | 45 | $svg: str-replace($svg, '"', '\''); 46 | $svg: str-replace($svg, '<', '%3C'); 47 | $svg: str-replace($svg, '>', '%3E'); 48 | $svg: str-replace($svg, '&', '%26'); 49 | $svg: str-replace($svg, '#', '%23'); 50 | $svg: str-replace($svg, '{', '%7B'); 51 | $svg: str-replace($svg, '}', '%7D'); 52 | $svg: str-replace($svg, ';', '%3B'); 53 | 54 | @return url("data:image/svg+xml;charset=utf8,#{$svg}"); 55 | 56 | } -------------------------------------------------------------------------------- /examples/virtual-backend-basic/HH-server.js: -------------------------------------------------------------------------------- 1 | /* 2 | Example virtual server code. Feel free to use this as a template for your own applications. 3 | This file MUST be named HS-server.js for it to be loaded. 4 | 5 | See HS-fs.js for an example of how to create your own modules from Browserify modules. 6 | 7 | See exampleClient.js for how to make requests to this server. 8 | */ 9 | 10 | // We can use 'require' as we would with Node's 'require'. 11 | var hyperhost = require('hyperhost') // This module enables to interact with HyperHost. It is similar to Express 12 | var custom = require('custom') // Require custom modules 13 | var fs = require('browserify-fs') // We can require any modules on NPM that work with Browserify 14 | 15 | var app = hyperhost.createApp() // Creates our app 16 | 17 | // Requests to this server are done via HyperHost P2P clients and are NOT ordinary HTTP requests! 18 | 19 | // Handles 'get requests' to the '/' route 20 | app.get('/', function (req, res) { 21 | // We can use our modules 22 | 23 | custom.someFunction() 24 | fs.mkdir('/home') 25 | fs.writeFile('/home/hello-world.txt', 'Virtual file system? Yes please!') 26 | 27 | // We can send any data over the connection (including files, blobs, anything) 28 | res.send({ 29 | exampleData: 'hello!', 30 | moreData: [1, 4, 2, 3], 31 | more: { 32 | anyData: {} 33 | } 34 | }) 35 | }) 36 | 37 | // Handles 'post requests' to the '/myroute' route 38 | app.post('/myroute', function (req, res) { 39 | // A more advanced way of doing the same thing 40 | res.body = { 41 | array: [1, 2, 3], 42 | object: {}, 43 | int: 5 44 | } 45 | res.body.int = 6 46 | res.end() // Call res.end() when finished. res.send() calls this automatically. 47 | }) 48 | 49 | // Handles both 'post' and 'get' requests 50 | app.all('/any/possible/route', function (req, res) { 51 | res.statuscode = 404 // We can define status codes 52 | res.kill() // We can also kill the connection (this frees up resources but the client will no longer be able to make requests during their session) 53 | }) 54 | 55 | app.listen() // This starts the virtual backend 56 | -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/sass/components/_button.scss: -------------------------------------------------------------------------------- 1 | /// 2 | /// Phantom by HTML5 UP 3 | /// html5up.net | @ajlkn 4 | /// Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | /// 6 | 7 | /* Button */ 8 | 9 | input[type="submit"], 10 | input[type="reset"], 11 | input[type="button"], 12 | button, 13 | .button { 14 | @include vendor('appearance', 'none'); 15 | @include vendor('transition', ( 16 | 'background-color #{_duration(transition)} ease-in-out', 17 | 'color #{_duration(transition)} ease-in-out', 18 | 'box-shadow #{_duration(transition)} ease-in-out' 19 | )); 20 | background-color: transparent; 21 | border-radius: _size(border-radius); 22 | border: 0; 23 | box-shadow: inset 0 0 0 (_size(border-width) * 2) _palette(fg); 24 | color: _palette(fg) !important; 25 | cursor: pointer; 26 | display: inline-block; 27 | font-size: 0.8em; 28 | font-weight: _font(weight-bold); 29 | height: 3.5em; 30 | letter-spacing: _font(letter-spacing); 31 | line-height: 3.45em; 32 | overflow: hidden; 33 | padding: 0 1.25em 0 #{1.25em + _font(letter-spacing)}; 34 | text-align: center; 35 | text-decoration: none; 36 | text-overflow: ellipsis; 37 | text-transform: uppercase; 38 | white-space: nowrap; 39 | 40 | &.icon { 41 | &:before { 42 | margin-right: 0.5em; 43 | } 44 | } 45 | 46 | &.fit { 47 | display: block; 48 | margin: 0 0 (_size(element-margin) * 0.5) 0; 49 | width: 100%; 50 | } 51 | 52 | &:hover { 53 | color: _palette(accent1) !important; 54 | box-shadow: inset 0 0 0 (_size(border-width) * 2) _palette(accent1); 55 | } 56 | 57 | &:active { 58 | background-color: transparentize(_palette(accent1), 0.9); 59 | } 60 | 61 | &.small { 62 | font-size: 0.6em; 63 | } 64 | 65 | &.big { 66 | font-size: 1em; 67 | } 68 | 69 | &.special { 70 | box-shadow: none; 71 | background-color: _palette(fg); 72 | color: _palette(bg) !important; 73 | 74 | &:hover { 75 | background-color: _palette(accent1); 76 | } 77 | 78 | &:active { 79 | background-color: darken(_palette(accent1), 8); 80 | } 81 | } 82 | 83 | &.disabled, 84 | &:disabled { 85 | @include vendor('pointer-events', 'none'); 86 | opacity: 0.25; 87 | } 88 | } -------------------------------------------------------------------------------- /src/runtime/virtualModules/HH-hyperhost.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016 Thomas Mullen. All rights reserved. 3 | MIT License 4 | 5 | This module is used by a virtual server running INSIDE HyperHost. 6 | It is not a component of HH itself, but a requirement for the virtual server. 7 | 8 | It is similar to Express.js, but with HH connections instead of HTTP. 9 | 10 | */ 11 | 12 | // Constructor for the response object, which abstracts away PeerJS 13 | var Response = function (conn, id) { 14 | this.body 15 | this.send = function (data) { 16 | this.body = data 17 | this.end() 18 | } 19 | this.end = function () { 20 | conn.send({ 21 | type: 'response', 22 | id: id, 23 | content: { 24 | statuscode: this.statuscode, 25 | body: this.body 26 | } 27 | }) 28 | } 29 | this.statuscode = 200 30 | this.kill = function () { 31 | conn.close() 32 | } 33 | } 34 | 35 | // Creates the server app 36 | module.exports.createApp = function () { 37 | var listening = false, 38 | 39 | // Constructs a new router function with the specified methods allowed 40 | RouterFunction = function (methods) { 41 | var routerFunction = function (route, requestListener, next) { 42 | addEventListener('hyperdata', function (e) { 43 | if (!listening) return // Ignore requests made before server is started 44 | if (route !== e.detail.request.route) return // Ignore invalid routes TODO: error here 45 | if (routerFunction.methods.indexOf(e.detail.request.method.toLowerCase()) === -1) { // Block invalid method 46 | console.error("Client requested unsupported route '" + e.detail.request.method + "' on route '" + route + "'") 47 | return 48 | } 49 | console.log(e.detail.id + ' : ' + e.detail.request.method.toUpperCase() + ' ' + route) 50 | requestListener(e.detail.request, new Response(e.detail.connection, e.detail.id), next) 51 | }, false) 52 | } 53 | routerFunction.methods = methods 54 | return routerFunction 55 | } 56 | 57 | // Router functions for different methods 58 | app = { 59 | all: new RouterFunction(['get', 'post']), 60 | get: new RouterFunction(['get']), 61 | post: new RouterFunction(['post']) 62 | } 63 | 64 | // Allows requests to be served 65 | app.listen = function () { 66 | listening = true 67 | console.log('Virtual server listenting...') 68 | } 69 | 70 | return app 71 | } 72 | -------------------------------------------------------------------------------- /src/runtime/virtualServer.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016 Thomas Mullen. All rights reserved. 3 | MIT License 4 | 5 | Emulates a Node.js server. 6 | 7 | */ 8 | 9 | const config = require('../config/config.json'), 10 | util = require('../util/util.js'), 11 | hyperhostRequireModule = require('./virtualModules/HH-hyperhost.js') 12 | 13 | function VirtualServer (startScript, modules, jsonFiles) { 14 | 'use strict' 15 | 16 | let moduleListing = [] 17 | 18 | // The 'require' emulator 19 | const HHrequire = function HHrequire (moduleName) { 20 | if (moduleListing.indexOf(moduleName) === -1) { 21 | return 22 | } else { 23 | return modules[moduleName] 24 | } 25 | } 26 | 27 | // Gets a Wzrd.in url from module name 28 | const getWzrdModuleUrl = function getWzrdModuleUrl (name, version) { 29 | return config.paths.wzrd + name + jsonFiles['package']['dependencies'][name] + (version ? '@' + version : '') 30 | } 31 | 32 | /* 33 | Launch the virtual server. 34 | */ 35 | this.launch = function launch () { 36 | let npmModuleList = Object.keys(jsonFiles['package']['dependencies']) // Get NPM modules from package.json 37 | moduleListing = Object.keys(modules) 38 | moduleListing = moduleListing.concat(npmModuleList) 39 | 40 | // Generate urls for wzrd.in files 41 | for (let i = 0; i < npmModuleList.length; i++) { 42 | modules[npmModuleList[i]] = getWzrdModuleUrl(npmModuleList[i], jsonFiles['package']['dependencies'][npmModuleList[i]]) 43 | } 44 | 45 | window.HyperHost.modules = modules // Expose the modules 46 | 47 | // Inject the virtual backend modules 48 | util.injectScripts(moduleListing, modules, function () { 49 | // Wzrd will put everything on the window, so we need to move it to the modules 50 | for (let i = 0; i < npmModuleList.length; i++) { 51 | modules[npmModuleList[i]] = window[util.camelize(npmModuleList[i])] 52 | } 53 | 54 | // Add the HyperHost virtual module 55 | moduleListing.push('hyperhost') 56 | modules['hyperhost'] = hyperhostRequireModule 57 | 58 | window.require = HHrequire // Overwrite any other 'require' methods 59 | 60 | // Inject the virtual start script after modules loaded 61 | const script = document.createElement('script') 62 | script.setAttribute('type', 'text/javascript') 63 | script.setAttribute('src', startScript) 64 | document.head.appendChild(script) 65 | }) 66 | } 67 | } 68 | 69 | module.exports = VirtualServer 70 | -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/js/ie/html5shiv.js: -------------------------------------------------------------------------------- 1 | /* 2 | HTML5 Shiv v3.6.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 3 | */ 4 | (function (l, f) { 5 | function m () { var a = e.elements; return typeof a === 'string' ? a.split(' ') : a } function i (a) { var b = n[a[o]]; b || (b = {}, h++, a[o] = h, n[h] = b); return b } function p (a, b, c) { b || (b = f); if (g) return b.createElement(a); c || (c = i(b)); b = c.cache[a] ? c.cache[a].cloneNode() : r.test(a) ? (c.cache[a] = c.createElem(a)).cloneNode() : c.createElem(a); return b.canHaveChildren && !s.test(a) ? c.frag.appendChild(b) : b } function t (a, b) { 6 | if (!b.cache)b.cache = {}, b.createElem = a.createElement, b.createFrag = a.createDocumentFragment, b.frag = b.createFrag() 7 | a.createElement = function (c) { return !e.shivMethods ? b.createElem(c) : p(c, a, b) }; a.createDocumentFragment = Function('h,f', 'return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&(' + m().join().replace(/\w+/g, function (a) { b.createElem(a); b.frag.createElement(a); return 'c("' + a + '")' }) + ');return n}')(e, b.frag) 8 | } function q (a) { 9 | a || (a = f); var b = i(a); if (e.shivCSS && !j && !b.hasCSS) { 10 | var c, d = a; c = d.createElement('p'); d = d.getElementsByTagName('head')[0] || d.documentElement; c.innerHTML = 'x' 11 | c = d.insertBefore(c.lastChild, d.firstChild); b.hasCSS = !!c 12 | }g || t(a, b); return a 13 | } var k = l.html5 || {}, s = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i, r = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i, j, o = '_html5shiv', h = 0, n = {}, g; (function () { 14 | try { 15 | var a = f.createElement('a'); a.innerHTML = ''; j = 'hidden' in a; var b; if (!(b = a.childNodes.length == 1)) { 16 | f.createElement('a'); var c = f.createDocumentFragment(); b = typeof c.cloneNode === 'undefined' || 17 | typeof c.createDocumentFragment === 'undefined' || typeof c.createElement === 'undefined' 18 | }g = b 19 | } catch (d) { g = j = !0 } 20 | })(); var e = {elements: k.elements || 'abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup main mark meter nav output progress section summary time video', version: '3.6.2', shivCSS: !1 !== k.shivCSS, supportsUnknownElements: g, shivMethods: !1 !== k.shivMethods, type: 'default', shivDocument: q, createElement: p, createDocumentFragment: function (a, b) { 21 | a || (a = f); if (g) return a.createDocumentFragment() 22 | for (var b = b || i(a), c = b.frag.cloneNode(), d = 0, e = m(), h = e.length; d < h; d++)c.createElement(e[d]); return c 23 | }}; l.html5 = e; q(f) 24 | })(this, document) 25 | -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/sass/layout/_footer.scss: -------------------------------------------------------------------------------- 1 | /// 2 | /// Phantom by HTML5 UP 3 | /// html5up.net | @ajlkn 4 | /// Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | /// 6 | 7 | /* Footer */ 8 | 9 | #footer { 10 | $gutter: _size(gutter); 11 | 12 | @include padding(5em, 0, (0, 0, 3em, 0)); 13 | background-color: _palette(bg-alt); 14 | 15 | > .inner { 16 | @include vendor('display', 'flex'); 17 | @include vendor('flex-wrap', 'wrap'); 18 | @include vendor('flex-direction', 'row'); 19 | 20 | > * > :last-child { 21 | margin-bottom: 0; 22 | } 23 | 24 | section:nth-child(1) { 25 | width: calc(66% - #{$gutter}); 26 | margin-right: $gutter; 27 | } 28 | 29 | section:nth-child(2) { 30 | width: calc(33% - #{$gutter}); 31 | margin-left: $gutter; 32 | } 33 | 34 | .copyright { 35 | width: 100%; 36 | padding: 0; 37 | margin-top: 5em; 38 | list-style: none; 39 | font-size: 0.8em; 40 | color: transparentize(_palette(fg), 0.5); 41 | 42 | a { 43 | color: inherit; 44 | } 45 | 46 | li { 47 | display: inline-block; 48 | border-left: solid 1px transparentize(_palette(fg), 0.85); 49 | line-height: 1; 50 | padding: 0 0 0 1em; 51 | margin: 0 0 0 1em; 52 | 53 | &:first-child { 54 | border-left: 0; 55 | padding-left: 0; 56 | margin-left: 0; 57 | } 58 | } 59 | } 60 | } 61 | 62 | @include breakpoint(large) { 63 | $gutter: _size(gutter) * 0.5; 64 | 65 | @include padding(5em, 0); 66 | 67 | > .inner { 68 | section:nth-child(1) { 69 | width: calc(66% - #{$gutter}); 70 | margin-right: $gutter; 71 | } 72 | 73 | section:nth-child(2) { 74 | width: calc(33% - #{$gutter}); 75 | margin-left: $gutter; 76 | } 77 | } 78 | } 79 | 80 | @include breakpoint(medium) { 81 | $gutter: _size(gutter); 82 | 83 | > .inner { 84 | section:nth-child(1) { 85 | width: 66%; 86 | margin-right: 0; 87 | } 88 | 89 | section:nth-child(2) { 90 | width: calc(33% - #{$gutter}); 91 | margin-left: $gutter; 92 | } 93 | } 94 | } 95 | 96 | @include breakpoint(small) { 97 | @include padding(3em, 0); 98 | 99 | > .inner { 100 | @include vendor('flex-direction', 'column'); 101 | 102 | section:nth-child(1) { 103 | width: 100%; 104 | margin-right: 0; 105 | margin: 3em 0 0 0; 106 | } 107 | 108 | section:nth-child(2) { 109 | @include vendor('order', '-1'); 110 | width: 100%; 111 | margin-left: 0; 112 | } 113 | 114 | .copyright { 115 | margin-top: 3em; 116 | } 117 | } 118 | } 119 | 120 | @include breakpoint(xsmall) { 121 | > .inner { 122 | .copyright { 123 | margin-top: 3em; 124 | 125 | li { 126 | border-left: 0; 127 | padding-left: 0; 128 | margin: 0.75em 0 0 0; 129 | display: block; 130 | line-height: inherit; 131 | 132 | &:first-child { 133 | margin-top: 0; 134 | } 135 | } 136 | } 137 | } 138 | } 139 | } -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/sass/components/_list.scss: -------------------------------------------------------------------------------- 1 | /// 2 | /// Phantom by HTML5 UP 3 | /// html5up.net | @ajlkn 4 | /// Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | /// 6 | 7 | /* List */ 8 | 9 | ol { 10 | list-style: decimal; 11 | margin: 0 0 _size(element-margin) 0; 12 | padding-left: 1.25em; 13 | 14 | li { 15 | padding-left: 0.25em; 16 | } 17 | } 18 | 19 | ul { 20 | list-style: disc; 21 | margin: 0 0 _size(element-margin) 0; 22 | padding-left: 1em; 23 | 24 | li { 25 | padding-left: 0.5em; 26 | } 27 | 28 | &.alt { 29 | list-style: none; 30 | padding-left: 0; 31 | 32 | li { 33 | border-top: solid _size(border-width) _palette(border); 34 | padding: 0.5em 0; 35 | 36 | &:first-child { 37 | border-top: 0; 38 | padding-top: 0; 39 | } 40 | } 41 | } 42 | 43 | &.icons { 44 | cursor: default; 45 | list-style: none; 46 | padding-left: 0; 47 | margin: -1em 0 _size(element-margin) -1em; 48 | 49 | li { 50 | display: inline-block; 51 | padding: 1em 0 0 1em; 52 | } 53 | } 54 | 55 | &.actions { 56 | cursor: default; 57 | list-style: none; 58 | padding-left: 0; 59 | 60 | li { 61 | display: inline-block; 62 | padding: 0 (_size(element-margin) * 0.5) 0 0; 63 | vertical-align: middle; 64 | 65 | &:last-child { 66 | padding-right: 0; 67 | } 68 | } 69 | 70 | &.small { 71 | li { 72 | padding: 0 (_size(element-margin) * 0.25) 0 0; 73 | } 74 | } 75 | 76 | &.vertical { 77 | li { 78 | display: block; 79 | padding: (_size(element-margin) * 0.5) 0 0 0; 80 | 81 | &:first-child { 82 | padding-top: 0; 83 | } 84 | 85 | > * { 86 | margin-bottom: 0; 87 | } 88 | } 89 | 90 | &.small { 91 | li { 92 | padding: (_size(element-margin) * 0.25) 0 0 0; 93 | 94 | &:first-child { 95 | padding-top: 0; 96 | } 97 | } 98 | } 99 | } 100 | 101 | &.fit { 102 | display: table; 103 | margin-left: (_size(element-margin) * -0.5); 104 | padding: 0; 105 | table-layout: fixed; 106 | width: calc(100% + #{(_size(element-margin) * 0.5)}); 107 | 108 | li { 109 | display: table-cell; 110 | padding: 0 0 0 (_size(element-margin) * 0.5); 111 | 112 | > * { 113 | margin-bottom: 0; 114 | } 115 | } 116 | 117 | &.small { 118 | margin-left: (_size(element-margin) * -0.25); 119 | width: calc(100% + #{(_size(element-margin) * 0.25)}); 120 | 121 | li { 122 | padding: 0 0 0 (_size(element-margin) * 0.25); 123 | } 124 | } 125 | } 126 | 127 | @include breakpoint(xsmall) { 128 | margin: 0 0 _size(element-margin) 0; 129 | 130 | li { 131 | padding: (_size(element-margin) * 0.5) 0 0 0; 132 | display: block; 133 | text-align: center; 134 | width: 100%; 135 | 136 | &:first-child { 137 | padding-top: 0; 138 | } 139 | 140 | > * { 141 | width: 100%; 142 | margin: 0 !important; 143 | 144 | &.icon { 145 | &:before { 146 | margin-left: -2em; 147 | } 148 | } 149 | } 150 | } 151 | 152 | &.small { 153 | li { 154 | padding: (_size(element-margin) * 0.25) 0 0 0; 155 | 156 | &:first-child { 157 | padding-top: 0; 158 | } 159 | } 160 | } 161 | } 162 | } 163 | } 164 | 165 | dl { 166 | margin: 0 0 _size(element-margin) 0; 167 | 168 | dt { 169 | display: block; 170 | font-weight: _font(weight-bold); 171 | margin: 0 0 (_size(element-margin) * 0.5) 0; 172 | } 173 | 174 | dd { 175 | margin-left: _size(element-margin); 176 | } 177 | } -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/sass/layout/_header.scss: -------------------------------------------------------------------------------- 1 | /// 2 | /// Phantom by HTML5 UP 3 | /// html5up.net | @ajlkn 4 | /// Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | /// 6 | 7 | /* Header */ 8 | 9 | #header { 10 | @include padding(5em, 0, (3em, 0, -5em, 0)); 11 | 12 | .logo { 13 | display: block; 14 | border-bottom: 0; 15 | color: inherit; 16 | font-weight: _font(weight-bold); 17 | letter-spacing: _font(letter-spacing); 18 | margin: 0 0 (_size(element-margin) * 1.25) 0; 19 | text-decoration: none; 20 | text-transform: uppercase; 21 | display: inline-block; 22 | 23 | > * { 24 | display: inline-block; 25 | vertical-align: middle; 26 | } 27 | 28 | .symbol { 29 | margin-right: 0.65em; 30 | 31 | img { 32 | display: block; 33 | width: 2em; 34 | height: 2em; 35 | } 36 | } 37 | } 38 | 39 | nav { 40 | position: fixed; 41 | right: 2em; 42 | top: 2em; 43 | z-index: _misc(z-index-base); 44 | 45 | ul { 46 | @include vendor('display', 'flex'); 47 | @include vendor('align-items', 'center'); 48 | list-style: none; 49 | margin: 0; 50 | padding: 0; 51 | 52 | li { 53 | display: block; 54 | padding: 0; 55 | 56 | a { 57 | display: block; 58 | position: relative; 59 | height: 3em; 60 | line-height: 3em; 61 | padding: 0 1.5em; 62 | background-color: transparentize(_palette(bg), 0.5); 63 | border-radius: _size(border-radius); 64 | border: 0; 65 | font-size: 0.8em; 66 | font-weight: _font(weight-bold); 67 | letter-spacing: _font(letter-spacing); 68 | text-transform: uppercase; 69 | } 70 | 71 | a[href="#menu"] { 72 | -webkit-tap-highlight-color: transparent; 73 | width: 4em; 74 | text-indent: 4em; 75 | font-size: 1em; 76 | overflow: hidden; 77 | padding: 0; 78 | white-space: nowrap; 79 | 80 | &:before, &:after { 81 | @include vendor('transition', 'opacity #{_duration(transition)} ease'); 82 | content: ''; 83 | display: block; 84 | position: absolute; 85 | top: 0; 86 | left: 0; 87 | width: 100%; 88 | height: 100%; 89 | background-position: center; 90 | background-repeat: no-repeat; 91 | background-size: 2em 2em; 92 | } 93 | 94 | &:before { 95 | background-image: svg-url(''); 96 | opacity: 0; 97 | } 98 | 99 | &:after { 100 | background-image: svg-url(''); 101 | opacity: 1; 102 | } 103 | 104 | &:hover { 105 | &:before { 106 | opacity: 1; 107 | } 108 | 109 | &:after { 110 | opacity: 0; 111 | } 112 | } 113 | } 114 | } 115 | } 116 | } 117 | 118 | @include breakpoint(small) { 119 | @include padding(3em, 0, (1em, 0, -3em, 0)); 120 | 121 | nav { 122 | right: 0.5em; 123 | top: 0.5em; 124 | 125 | ul { 126 | li { 127 | a[href="#menu"] { 128 | &:before, &:after { 129 | background-size: 1.5em 1.5em; 130 | } 131 | } 132 | } 133 | } 134 | } 135 | } 136 | } -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/sass/base/_typography.scss: -------------------------------------------------------------------------------- 1 | /// 2 | /// Phantom by HTML5 UP 3 | /// html5up.net | @ajlkn 4 | /// Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | /// 6 | 7 | /* Type */ 8 | 9 | body, input, select, textarea { 10 | color: _palette(fg); 11 | font-family: _font(family); 12 | font-size: 16pt; 13 | font-weight: _font(weight); 14 | line-height: 1.75; 15 | 16 | @include breakpoint(xlarge) { 17 | font-size: 14pt; 18 | } 19 | 20 | @include breakpoint(large) { 21 | font-size: 12pt; 22 | } 23 | } 24 | 25 | a { 26 | @include vendor('transition', ( 27 | 'border-bottom-color #{_duration(transition)} ease', 28 | 'color #{_duration(transition)} ease' 29 | )); 30 | text-decoration: none; 31 | color: _palette(fg); 32 | border-bottom: dotted 1px transparentize(_palette(fg), 0.5); 33 | 34 | &:hover { 35 | border-bottom-color: transparent; 36 | color: _palette(accent1) !important; 37 | } 38 | } 39 | 40 | strong, b { 41 | color: _palette(fg-bold); 42 | font-weight: _font(weight-bold); 43 | } 44 | 45 | em, i { 46 | font-style: italic; 47 | } 48 | 49 | p { 50 | margin: 0 0 _size(element-margin) 0; 51 | } 52 | 53 | h1 { 54 | font-size: 2.75em; 55 | color: _palette(fg-bold); 56 | font-weight: _font(weight-bold-alt); 57 | line-height: 1.3; 58 | margin: 0 0 (_size(element-margin) * 0.5) 0; 59 | letter-spacing: _font(letter-spacing-alt); 60 | 61 | a { 62 | color: inherit; 63 | } 64 | 65 | @include breakpoint(small) { 66 | font-size: 2em; 67 | margin: 0 0 (_size(element-margin) * 0.5) 0; 68 | } 69 | 70 | @include breakpoint(xxsmall) { 71 | font-size: 1.75em; 72 | } 73 | } 74 | 75 | h2, h3, h4, h5, h6 { 76 | color: _palette(fg-bold); 77 | font-weight: _font(weight-bold); 78 | line-height: 1.5; 79 | margin: 0 0 (_size(element-margin) * 1) 0; 80 | text-transform: uppercase; 81 | letter-spacing: _font(letter-spacing); 82 | 83 | a { 84 | color: inherit; 85 | } 86 | } 87 | 88 | h2 { 89 | font-size: 1.1em; 90 | } 91 | 92 | h3 { 93 | font-size: 1em; 94 | } 95 | 96 | h4 { 97 | font-size: 0.8em; 98 | } 99 | 100 | h5 { 101 | font-size: 0.8em; 102 | } 103 | 104 | h6 { 105 | font-size: 0.8em; 106 | } 107 | 108 | @include breakpoint(medium) { 109 | h1, h2, h3, h4, h5, h6 { 110 | br { 111 | display: none; 112 | } 113 | } 114 | } 115 | 116 | @include breakpoint(small) { 117 | h2 { 118 | font-size: 1em; 119 | } 120 | 121 | h3 { 122 | font-size: 0.8em; 123 | } 124 | } 125 | 126 | sub { 127 | font-size: 0.8em; 128 | position: relative; 129 | top: 0.5em; 130 | } 131 | 132 | sup { 133 | font-size: 0.8em; 134 | position: relative; 135 | top: -0.5em; 136 | } 137 | 138 | blockquote { 139 | border-left: solid (_size(border-width) * 4) _palette(border); 140 | font-style: italic; 141 | margin: 0 0 _size(element-margin) 0; 142 | padding: (_size(element-margin) / 4) 0 (_size(element-margin) / 4) _size(element-margin); 143 | } 144 | 145 | code { 146 | background: _palette(border-bg); 147 | border-radius: _size(border-radius); 148 | border: solid _size(border-width) _palette(border); 149 | font-family: _font(family-fixed); 150 | font-size: 0.9em; 151 | margin: 0 0.25em; 152 | padding: 0.25em 0.65em; 153 | } 154 | 155 | pre { 156 | -webkit-overflow-scrolling: touch; 157 | font-family: _font(family-fixed); 158 | font-size: 0.9em; 159 | margin: 0 0 _size(element-margin) 0; 160 | 161 | code { 162 | display: block; 163 | line-height: 1.75; 164 | padding: 1em 1.5em; 165 | overflow-x: auto; 166 | } 167 | } 168 | 169 | hr { 170 | border: 0; 171 | border-bottom: solid _size(border-width) _palette(border); 172 | margin: _size(element-margin) 0; 173 | 174 | &.major { 175 | margin: (_size(element-margin) * 1.5) 0; 176 | } 177 | } 178 | 179 | .align-left { 180 | text-align: left; 181 | } 182 | 183 | .align-center { 184 | text-align: center; 185 | } 186 | 187 | .align-right { 188 | text-align: right; 189 | } -------------------------------------------------------------------------------- /src/processing/io.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016 Thomas Mullen. All rights reserved. 3 | MIT License 4 | 5 | Builds content trees from different inputs 6 | */ 7 | 8 | const util = require('../util/util.js'), 9 | config = require('../config/config.json') 10 | 11 | function IO () { 12 | 'use strict' 13 | 14 | let contentTree = {nodes: []} 15 | 16 | let _handlers = {} 17 | const _emit = function _emit (event, data) { 18 | var fn = _handlers[event] 19 | if (fn && typeof (fn) === 'function') { 20 | fn(data) 21 | } 22 | } 23 | 24 | let remainingFiles = 0, // For tracking async load 25 | traversalComplete // 26 | 27 | // Traverses and loads a webkitEntry 28 | const traverseWebkitEntry = function travserseWebkitEntry (entry, ancestors, callback) { 29 | if (entry.isFile) { 30 | entry.file(function (file) { 31 | let fileReader = new FileReader(), 32 | extension = entry.name.split('.') 33 | extension = extension[extension.length - 1].toLowerCase() 34 | 35 | remainingFiles++ 36 | fileReader.addEventListener('load', () => { 37 | util.deepSetTree(contentTree, { 38 | name: entry.name, 39 | content: fileReader.result 40 | }, ancestors) 41 | 42 | // Check for completion 43 | remainingFiles-- 44 | if (remainingFiles === 0 && traversalComplete) { 45 | callback() 46 | } 47 | }) 48 | 49 | if (config.extensions.view.indexOf(extension) !== -1) { 50 | // Views must remain text 51 | fileReader.readAsText(file) 52 | } else { 53 | // Everything else must be base64 54 | fileReader.readAsDataURL(file) 55 | } 56 | }, function (err) { 57 | console.error(err) 58 | }) 59 | } else if (entry.isDirectory) { 60 | util.deepSetTree(contentTree, { 61 | name: entry.name, 62 | nodes: [] 63 | }, ancestors) 64 | 65 | let dirReader = entry.createReader() 66 | dirReader.readEntries((entries) => { 67 | for (var i = 0; i < entries.length; i++) { 68 | let newAncestors = ancestors.slice(0) // Clone ancestors array 69 | newAncestors.push(entry.name) 70 | traverseWebkitEntry(entries[i], newAncestors, callback) 71 | } 72 | }) 73 | } 74 | } 75 | 76 | /* 77 | Listen for an event. 78 | */ 79 | this.on = function on (event, handler) { 80 | _handlers[event] = handler 81 | } 82 | 83 | this.getContentTree = function () { 84 | return contentTree 85 | } 86 | 87 | /* 88 | Consumes a content tree directly. 89 | */ 90 | this.contentTree = function (newContentTree) { 91 | contentTree = newContentTree 92 | _emit('digest', {}) 93 | } 94 | 95 | /* 96 | Builds a true content tree from a tree containing File objects. 97 | */ 98 | this.fileTree = function (fileTree) { 99 | throw new Error('Not implemented') // TODO 100 | } 101 | 102 | /* 103 | Builds content tree from JSZip object. 104 | */ 105 | this.zip = function (zip) { 106 | throw new Error('Not implemented') // TODO 107 | } 108 | 109 | /* 110 | Builds content tree from an array of files. Use with 111 | */ 112 | this.fileArray = function (fileArray) { 113 | throw new Error('Not implemented') // TODO 114 | } 115 | 116 | /* 117 | Builds content tree from a webkitdirectory. Use with 118 | */ 119 | this.webkitDirectory = function (fileArray) { 120 | throw new Error('Not implemented') // TODO 121 | } 122 | 123 | /* 124 | Builds from a drop event. Currently only supports webkitdirectory. 125 | */ 126 | this.dropEvent = function (event) { 127 | let items = event.dataTransfer.items 128 | 129 | traversalComplete = false 130 | for (var i = 0; i < items.length; i++) { 131 | if (items[i].webkitGetAsEntry) { 132 | traverseWebkitEntry(items[i].webkitGetAsEntry(), [], function () { 133 | contentTree = contentTree.nodes[0].nodes 134 | _emit('digest', {}) 135 | }) 136 | } else { 137 | // TODO multiple and single files 138 | } 139 | } 140 | traversalComplete = true 141 | } 142 | } 143 | 144 | module.exports = IO 145 | -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/js/ie/respond.min.js: -------------------------------------------------------------------------------- 1 | /*! Respond.js v1.4.2: min/max-width media query polyfill 2 | * Copyright 2014 Scott Jehl 3 | * Licensed under MIT 4 | * http://j.mp/respondjs */ 5 | 6 | !function(a){"use strict";a.matchMedia=a.matchMedia||function(a){var b,c=a.documentElement,d=c.firstElementChild||c.firstChild,e=a.createElement("body"),f=a.createElement("div");return f.id="mq-test-1",f.style.cssText="position:absolute;top:-100em",e.style.background="none",e.appendChild(f),function(a){return f.innerHTML='­',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";function b(){v(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))},g=function(a){return a.replace(c.regex.minmaxwh,"").match(c.regex.other)};if(c.ajax=f,c.queue=d,c.unsupportedmq=g,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,comments:/\/\*[^*]*\*+([^/][^*]*\*+)*\//gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\(\s*min\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,maxw:/\(\s*max\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,minmaxwh:/\(\s*m(in|ax)\-(height|width)\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/gi,other:/\([^\)]*\)/g},c.mediaQueriesSupported=a.matchMedia&&null!==a.matchMedia("only all")&&a.matchMedia("only all").matches,!c.mediaQueriesSupported){var h,i,j,k=a.document,l=k.documentElement,m=[],n=[],o=[],p={},q=30,r=k.getElementsByTagName("head")[0]||l,s=k.getElementsByTagName("base")[0],t=r.getElementsByTagName("link"),u=function(){var a,b=k.createElement("div"),c=k.body,d=l.style.fontSize,e=c&&c.style.fontSize,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",c||(c=f=k.createElement("body"),c.style.background="none"),l.style.fontSize="100%",c.style.fontSize="100%",c.appendChild(b),f&&l.insertBefore(c,l.firstChild),a=b.offsetWidth,f?l.removeChild(c):c.removeChild(b),l.style.fontSize=d,e&&(c.style.fontSize=e),a=j=parseFloat(a)},v=function(b){var c="clientWidth",d=l[c],e="CSS1Compat"===k.compatMode&&d||k.body[c]||d,f={},g=t[t.length-1],p=(new Date).getTime();if(b&&h&&q>p-h)return a.clearTimeout(i),i=a.setTimeout(v,q),void 0;h=p;for(var s in m)if(m.hasOwnProperty(s)){var w=m[s],x=w.minw,y=w.maxw,z=null===x,A=null===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?j||u():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?j||u():1)),w.hasquery&&(z&&A||!(z||e>=x)||!(A||y>=e))||(f[w.media]||(f[w.media]=[]),f[w.media].push(n[w.rules]))}for(var C in o)o.hasOwnProperty(C)&&o[C]&&o[C].parentNode===r&&r.removeChild(o[C]);o.length=0;for(var D in f)if(f.hasOwnProperty(D)){var E=k.createElement("style"),F=f[D].join("\n");E.type="text/css",E.media=D,r.insertBefore(E,g.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(k.createTextNode(F)),o.push(E)}},w=function(a,b,d){var e=a.replace(c.regex.comments,"").replace(c.regex.keyframes,"").match(c.regex.media),f=e&&e.length||0;b=b.substring(0,b.lastIndexOf("/"));var h=function(a){return a.replace(c.regex.urls,"$1"+b+"$2$3")},i=!f&&d;b.length&&(b+="/"),i&&(f=1);for(var j=0;f>j;j++){var k,l,o,p;i?(k=d,n.push(h(a))):(k=e[j].match(c.regex.findStyles)&&RegExp.$1,n.push(RegExp.$2&&h(RegExp.$2))),o=k.split(","),p=o.length;for(var q=0;p>q;q++)l=o[q],g(l)||m.push({media:l.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:n.length-1,hasquery:l.indexOf("(")>-1,minw:l.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:l.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}v()},x=function(){if(d.length){var b=d.shift();f(b.href,function(c){w(c,b.href,b.media),p[b.href]=!0,a.setTimeout(function(){x()},0)})}},y=function(){for(var b=0;b .inner { 31 | @include vendor('transition', 'opacity #{_duration(menu)} ease'); 32 | -webkit-overflow-scrolling: touch; 33 | position: absolute; 34 | top: 0; 35 | left: 0; 36 | width: 100%; 37 | height: 100%; 38 | padding: 2.75em; 39 | opacity: 0; 40 | overflow-y: auto; 41 | 42 | > ul { 43 | list-style: none; 44 | margin: 0 0 (_size(element-margin) * 0.5) 0; 45 | padding: 0; 46 | 47 | > li { 48 | padding: 0; 49 | border-top: solid 1px transparentize(_palette(bg), 0.85); 50 | 51 | a { 52 | display: block; 53 | padding: 1em 0; 54 | line-height: 1.5; 55 | border: 0; 56 | color: inherit; 57 | } 58 | 59 | &:first-child { 60 | border-top: 0; 61 | margin-top: -1em; 62 | } 63 | } 64 | } 65 | } 66 | 67 | > .close { 68 | @include vendor('transition', ( 69 | 'opacity #{_duration(menu)} ease', 70 | 'transform #{_duration(menu)} ease' 71 | )); 72 | @include vendor('transform', 'scale(0.25) rotate(180deg)'); 73 | -webkit-tap-highlight-color: transparent; 74 | display: block; 75 | position: absolute; 76 | top: 2em; 77 | left: -6em; 78 | width: 6em; 79 | text-indent: 6em; 80 | height: 3em; 81 | border: 0; 82 | font-size: 1em; 83 | opacity: 0; 84 | overflow: hidden; 85 | padding: 0; 86 | white-space: nowrap; 87 | 88 | &:before, &:after { 89 | @include vendor('transition', 'opacity #{_duration(transition)} ease'); 90 | content: ''; 91 | display: block; 92 | position: absolute; 93 | top: 0; 94 | left: 0; 95 | width: 100%; 96 | height: 100%; 97 | background-position: center; 98 | background-repeat: no-repeat; 99 | background-size: 2em 2em; 100 | } 101 | 102 | &:before { 103 | background-image: svg-url(''); 104 | opacity: 0; 105 | } 106 | 107 | &:after { 108 | background-image: svg-url(''); 109 | opacity: 1; 110 | } 111 | 112 | &:hover { 113 | &:before { 114 | opacity: 1; 115 | } 116 | 117 | &:after { 118 | opacity: 0; 119 | } 120 | } 121 | } 122 | 123 | @include breakpoint(small) { 124 | @include vendor('transform', 'translateX(#{_size(menu) * 0.75})'); 125 | width: (_size(menu) * 0.75); 126 | 127 | > .inner { 128 | padding: 2.75em 1.5em; 129 | } 130 | 131 | > .close { 132 | top: 0.5em; 133 | left: -4.25em; 134 | width: 4.25em; 135 | text-indent: 4.25em; 136 | 137 | &:before, &:after { 138 | background-size: 1.5em 1.5em; 139 | } 140 | } 141 | } 142 | } 143 | 144 | body.is-menu-visible { 145 | #wrapper { 146 | @include vendor('pointer-events', 'none'); 147 | cursor: default; 148 | opacity: 0.25; 149 | } 150 | 151 | #menu { 152 | @include vendor('transform', 'translateX(0)'); 153 | visibility: visible; 154 | 155 | > * { 156 | opacity: 1; 157 | } 158 | 159 | .close { 160 | @include vendor('transform', 'scale(1.0) rotate(0deg)'); 161 | opacity: 1; 162 | } 163 | } 164 | } -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/js/main.js: -------------------------------------------------------------------------------- 1 | /* 2 | Phantom by HTML5 UP 3 | html5up.net | @ajlkn 4 | Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | */ 6 | 7 | (function ($) { 8 | skel.breakpoints({ 9 | xlarge: '(max-width: 1680px)', 10 | large: '(max-width: 1280px)', 11 | medium: '(max-width: 980px)', 12 | small: '(max-width: 736px)', 13 | xsmall: '(max-width: 480px)' 14 | }) 15 | 16 | $(function () { 17 | var $window = $(window), 18 | $body = $('body') 19 | 20 | // Disable animations/transitions until the page has loaded. 21 | $body.addClass('is-loading') 22 | 23 | $window.on('load', function () { 24 | window.setTimeout(function () { 25 | $body.removeClass('is-loading') 26 | }, 100) 27 | }) 28 | 29 | // Touch? 30 | if (skel.vars.touch) { 31 | $body.addClass('is-touch') 32 | } 33 | 34 | // Forms. 35 | var $form = $('form') 36 | 37 | // Auto-resizing textareas. 38 | $form.find('textarea').each(function () { 39 | var $this = $(this), 40 | $wrapper = $('
'), 41 | $submits = $this.find('input[type="submit"]') 42 | 43 | $this 44 | .wrap($wrapper) 45 | .attr('rows', 1) 46 | .css('overflow', 'hidden') 47 | .css('resize', 'none') 48 | .on('keydown', function (event) { 49 | if (event.keyCode == 13 50 | && event.ctrlKey) { 51 | event.preventDefault() 52 | event.stopPropagation() 53 | 54 | $(this).blur() 55 | } 56 | }) 57 | .on('blur focus', function () { 58 | $this.val($.trim($this.val())) 59 | }) 60 | .on('input blur focus --init', function () { 61 | $wrapper 62 | .css('height', $this.height()) 63 | 64 | $this 65 | .css('height', 'auto') 66 | .css('height', $this.prop('scrollHeight') + 'px') 67 | }) 68 | .on('keyup', function (event) { 69 | if (event.keyCode == 9) { 70 | $this 71 | .select() 72 | } 73 | }) 74 | .triggerHandler('--init') 75 | 76 | // Fix. 77 | if (skel.vars.browser == 'ie' 78 | || skel.vars.mobile) { 79 | $this 80 | .css('max-height', '10em') 81 | .css('overflow-y', 'auto') 82 | } 83 | }) 84 | 85 | // Fix: Placeholder polyfill. 86 | $form.placeholder() 87 | 88 | // Prioritize "important" elements on medium. 89 | skel.on('+medium -medium', function () { 90 | $.prioritize( 91 | '.important\\28 medium\\29', 92 | skel.breakpoint('medium').active 93 | ) 94 | }) 95 | 96 | // Menu. 97 | var $menu = $('#menu') 98 | 99 | $menu.wrapInner('
') 100 | 101 | $menu._locked = false 102 | 103 | $menu._lock = function () { 104 | if ($menu._locked) { 105 | return false 106 | } 107 | 108 | $menu._locked = true 109 | 110 | window.setTimeout(function () { 111 | $menu._locked = false 112 | }, 350) 113 | 114 | return true 115 | } 116 | 117 | $menu._show = function () { 118 | if ($menu._lock()) { 119 | $body.addClass('is-menu-visible') 120 | } 121 | } 122 | 123 | $menu._hide = function () { 124 | if ($menu._lock()) { 125 | $body.removeClass('is-menu-visible') 126 | } 127 | } 128 | 129 | $menu._toggle = function () { 130 | if ($menu._lock()) { 131 | $body.toggleClass('is-menu-visible') 132 | } 133 | } 134 | 135 | $menu 136 | .appendTo($body) 137 | .on('click', function (event) { 138 | event.stopPropagation() 139 | }) 140 | .on('click', 'a', function (event) { 141 | var href = $(this).attr('href') 142 | 143 | event.preventDefault() 144 | event.stopPropagation() 145 | 146 | // Hide. 147 | $menu._hide() 148 | 149 | // Redirect. 150 | if (href == '#menu') { 151 | return 152 | } 153 | 154 | window.setTimeout(function () { 155 | window.location.href = href 156 | }, 350) 157 | }) 158 | .append('Close') 159 | 160 | $body 161 | .on('click', 'a[href="#menu"]', function (event) { 162 | event.stopPropagation() 163 | event.preventDefault() 164 | 165 | // Toggle. 166 | $menu._toggle() 167 | }) 168 | .on('click', function (event) { 169 | // Hide. 170 | $menu._hide() 171 | }) 172 | .on('keydown', function (event) { 173 | // Hide on escape. 174 | if (event.keyCode == 27) { $menu._hide() } 175 | }) 176 | }) 177 | })(jQuery) 178 | -------------------------------------------------------------------------------- /src/runtime/staticServer.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016 Thomas Mullen. All rights reserved. 3 | MIT License 4 | 5 | Serves static resources over WebRTC. 6 | 7 | */ 8 | 9 | const globalConfig = require('../config/config.json') 10 | 11 | function StaticServer (views, hasVirtualBackend) { 12 | 'use strict' 13 | 14 | const myPeerID = parseInt(Math.random() * 1e15, 10).toString(16), // A random PeerJS ID 15 | maxReconnectAttempts = globalConfig.maxReconnectAttempts // Max attempts to connect to signalling server 16 | 17 | let peer, // The PeerJS peer object 18 | heartbeater, 19 | _handlers = {} 20 | 21 | const _emit = function _emit (event, data) { 22 | var fn = _handlers[event] 23 | if (fn && typeof (fn) === 'function') { 24 | fn(data) 25 | } 26 | } 27 | 28 | /* 29 | Listen for an event. 30 | */ 31 | this.on = function on (event, handler) { 32 | _handlers[event] = handler 33 | } 34 | 35 | // Fixes PeerJS' habit of disconnecting us from the signalling server 36 | const makePeerHeartbeater = function makePeerHeartbeater (peer) { 37 | let timeoutID = 0 38 | 39 | function heartbeat () { 40 | timeoutID = setTimeout(heartbeat, 20000) 41 | if (peer.socket._wsOpen()) { 42 | peer.socket.send({ 43 | type: 'HEARTBEAT' 44 | }) 45 | } 46 | } 47 | heartbeat() 48 | 49 | return { 50 | start: function () { 51 | if (timeoutID === 0) { 52 | heartbeat() 53 | } 54 | }, 55 | stop: function () { 56 | clearTimeout(timeoutID) 57 | timeoutID = 0 58 | } 59 | } 60 | }, 61 | 62 | // Returns the view for the provided path 63 | getView = function (path) { 64 | for (let i = 0; i < views.length; i++) { 65 | if (views[i].path === path) { 66 | return views[i] 67 | } 68 | } 69 | } 70 | 71 | this.clientURL = globalConfig.paths.client + myPeerID // The URL where clients can connect 72 | this.views = views // An array of compiled views 73 | 74 | /* 75 | Connects to signalling server and starts serving views. 76 | */ 77 | this.launch = function launch () { 78 | this.config = this.config || globalConfig.peerJS 79 | 80 | peer = new Peer(myPeerID, this.config) // Create the peer 81 | 82 | peer.on('open', function (id) { 83 | _emit('ready') 84 | }) 85 | 86 | peer.on('error', (err) => { 87 | // TODO: Route PeerJS errors 88 | }) 89 | heartbeater = makePeerHeartbeater(peer) 90 | 91 | // Handle incoming connections 92 | peer.on('connection', (conn) => { 93 | // TODO: Eventing 94 | 95 | conn.on('close', () => { 96 | // TODO: Eventing 97 | }) 98 | 99 | // Any data received by the server is intended for the virtual backend 100 | conn.on('data', (data) => { 101 | // TODO: Eventing 102 | 103 | // Send server a request event 104 | if (data.type === 'request') { 105 | let event = new CustomEvent('hyperdata', { 106 | detail: { 107 | request: JSON.parse(data.request), 108 | connection: conn, 109 | id: data.id 110 | } 111 | }) 112 | dispatchEvent(event) 113 | } 114 | 115 | // Intercept post-load view requests 116 | else if (data.type === 'view') { 117 | let view = getView(data.path) 118 | view.body = view.content 119 | conn.send({ 120 | type: 'view', 121 | path: data.path, 122 | content: { 123 | view: view, 124 | hasVirtualBackend: hasVirtualBackend 125 | } 126 | }) 127 | } 128 | }) 129 | }) 130 | 131 | // Handle disconnections from signalling server 132 | let failures = 0 133 | peer.on('disconnected', () => { 134 | // TODO: Eventing 135 | peer.reconnect() // Auto-reconnect 136 | 137 | let check = setInterval(() => { // Check the reconnection worked 138 | if (!peer.disconnected) { 139 | // TODO: Eventing 140 | failures = 0 141 | clearInterval(check) 142 | } else { 143 | failures++ 144 | if (failures >= maxReconnectAttempts) { 145 | // TODO: Eventing 146 | throw new Error('Could not reconnect to signalling server.') 147 | } 148 | } 149 | }, 1000) 150 | }) 151 | 152 | return this.clientURL 153 | } 154 | } 155 | 156 | module.exports = StaticServer 157 | -------------------------------------------------------------------------------- /src/processing/flattener.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016 Thomas Mullen. All rights reserved. 3 | MIT License 4 | 5 | Flattens the content tree into two arrays of views and assets. 6 | 7 | The content tree has the following example structure: 8 | 9 | [ 10 | { 11 | name: 'folder', 12 | nodes : [ 13 | { 14 | name : 'nested file', 15 | content : 'content of file here' 16 | } 17 | ] 18 | }, 19 | { 20 | name : 'a file', 21 | content : 'some file content' 22 | } 23 | ] 24 | 25 | */ 26 | 27 | const util = require('../util/util.js'), 28 | config = require('../config/config.json') 29 | 30 | function Flattener () { 31 | 'use strict' 32 | 33 | let views, 34 | assets, 35 | startScript, 36 | virtualModules, 37 | jsonFiles, 38 | foundIndex 39 | 40 | const pushFile = function pushFile (path, item, isRoot) { 41 | const ext = util.nameToExtension(item.name) 42 | 43 | // Views must not be encoded! 44 | if (util.contains(config.extensions.view, ext)) { 45 | if (path + item.name === 'index.html') { // Find the root HTML page 46 | foundIndex = true 47 | } 48 | 49 | if (ext === 'json') { 50 | jsonFiles[path + item.name.split('.')[0]] = JSON.parse(item.content) // JSON files are reserved for the server. If you need them in client, use a virtual backend to serve them 51 | } else { 52 | views.push({ 53 | content: item.content, 54 | path: path + item.name, 55 | extension: ext, 56 | isRoot: isRoot 57 | }) 58 | } 59 | } 60 | 61 | // Should not be encoded initially, but we will encode them 62 | else if (util.contains(config.extensions.text, ext)) { 63 | const dataURI = item.dataURI || util.toDataURI(item.content, util.nameToExtension(item.name)) 64 | 65 | if (item.name.substring(0, 3) === 'HH-') { 66 | if (item.name === 'HH-server.js') { // Virtual server start file 67 | startScript = dataURI 68 | } else { // Virtual server module 69 | const name = item.name.substring(3).slice(0, -3) 70 | virtualModules[name] = dataURI 71 | } 72 | } else { 73 | assets.push({ 74 | old: path + item.name, 75 | new: dataURI, 76 | extension: ext, 77 | name: item.name, 78 | isFont: false 79 | }) 80 | } 81 | } 82 | 83 | // Misc files should always be encoded 84 | else { 85 | const dataURI = item.dataURI || util.toDataURI(item.content, util.nameToExtension(item.name)), 86 | isFont = util.contains(config.extensions.image, ext) // Identify fonts 87 | 88 | assets.push({ 89 | old: path + item.name, 90 | new: dataURI, 91 | extension: ext, 92 | name: item.name, 93 | isFont: isFont 94 | }) 95 | } 96 | }, 97 | 98 | // Traverses an item of unknown type in the content tree 99 | traverseFileTree = function traverseFileTree (item, path, depth, ancestors) { 100 | if (item.name[0] === '.' || item.isRemoved) return // Ignore hidden files 101 | 102 | if (!item.nodes) { // No child node array, must be a file 103 | pushFile(path, item, depth <= 1) 104 | } else { 105 | // Recursively traverse folder 106 | for (let i = 0; i < item.nodes.length; i++) { 107 | const newPath = path + item.name + '/', 108 | newAncestors = ancestors.slice(0) 109 | newAncestors.push(item.name) 110 | 111 | traverseFileTree(item.nodes[i], newPath, depth + 1, newAncestors) 112 | } 113 | } 114 | } 115 | 116 | /* 117 | Flattens a content tree and returns the result. 118 | 119 | Returns an object containing : 120 | an array of views, 121 | an array of assets, 122 | a virtual server start script (if one exists), 123 | a dictionary of virtual modules, 124 | a dictionary of json files. 125 | */ 126 | this.flatten = function flatten (tree) { 127 | // Reset working variables 128 | views = [] 129 | assets = [] 130 | virtualModules = {} 131 | foundIndex = false 132 | jsonFiles = { 133 | package: { 134 | dependencies: {} 135 | } 136 | } 137 | 138 | // Iterate across root level of tree 139 | for (let i = 0; i < tree.length; i++) { 140 | traverseFileTree(tree[i], '', 0, []) 141 | } 142 | 143 | if (!foundIndex) { 144 | throw new Error('No index.html in root level of content tree.') 145 | } 146 | 147 | return { 148 | views, 149 | assets, 150 | startScript, 151 | virtualModules, 152 | jsonFiles 153 | } 154 | } 155 | } 156 | 157 | module.exports = Flattener 158 | -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/sass/components/_form.scss: -------------------------------------------------------------------------------- 1 | /// 2 | /// Phantom by HTML5 UP 3 | /// html5up.net | @ajlkn 4 | /// Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | /// 6 | 7 | /* Form */ 8 | 9 | form { 10 | margin: (_size(element-margin) * -0.5) 0 _size(element-margin) 0; 11 | 12 | &:after { 13 | content: ''; 14 | display: block; 15 | clear: both; 16 | height: 1px; 17 | } 18 | 19 | .field { 20 | position: relative; 21 | float: left; 22 | margin: 0 0 (_size(element-margin) * 0.65) 0; 23 | vertical-align: top; 24 | width: 100%; 25 | } 26 | 27 | .half { 28 | width: calc(50% + #{_size(field-gutter) * 0.5}) !important; 29 | padding-left: _size(field-gutter); 30 | } 31 | 32 | .half.first { 33 | width: calc(50% - #{_size(field-gutter) * 0.5}) !important; 34 | padding-left: 0; 35 | } 36 | 37 | :last-child { 38 | margin-bottom: 0; 39 | } 40 | 41 | .half:nth-last-child(2) { 42 | margin-bottom: 0; 43 | } 44 | 45 | .actions { 46 | position: relative; 47 | clear: both; 48 | padding-top: (_size(element-margin) * 0.5); 49 | } 50 | 51 | @include breakpoint(xsmall) { 52 | .half { 53 | width: 100% !important; 54 | padding-left: 0; 55 | } 56 | 57 | .half.first { 58 | width: 100% !important; 59 | padding-left: 0; 60 | } 61 | 62 | .half:nth-last-child(2) { 63 | margin: 0 0 (_size(element-margin) * 0.65) 0; 64 | } 65 | } 66 | } 67 | 68 | label { 69 | display: block; 70 | font-size: 0.9em; 71 | font-weight: _font(weight-bold); 72 | margin: 0 0 (_size(element-margin) * 0.5) 0; 73 | } 74 | 75 | input[type="text"], 76 | input[type="password"], 77 | input[type="email"], 78 | input[type="tel"], 79 | select, 80 | textarea { 81 | @include vendor('appearance', 'none'); 82 | background-color: transparent; 83 | border: none; 84 | border-radius: 0; 85 | border-bottom: solid _size(border-width) _palette(border); 86 | color: inherit; 87 | display: block; 88 | outline: 0; 89 | padding: 0; 90 | text-decoration: none; 91 | width: 100%; 92 | 93 | &:invalid { 94 | box-shadow: none; 95 | } 96 | 97 | &:focus { 98 | border-bottom-color: _palette(accent1); 99 | box-shadow: inset 0 -1px 0 0 _palette(accent1); 100 | } 101 | } 102 | 103 | .select-wrapper { 104 | @include icon; 105 | display: block; 106 | position: relative; 107 | 108 | &:before { 109 | color: _palette(border); 110 | content: '\f078'; 111 | display: block; 112 | height: _size(element-height); 113 | line-height: _size(element-height); 114 | pointer-events: none; 115 | position: absolute; 116 | right: 0; 117 | text-align: center; 118 | top: 0; 119 | width: _size(element-height); 120 | } 121 | 122 | select::-ms-expand { 123 | display: none; 124 | } 125 | } 126 | 127 | input[type="text"], 128 | input[type="password"], 129 | input[type="email"], 130 | select { 131 | height: _size(element-height); 132 | } 133 | 134 | textarea { 135 | padding: 0; 136 | min-height: (_size(element-height) * 1.25); 137 | } 138 | 139 | input[type="checkbox"], 140 | input[type="radio"], { 141 | @include vendor('appearance', 'none'); 142 | display: block; 143 | float: left; 144 | margin-right: -2em; 145 | opacity: 0; 146 | width: 1em; 147 | z-index: -1; 148 | 149 | & + label { 150 | @include icon; 151 | color: _palette(fg); 152 | cursor: pointer; 153 | display: inline-block; 154 | font-size: 1em; 155 | font-weight: _font(weight); 156 | padding-left: (_size(element-height) * 0.6) + 0.75em; 157 | padding-right: 0.75em; 158 | position: relative; 159 | 160 | &:before { 161 | border-radius: _size(border-radius); 162 | border: solid _size(border-width) _palette(border); 163 | content: ''; 164 | display: inline-block; 165 | height: (_size(element-height) * 0.6); 166 | left: 0; 167 | line-height: (_size(element-height) * 0.575); 168 | position: absolute; 169 | text-align: center; 170 | top: 0; 171 | width: (_size(element-height) * 0.6); 172 | } 173 | } 174 | 175 | &:checked + label { 176 | &:before { 177 | background: _palette(fg); 178 | border-color: _palette(fg); 179 | color: _palette(bg); 180 | content: '\f00c'; 181 | } 182 | } 183 | 184 | &:focus + label { 185 | &:before { 186 | border-color: _palette(accent1); 187 | box-shadow: 0 0 0 _size(border-width) _palette(accent1); 188 | } 189 | } 190 | } 191 | 192 | input[type="checkbox"] { 193 | & + label { 194 | &:before { 195 | border-radius: _size(border-radius); 196 | } 197 | } 198 | } 199 | 200 | input[type="radio"] { 201 | & + label { 202 | &:before { 203 | border-radius: 100%; 204 | } 205 | } 206 | } -------------------------------------------------------------------------------- /src/processing/compiler.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016 Thomas Mullen. All rights reserved. 3 | MIT License 4 | 5 | Injects encoded assets and subviews into views. 6 | */ 7 | 8 | const util = require('../util/util.js') 9 | 10 | function Compiler () { 11 | 'use strict' 12 | 13 | // Inject assets into views 14 | const injectAssets = function injectAssets (views, assets) { 15 | let i, i2, regex 16 | i = views.length 17 | while (i--) { 18 | i2 = assets.length 19 | while (i2--) { 20 | if (views[i].isRoot) { 21 | // Find instances of the path name and replace with encoded content 22 | regex = new RegExp('(.\/|)' + util.escapeRegex(assets[i2].old), 'g') 23 | views[i].content = views[i].content.replace(regex, assets[i2].new) 24 | } else if (views[i].extension === 'css') { 25 | // Relaxes exact path matching for CSS files (only name match is required) 26 | regex = new RegExp('url\(([^)]*)(.\/|)' + util.escapeRegex(assets[i2].name) + '([^)]*)\)', 'g') 27 | views[i].content = views[i].content.replace(regex, 'url(' + assets[i2].new) 28 | } else { 29 | /* 30 | TODO: Support relative paths in more than just stylesheets. 31 | 32 | Javascript may have many false matches. 33 | Other types are completely unknown. 34 | */ 35 | } 36 | } 37 | } 38 | }, 39 | 40 | // Inject subsviews into views 41 | injectViews = function injectViews (views) { 42 | let i, i2, regex, navScript 43 | 44 | i = views.length 45 | while (i--) { 46 | if (views[i].isInvalid) continue 47 | if (views[i].extension !== 'html') continue // Subviews only make sense for HTML 48 | 49 | i2 = views.length 50 | while (i2--) { 51 | if (views[i2].isInvalid) continue 52 | 53 | switch (views[i2].extension) { 54 | 55 | case 'css': 56 | // External CSS files are replaced by embedded stylesheets 57 | regex = new RegExp("", 'g') 58 | views[i].content = views[i].content.replace(regex, '') 59 | 60 | break 61 | 62 | case 'html': 63 | // Links to internal HTML files are replaced via navigation scripts 64 | regex = new RegExp("href\\s*=\\s*['\"](.\/|)" + util.escapeRegex(views[i2].path) + "(#[^'\"]*['\"]|['\"])", 'g') 65 | 66 | navScript = `href='#' onclick="event.preventDefault();var parent=window.parent;var event = new CustomEvent('hypermessage', {detail: {type: 'navigate',path:'` + views[i2].path + `'}});parent.dispatchEvent(event)"` 67 | 68 | views[i].content = views[i].content.replace(regex, navScript) 69 | 70 | break 71 | 72 | default: 73 | // TODO support other kinds of injectable views (are there any?) 74 | continue 75 | } 76 | } 77 | } 78 | }, 79 | 80 | // Replaces hash links with scrolling scripts 81 | replaceHashLinks = function replaceHashLinks (views) { 82 | let i, i2, regex, regex2, regex3, matches, anchorID 83 | 84 | i = views.length 85 | while (i--) { 86 | if (views[i].isInvalid) continue 87 | if (views[i].extension !== 'html') continue 88 | 89 | // Replace hash links 90 | 91 | // Get all href attributes that begin with a hash 92 | regex = new RegExp("href\\s*=\\s*['\"](.\/|)\\s*#[^'\"]+['\"]", 'g') 93 | matches = views[i].content.match(regex) 94 | 95 | if (matches !== null) { 96 | i2 = matches.length 97 | while (i2--) { 98 | // Get the actual name (without the #) 99 | regex2 = new RegExp("#[^'\"]+['\"]", 'g') 100 | anchorID = matches[i2].match(regex2)[0] 101 | anchorID = anchorID.substr(1, anchorID.length - 2) 102 | 103 | // Get the full href again 104 | regex3 = new RegExp("href\\s*=\\s*['\"](.\/|)\\s*#" + util.escapeRegex(anchorID) + "['\"]", 'g') 105 | 106 | // Inject a script to control scrolling 107 | // TODO: Is this the best solution? 108 | views[i].content = views[i].content.replace(regex3, `href="#" onclick="event.preventDefault(); document.getElementById('` + anchorID + `').scrollIntoView();"`) 109 | } 110 | } 111 | } 112 | } 113 | 114 | /* 115 | Accepts an array of views and an array of pre-encoded assets. 116 | Compiles these views in-place. 117 | Returns the array of compiled views. 118 | */ 119 | this.compile = function compile (views, assets) { 120 | injectAssets(views, assets) 121 | injectViews(views) 122 | replaceHashLinks(views) 123 | return views 124 | } 125 | } 126 | 127 | module.exports = Compiler 128 | -------------------------------------------------------------------------------- /examples/html5up-phantom-example/generic.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Generic - Phantom by HTML5 UP 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 39 | 40 | 41 | 51 | 52 | 53 |
54 |
55 |

Generic Page

56 | 57 |

Donec eget ex magna. Interdum et malesuada fames ac ante ipsum primis in faucibus. Pellentesque venenatis dolor imperdiet dolor mattis sagittis. Praesent rutrum sem diam, vitae egestas enim auctor sit amet. Pellentesque leo mauris, consectetur id ipsum sit amet, fergiat. Pellentesque in mi eu massa lacinia malesuada et a elit. Donec urna ex, lacinia in purus ac, pretium pulvinar mauris. Curabitur sapien risus, commodo eget turpis at, elementum convallis elit. Pellentesque enim turpis, hendrerit tristique.

58 |

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis dapibus rutrum facilisis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Etiam tristique libero eu nibh porttitor fermentum. Nullam venenatis erat id vehicula viverra. Nunc ultrices eros ut ultricies condimentum. Mauris risus lacus, blandit sit amet venenatis non, bibendum vitae dolor. Nunc lorem mauris, fringilla in aliquam at, euismod in lectus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In non lorem sit amet elit placerat maximus. Pellentesque aliquam maximus risus, vel venenatis mauris vehicula hendrerit.

59 |

Interdum et malesuada fames ac ante ipsum primis in faucibus. Pellentesque venenatis dolor imperdiet dolor mattis sagittis. Praesent rutrum sem diam, vitae egestas enim auctor sit amet. Pellentesque leo mauris, consectetur id ipsum sit amet, fersapien risus, commodo eget turpis at, elementum convallis elit. Pellentesque enim turpis, hendrerit tristique lorem ipsum dolor.

60 |
61 |
62 | 63 | 64 |
65 |
66 |
67 |

Get in touch

68 |
69 |
70 | 71 |
72 |
73 | 74 |
75 |
76 | 77 |
78 |
    79 |
  • 80 |
81 |
82 |
83 |
84 |

Follow

85 | 95 |
96 | 99 |
100 |
101 | 102 |
103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 |
3 | HyperHost 4 |
5 | HyperHost 6 |
7 |
8 |

9 |

Peer-To-Peer Node Servers in the Browser.

10 |
11 | 12 | *Currently just a prototype. A production version is in development.* 13 | 14 | ### Demo 15 | Drag and drop your website (with at least an **index.html**) into https://t-mullen.github.io/hyperhost/. 16 | It will be instantly served ***from your browser*** via WebRTC. 17 | 18 | ### Node Servers 19 | HyperHost emulates a Node server in your browser by replacing HTTP requests with WebRTC connections. 20 | This, along with the huge number of [Browserified](https://github.com/substack/node-browserify) Node modules, allows you to run a full server from your browser. 21 | 22 | Drag and drop a folder containing a file an **index.html** and a **HH-server.js**. 23 | Inside **HH-server.js**, you can put your Node start script. 24 | 25 | Example of a **HH-server.js**: 26 | ```javascript 27 | // HyperHost gives you access to a Node-like 'require' 28 | var hyperhost = require('hyperhost'); // This special module lets us handle WebRTC connections 29 | var fs = require('browserify-fs'); // require any module that can be Browserified 30 | var custom = require('custom'); // require custom modules that you upload with the "HH-" prefix (ie HH-custom.js" 31 | 32 | var app = hyperhost.createApp(); 33 | app.get('/', function (req, res) { 34 | 35 | custom.someFunction(); 36 | 37 | fs.mkdir('/home'); 38 | fs.writeFile('/home/hello-world.txt', "browserify-fs is used to create a virtual file system!"); 39 | 40 | // Send any data over WebRTC (objects, files, blobs) 41 | res.send({ 42 | exampleData: "send any serializable data", 43 | a : [] 44 | }); 45 | }); 46 | 47 | app.listen(); 48 | ``` 49 | 50 | ### Pull from NPM 51 | 52 | You can pull NPM modules via [WZRD](https://wzrd.in/) by adding a **package.json**: 53 | ```javascript 54 | { 55 | "name": "MyNodeApp", 56 | "dependencies": { 57 | "browserify-fs": ">1.0.0", // These are modules that will be pulled from NPM 58 | "crypto-browserify" : "", // 59 | } 60 | } 61 | ``` 62 | 63 | ### Client Code 64 | 65 | Calls to this Node server can only be made from the pages being hosted. (Think of it like CORS) 66 | Including **hyperclient.js** in your hosted files provides the `HyperRequest` object, similar to the `XMLHttpRequest` object. 67 | ```javascript 68 | //Here is an example request 69 | var hyp = HyperRequest(); //Create a new HyperRequest 70 | hyp.onload = function (response) { //Set the callback 71 | console.log(response); 72 | document.getElementById("output").innerHTML = JSON.stringify(response); 73 | } 74 | hyp.open("GET", "/"); //Set the method and route 75 | hyp.send({ //Send arbitrary data to server 76 | message: "hello", 77 | moreData: [12, 42, 21, ], 78 | evenMore: {} 79 | }); 80 | ``` 81 | 82 | ### How It Works 83 | First, the files you upload are read and seperated into static assets (images, HTML, CSS, etc) and server code (Javascript with the "HH-" prefix, or a package.json). 84 | 85 | The static assets are base64 encoded and bundled into a single large file (with some extra scripts for changing page). The server code is injected into the host page, along with any external NPM modules. The server is now running. 86 | 87 | When a client connects, they first connect to a signalling server, which helps with the creation of a WebRTC connection to the host page. When a connection is established, the static resource bundle is sent and displayed by the client. 88 | 89 | The same connection is used to handle any subsequent requests to the host (by way of the HyperRequest object). These requests are forwarded to the server code, which sends a response back the same way. 90 | 91 | ### Custom Usage 92 | 93 | The demo at https://rationalcoding.github.io/hyperhost/ is just one use-case. 94 | You can easily integrate instant hosting over WebRTC into any project. 95 | ```javascript 96 | var host = new HyperHost(); // Create a new HyperHost instance 97 | 98 | host.on('ready', function(url){ 99 | window.open(url); // Open the window when a URL is available 100 | }); 101 | 102 | host.io.on('digest', function(){ 103 | host.launch(); // Launch the server when digest is completed 104 | }); 105 | 106 | // Digest the content to be served. 107 | host.io.contentTree([ 108 | { 109 | name : 'index.html', 110 | content : 'Hello World' 111 | }, 112 | { 113 | name : "HH-server.js", 114 | content : 'var hyperhost = require("hyperhost"); console.log(hyperhost);' 115 | } 116 | ]); 117 | ``` 118 | 119 | ## Great for demos and hackathons! 120 | 121 | **Upcoming Features:** 122 | - Distributed hosting - Allow clients to opt-in to helping you host the site via a mesh network. 123 | - More ways to upload your site. 124 | - Full documentation and better examples. 125 | - More custom modules (WebSockets, MySQL, templating views) 126 | 127 | **Current Limitations:** 128 | - Any Node modules used must be Browserify-able. 129 | - The host must be running Chrome. The client can be [any browser supporting WebRTC](http://caniuse.com/#feat=rtcpeerconnection). 130 | - Very large pages can freeze up when clients attempt to load them. 131 | - Relative URLs pointing to hosted files inside **Javascript** files will not work. (JS cannot easily be refactored, an API for allowing this is forthcoming) 132 | - The **require** method only supports module *names* and not *paths*. `require('custom')`, not `require('./custom')`. (Use Browserify before uploading if you need this behaviour) 133 | 134 | **Notes:** 135 | You can host the files in this repo anywhere (even on a file:// domain!) if you don't want to use Github's servers for the initial resources. You can also use any PeerJS signalling server (with the addition of a `/api/peers` route that returns all peer IDs) 136 | -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/sass/components/_tiles.scss: -------------------------------------------------------------------------------- 1 | /// 2 | /// Phantom by HTML5 UP 3 | /// html5up.net | @ajlkn 4 | /// Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | /// 6 | 7 | /* Tiles */ 8 | 9 | .tiles { 10 | $gutter: _size(gutter); 11 | $duration: 0.5s; 12 | $ease: 'ease'; 13 | 14 | @include vendor('display', 'flex'); 15 | @include vendor('flex-wrap', 'wrap'); 16 | postiion: relative; 17 | margin: ($gutter * -1) 0 0 ($gutter * -1); 18 | 19 | article { 20 | @include vendor('transition', ( 21 | 'transform #{$duration} #{$ease}', 22 | 'opacity #{$duration} #{$ease}' 23 | )); 24 | position: relative; 25 | width: calc(#{(100% / 3)} - #{$gutter * 1}); 26 | margin: $gutter 0 0 $gutter; 27 | 28 | > .image { 29 | @include vendor('transition', 'transform #{$duration} #{$ease}'); 30 | position: relative; 31 | display: block; 32 | width: 100%; 33 | border-radius: _size(border-radius); 34 | overflow: hidden; 35 | 36 | img { 37 | display: block; 38 | width: 100%; 39 | } 40 | 41 | &:before { 42 | @include vendor('pointer-events', 'none'); 43 | @include vendor('transition', ( 44 | 'background-color #{$duration} #{$ease}', 45 | 'opacity #{$duration} #{$ease}' 46 | )); 47 | content: ''; 48 | display: block; 49 | position: absolute; 50 | top: 0; 51 | left: 0; 52 | width: 100%; 53 | height: 100%; 54 | opacity: 1.0; 55 | z-index: 1; 56 | opacity: 0.8; 57 | } 58 | 59 | &:after { 60 | @include vendor('pointer-events', 'none'); 61 | @include vendor('transition', 'opacity #{$duration} #{$ease}'); 62 | content: ''; 63 | display: block; 64 | position: absolute; 65 | top: 0; 66 | left: 0; 67 | width: 100%; 68 | height: 100%; 69 | background-image: svg-url(''); 70 | background-position: center; 71 | background-repeat: no-repeat; 72 | background-size: 100% 100%; 73 | opacity: 0.25; 74 | z-index: 2; 75 | } 76 | } 77 | 78 | > a { 79 | @include vendor('display', 'flex'); 80 | @include vendor('flex-direction', 'column'); 81 | @include vendor('align-items', 'center'); 82 | @include vendor('justify-content', 'center'); 83 | @include vendor('transition', ( 84 | 'background-color #{$duration} #{$ease}', 85 | 'transform #{$duration} #{$ease}' 86 | )); 87 | position: absolute; 88 | top: 0; 89 | left: 0; 90 | width: 100%; 91 | height: 100%; 92 | padding: 1em; 93 | border-radius: _size(border-radius); 94 | border-bottom: 0; 95 | color: _palette(fg-accent); 96 | text-align: center; 97 | text-decoration: none; 98 | z-index: 3; 99 | 100 | > :last-child { 101 | margin: 0; 102 | } 103 | 104 | &:hover { 105 | color: _palette(fg-accent) !important; 106 | } 107 | 108 | h2 { 109 | margin: 0; 110 | } 111 | 112 | .content { 113 | @include vendor('transition', ( 114 | 'max-height #{$duration} #{$ease}', 115 | 'opacity #{$duration} #{$ease}' 116 | )); 117 | width: 100%; 118 | max-height: 0; 119 | line-height: 1.5; 120 | margin-top: 0.35em; 121 | opacity: 0; 122 | 123 | > :last-child { 124 | margin-bottom: 0; 125 | } 126 | } 127 | } 128 | 129 | &.style1 { 130 | > .image:before { 131 | background-color: _palette(accent1); 132 | } 133 | } 134 | 135 | &.style2 { 136 | > .image:before { 137 | background-color: _palette(accent2); 138 | } 139 | } 140 | 141 | &.style3 { 142 | > .image:before { 143 | background-color: _palette(accent3); 144 | } 145 | } 146 | 147 | &.style4 { 148 | > .image:before { 149 | background-color: _palette(accent4); 150 | } 151 | } 152 | 153 | &.style5 { 154 | > .image:before { 155 | background-color: _palette(accent5); 156 | } 157 | } 158 | 159 | &.style6 { 160 | > .image:before { 161 | background-color: _palette(accent6); 162 | } 163 | } 164 | 165 | body:not(.is-touch) & { 166 | &:hover { 167 | > .image { 168 | @include vendor('transform', 'scale(1.1)'); 169 | 170 | &:before { 171 | background-color: _palette(bg-accent); 172 | opacity: 0.35; 173 | } 174 | 175 | &:after { 176 | opacity: 0; 177 | } 178 | } 179 | 180 | .content { 181 | max-height: 15em; 182 | opacity: 1; 183 | } 184 | } 185 | } 186 | } 187 | 188 | * + & { 189 | margin-top: _size(element-margin); 190 | } 191 | 192 | body.is-loading & { 193 | article { 194 | @include vendor('transform', 'scale(0.9)'); 195 | opacity: 0; 196 | } 197 | } 198 | 199 | body.is-touch & { 200 | article { 201 | .content { 202 | max-height: 15em; 203 | opacity: 1; 204 | } 205 | } 206 | } 207 | 208 | @include breakpoint(large) { 209 | $gutter: _size(gutter) * 0.5; 210 | 211 | margin: ($gutter * -1) 0 0 ($gutter * -1); 212 | 213 | article { 214 | width: calc(#{(100% / 3)} - #{$gutter * 1}); 215 | margin: $gutter 0 0 $gutter; 216 | } 217 | } 218 | 219 | @include breakpoint(medium) { 220 | $gutter: _size(gutter); 221 | 222 | margin: ($gutter * -1) 0 0 ($gutter * -1); 223 | 224 | article { 225 | width: calc(#{(100% / 2)} - #{$gutter * 1}); 226 | margin: $gutter 0 0 $gutter; 227 | } 228 | } 229 | 230 | @include breakpoint(small) { 231 | $gutter: _size(gutter) * 0.5; 232 | 233 | margin: ($gutter * -1) 0 0 ($gutter * -1); 234 | 235 | article { 236 | width: calc(#{(100% / 2)} - #{$gutter * 1}); 237 | margin: $gutter 0 0 $gutter; 238 | 239 | &:hover { 240 | > .image { 241 | @include vendor('transform', 'scale(1.0)'); 242 | } 243 | } 244 | } 245 | } 246 | 247 | @include breakpoint(xsmall) { 248 | $gutter: _size(gutter) * 0.5; 249 | 250 | margin: 0; 251 | 252 | article { 253 | width: 100%; 254 | margin: $gutter 0 0 0; 255 | } 256 | } 257 | } 258 | 259 | -------------------------------------------------------------------------------- /src/util/util.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2016 Thomas Mullen. All rights reserved. 4 | MIT License 5 | 6 | Utilities. 7 | 8 | */ 9 | 10 | var mimeTypes = require('./mimeTypes.json') 11 | 12 | var base64 = { 13 | _keyStr: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', 14 | 15 | encode: function (input) { 16 | var output = '', 17 | chr1, chr2, chr3, enc1, enc2, enc3, enc4, 18 | i = 0 19 | 20 | input = base64._utf8_encode(input) 21 | 22 | while (i < input.length) { 23 | chr1 = input.charCodeAt(i++) 24 | chr2 = input.charCodeAt(i++) 25 | chr3 = input.charCodeAt(i++) 26 | 27 | enc1 = chr1 >> 2 28 | enc2 = ((chr1 & 3) << 4) | (chr2 >> 4) 29 | enc3 = ((chr2 & 15) << 2) | (chr3 >> 6) 30 | enc4 = chr3 & 63 31 | 32 | if (isNaN(chr2)) { 33 | enc3 = enc4 = 64 34 | } else if (isNaN(chr3)) { 35 | enc4 = 64 36 | } 37 | 38 | output = output + 39 | this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + 40 | this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4) 41 | } 42 | return output 43 | }, 44 | 45 | // private method for UTF-8 encoding 46 | _utf8_encode: function (string) { 47 | string = string.replace(/\r\n/g, '\n') 48 | 49 | var utftext = '' 50 | 51 | for (var n = 0; n < string.length; n++) { 52 | var c = string.charCodeAt(n) 53 | if (c < 128) { 54 | utftext += String.fromCharCode(c) 55 | } else if ((c > 127) && (c < 2048)) { 56 | utftext += String.fromCharCode((c >> 6) | 192) 57 | + String.fromCharCode((c & 63) | 128) 58 | } else { 59 | utftext += String.fromCharCode((c >> 12) | 224); 60 | +String.fromCharCode(((c >> 6) & 63) | 128); 61 | +String.fromCharCode((c & 63) | 128) 62 | } 63 | } 64 | return utftext 65 | } 66 | } 67 | 68 | // Escapes a regex expression 69 | module.exports.escapeRegex = function (str) { 70 | return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&') 71 | } 72 | 73 | // Creates a dataURI from some data 74 | module.exports.toDataURI = function (content, extension) { 75 | var prefix = 'data:' + mimeTypes[extension] + ';base64,' 76 | 77 | if (content.slice(0, 5) === 'data:') { 78 | return content // Likely alredy encoded 79 | } 80 | if (content.indexOf(prefix) !== -1) { 81 | return content // Likely to be already encoded 82 | } 83 | try { 84 | return prefix + base64.encode(content) 85 | } catch (err) { 86 | console.warn(err) 87 | try { 88 | return prefix + base64.encode(unescape(encodeURIComponent(content))) 89 | } catch (err) { 90 | console.warn(err) 91 | return '' 92 | } 93 | } 94 | } 95 | 96 | // Gets the extension of a file name 97 | module.exports.nameToExtension = function (name) { 98 | var ext = name.split('.') 99 | ext = ext[ext.length - 1].toLowerCase() 100 | return ext 101 | } 102 | 103 | // Check if array contains an item 104 | module.exports.contains = function (array, item) { 105 | return array.indexOf(item) !== -1 106 | } 107 | 108 | // Deeply sets a nested object/array tree, creating ancestors where they are missing 109 | // Ancestors is an array of names that lead from root to the target object 110 | module.exports.deepSetTree = function (tempObj, value, ancestors) { 111 | for (var i = 0; i < ancestors.length; i++) { 112 | var found = false 113 | for (var i2 = 0; i2 < tempObj.nodes.length; i2++) { // Locate the ancestors 114 | if (tempObj.nodes[i2].name === ancestors[i]) { 115 | tempObj = tempObj.nodes[i2] 116 | found = true 117 | break 118 | } 119 | } 120 | if (!found) { 121 | tempObj.nodes.push({ // Create the ancestor if it doesn't exits 122 | name: ancestors[i], 123 | nodes: [] 124 | }) 125 | for (var i2 = 0; i2 < tempObj.nodes.length; i2++) { // Get the reference of the new object 126 | if (tempObj.nodes[i2].name === ancestors[i]) { 127 | tempObj = tempObj.nodes[i2] 128 | break 129 | } 130 | } 131 | } 132 | } 133 | tempObj.nodes.push(value) 134 | } 135 | 136 | // Injects an array of urls as scripts into the document 137 | module.exports.injectScripts = function (scripts, mappingObject, callback) { 138 | var remaining = scripts.length 139 | 140 | function loadScript (i) { 141 | if (!scripts[i]) { 142 | callback() 143 | return 144 | } 145 | var script = document.createElement('script') 146 | script.type = 'text/javascript' 147 | 148 | if (script.readyState) { // IE 149 | script.onreadystatechange = function () { 150 | if (script.readyState === 'loaded' || script.readyState === 'complete') { 151 | script.onreadystatechange = null 152 | remaining-- 153 | if (remaining === 0) { 154 | callback() 155 | } else { 156 | if (i < scripts.length - 1) { 157 | loadScript(i + 1) 158 | } 159 | } 160 | } 161 | } 162 | } else { // Others 163 | script.onload = function () { 164 | remaining-- 165 | if (remaining === 0) { 166 | callback() 167 | } else { 168 | loadScript(i + 1) 169 | } 170 | } 171 | } 172 | 173 | script.src = mappingObject[scripts[i]] 174 | document.getElementsByTagName('head')[0].appendChild(script) 175 | } 176 | loadScript(0) 177 | } 178 | 179 | // Basic ajax call 180 | module.exports.ajax = function (method, url, xOriginProxy, successCallback, errorCallback) { 181 | var xhr = new XMLHttpRequest() 182 | url = xOriginProxy + url 183 | xhr.open(method, url, true) 184 | xhr.onreadystatechange = function (e) { 185 | if (this.readyState === 4) { 186 | if (this.status >= 200 && this.status < 400) { 187 | if (successCallback && successCallback.constructor == Function) { 188 | return successCallback(this.responseText) 189 | } 190 | } else { 191 | if (errorCallback && errorCallback.constructor == Function) { 192 | return errorCallback(this.statusText) 193 | } else { 194 | console.error("Failed to get resource '" + url + "' Error: " + this.statusText) 195 | } 196 | } 197 | } 198 | } 199 | xhr.onerror = function (e) { 200 | if (errorCallback && errorCallback.constructor == Function) { 201 | return errorCallback(this.statusText) 202 | } else { 203 | console.error('Failed to get resource. Error: ' + this.statusText) 204 | } 205 | } 206 | xhr.send(null) 207 | } 208 | 209 | // Ajax-es an array of urls, only returning when all have been loaded 210 | module.exports.ajaxMulti = function (arr, successCallback, errorCallback) { 211 | var result = [] 212 | var remaining = arr.length 213 | for (var i = 0; i < arr.length; i++) { 214 | ajax(arr[i], 215 | function (data) { 216 | result[i] = data 217 | remaining-- 218 | if (remaining === 0) { 219 | successCallback(result) 220 | } 221 | }, errorCallback) 222 | } 223 | } 224 | 225 | // dash-case to camelCase 226 | module.exports.camelize = function (str) { 227 | return str.replace(/-([a-z])/g, function (g) { 228 | return g[1].toUpperCase() 229 | }) 230 | } 231 | -------------------------------------------------------------------------------- /dist/client/hyperclient.js: -------------------------------------------------------------------------------- 1 | /* 2 | Client that connects to and renders websites served by a HyperHost host. 3 | Thomas Mullen 2016 4 | */ 5 | 6 | (function (Peer) { 7 | 'use strict' 8 | 9 | var initialized = false, 10 | dataLoaded = false, 11 | conn, 12 | 13 | viewframeElement = document.getElementById('HYPERHOST-viewframe'), 14 | dropzoneElement = document.getElementById('HYPERHOST-dropzone'), 15 | h1Element = document.getElementById('HYPERHOST-HEADER'), 16 | h2Element = document.querySelector('#HYPERHOST-dropzone > div > h2'), 17 | aElement = document.querySelector('#HYPERHOST-dropzone > div > a'), 18 | 19 | getParameterByName = function getParameterByName (name, url) { 20 | if (!url) url = window.location.href 21 | name = name.replace(/[\[\]]/g, '\\$&') 22 | var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), 23 | results = regex.exec(url) 24 | if (!results) return null 25 | if (!results[2]) return '' 26 | return decodeURIComponent(results[2].replace(/\+/g, ' ')) 27 | }, 28 | 29 | // Define the HyperRequest object (akin to XMLHttpRequest) 30 | HyperRequestSrc = 'var HyperRequest=function(){var e={};return e.onload=function(){},e.open=function(t,n){e.method=t,e.route=n},e.send=function(t){function n(t){"response"===t.detail.type&&t.detail.id===r&&(window.removeEventListener(i,n),e.onload(t.detail.response))}var o=window.parent,r=Math.random().toString().substr(0,30),d=new CustomEvent("hypermessage",{detail:{type:"request",request:{method:e.method,route:e.route,body:t},id:r}});o.dispatchEvent(d);var i=window.addEventListener("hypermessage",n)},e};', 31 | /* 32 | var HyperRequest = function () { 33 | var self = {}; 34 | self.onload = function () {} 35 | self.open = function (method, route) { 36 | self.method = method; 37 | self.route = route; 38 | } 39 | self.send = function (body) { 40 | var parent = window.parent; 41 | var id = Math.random().toString().substr(0, 30); 42 | var event = new CustomEvent("hypermessage", { 43 | detail: { 44 | type: "request", 45 | request: { 46 | method: self.method, 47 | route: self.route, 48 | body: body 49 | }, 50 | id: id 51 | } 52 | }); 53 | parent.dispatchEvent(event) 54 | 55 | function handleResponse(e) { 56 | if (e.detail.type === "response" && e.detail.id === id) { 57 | window.removeEventListener(listener, handleResponse); 58 | self.onload(e.detail.response); 59 | } 60 | } 61 | var listener = window.addEventListener('hypermessage', handleResponse); 62 | } 63 | return self; 64 | } 65 | */ 66 | 67 | // Renders a different compiled HTML page in the viewframe 68 | HYPERHOST_NAVIGATE = function HYPERHOST_NAVIGATE (path) { 69 | console.log('Requested ' + path) 70 | conn.send({ 71 | type: 'view', 72 | path: path 73 | }) 74 | }, 75 | 76 | // Send message to viewFrame document (across iframe) 77 | sendHyperMessage = function sendHyperMessage (data) { 78 | var childWindow = viewframeElement.contentWindow 79 | var event = new CustomEvent('hypermessage', { 80 | detail: data 81 | }) 82 | childWindow.dispatchEvent(event) 83 | }, 84 | 85 | // Make a request to the virtual backend 86 | makeHyperRequest = function makeHyperRequest (id, request) { 87 | conn.send({ 88 | id: id, 89 | type: 'request', 90 | request: JSON.stringify(request) 91 | }) 92 | }, 93 | 94 | // Listen to messages from viewFrame document (across iframe) 95 | handleHyperMessage = function handleHyperMessage (e) { 96 | if (e.detail.type === 'navigate') { 97 | HYPERHOST_NAVIGATE(e.detail.path) 98 | } else if (e.detail.type === 'request') { 99 | makeHyperRequest(e.detail.id, e.detail.request) 100 | } 101 | }, 102 | 103 | // Initialize the client 104 | initialize = function initialize () { 105 | if (initialized) { 106 | return 107 | } else { 108 | initialized = true 109 | } 110 | 111 | var MY_ID = parseInt(Math.random() * 1e15, 10).toString(16), 112 | PEER_SERVER = { 113 | host: 'peerjs-server-tmullen.mybluemix.net', 114 | port: 443, 115 | path: '/server', 116 | secure: true 117 | }, 118 | peer = new Peer(MY_ID, PEER_SERVER), // Create the peer object 119 | 120 | // Heartbeat to prevent disconnection from signalling server 121 | makePeerHeartbeater = function makePeerHeartbeater (peer) { 122 | var timeoutId = 0 123 | 124 | function heartbeat () { 125 | timeoutId = setTimeout(heartbeat, 20000) 126 | if (peer.socket._wsOpen()) { 127 | peer.socket.send({ 128 | type: 'HEARTBEAT' 129 | }) 130 | } 131 | } 132 | heartbeat() 133 | } 134 | makePeerHeartbeater(peer) 135 | 136 | var OTHER_ID = getParameterByName('site', document.location) // Get the server's id from url 137 | if (!OTHER_ID) { // If no siteId, just go to main HyperHost 138 | window.location = window.location.href.replace('client.html', 'index.html') 139 | } 140 | 141 | peer.on('error', function (err) { 142 | console.error(err) 143 | if (!dataLoaded) { 144 | h1Element.innerHTML = 'Host could not be reached.' 145 | aElement.style.display = 'inherit' 146 | } 147 | }) 148 | 149 | conn = peer.connect(OTHER_ID, { 150 | reliable: true 151 | }) 152 | conn.on('data', function (data) { 153 | if (data.type === 'view') { 154 | console.log('Data received, rendering page...') 155 | var newView = data.content.view, 156 | path = data.path 157 | dataLoaded = true 158 | viewframeElement.style.display = 'inherit' 159 | dropzoneElement.style.display = 'none' 160 | 161 | if (newView) { 162 | viewframeElement.srcdoc = newView.body.replace('', '') 163 | 164 | history.pushState(path, path) 165 | console.log('Navigated to ' + path) 166 | return 167 | } else { 168 | console.error('HyperHost path "' + path + '" does not exist!') 169 | if (path === 'index.html') { 170 | window.location.hash = '' 171 | h1Element.innerHTML = 'HyperHost' 172 | h2Element.innerHTML = 'Drop Website Root Folder Here to Instantly Host' 173 | viewframeElement.style.display = 'none' 174 | dropzoneElement.style.display = 'inherit' 175 | } 176 | } 177 | } else if (data.type === 'response') { 178 | sendHyperMessage({ 179 | type: 'response', 180 | response: data.content, 181 | id: data.id 182 | }) 183 | } 184 | }) 185 | conn.on('open', function () { 186 | HYPERHOST_NAVIGATE('index.html') 187 | }) 188 | conn.on('close', function () { 189 | console.log('Connection to host closed.') 190 | if (!dataLoaded) { 191 | h1Element.innerHTML = 'Connection closed by host.' 192 | aElement.style.display = 'inherit' 193 | } 194 | }) 195 | } 196 | 197 | window.addEventListener('popstate', function (event) { 198 | HYPERHOST_NAVIGATE(event.state, true) 199 | }) 200 | window.addEventListener('hypermessage', handleHyperMessage) 201 | document.addEventListener('DOMContentLoaded', initialize) 202 | }(Peer)) 203 | -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/js/skel.min.js: -------------------------------------------------------------------------------- 1 | /* skel.js v3.0.1 | (c) skel.io | MIT licensed */ 2 | var skel=function(){"use strict";var t={breakpointIds:null,events:{},isInit:!1,obj:{attachments:{},breakpoints:{},head:null,states:{}},sd:"/",state:null,stateHandlers:{},stateId:"",vars:{},DOMReady:null,indexOf:null,isArray:null,iterate:null,matchesMedia:null,extend:function(e,n){t.iterate(n,function(i){t.isArray(n[i])?(t.isArray(e[i])||(e[i]=[]),t.extend(e[i],n[i])):"object"==typeof n[i]?("object"!=typeof e[i]&&(e[i]={}),t.extend(e[i],n[i])):e[i]=n[i]})},newStyle:function(t){var e=document.createElement("style");return e.type="text/css",e.innerHTML=t,e},_canUse:null,canUse:function(e){t._canUse||(t._canUse=document.createElement("div"));var n=t._canUse.style,i=e.charAt(0).toUpperCase()+e.slice(1);return e in n||"Moz"+i in n||"Webkit"+i in n||"O"+i in n||"ms"+i in n},on:function(e,n){var i=e.split(/[\s]+/);return t.iterate(i,function(e){var a=i[e];if(t.isInit){if("init"==a)return void n();if("change"==a)n();else{var r=a.charAt(0);if("+"==r||"!"==r){var o=a.substring(1);if(o in t.obj.breakpoints)if("+"==r&&t.obj.breakpoints[o].active)n();else if("!"==r&&!t.obj.breakpoints[o].active)return void n()}}}t.events[a]||(t.events[a]=[]),t.events[a].push(n)}),t},trigger:function(e){return t.events[e]&&0!=t.events[e].length?(t.iterate(t.events[e],function(n){t.events[e][n]()}),t):void 0},breakpoint:function(e){return t.obj.breakpoints[e]},breakpoints:function(e){function n(t,e){this.name=this.id=t,this.media=e,this.active=!1,this.wasActive=!1}return n.prototype.matches=function(){return t.matchesMedia(this.media)},n.prototype.sync=function(){this.wasActive=this.active,this.active=this.matches()},t.iterate(e,function(i){t.obj.breakpoints[i]=new n(i,e[i])}),window.setTimeout(function(){t.poll()},0),t},addStateHandler:function(e,n){t.stateHandlers[e]=n},callStateHandler:function(e){var n=t.stateHandlers[e]();t.iterate(n,function(e){t.state.attachments.push(n[e])})},changeState:function(e){t.iterate(t.obj.breakpoints,function(e){t.obj.breakpoints[e].sync()}),t.vars.lastStateId=t.stateId,t.stateId=e,t.breakpointIds=t.stateId===t.sd?[]:t.stateId.substring(1).split(t.sd),t.obj.states[t.stateId]?t.state=t.obj.states[t.stateId]:(t.obj.states[t.stateId]={attachments:[]},t.state=t.obj.states[t.stateId],t.iterate(t.stateHandlers,t.callStateHandler)),t.detachAll(t.state.attachments),t.attachAll(t.state.attachments),t.vars.stateId=t.stateId,t.vars.state=t.state,t.trigger("change"),t.iterate(t.obj.breakpoints,function(e){t.obj.breakpoints[e].active?t.obj.breakpoints[e].wasActive||t.trigger("+"+e):t.obj.breakpoints[e].wasActive&&t.trigger("-"+e)})},generateStateConfig:function(e,n){var i={};return t.extend(i,e),t.iterate(t.breakpointIds,function(e){t.extend(i,n[t.breakpointIds[e]])}),i},getStateId:function(){var e="";return t.iterate(t.obj.breakpoints,function(n){var i=t.obj.breakpoints[n];i.matches()&&(e+=t.sd+i.id)}),e},poll:function(){var e="";e=t.getStateId(),""===e&&(e=t.sd),e!==t.stateId&&t.changeState(e)},_attach:null,attach:function(e){var n=t.obj.head,i=e.element;return i.parentNode&&i.parentNode.tagName?!1:(t._attach||(t._attach=n.firstChild),n.insertBefore(i,t._attach.nextSibling),e.permanent&&(t._attach=i),!0)},attachAll:function(e){var n=[];t.iterate(e,function(t){n[e[t].priority]||(n[e[t].priority]=[]),n[e[t].priority].push(e[t])}),n.reverse(),t.iterate(n,function(e){t.iterate(n[e],function(i){t.attach(n[e][i])})})},detach:function(t){var e=t.element;return t.permanent||!e.parentNode||e.parentNode&&!e.parentNode.tagName?!1:(e.parentNode.removeChild(e),!0)},detachAll:function(e){var n={};t.iterate(e,function(t){n[e[t].id]=!0}),t.iterate(t.obj.attachments,function(e){e in n||t.detach(t.obj.attachments[e])})},attachment:function(e){return e in t.obj.attachments?t.obj.attachments[e]:null},newAttachment:function(e,n,i,a){return t.obj.attachments[e]={id:e,element:n,priority:i,permanent:a}},init:function(){t.initMethods(),t.initVars(),t.initEvents(),t.obj.head=document.getElementsByTagName("head")[0],t.isInit=!0,t.trigger("init")},initEvents:function(){t.on("resize",function(){t.poll()}),t.on("orientationChange",function(){t.poll()}),t.DOMReady(function(){t.trigger("ready")}),window.onload&&t.on("load",window.onload),window.onload=function(){t.trigger("load")},window.onresize&&t.on("resize",window.onresize),window.onresize=function(){t.trigger("resize")},window.onorientationchange&&t.on("orientationChange",window.onorientationchange),window.onorientationchange=function(){t.trigger("orientationChange")}},initMethods:function(){document.addEventListener?!function(e,n){t.DOMReady=n()}("domready",function(){function t(t){for(r=1;t=n.shift();)t()}var e,n=[],i=document,a="DOMContentLoaded",r=/^loaded|^c/.test(i.readyState);return i.addEventListener(a,e=function(){i.removeEventListener(a,e),t()}),function(t){r?t():n.push(t)}}):!function(e,n){t.DOMReady=n()}("domready",function(t){function e(t){for(h=1;t=i.shift();)t()}var n,i=[],a=!1,r=document,o=r.documentElement,s=o.doScroll,c="DOMContentLoaded",d="addEventListener",u="onreadystatechange",l="readyState",f=s?/^loaded|^c/:/^loaded|c/,h=f.test(r[l]);return r[d]&&r[d](c,n=function(){r.removeEventListener(c,n,a),e()},a),s&&r.attachEvent(u,n=function(){/^c/.test(r[l])&&(r.detachEvent(u,n),e())}),t=s?function(e){self!=top?h?e():i.push(e):function(){try{o.doScroll("left")}catch(n){return setTimeout(function(){t(e)},50)}e()}()}:function(t){h?t():i.push(t)}}),Array.prototype.indexOf?t.indexOf=function(t,e){return t.indexOf(e)}:t.indexOf=function(t,e){if("string"==typeof t)return t.indexOf(e);var n,i,a=e?e:0;if(!this)throw new TypeError;if(i=this.length,0===i||a>=i)return-1;for(0>a&&(a=i-Math.abs(a)),n=a;i>n;n++)if(this[n]===t)return n;return-1},Array.isArray?t.isArray=function(t){return Array.isArray(t)}:t.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},Object.keys?t.iterate=function(t,e){if(!t)return[];var n,i=Object.keys(t);for(n=0;i[n]&&e(i[n],t[i[n]])!==!1;n++);}:t.iterate=function(t,e){if(!t)return[];var n;for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])===!1)break},window.matchMedia?t.matchesMedia=function(t){return""==t?!0:window.matchMedia(t).matches}:window.styleMedia||window.media?t.matchesMedia=function(t){if(""==t)return!0;var e=window.styleMedia||window.media;return e.matchMedium(t||"all")}:window.getComputedStyle?t.matchesMedia=function(t){if(""==t)return!0;var e=document.createElement("style"),n=document.getElementsByTagName("script")[0],i=null;e.type="text/css",e.id="matchmediajs-test",n.parentNode.insertBefore(e,n),i="getComputedStyle"in window&&window.getComputedStyle(e,null)||e.currentStyle;var a="@media "+t+"{ #matchmediajs-test { width: 1px; } }";return e.styleSheet?e.styleSheet.cssText=a:e.textContent=a,"1px"===i.width}:t.matchesMedia=function(t){if(""==t)return!0;var e,n,i,a,r={"min-width":null,"max-width":null},o=!1;for(i=t.split(/\s+and\s+/),e=0;er["max-width"]||null!==r["min-height"]&&cr["max-height"]?!1:!0},navigator.userAgent.match(/MSIE ([0-9]+)/)&&RegExp.$1<9&&(t.newStyle=function(t){var e=document.createElement("span");return e.innerHTML=' ",e})},initVars:function(){var e,n,i,a=navigator.userAgent;e="other",n=0,i=[["firefox",/Firefox\/([0-9\.]+)/],["bb",/BlackBerry.+Version\/([0-9\.]+)/],["bb",/BB[0-9]+.+Version\/([0-9\.]+)/],["opera",/OPR\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)/],["edge",/Edge\/([0-9\.]+)/],["safari",/Version\/([0-9\.]+).+Safari/],["chrome",/Chrome\/([0-9\.]+)/],["ie",/MSIE ([0-9]+)/],["ie",/Trident\/.+rv:([0-9]+)/]],t.iterate(i,function(t,i){return a.match(i[1])?(e=i[0],n=parseFloat(RegExp.$1),!1):void 0}),t.vars.browser=e,t.vars.browserVersion=n,e="other",n=0,i=[["ios",/([0-9_]+) like Mac OS X/,function(t){return t.replace("_",".").replace("_","")}],["ios",/CPU like Mac OS X/,function(t){return 0}],["wp",/Windows Phone ([0-9\.]+)/,null],["android",/Android ([0-9\.]+)/,null],["mac",/Macintosh.+Mac OS X ([0-9_]+)/,function(t){return t.replace("_",".").replace("_","")}],["windows",/Windows NT ([0-9\.]+)/,null],["bb",/BlackBerry.+Version\/([0-9\.]+)/,null],["bb",/BB[0-9]+.+Version\/([0-9\.]+)/,null]],t.iterate(i,function(t,i){return a.match(i[1])?(e=i[0],n=parseFloat(i[2]?i[2](RegExp.$1):RegExp.$1),!1):void 0}),t.vars.os=e,t.vars.osVersion=n,t.vars.IEVersion="ie"==t.vars.browser?t.vars.browserVersion:99,t.vars.touch="wp"==t.vars.os?navigator.msMaxTouchPoints>0:!!("ontouchstart"in window),t.vars.mobile="wp"==t.vars.os||"android"==t.vars.os||"ios"==t.vars.os||"bb"==t.vars.os}};return t.init(),t}();!function(t,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():t.skel=e()}(this,function(){return skel}); 3 | -------------------------------------------------------------------------------- /examples/html5up-phantom-example/index.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Phantom by HTML5 UP 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 39 | 40 | 41 | 51 | 52 | 53 |
54 |
55 |
56 |

This is Phantom, a free, fully responsive site
57 | template designed by HTML5 UP.

58 |

Etiam quis viverra lorem, in semper lorem. Sed nisl arcu euismod sit amet nisi euismod sed cursus arcu elementum ipsum arcu vivamus quis venenatis orci lorem ipsum et magna feugiat veroeros aliquam. Lorem ipsum dolor sit amet nullam dolore.

59 |
60 |
61 | 72 | 83 | 94 | 105 | 116 | 127 | 138 | 149 | 160 | 171 | 182 | 193 |
194 |
195 |
196 | 197 | 198 |
199 |
200 |
201 |

Get in touch

202 |
203 |
204 | 205 |
206 |
207 | 208 |
209 |
210 | 211 |
212 |
    213 |
  • 214 |
215 |
216 |
217 |
218 |

Follow

219 | 229 |
230 | 233 |
234 |
235 | 236 |
237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/js/util.js: -------------------------------------------------------------------------------- 1 | (function ($) { 2 | /** 3 | * Generate an indented list of links from a nav. Meant for use with panel(). 4 | * @return {jQuery} jQuery object. 5 | */ 6 | $.fn.navList = function () { 7 | var $this = $(this) 8 | $a = $this.find('a'), 9 | b = [] 10 | 11 | $a.each(function () { 12 | var $this = $(this), 13 | indent = Math.max(0, $this.parents('li').length - 1), 14 | href = $this.attr('href'), 15 | target = $this.attr('target') 16 | 17 | b.push( 18 | '' + 23 | '' + 24 | $this.text() + 25 | '' 26 | ) 27 | }) 28 | 29 | return b.join('') 30 | } 31 | 32 | /** 33 | * Panel-ify an element. 34 | * @param {object} userConfig User config. 35 | * @return {jQuery} jQuery object. 36 | */ 37 | $.fn.panel = function (userConfig) { 38 | // No elements? 39 | if (this.length == 0) { 40 | return $this 41 | } 42 | 43 | // Multiple elements? 44 | if (this.length > 1) { 45 | for (var i = 0; i < this.length; i++) { 46 | $(this[i]).panel(userConfig) 47 | } 48 | 49 | return $this 50 | } 51 | 52 | // Vars. 53 | var $this = $(this), 54 | $body = $('body'), 55 | $window = $(window), 56 | id = $this.attr('id'), 57 | config 58 | 59 | // Config. 60 | config = $.extend({ 61 | 62 | // Delay. 63 | delay: 0, 64 | 65 | // Hide panel on link click. 66 | hideOnClick: false, 67 | 68 | // Hide panel on escape keypress. 69 | hideOnEscape: false, 70 | 71 | // Hide panel on swipe. 72 | hideOnSwipe: false, 73 | 74 | // Reset scroll position on hide. 75 | resetScroll: false, 76 | 77 | // Reset forms on hide. 78 | resetForms: false, 79 | 80 | // Side of viewport the panel will appear. 81 | side: null, 82 | 83 | // Target element for "class". 84 | target: $this, 85 | 86 | // Class to toggle. 87 | visibleClass: 'visible' 88 | 89 | }, userConfig) 90 | 91 | // Expand "target" if it's not a jQuery object already. 92 | if (typeof config.target !== 'jQuery') { 93 | config.target = $(config.target) 94 | } 95 | 96 | // Panel. 97 | 98 | // Methods. 99 | $this._hide = function (event) { 100 | // Already hidden? Bail. 101 | if (!config.target.hasClass(config.visibleClass)) { 102 | return 103 | } 104 | 105 | // If an event was provided, cancel it. 106 | if (event) { 107 | event.preventDefault() 108 | event.stopPropagation() 109 | } 110 | 111 | // Hide. 112 | config.target.removeClass(config.visibleClass) 113 | 114 | // Post-hide stuff. 115 | window.setTimeout(function () { 116 | // Reset scroll position. 117 | if (config.resetScroll) { $this.scrollTop(0) } 118 | 119 | // Reset forms. 120 | if (config.resetForms) { 121 | $this.find('form').each(function () { 122 | this.reset() 123 | }) 124 | } 125 | }, config.delay) 126 | } 127 | 128 | // Vendor fixes. 129 | $this 130 | .css('-ms-overflow-style', '-ms-autohiding-scrollbar') 131 | .css('-webkit-overflow-scrolling', 'touch') 132 | 133 | // Hide on click. 134 | if (config.hideOnClick) { 135 | $this.find('a') 136 | .css('-webkit-tap-highlight-color', 'rgba(0,0,0,0)') 137 | 138 | $this 139 | .on('click', 'a', function (event) { 140 | var $a = $(this), 141 | href = $a.attr('href'), 142 | target = $a.attr('target') 143 | 144 | if (!href || href == '#' || href == '' || href == '#' + id) { 145 | return 146 | } 147 | 148 | // Cancel original event. 149 | event.preventDefault() 150 | event.stopPropagation() 151 | 152 | // Hide panel. 153 | $this._hide() 154 | 155 | // Redirect to href. 156 | window.setTimeout(function () { 157 | if (target == '_blank') { 158 | window.open(href) 159 | } else { 160 | window.location.href = href 161 | } 162 | }, config.delay + 10) 163 | }) 164 | } 165 | 166 | // Event: Touch stuff. 167 | $this.on('touchstart', function (event) { 168 | $this.touchPosX = event.originalEvent.touches[0].pageX 169 | $this.touchPosY = event.originalEvent.touches[0].pageY 170 | }) 171 | 172 | $this.on('touchmove', function (event) { 173 | if ($this.touchPosX === null 174 | || $this.touchPosY === null) { 175 | return 176 | } 177 | 178 | var diffX = $this.touchPosX - event.originalEvent.touches[0].pageX, 179 | diffY = $this.touchPosY - event.originalEvent.touches[0].pageY, 180 | th = $this.outerHeight(), 181 | ts = ($this.get(0).scrollHeight - $this.scrollTop()) 182 | 183 | // Hide on swipe? 184 | if (config.hideOnSwipe) { 185 | var result = false, 186 | boundary = 20, 187 | delta = 50 188 | 189 | switch (config.side) { 190 | 191 | case 'left': 192 | result = (diffY < boundary && diffY > (-1 * boundary)) && (diffX > delta) 193 | break 194 | 195 | case 'right': 196 | result = (diffY < boundary && diffY > (-1 * boundary)) && (diffX < (-1 * delta)) 197 | break 198 | 199 | case 'top': 200 | result = (diffX < boundary && diffX > (-1 * boundary)) && (diffY > delta) 201 | break 202 | 203 | case 'bottom': 204 | result = (diffX < boundary && diffX > (-1 * boundary)) && (diffY < (-1 * delta)) 205 | break 206 | 207 | default: 208 | break 209 | 210 | } 211 | 212 | if (result) { 213 | $this.touchPosX = null 214 | $this.touchPosY = null 215 | $this._hide() 216 | 217 | return false 218 | } 219 | } 220 | 221 | // Prevent vertical scrolling past the top or bottom. 222 | if (($this.scrollTop() < 0 && diffY < 0) 223 | || (ts > (th - 2) && ts < (th + 2) && diffY > 0)) { 224 | event.preventDefault() 225 | event.stopPropagation() 226 | } 227 | }) 228 | 229 | // Event: Prevent certain events inside the panel from bubbling. 230 | $this.on('click touchend touchstart touchmove', function (event) { 231 | event.stopPropagation() 232 | }) 233 | 234 | // Event: Hide panel if a child anchor tag pointing to its ID is clicked. 235 | $this.on('click', 'a[href="#' + id + '"]', function (event) { 236 | event.preventDefault() 237 | event.stopPropagation() 238 | 239 | config.target.removeClass(config.visibleClass) 240 | }) 241 | 242 | // Body. 243 | 244 | // Event: Hide panel on body click/tap. 245 | $body.on('click touchend', function (event) { 246 | $this._hide(event) 247 | }) 248 | 249 | // Event: Toggle. 250 | $body.on('click', 'a[href="#' + id + '"]', function (event) { 251 | event.preventDefault() 252 | event.stopPropagation() 253 | 254 | config.target.toggleClass(config.visibleClass) 255 | }) 256 | 257 | // Window. 258 | 259 | // Event: Hide on ESC. 260 | if (config.hideOnEscape) { 261 | $window.on('keydown', function (event) { 262 | if (event.keyCode == 27) { 263 | $this._hide(event) 264 | } 265 | }) 266 | } 267 | 268 | return $this 269 | } 270 | 271 | /** 272 | * Apply "placeholder" attribute polyfill to one or more forms. 273 | * @return {jQuery} jQuery object. 274 | */ 275 | $.fn.placeholder = function () { 276 | // Browser natively supports placeholders? Bail. 277 | if (typeof (document.createElement('input')).placeholder !== 'undefined') { 278 | return $(this) 279 | } 280 | 281 | // No elements? 282 | if (this.length == 0) { 283 | return $this 284 | } 285 | 286 | // Multiple elements? 287 | if (this.length > 1) { 288 | for (var i = 0; i < this.length; i++) { 289 | $(this[i]).placeholder() 290 | } 291 | 292 | return $this 293 | } 294 | 295 | // Vars. 296 | var $this = $(this) 297 | 298 | // Text, TextArea. 299 | $this.find('input[type=text],textarea') 300 | .each(function () { 301 | var i = $(this) 302 | 303 | if (i.val() == '' 304 | || i.val() == i.attr('placeholder')) { 305 | i 306 | .addClass('polyfill-placeholder') 307 | .val(i.attr('placeholder')) 308 | } 309 | }) 310 | .on('blur', function () { 311 | var i = $(this) 312 | 313 | if (i.attr('name').match(/-polyfill-field$/)) { return } 314 | 315 | if (i.val() == '') { 316 | i 317 | .addClass('polyfill-placeholder') 318 | .val(i.attr('placeholder')) 319 | } 320 | }) 321 | .on('focus', function () { 322 | var i = $(this) 323 | 324 | if (i.attr('name').match(/-polyfill-field$/)) { return } 325 | 326 | if (i.val() == i.attr('placeholder')) { 327 | i 328 | .removeClass('polyfill-placeholder') 329 | .val('') 330 | } 331 | }) 332 | 333 | // Password. 334 | $this.find('input[type=password]') 335 | .each(function () { 336 | var i = $(this) 337 | var x = $( 338 | $('
') 339 | .append(i.clone()) 340 | .remove() 341 | .html() 342 | .replace(/type="password"/i, 'type="text"') 343 | .replace(/type=password/i, 'type=text') 344 | ) 345 | 346 | if (i.attr('id') != '') { 347 | x.attr('id', i.attr('id') + '-polyfill-field') 348 | } 349 | 350 | if (i.attr('name') != '') { x.attr('name', i.attr('name') + '-polyfill-field') } 351 | 352 | x.addClass('polyfill-placeholder') 353 | .val(x.attr('placeholder')).insertAfter(i) 354 | 355 | if (i.val() == '') { i.hide() } else { x.hide() } 356 | 357 | i 358 | .on('blur', function (event) { 359 | event.preventDefault() 360 | 361 | var x = i.parent().find('input[name=' + i.attr('name') + '-polyfill-field]') 362 | 363 | if (i.val() == '') { 364 | i.hide() 365 | x.show() 366 | } 367 | }) 368 | 369 | x 370 | .on('focus', function (event) { 371 | event.preventDefault() 372 | 373 | var i = x.parent().find('input[name=' + x.attr('name').replace('-polyfill-field', '') + ']') 374 | 375 | x.hide() 376 | 377 | i 378 | .show() 379 | .focus() 380 | }) 381 | .on('keypress', function (event) { 382 | event.preventDefault() 383 | x.val('') 384 | }) 385 | }) 386 | 387 | // Events. 388 | $this 389 | .on('submit', function () { 390 | $this.find('input[type=text],input[type=password],textarea') 391 | .each(function (event) { 392 | var i = $(this) 393 | 394 | if (i.attr('name').match(/-polyfill-field$/)) { 395 | i.attr('name', '') 396 | } 397 | 398 | if (i.val() == i.attr('placeholder')) { 399 | i.removeClass('polyfill-placeholder') 400 | i.val('') 401 | } 402 | }) 403 | }) 404 | .on('reset', function (event) { 405 | event.preventDefault() 406 | 407 | $this.find('select') 408 | .val($('option:first').val()) 409 | 410 | $this.find('input,textarea') 411 | .each(function () { 412 | var i = $(this), 413 | x 414 | 415 | i.removeClass('polyfill-placeholder') 416 | 417 | switch (this.type) { 418 | 419 | case 'submit': 420 | case 'reset': 421 | break 422 | 423 | case 'password': 424 | i.val(i.attr('defaultValue')) 425 | 426 | x = i.parent().find('input[name=' + i.attr('name') + '-polyfill-field]') 427 | 428 | if (i.val() == '') { 429 | i.hide() 430 | x.show() 431 | } else { 432 | i.show() 433 | x.hide() 434 | } 435 | 436 | break 437 | 438 | case 'checkbox': 439 | case 'radio': 440 | i.attr('checked', i.attr('defaultValue')) 441 | break 442 | 443 | case 'text': 444 | case 'textarea': 445 | i.val(i.attr('defaultValue')) 446 | 447 | if (i.val() == '') { 448 | i.addClass('polyfill-placeholder') 449 | i.val(i.attr('placeholder')) 450 | } 451 | 452 | break 453 | 454 | default: 455 | i.val(i.attr('defaultValue')) 456 | break 457 | 458 | } 459 | }) 460 | }) 461 | 462 | return $this 463 | } 464 | 465 | /** 466 | * Moves elements to/from the first positions of their respective parents. 467 | * @param {jQuery} $elements Elements (or selector) to move. 468 | * @param {bool} condition If true, moves elements to the top. Otherwise, moves elements back to their original locations. 469 | */ 470 | $.prioritize = function ($elements, condition) { 471 | var key = '__prioritize' 472 | 473 | // Expand $elements if it's not already a jQuery object. 474 | if (typeof $elements !== 'jQuery') { 475 | $elements = $($elements) 476 | } 477 | 478 | // Step through elements. 479 | $elements.each(function () { 480 | var $e = $(this), $p, 481 | $parent = $e.parent() 482 | 483 | // No parent? Bail. 484 | if ($parent.length == 0) { return } 485 | 486 | // Not moved? Move it. 487 | if (!$e.data(key)) { 488 | // Condition is false? Bail. 489 | if (!condition) { 490 | return 491 | } 492 | 493 | // Get placeholder (which will serve as our point of reference for when this element needs to move back). 494 | $p = $e.prev() 495 | 496 | // Couldn't find anything? Means this element's already at the top, so bail. 497 | if ($p.length == 0) { 498 | return 499 | } 500 | 501 | // Move element to top of parent. 502 | $e.prependTo($parent) 503 | 504 | // Mark element as moved. 505 | $e.data(key, $p) 506 | } 507 | 508 | // Moved already? 509 | else { 510 | // Condition is true? Bail. 511 | if (condition) { 512 | return 513 | } 514 | 515 | $p = $e.data(key) 516 | 517 | // Move element back to its original location (using our placeholder). 518 | $e.insertAfter($p) 519 | 520 | // Unmark element as moved. 521 | $e.removeData(key) 522 | } 523 | }) 524 | } 525 | })(jQuery) 526 | -------------------------------------------------------------------------------- /examples/html5up-phantom-example/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Creative Commons Attribution 3.0 Unported 2 | http://creativecommons.org/licenses/by/3.0/ 3 | 4 | License 5 | 6 | THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. 7 | 8 | BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. 9 | 10 | 1. Definitions 11 | 12 | 1. "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License. 13 | 2. "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined above) for the purposes of this License. 14 | 3. "Distribute" means to make available to the public the original and copies of the Work or Adaptation, as appropriate, through sale or other transfer of ownership. 15 | 4. "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License. 16 | 5. "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast. 17 | 6. "Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work. 18 | 7. "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation. 19 | 8. "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images. 20 | 9. "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium. 21 | 22 | 2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws. 23 | 24 | 3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below: 25 | 26 | 1. to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections; 27 | 2. to create and Reproduce Adaptations provided that any such Adaptation, including any translation in any medium, takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original Work. For example, a translation could be marked "The original work was translated from English to Spanish," or a modification could indicate "The original work has been modified."; 28 | 3. to Distribute and Publicly Perform the Work including as incorporated in Collections; and, 29 | 4. to Distribute and Publicly Perform Adaptations. 30 | 5. 31 | 32 | For the avoidance of doubt: 33 | 1. Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; 34 | 2. Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor waives the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; and, 35 | 3. Voluntary License Schemes. The Licensor waives the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License. 36 | 37 | The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved. 38 | 39 | 4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions: 40 | 41 | 1. You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(b), as requested. If You create an Adaptation, upon notice from any Licensor You must, to the extent practicable, remove from the Adaptation any credit as required by Section 4(b), as requested. 42 | 2. If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and (iv) , consistent with Section 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). The credit required by this Section 4 (b) may be implemented in any reasonable manner; provided, however, that in the case of a Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties. 43 | 3. Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. Licensor agrees that in those jurisdictions (e.g. Japan), in which any exercise of the right granted in Section 3(b) of this License (the right to make Adaptations) would be deemed to be a distortion, mutilation, modification or other derogatory action prejudicial to the Original Author's honor and reputation, the Licensor will waive or not assert, as appropriate, this Section, to the fullest extent permitted by the applicable national law, to enable You to reasonably exercise Your right under Section 3(b) of this License (right to make Adaptations) but not otherwise. 44 | 45 | 5. Representations, Warranties and Disclaimer 46 | 47 | UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. 48 | 49 | 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 50 | 51 | 7. Termination 52 | 53 | 1. This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Adaptations or Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License. 54 | 2. Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above. 55 | 56 | 8. Miscellaneous 57 | 58 | 1. Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License. 59 | 2. Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License. 60 | 3. If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. 61 | 4. No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent. 62 | 5. This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You. 63 | 6. The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law. 64 | -------------------------------------------------------------------------------- /examples/html5up-phantom-example/assets/sass/libs/_skel.scss: -------------------------------------------------------------------------------- 1 | // skel.scss v3.0.1 | (c) skel.io | MIT licensed */ 2 | 3 | // Vars. 4 | 5 | /// Breakpoints. 6 | /// @var {list} 7 | $breakpoints: () !global; 8 | 9 | /// Vendor prefixes. 10 | /// @var {list} 11 | $vendor-prefixes: ( 12 | '-moz-', 13 | '-webkit-', 14 | '-ms-', 15 | '' 16 | ); 17 | 18 | /// Properties that should be vendorized. 19 | /// @var {list} 20 | $vendor-properties: ( 21 | 'align-content', 22 | 'align-items', 23 | 'align-self', 24 | 'animation', 25 | 'animation-delay', 26 | 'animation-direction', 27 | 'animation-duration', 28 | 'animation-fill-mode', 29 | 'animation-iteration-count', 30 | 'animation-name', 31 | 'animation-play-state', 32 | 'animation-timing-function', 33 | 'appearance', 34 | 'backface-visibility', 35 | 'box-sizing', 36 | 'filter', 37 | 'flex', 38 | 'flex-basis', 39 | 'flex-direction', 40 | 'flex-flow', 41 | 'flex-grow', 42 | 'flex-shrink', 43 | 'flex-wrap', 44 | 'justify-content', 45 | 'order', 46 | 'perspective', 47 | 'pointer-events', 48 | 'transform', 49 | 'transform-origin', 50 | 'transform-style', 51 | 'transition', 52 | 'transition-delay', 53 | 'transition-duration', 54 | 'transition-property', 55 | 'transition-timing-function', 56 | 'user-select' 57 | ); 58 | 59 | /// Values that should be vendorized. 60 | /// @var {list} 61 | $vendor-values: ( 62 | 'filter', 63 | 'flex', 64 | 'linear-gradient', 65 | 'radial-gradient', 66 | 'transform' 67 | ); 68 | 69 | // Functions. 70 | 71 | /// Removes a specific item from a list. 72 | /// @author Hugo Giraudel 73 | /// @param {list} $list List. 74 | /// @param {integer} $index Index. 75 | /// @return {list} Updated list. 76 | @function remove-nth($list, $index) { 77 | 78 | $result: null; 79 | 80 | @if type-of($index) != number { 81 | @warn "$index: #{quote($index)} is not a number for `remove-nth`."; 82 | } 83 | @else if $index == 0 { 84 | @warn "List index 0 must be a non-zero integer for `remove-nth`."; 85 | } 86 | @else if abs($index) > length($list) { 87 | @warn "List index is #{$index} but list is only #{length($list)} item long for `remove-nth`."; 88 | } 89 | @else { 90 | 91 | $result: (); 92 | $index: if($index < 0, length($list) + $index + 1, $index); 93 | 94 | @for $i from 1 through length($list) { 95 | 96 | @if $i != $index { 97 | $result: append($result, nth($list, $i)); 98 | } 99 | 100 | } 101 | 102 | } 103 | 104 | @return $result; 105 | 106 | } 107 | 108 | /// Replaces a substring within another string. 109 | /// @author Hugo Giraudel 110 | /// @param {string} $string String. 111 | /// @param {string} $search Substring. 112 | /// @param {string} $replace Replacement. 113 | /// @return {string} Updated string. 114 | @function str-replace($string, $search, $replace: '') { 115 | 116 | $index: str-index($string, $search); 117 | 118 | @if $index { 119 | @return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace); 120 | } 121 | 122 | @return $string; 123 | 124 | } 125 | 126 | /// Replaces a substring within each string in a list. 127 | /// @param {list} $strings List of strings. 128 | /// @param {string} $search Substring. 129 | /// @param {string} $replace Replacement. 130 | /// @return {list} Updated list of strings. 131 | @function str-replace-all($strings, $search, $replace: '') { 132 | 133 | @each $string in $strings { 134 | $strings: set-nth($strings, index($strings, $string), str-replace($string, $search, $replace)); 135 | } 136 | 137 | @return $strings; 138 | 139 | } 140 | 141 | /// Gets a value from a map. 142 | /// @author Hugo Giraudel 143 | /// @param {map} $map Map. 144 | /// @param {string} $keys Key(s). 145 | /// @return {string} Value. 146 | @function val($map, $keys...) { 147 | 148 | @if nth($keys, 1) == null { 149 | $keys: remove-nth($keys, 1); 150 | } 151 | 152 | @each $key in $keys { 153 | $map: map-get($map, $key); 154 | } 155 | 156 | @return $map; 157 | 158 | } 159 | 160 | // Mixins. 161 | 162 | /// Sets the global box model. 163 | /// @param {string} $model Model (default is content). 164 | @mixin boxModel($model: 'content') { 165 | 166 | $x: $model + '-box'; 167 | 168 | *, *:before, *:after { 169 | -moz-box-sizing: #{$x}; 170 | -webkit-box-sizing: #{$x}; 171 | box-sizing: #{$x}; 172 | } 173 | 174 | } 175 | 176 | /// Wraps @content in a @media block using a given breakpoint. 177 | /// @param {string} $breakpoint Breakpoint. 178 | /// @param {map} $queries Additional queries. 179 | @mixin breakpoint($breakpoint: null, $queries: null) { 180 | 181 | $query: 'screen'; 182 | 183 | // Breakpoint. 184 | @if $breakpoint and map-has-key($breakpoints, $breakpoint) { 185 | $query: $query + ' and ' + map-get($breakpoints, $breakpoint); 186 | } 187 | 188 | // Queries. 189 | @if $queries { 190 | @each $k, $v in $queries { 191 | $query: $query + ' and (' + $k + ':' + $v + ')'; 192 | } 193 | } 194 | 195 | @media #{$query} { 196 | @content; 197 | } 198 | 199 | } 200 | 201 | /// Wraps @content in a @media block targeting a specific orientation. 202 | /// @param {string} $orientation Orientation. 203 | @mixin orientation($orientation) { 204 | @media screen and (orientation: #{$orientation}) { 205 | @content; 206 | } 207 | } 208 | 209 | /// Utility mixin for containers. 210 | /// @param {mixed} $width Width. 211 | @mixin containers($width) { 212 | 213 | // Locked? 214 | $lock: false; 215 | 216 | @if length($width) == 2 { 217 | $width: nth($width, 1); 218 | $lock: true; 219 | } 220 | 221 | // Modifiers. 222 | .container.\31 25\25 { width: 100%; max-width: $width * 1.25; min-width: $width; } 223 | .container.\37 5\25 { width: $width * 0.75; } 224 | .container.\35 0\25 { width: $width * 0.5; } 225 | .container.\32 5\25 { width: $width * 0.25; } 226 | 227 | // Main class. 228 | .container { 229 | @if $lock { 230 | width: $width !important; 231 | } 232 | @else { 233 | width: $width; 234 | } 235 | } 236 | 237 | } 238 | 239 | /// Utility mixin for grid. 240 | /// @param {list} $gutters Column and row gutters (default is 40px). 241 | /// @param {string} $breakpointName Optional breakpoint name. 242 | @mixin grid($gutters: 40px, $breakpointName: null) { 243 | 244 | // Gutters. 245 | @include grid-gutters($gutters); 246 | @include grid-gutters($gutters, \32 00\25, 2); 247 | @include grid-gutters($gutters, \31 50\25, 1.5); 248 | @include grid-gutters($gutters, \35 0\25, 0.5); 249 | @include grid-gutters($gutters, \32 5\25, 0.25); 250 | 251 | // Cells. 252 | $x: ''; 253 | 254 | @if $breakpointName { 255 | $x: '\\28' + $breakpointName + '\\29'; 256 | } 257 | 258 | .\31 2u#{$x}, .\31 2u\24#{$x} { width: 100%; clear: none; margin-left: 0; } 259 | .\31 1u#{$x}, .\31 1u\24#{$x} { width: 91.6666666667%; clear: none; margin-left: 0; } 260 | .\31 0u#{$x}, .\31 0u\24#{$x} { width: 83.3333333333%; clear: none; margin-left: 0; } 261 | .\39 u#{$x}, .\39 u\24#{$x} { width: 75%; clear: none; margin-left: 0; } 262 | .\38 u#{$x}, .\38 u\24#{$x} { width: 66.6666666667%; clear: none; margin-left: 0; } 263 | .\37 u#{$x}, .\37 u\24#{$x} { width: 58.3333333333%; clear: none; margin-left: 0; } 264 | .\36 u#{$x}, .\36 u\24#{$x} { width: 50%; clear: none; margin-left: 0; } 265 | .\35 u#{$x}, .\35 u\24#{$x} { width: 41.6666666667%; clear: none; margin-left: 0; } 266 | .\34 u#{$x}, .\34 u\24#{$x} { width: 33.3333333333%; clear: none; margin-left: 0; } 267 | .\33 u#{$x}, .\33 u\24#{$x} { width: 25%; clear: none; margin-left: 0; } 268 | .\32 u#{$x}, .\32 u\24#{$x} { width: 16.6666666667%; clear: none; margin-left: 0; } 269 | .\31 u#{$x}, .\31 u\24#{$x} { width: 8.3333333333%; clear: none; margin-left: 0; } 270 | 271 | .\31 2u\24#{$x} + *, 272 | .\31 1u\24#{$x} + *, 273 | .\31 0u\24#{$x} + *, 274 | .\39 u\24#{$x} + *, 275 | .\38 u\24#{$x} + *, 276 | .\37 u\24#{$x} + *, 277 | .\36 u\24#{$x} + *, 278 | .\35 u\24#{$x} + *, 279 | .\34 u\24#{$x} + *, 280 | .\33 u\24#{$x} + *, 281 | .\32 u\24#{$x} + *, 282 | .\31 u\24#{$x} + * { 283 | clear: left; 284 | } 285 | 286 | .\-11u#{$x} { margin-left: 91.6666666667% } 287 | .\-10u#{$x} { margin-left: 83.3333333333% } 288 | .\-9u#{$x} { margin-left: 75% } 289 | .\-8u#{$x} { margin-left: 66.6666666667% } 290 | .\-7u#{$x} { margin-left: 58.3333333333% } 291 | .\-6u#{$x} { margin-left: 50% } 292 | .\-5u#{$x} { margin-left: 41.6666666667% } 293 | .\-4u#{$x} { margin-left: 33.3333333333% } 294 | .\-3u#{$x} { margin-left: 25% } 295 | .\-2u#{$x} { margin-left: 16.6666666667% } 296 | .\-1u#{$x} { margin-left: 8.3333333333% } 297 | 298 | } 299 | 300 | /// Utility mixin for grid. 301 | /// @param {list} $gutters Gutters. 302 | /// @param {string} $class Optional class name. 303 | /// @param {integer} $multiplier Multiplier (default is 1). 304 | @mixin grid-gutters($gutters, $class: null, $multiplier: 1) { 305 | 306 | // Expand gutters if it's not a list. 307 | @if length($gutters) == 1 { 308 | $gutters: ($gutters, 0); 309 | } 310 | 311 | // Get column and row gutter values. 312 | $c: nth($gutters, 1); 313 | $r: nth($gutters, 2); 314 | 315 | // Get class (if provided). 316 | $x: ''; 317 | 318 | @if $class { 319 | $x: '.' + $class; 320 | } 321 | 322 | // Default. 323 | .row#{$x} > * { padding: ($r * $multiplier) 0 0 ($c * $multiplier); } 324 | .row#{$x} { margin: ($r * $multiplier * -1) 0 -1px ($c * $multiplier * -1); } 325 | 326 | // Uniform. 327 | .row.uniform#{$x} > * { padding: ($c * $multiplier) 0 0 ($c * $multiplier); } 328 | .row.uniform#{$x} { margin: ($c * $multiplier * -1) 0 -1px ($c * $multiplier * -1); } 329 | 330 | } 331 | 332 | /// Wraps @content in vendorized keyframe blocks. 333 | /// @param {string} $name Name. 334 | @mixin keyframes($name) { 335 | 336 | @-moz-keyframes #{$name} { @content; } 337 | @-webkit-keyframes #{$name} { @content; } 338 | @-ms-keyframes #{$name} { @content; } 339 | @keyframes #{$name} { @content; } 340 | 341 | } 342 | 343 | /// 344 | /// Sets breakpoints. 345 | /// @param {map} $x Breakpoints. 346 | /// 347 | @mixin skel-breakpoints($x: ()) { 348 | $breakpoints: $x !global; 349 | } 350 | 351 | /// 352 | /// Initializes layout module. 353 | /// @param {map} config Config. 354 | /// 355 | @mixin skel-layout($config: ()) { 356 | 357 | // Config. 358 | $configPerBreakpoint: (); 359 | 360 | $z: map-get($config, 'breakpoints'); 361 | 362 | @if $z { 363 | $configPerBreakpoint: $z; 364 | } 365 | 366 | // Reset. 367 | $x: map-get($config, 'reset'); 368 | 369 | @if $x { 370 | 371 | /* Reset */ 372 | 373 | @include reset($x); 374 | 375 | } 376 | 377 | // Box model. 378 | $x: map-get($config, 'boxModel'); 379 | 380 | @if $x { 381 | 382 | /* Box Model */ 383 | 384 | @include boxModel($x); 385 | 386 | } 387 | 388 | // Containers. 389 | $containers: map-get($config, 'containers'); 390 | 391 | @if $containers { 392 | 393 | /* Containers */ 394 | 395 | .container { 396 | margin-left: auto; 397 | margin-right: auto; 398 | } 399 | 400 | // Use default is $containers is just "true". 401 | @if $containers == true { 402 | $containers: 960px; 403 | } 404 | 405 | // Apply base. 406 | @include containers($containers); 407 | 408 | // Apply per-breakpoint. 409 | @each $name in map-keys($breakpoints) { 410 | 411 | // Get/use breakpoint setting if it exists. 412 | $x: map-get($configPerBreakpoint, $name); 413 | 414 | // Per-breakpoint config exists? 415 | @if $x { 416 | $y: map-get($x, 'containers'); 417 | 418 | // Setting exists? Use it. 419 | @if $y { 420 | $containers: $y; 421 | } 422 | 423 | } 424 | 425 | // Create @media block. 426 | @media screen and #{map-get($breakpoints, $name)} { 427 | @include containers($containers); 428 | } 429 | 430 | } 431 | 432 | } 433 | 434 | // Grid. 435 | $grid: map-get($config, 'grid'); 436 | 437 | @if $grid { 438 | 439 | /* Grid */ 440 | 441 | // Use defaults if $grid is just "true". 442 | @if $grid == true { 443 | $grid: (); 444 | } 445 | 446 | // Sub-setting: Gutters. 447 | $grid-gutters: 40px; 448 | $x: map-get($grid, 'gutters'); 449 | 450 | @if $x { 451 | $grid-gutters: $x; 452 | } 453 | 454 | // Rows. 455 | .row { 456 | border-bottom: solid 1px transparent; 457 | -moz-box-sizing: border-box; 458 | -webkit-box-sizing: border-box; 459 | box-sizing: border-box; 460 | } 461 | 462 | .row > * { 463 | float: left; 464 | -moz-box-sizing: border-box; 465 | -webkit-box-sizing: border-box; 466 | box-sizing: border-box; 467 | } 468 | 469 | .row:after, .row:before { 470 | content: ''; 471 | display: block; 472 | clear: both; 473 | height: 0; 474 | } 475 | 476 | .row.uniform > * > :first-child { 477 | margin-top: 0; 478 | } 479 | 480 | .row.uniform > * > :last-child { 481 | margin-bottom: 0; 482 | } 483 | 484 | // Gutters (0%). 485 | @include grid-gutters($grid-gutters, \30 \25, 0); 486 | 487 | // Apply base. 488 | @include grid($grid-gutters); 489 | 490 | // Apply per-breakpoint. 491 | @each $name in map-keys($breakpoints) { 492 | 493 | // Get/use breakpoint setting if it exists. 494 | $x: map-get($configPerBreakpoint, $name); 495 | 496 | // Per-breakpoint config exists? 497 | @if $x { 498 | $y: map-get($x, 'grid'); 499 | 500 | // Setting exists? 501 | @if $y { 502 | 503 | // Sub-setting: Gutters. 504 | $x: map-get($y, 'gutters'); 505 | 506 | @if $x { 507 | $grid-gutters: $x; 508 | } 509 | 510 | } 511 | 512 | } 513 | 514 | // Create @media block. 515 | @media screen and #{map-get($breakpoints, $name)} { 516 | @include grid($grid-gutters, $name); 517 | } 518 | 519 | } 520 | 521 | } 522 | 523 | } 524 | 525 | /// Resets browser styles. 526 | /// @param {string} $mode Mode (default is 'normalize'). 527 | @mixin reset($mode: 'normalize') { 528 | 529 | @if $mode == 'normalize' { 530 | 531 | // normalize.css v3.0.2 | MIT License | git.io/normalize 532 | html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{height:auto}input[type=search]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:700}table{border-collapse:collapse;border-spacing:0}td,th{padding:0} 533 | 534 | } 535 | @else if $mode == 'full' { 536 | 537 | // meyerweb.com/eric/tools/css/reset v2.0 | 20110126 | License: none (public domain) 538 | html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline;}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block;}body{line-height:1;}ol,ul{list-style:none;}blockquote,q{quotes:none;}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none;}table{border-collapse:collapse;border-spacing:0;}body{-webkit-text-size-adjust:none} 539 | 540 | } 541 | 542 | } 543 | 544 | /// Vendorizes a declaration's property and/or value(s). 545 | /// @param {string} $property Property. 546 | /// @param {mixed} $value String/list of value(s). 547 | @mixin vendor($property, $value) { 548 | 549 | // Determine if property should expand. 550 | $expandProperty: index($vendor-properties, $property); 551 | 552 | // Determine if value should expand (and if so, add '-prefix-' placeholder). 553 | $expandValue: false; 554 | 555 | @each $x in $value { 556 | @each $y in $vendor-values { 557 | @if $y == str-slice($x, 1, str-length($y)) { 558 | 559 | $value: set-nth($value, index($value, $x), '-prefix-' + $x); 560 | $expandValue: true; 561 | 562 | } 563 | } 564 | } 565 | 566 | // Expand property? 567 | @if $expandProperty { 568 | @each $vendor in $vendor-prefixes { 569 | #{$vendor}#{$property}: #{str-replace-all($value, '-prefix-', $vendor)}; 570 | } 571 | } 572 | 573 | // Expand just the value? 574 | @elseif $expandValue { 575 | @each $vendor in $vendor-prefixes { 576 | #{$property}: #{str-replace-all($value, '-prefix-', $vendor)}; 577 | } 578 | } 579 | 580 | // Neither? Treat them as a normal declaration. 581 | @else { 582 | #{$property}: #{$value}; 583 | } 584 | 585 | } -------------------------------------------------------------------------------- /examples/html5up-phantom-example/elements.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Elements - Phantom by HTML5 UP 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 39 | 40 | 41 | 51 | 52 | 53 |
54 |
55 |

Elements

56 | 57 | 58 |
59 |

Text

60 |

This is bold and this is strong. This is italic and this is emphasized. 61 | This is superscript text and this is subscript text. 62 | This is underlined and this is code: for (;;) { ... }. Finally, this is a link.

63 |
64 |

Nunc lacinia ante nunc ac lobortis. Interdum adipiscing gravida odio porttitor sem non mi integer non faucibus ornare mi ut ante amet placerat aliquet. Volutpat eu sed ante lacinia sapien lorem accumsan varius montes viverra nibh in adipiscing blandit tempus accumsan.

65 |
66 |

Heading Level 2

67 |

Heading Level 3

68 |

Heading Level 4

69 |
70 |

Blockquote

71 |
Fringilla nisl. Donec accumsan interdum nisi, quis tincidunt felis sagittis eget tempus euismod. Vestibulum ante ipsum primis in faucibus vestibulum. Blandit adipiscing eu felis iaculis volutpat ac adipiscing accumsan faucibus. Vestibulum ante ipsum primis in faucibus lorem ipsum dolor sit amet nullam adipiscing eu felis.
72 |

Preformatted

73 |
i = 0;
 74 | 
 75 | while (!deck.isInOrder()) {
 76 |     print 'Iteration ' + i;
 77 |     deck.shuffle();
 78 |     i++;
 79 | }
 80 | 
 81 | print 'It took ' + i + ' iterations to sort the deck.';
82 |
83 | 84 | 85 |
86 |

Lists

87 |
88 |
89 |

Unordered

90 |
    91 |
  • Dolor pulvinar etiam.
  • 92 |
  • Sagittis adipiscing.
  • 93 |
  • Felis enim feugiat.
  • 94 |
95 |

Alternate

96 |
    97 |
  • Dolor pulvinar etiam.
  • 98 |
  • Sagittis adipiscing.
  • 99 |
  • Felis enim feugiat.
  • 100 |
101 |
102 |
103 |

Ordered

104 |
    105 |
  1. Dolor pulvinar etiam.
  2. 106 |
  3. Etiam vel felis viverra.
  4. 107 |
  5. Felis enim feugiat.
  6. 108 |
  7. Dolor pulvinar etiam.
  8. 109 |
  9. Etiam vel felis lorem.
  10. 110 |
  11. Felis enim et feugiat.
  12. 111 |
112 |

Icons

113 | 119 | 125 |
126 |
127 |

Actions

128 |
129 |
130 | 134 | 138 | 142 | 146 |
147 |
148 | 152 | 156 |
157 |
158 |
159 | 160 | 161 |
162 |

Table

163 |

Default

164 |
165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 |
NameDescriptionPrice
Item OneAnte turpis integer aliquet porttitor.29.99
Item TwoVis ac commodo adipiscing arcu aliquet.19.99
Item Three Morbi faucibus arcu accumsan lorem.29.99
Item FourVitae integer tempus condimentum.19.99
Item FiveAnte turpis integer aliquet porttitor.29.99
100.00
207 |
208 | 209 |

Alternate

210 |
211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 |
NameDescriptionPrice
Item OneAnte turpis integer aliquet porttitor.29.99
Item TwoVis ac commodo adipiscing arcu aliquet.19.99
Item Three Morbi faucibus arcu accumsan lorem.29.99
Item FourVitae integer tempus condimentum.19.99
Item FiveAnte turpis integer aliquet porttitor.29.99
100.00
253 |
254 |
255 | 256 | 257 |
258 |

Buttons

259 | 263 | 268 | 273 | 278 | 283 |
    284 |
  • Disabled
  • 285 |
  • Disabled
  • 286 |
287 |
288 | 289 | 290 |
291 |

Form

292 |
293 |
294 |
295 | 296 |
297 |
298 | 299 |
300 |
301 |
302 | 309 |
310 |
311 |
312 | 313 | 314 |
315 |
316 | 317 | 318 |
319 |
320 | 321 | 322 |
323 |
324 | 325 | 326 |
327 |
328 | 329 | 330 |
331 |
332 | 333 |
334 |
335 |
    336 |
  • 337 |
  • 338 |
339 |
340 |
341 |
342 |
343 | 344 | 345 |
346 |

Image

347 |

Fit

348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |

Left & Right

363 |

Fringilla nisl. Donec accumsan interdum nisi, quis tincidunt felis sagittis eget. tempus euismod. Vestibulum ante ipsum primis in faucibus vestibulum. Blandit adipiscing eu felis iaculis volutpat ac adipiscing accumsan eu faucibus. Integer ac pellentesque praesent tincidunt felis sagittis eget. tempus euismod. Vestibulum ante ipsum primis in faucibus vestibulum. Blandit adipiscing eu felis iaculis volutpat ac adipiscing accumsan eu faucibus. Integer ac pellentesque praesent. Donec accumsan interdum nisi, quis tincidunt felis sagittis eget. tempus euismod. Vestibulum ante ipsum primis in faucibus vestibulum. Blandit adipiscing eu felis iaculis volutpat ac adipiscing accumsan eu faucibus. Integer ac pellentesque praesent tincidunt felis sagittis eget. tempus euismod. Vestibulum ante ipsum primis in faucibus vestibulum. Blandit adipiscing eu felis iaculis volutpat ac adipiscing accumsan eu faucibus. Integer ac pellentesque praesent. Blandit adipiscing eu felis iaculis volutpat ac adipiscing accumsan eu faucibus. Integer ac pellentesque praesent tincidunt felis sagittis eget. tempus euismod. Vestibulum ante ipsum primis in faucibus vestibulum. Blandit adipiscing eu felis iaculis volutpat ac adipiscing accumsan eu faucibus. Integer ac pellentesque praesent.

364 |

Fringilla nisl. Donec accumsan interdum nisi, quis tincidunt felis sagittis eget. tempus euismod. Vestibulum ante ipsum primis in faucibus vestibulum. Blandit adipiscing eu felis iaculis volutpat ac adipiscing accumsan eu faucibus. Integer ac pellentesque praesent tincidunt felis sagittis eget. tempus euismod. Vestibulum ante ipsum primis in faucibus vestibulum. Blandit adipiscing eu felis iaculis volutpat ac adipiscing accumsan eu faucibus. Integer ac pellentesque praesent. Donec accumsan interdum nisi, quis tincidunt felis sagittis eget. tempus euismod. Vestibulum ante ipsum primis in faucibus vestibulum. Blandit adipiscing eu felis iaculis volutpat ac adipiscing accumsan eu faucibus. Integer ac pellentesque praesent tincidunt felis sagittis eget. tempus euismod. Vestibulum ante ipsum primis in faucibus vestibulum. Blandit adipiscing eu felis iaculis volutpat ac adipiscing accumsan eu faucibus. Integer ac pellentesque praesent. Blandit adipiscing eu felis iaculis volutpat ac adipiscing accumsan eu faucibus. Integer ac pellentesque praesent tincidunt felis sagittis eget. tempus euismod. Vestibulum ante ipsum primis in faucibus vestibulum. Blandit adipiscing eu felis iaculis volutpat ac adipiscing accumsan eu faucibus. Integer ac pellentesque praesent.

365 |
366 | 367 |
368 |
369 | 370 | 371 |
372 |
373 |
374 |

Get in touch

375 |
376 |
377 | 378 |
379 |
380 | 381 |
382 |
383 | 384 |
385 |
    386 |
  • 387 |
388 |
389 |
390 |
391 |

Follow

392 | 402 |
403 | 406 |
407 |
408 | 409 |
410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | --------------------------------------------------------------------------------