Commit 9ea3437a authored by Robert Knight's avatar Robert Knight Committed by GitHub

Merge pull request #273 from hypothesis/add-docs-for-on-login

Add docs for on login
parents 9d8ab81f 97d8dbf7
Configuring the sidebar
=======================
Configuring the client
======================
The Hypothesis sidebar can be configured by providing a settings object in the
body of the hosting page:
### Configuring the client using JSON
The Hypothesis client can be configured by providing a JSON config object in
the body of the hosting page:
```html
<script type="application/json" class="js-hypothesis-config">
......@@ -13,57 +15,101 @@ body of the hosting page:
<script async src="https://hypothes.is/embed.js"></script>
```
Not all configuration settings can be set in this way, some must be
[set using JavaScript](#configuring-the-client-using-javascript) (see below).
**N.B.** The body of the `.js-hypothesis-config` tag must be [valid
JSON](http://jsonlint.com/) -- invalid JSON will cause the entire config object
to be ignored.
Config keys
-----------
### Configuring the client using JavaScript
Alternatively, the Hypothesis client can be configured from the hosting page by
providing a JavaScript function named `window.hypothesisConfig` that returns
a configuration object. Some configuration settings (for example settings that
register callback or event handler functions) can _only_ be set from
JavaScript:
```html
window.hypothesisConfig = function () {
return {
"openSidebar": true
};
};
```
Config settings
---------------
## Client behavior
### Client behavior
These keys configure the behavior and initial state of the client when it
These settings configure the behavior and initial state of the client when it
loads.
### `openLoginForm`
#### `openLoginForm`
_Boolean_. Controls whether the login panel is automatically opened on startup,
as if the user had clicked "Log in" themselves. (Default: _false_.)
### `openSidebar`
#### `openSidebar`
_Boolean_. Controls whether the sidebar opens automatically on startup.
(Default: _false_.)
### `showHighlights`
#### `showHighlights`
_Boolean_. Controls whether the in-document highlights are shown by default.
(Default: _true_.)
## Annotation services
### Annotation services
These keys configure which annotation services the client connects to and where
These settings configure which annotation services the client connects to and where
it loads assets from. By default, the client will connect to the public
Hypothesis service at [hypothes.is](https://hypothes.is).
### `assetRoot`
#### `assetRoot`
_String_. The URL from which client assets are loaded.
### `sidebarAppUrl`
#### `sidebarAppUrl`
_String_. The URL for the sidebar application which displays annotations
(Default: _https://hypothes.is/app.html_).
### `services`
#### `services`
_Array_. A list of additional annotation services which the client should
retrieve annotations from, optionally including information about the identity
of the user on that service. This list is in addition to the public
[Hypothesis](https://hypothes.is/) service.
Each service description is an object with the keys:
**N.B.** Currently only one additional annotation service is supported - only
the first item in this `services` array is used, and any further items in the
array are ignored.
Each item in the array should be an object describing an annotation service,
with the following keys:
* `authority` _String_. The domain name which the annotation service is associated with.
* `grantToken` _String|null_. An OAuth grant token which the client can exchange for an access token in order to make authenticated requests to the service. If _null_, the user will only be able to read rather than create or modify annotations. (Default: _null_)
* `icon` _String|null_. The URL to an image for the annotation service. This image will appear to the left of the name of the currently selected group. The image should be suitable for display at 16x16px and the recommended format is SVG.
* `onLogin` _function_. A JavaScript function that the Hypothesis client will
call in order to login (for example, when the user clicks a login button in
the Hypothesis client's sidebar).
This setting can only be [set using window.hypothesisConfig](#configuring-the-client-using-javascript).
If the hosting page provides an `onLogin` function then the Hypothesis client
will call this function instead of doing its usual procedure for logging in
to the public service at [hypothes.is](https://hypothes.is/).
No arguments are passed to the `onLogin` function.
The `onLogin` function should cause a login procedure for the hosting page
to be performed - for example by redirecting to a login page, or by opening
a popup login window. After a successful login the hosting page should
reload the original page with a non-null `grantToken` for the logged-in user
in the `services` configuration setting.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment