Ember addon to build apps as self contained HTML files
A quine is a computer program which takes no input and produces a copy of its
own source code as its only output.
~ Quine (computing) - Wikipedia)
Ember Quine is an Ember addon that enables an Ember app to be self downloaded
as a single HTML file that runs offline (via the file://
URI).
This is best understood through demonstration. Vist the
live example and play with it.
ember install ember-quine
By default all JS and CSS assets are compiled into the final index.html
file.
To disabled this (for development purposes) add the following to yourconfig/environment.js
:
ENV['ember-quine'] = { enabled: false };
This addon provides a quine service which exposes methods to download the app
and load/save/remove data from the document storage mechanism.
Use the download()
method to have the browser download a copy of the current
running quine.
import Component from '@ember/component';
import { inject as service } from '@ember/service';
export default Component.extend({
quine: service(),
actions: {
download(filename) {
this.quine.download(filename);
}
}
});
This works by reading the HTML nodes (head and body) and capturing their
innerHTML. It then constructs a new HTML document with string concatenation. It
then builds a new tag with its href set to the constructed HTML. It adds
the tag to the document, triggers a click action, and then removes the element.
Initiates a download of the quine. It will reset quine.isDirty
to false.
Triggered Events
Params
string|undefined
- the filename to save as. Will default to the.html
extension if missing.The data storage provided saves data to the DOM directly. See Data Store
section for more information.
Loads the data from the DOM and returns the value stored.
Returns: any
- The payload stored in the data store or undefined if not
found
Params
Saves data to the DOM. Will set quine.isDirty
to true.
Triggered Events
Params
string
- The name of the store to saveany
- The payload to be saved to the data storeRemoves a stored set of data by storeName from the DOM. Will setquine.isDirty
to true.
Triggered Events
Params
string
- The name of the store to destroyRemoves all data from the DOM. quine.isDirty to true.
Triggered Events
See the Contributing guide for details.
This project is licensed under the MIT License.