Skip to content

Commit

Permalink
docs: improve quickstart documentation (#851)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredguth authored and gr2m committed Apr 8, 2018
1 parent 3e56543 commit b279c51
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
12 changes: 7 additions & 5 deletions docs/guides/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ App-specific plugins
~~~~~~~~~~~~~~~~~~~~

You can extend your Hoodie’s client by creating the file ``hoodie/client/index.js``
in your app’s repository, which should export a `Hoodie Client plugin <../api/client/hoodie.html#hoodie-plugin>`.
It will dynamically be bundled into your client accessible at the ``/hoodie/client.js`` route.
in your app’s repository, which should export a `Hoodie Client plugin <http://docs.hood.ie/en/latest/api/client/hoodie.html#hoodie-plugin>`.
It will dynamically be bundled into your client ``/hoodie/client.js``.


Example

.. code:: js
// /hoodie/client.js
// /hoodie/client/index.js
module.exports = function (hoodie) {
hoodie.hello = function (what) {
return Promise.resolve('Hello, ' + (what || 'world') + '!')
Expand Down Expand Up @@ -49,11 +50,12 @@ Example
next()
}
Try it it at http://localhost:8080/hoodie/<app name>/api

3rd party plugins
~~~~~~~~~~~~~~~~~

Hoodie plugins are npm modules. We recommend to prefix your plugin names with
Hoodie plugins are `npm modules <https://www.npmjs.com/search?q=hoodie-plugin->`. We recommend to prefix your plugin names with
``hoodie-plugin-``, but it’s not required. The folder structure is the same as
for app-specific plugins:

Expand All @@ -69,7 +71,7 @@ The server plugin must be loadable via ``require('hoodie-plugin-foo/hoodie/serve
A Hoodie server plugin is a `hapi plugin <http://hapijs.com/tutorials/plugins>`_.
The client plugin must be loadable via ``require('hoodie-plugin-foo/hoodie/client')``
A Hoodie client plugin can be a function or an object,
it will be passed into `hoodie.plugin() <../api/client/hoodie.html#hoodie-plugin>`
it will be passed into `hoodie.plugin() <http://docs.hood.ie/en/latest/api/client/hoodie.html#hoodie-plugin>`

Hoodie plugins can extend the Hoodie client, the Hoodie server and provide a
web UI for `/hoodie/<plugin name>`. All extension points are optional.
Expand Down
23 changes: 21 additions & 2 deletions docs/guides/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ questions, you can simply press enter to leave the default values.

.. code:: bash
$ npm init
$ npm init -y
Now we can install **hoodie** using npm

Expand All @@ -57,7 +57,7 @@ like this
.. code:: json
{
"name": "funky",
"name": "testapp",
"version": "1.0.0",
"description": "",
"main": "index.js",
Expand Down Expand Up @@ -91,6 +91,25 @@ at http://127.0.0.1:8080 after you restart the server. All assets in the public
folder, like images, CSS files or JavaScript files, will be served by your
Hoodie Backend at :code:`http://127.0.0.1:8080/<path/to/your/file.ext>`.

If you just want to try, you can copy https://raw.githubusercontent.com/gr2m/sweet.la/master/public/index.html to your index.html. (This code was created to present Hoodie in an event, you can watch it at https://www.youtube.com/watch?v=TSDyxtVbbME&t=1272s)
Open the Console and try:

.. code:: bash
hoodie
Also try:

.. code:: bash
hoodie.account.signUp({username: 'foo', password: 'secret'})
Now, test using it offline and back online. You can also open a second browser (incognito) and see the changes being replicated.



Note for npm v2
---------------

Expand Down

0 comments on commit b279c51

Please sign in to comment.