kopia lustrzana https://gitlab.com/rysiekpl/libresilient
Update docs/QUICKSTART.md
rodzic
a7988e3e0a
commit
25ff0968d9
|
@ -30,20 +30,20 @@ We shall start with a completely minimal (but not really useful) deployment of L
|
|||
|
||||
To start, we need:
|
||||
|
||||
- [`libresilient.js`](https://gitlab.com/rysiekpl/libresilient/-/blob/master/libresilient.js)\
|
||||
- [`libresilient.js`](../libresilient.js)\
|
||||
This script is responsible for loading the service worker script. It can be included using a `<script>` tag or copy-pasted into the HTML. We'll go with the `<script>` tag.\
|
||||
the `libresilient.js` script should be located in the same directory as the `service-worker.js` script.
|
||||
|
||||
- [`service-worker.js`](https://gitlab.com/rysiekpl/libresilient/-/blob/master/service-worker.js)\
|
||||
- [`service-worker.js`](../service-worker.js)\
|
||||
This is the heart of LibResilient. Once loaded, it will use the supplied configuration (in `config.json`) to load and configure plugins. Plugins in turn will perform actual requests and other tasks.
|
||||
|
||||
- the [`fetch` plugin](https://gitlab.com/rysiekpl/libresilient/-/blob/master/plugins/fetch/)\
|
||||
- the [`fetch` plugin](../plugins/fetch/)\
|
||||
This LibResilient plugin uses the basic [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) to retrieve content.\
|
||||
LibResilient expects plugins to be in the `plugins/` subdirectory of the directory where the `service-worker.js` script is located; each plugin is a directory with at least the file `index.js` in it (containing plugin code). In our case this means `/plugins/fetch/index.js` should exist for our hypothetical website.
|
||||
|
||||
- `config.json`\
|
||||
That's the config file, and should also reside in the same directory as `service-worker.js`.\
|
||||
We will write it from scratch, although an example is available [here](https://gitlab.com/rysiekpl/libresilient/-/blob/master/config.json.example).
|
||||
We will write it from scratch, although an example is available [here](../config.json.example).
|
||||
|
||||
Our `config.json` has to be a [valid JSON file](https://jsonlint.com/); for now it should only contain this:
|
||||
|
||||
|
@ -101,7 +101,7 @@ Bare minimum would be to add offline cache to our website. This would at least a
|
|||
|
||||
This is now easy to do. We need just two things:
|
||||
|
||||
- the [`cache` plugin](https://gitlab.com/rysiekpl/libresilient/-/blob/master/plugins/cache/)\
|
||||
- the [`cache` plugin](../plugins/cache/)\
|
||||
This LibResilient plugin makes use of the [Cache API](https://developer.mozilla.org/en-US/docs/Web/API/Cache) to store and retrieve content offline.\
|
||||
As with `fetch` plugin before, we need it in the `plugins/` subdirectory of our website.
|
||||
|
||||
|
@ -186,7 +186,7 @@ But it does not let them get new content in such a case. For that we need an alt
|
|||
|
||||
The simplest available is the `alt-fetch` transport plugin. It still uses the Fetch API, but instead of fetching content from the original website address, it uses other, configured endpoints. We will need:
|
||||
|
||||
- the [`alt-fetch` plugin](https://gitlab.com/rysiekpl/libresilient/-/blob/master/plugins/alt-fetch/)\
|
||||
- the [`alt-fetch` plugin](../plugins/alt-fetch/)\
|
||||
This LibResilient plugin performs [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/fetch) to configured alternative endpoints in order to retrieve content.
|
||||
|
||||
- some actual alternative endpoint where our website content can be made available\
|
||||
|
|
Ładowanie…
Reference in New Issue