Commit 632846d0 authored by Robert Knight's avatar Robert Knight Committed by GitHub

Merge pull request #63 from hypothesis/remove-firstrun-config-option

Replace "firstRun" config option with "openSidebar" and "openLoginForm"
parents cbfa2acd 56fd70cf
Configuring the sidebar
=======================
The Hypothesis sidebar can be configured by providing a settings object in the
body of the hosting page:
```html
<script type="application/json" class="js-hypothesis-config">
{
"openSidebar": true
}
</script>
<script async src="https://hypothes.is/embed.js"></script>
```
**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
-----------
### `openLoginForm`
_Boolean_. Controls whether the login panel is automatically opened on startup,
as if the user had clicked "Log in" themselves.
### `openSidebar`
_Boolean_. Controls whether the sidebar opens automatically on startup.
...@@ -24,7 +24,7 @@ module.exports = class Sidebar extends Host ...@@ -24,7 +24,7 @@ module.exports = class Sidebar extends Host
super super
this.hide() this.hide()
if options.firstRun || options.annotations if options.openSidebar || options.annotations
this.on 'panelReady', => this.show() this.on 'panelReady', => this.show()
if @plugins.BucketBar? if @plugins.BucketBar?
......
...@@ -55,12 +55,12 @@ describe('annotator configuration', function () { ...@@ -55,12 +55,12 @@ describe('annotator configuration', function () {
it('merges the config from hypothesisConfig()', function () { it('merges the config from hypothesisConfig()', function () {
var fakeWindow = Object.assign({}, fakeWindowBase, { var fakeWindow = Object.assign({}, fakeWindowBase, {
hypothesisConfig: function () { hypothesisConfig: function () {
return {firstRun: true}; return {foo: true};
}, },
}); });
assert.deepEqual(config(fakeWindow), { assert.deepEqual(config(fakeWindow), {
app: 'app.html', app: 'app.html',
firstRun: true, foo: true,
}); });
}); });
......
...@@ -79,7 +79,11 @@ module.exports = function AppController( ...@@ -79,7 +79,11 @@ module.exports = function AppController(
// update the auth info in the top bar and show the login form // update the auth info in the top bar and show the login form
// after first install of the extension. // after first install of the extension.
$scope.auth = authStateFromUserID(state.userid); $scope.auth = authStateFromUserID(state.userid);
if (!state.userid && settings.firstRun) {
// FIXME: Fix this horrendous !== 'false' conditional. Unfortunately, we
// currently pass settings from the hosting page into the sidebar via the
// URL query string, so type information is lost. Ugh.
if (!state.userid && settings.openLoginForm && settings.openLoginForm !== 'false') {
$scope.login(); $scope.login();
} }
}); });
......
...@@ -94,7 +94,6 @@ describe('AppController', function () { ...@@ -94,7 +94,6 @@ describe('AppController', function () {
}; };
fakeSettings = { fakeSettings = {
firstRun: false,
serviceUrl: 'http://fake.service.com/', serviceUrl: 'http://fake.service.com/',
}; };
......
...@@ -45,7 +45,7 @@ function LiveReloadServer(port, appServer) { ...@@ -45,7 +45,7 @@ function LiveReloadServer(port, appServer) {
liveReloadServer: 'ws://' + appHost + ':${port}', liveReloadServer: 'ws://' + appHost + ':${port}',
// Open the sidebar when the page loads // Open the sidebar when the page loads
firstRun: true, openSidebar: true,
}; };
}; };
......
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