Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sukima/ember-quine
Ember addon to build apps as self contained HTML files
https://github.com/sukima/ember-quine
ember ember-addon ember-cli emberjs javascript
Last synced: 16 days ago
JSON representation
Ember addon to build apps as self contained HTML files
- Host: GitHub
- URL: https://github.com/sukima/ember-quine
- Owner: sukima
- License: mit
- Created: 2019-10-16T04:47:26.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-11T09:35:41.000Z (almost 2 years ago)
- Last Synced: 2024-04-26T21:47:36.172Z (6 months ago)
- Topics: ember, ember-addon, ember-cli, emberjs, javascript
- Language: JavaScript
- Homepage: https://sukima.github.io/ember-quine/
- Size: 1.61 MB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 29
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
ember-quine
==============================================================================> 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](https://en.wikipedia.org/wiki/Quine_(computing))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](https://sukima.github.io/ember-quine/) and play with it.Compatibility
------------------------------------------------------------------------------* Ember.js v3.4 or above
* Ember CLI v2.13 or above
* Node.js v8 or aboveInstallation
------------------------------------------------------------------------------```
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 your
`config/environment.js`:```js
ENV['ember-quine'] = { enabled: false };
```Usage
------------------------------------------------------------------------------This addon provides a quine service which exposes methods to download the app
and load/save/remove data from the document storage mechanism.### Downloading the Quine App
Use the `download()` method to have the browser download a copy of the current
running quine.```js
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.#### quine.download(filename)
Initiates a download of the quine. It will reset `quine.isDirty` to false.
**Triggered Events**
* didDownload
**Params**
* filename `string|undefined` - the filename to save as. Will default to the
application name. It will add an `.html` extension if missing.### Data Storage
The data storage provided saves data to the DOM directly. See Data Store
section for more information.#### quine.loadStore(storeName)
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**
* storeName string - The name of the store to load
#### quine.saveStore(storeName, data)
Saves data to the DOM. Will set `quine.isDirty` to true.
**Triggered Events**
* didSaveStore - passes an object with a storeName property
* didChange**Params**
* storeName `string` - The name of the store to save
* data `any` - The payload to be saved to the data store#### quine.destroyStore(storeName)
Removes a stored set of data by storeName from the DOM. Will set
`quine.isDirty` to true.**Triggered Events**
* didDestroyStore - passes an object with a storeName property
* didChange**Params**
* storeName `string` - The name of the store to destroy
#### quine.destroyAllStores()
Removes all data from the DOM. quine.isDirty to true.
**Triggered Events**
* didDestroyAllStores
* didChangeContributing
------------------------------------------------------------------------------See the [Contributing](CONTRIBUTING.md) guide for details.
License
------------------------------------------------------------------------------This project is licensed under the [MIT License](LICENSE.md).