Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
8775ce22
Commit
8775ce22
authored
Feb 03, 2023
by
Alejandro Celaya
Committed by
Alejandro Celaya
Feb 03, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adapt configuration to support the new user profile mini-app
parent
fc9dba5f
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
61 additions
and
5 deletions
+61
-5
release.yml
.github/workflows/release.yml
+2
-0
rollup-boot.config.mjs
rollup-boot.config.mjs
+5
-0
app.js
src/annotator/config/app.js
+1
-1
index.js
src/annotator/config/index.js
+10
-2
settings.js
src/annotator/config/settings.js
+4
-0
index-test.js
src/annotator/config/test/index-test.js
+8
-0
settings-test.js
src/annotator/config/test/settings-test.js
+10
-0
boot.js
src/boot/boot.js
+4
-0
index.js
src/boot/index.js
+4
-0
router.js
src/sidebar/services/router.js
+7
-1
router-test.js
src/sidebar/services/test/router-test.js
+5
-0
route.js
src/sidebar/store/modules/route.js
+1
-1
No files found.
.github/workflows/release.yml
View file @
8775ce22
...
@@ -28,6 +28,7 @@ jobs:
...
@@ -28,6 +28,7 @@ jobs:
environment
:
qa
environment
:
qa
env
:
env
:
NOTEBOOK_APP_URL
:
https://qa.hypothes.is/notebook
NOTEBOOK_APP_URL
:
https://qa.hypothes.is/notebook
PROFILE_APP_URL
:
https://qa.hypothes.is/user-profile
SIDEBAR_APP_URL
:
https://qa.hypothes.is/app.html
SIDEBAR_APP_URL
:
https://qa.hypothes.is/app.html
steps
:
steps
:
...
@@ -69,6 +70,7 @@ jobs:
...
@@ -69,6 +70,7 @@ jobs:
environment
:
production
environment
:
production
env
:
env
:
NOTEBOOK_APP_URL
:
https://hypothes.is/notebook
NOTEBOOK_APP_URL
:
https://hypothes.is/notebook
PROFILE_APP_URL
:
https://hypothes.is/user-profile
SIDEBAR_APP_URL
:
https://hypothes.is/app.html
SIDEBAR_APP_URL
:
https://hypothes.is/app.html
steps
:
steps
:
...
...
rollup-boot.config.mjs
View file @
8775ce22
...
@@ -21,6 +21,10 @@ const notebookAppUrl = process.env.NOTEBOOK_APP_URL
...
@@ -21,6 +21,10 @@ const notebookAppUrl = process.env.NOTEBOOK_APP_URL
?
`
${
process
.
env
.
NOTEBOOK_APP_URL
}
`
?
`
${
process
.
env
.
NOTEBOOK_APP_URL
}
`
:
`
${
localhost
}
:5000/notebook`
;
:
`
${
localhost
}
:5000/notebook`
;
const
profileAppUrl
=
process
.
env
.
PROFILE_APP_URL
?
`
${
process
.
env
.
PROFILE_APP_URL
}
`
:
`
${
localhost
}
:5000/user-profile`
;
const
sidebarAppUrl
=
process
.
env
.
SIDEBAR_APP_URL
const
sidebarAppUrl
=
process
.
env
.
SIDEBAR_APP_URL
?
`
${
process
.
env
.
SIDEBAR_APP_URL
}
`
?
`
${
process
.
env
.
SIDEBAR_APP_URL
}
`
:
`
${
localhost
}
:5000/app.html`
;
:
`
${
localhost
}
:5000/app.html`
;
...
@@ -52,6 +56,7 @@ export default {
...
@@ -52,6 +56,7 @@ export default {
values
:
{
values
:
{
__ASSET_ROOT__
:
assetRoot
,
__ASSET_ROOT__
:
assetRoot
,
__NOTEBOOK_APP_URL__
:
notebookAppUrl
,
__NOTEBOOK_APP_URL__
:
notebookAppUrl
,
__PROFILE_APP_URL__
:
profileAppUrl
,
__SIDEBAR_APP_URL__
:
sidebarAppUrl
,
__SIDEBAR_APP_URL__
:
sidebarAppUrl
,
},
},
}),
}),
...
...
src/annotator/config/app.js
View file @
8775ce22
...
@@ -36,7 +36,7 @@ export function createAppConfig(appURL, config) {
...
@@ -36,7 +36,7 @@ export function createAppConfig(appURL, config) {
appConfig
.
origin
=
new
URL
(
appURL
).
origin
;
appConfig
.
origin
=
new
URL
(
appURL
).
origin
;
// Pass the version of the client, so we can check if it is the same as the
// Pass the version of the client, so we can check if it is the same as the
// one used in the sidebar/notebook.
// one used in the sidebar/notebook
/profile
.
appConfig
.
version
=
'__VERSION__'
;
appConfig
.
version
=
'__VERSION__'
;
// Pass the URL of the page that embedded the client.
// Pass the URL of the page that embedded the client.
...
...
src/annotator/config/index.js
View file @
8775ce22
...
@@ -23,7 +23,7 @@ import { urlFromLinkTag } from './url-from-link-tag';
...
@@ -23,7 +23,7 @@ import { urlFromLinkTag } from './url-from-link-tag';
* Named subset of the Hypothesis client configuration that is relevant in
* Named subset of the Hypothesis client configuration that is relevant in
* a particular context.
* a particular context.
*
*
* @typedef {'sidebar'|'notebook'|'annotator'|'all'} Context
* @typedef {'sidebar'|'notebook'|'
profile'|'
annotator'|'all'} Context
*/
*/
/**
/**
...
@@ -61,6 +61,7 @@ function configurationKeys(context) {
...
@@ -61,6 +61,7 @@ function configurationKeys(context) {
'theme'
,
'theme'
,
'usernameUrl'
,
'usernameUrl'
,
],
],
profile
:
[
'profileAppUrl'
],
};
};
switch
(
context
)
{
switch
(
context
)
{
...
@@ -70,9 +71,11 @@ function configurationKeys(context) {
...
@@ -70,9 +71,11 @@ function configurationKeys(context) {
return
contexts
.
sidebar
;
return
contexts
.
sidebar
;
case
'notebook'
:
case
'notebook'
:
return
contexts
.
notebook
;
return
contexts
.
notebook
;
case
'profile'
:
return
contexts
.
profile
;
case
'all'
:
case
'all'
:
// Complete list of configuration keys used for testing.
// Complete list of configuration keys used for testing.
return
[...
contexts
.
annotator
,
...
contexts
.
sidebar
,
...
contexts
.
notebook
]
;
return
Object
.
values
(
contexts
).
flat
()
;
default
:
default
:
throw
new
Error
(
`Invalid application context used: "
${
context
}
"`
);
throw
new
Error
(
`Invalid application context used: "
${
context
}
"`
);
}
}
...
@@ -177,6 +180,11 @@ const configDefinitions = {
...
@@ -177,6 +180,11 @@ const configDefinitions = {
defaultValue
:
null
,
defaultValue
:
null
,
getValue
:
settings
=>
settings
.
notebookAppUrl
,
getValue
:
settings
=>
settings
.
notebookAppUrl
,
},
},
profileAppUrl
:
{
allowInBrowserExt
:
true
,
defaultValue
:
null
,
getValue
:
settings
=>
settings
.
profileAppUrl
,
},
sidebarAppUrl
:
{
sidebarAppUrl
:
{
allowInBrowserExt
:
true
,
allowInBrowserExt
:
true
,
defaultValue
:
null
,
defaultValue
:
null
,
...
...
src/annotator/config/settings.js
View file @
8775ce22
...
@@ -14,6 +14,7 @@ import { urlFromLinkTag } from './url-from-link-tag';
...
@@ -14,6 +14,7 @@ import { urlFromLinkTag } from './url-from-link-tag';
* @prop {string} clientUrl
* @prop {string} clientUrl
* @prop {string} sidebarAppUrl
* @prop {string} sidebarAppUrl
* @prop {string} notebookAppUrl
* @prop {string} notebookAppUrl
* @prop {string} profileAppUrl
* @prop {(name: string) => unknown} hostPageSetting
* @prop {(name: string) => unknown} hostPageSetting
*/
*/
...
@@ -175,6 +176,9 @@ export function settingsFrom(window_) {
...
@@ -175,6 +176,9 @@ export function settingsFrom(window_) {
get
notebookAppUrl
()
{
get
notebookAppUrl
()
{
return
urlFromLinkTag
(
window_
,
'notebook'
,
'html'
);
return
urlFromLinkTag
(
window_
,
'notebook'
,
'html'
);
},
},
get
profileAppUrl
()
{
return
urlFromLinkTag
(
window_
,
'profile'
,
'html'
);
},
get
showHighlights
()
{
get
showHighlights
()
{
return
showHighlights
();
return
showHighlights
();
},
},
...
...
src/annotator/config/test/index-test.js
View file @
8775ce22
...
@@ -12,6 +12,7 @@ describe('annotator/config/index', () => {
...
@@ -12,6 +12,7 @@ describe('annotator/config/index', () => {
clientUrl
:
'fakeValue'
,
clientUrl
:
'fakeValue'
,
group
:
'fakeValue'
,
group
:
'fakeValue'
,
notebookAppUrl
:
'fakeValue'
,
notebookAppUrl
:
'fakeValue'
,
profileAppUrl
:
'fakeValue'
,
showHighlights
:
'fakeValue'
,
showHighlights
:
'fakeValue'
,
sidebarAppUrl
:
'fakeValue'
,
sidebarAppUrl
:
'fakeValue'
,
query
:
'fakeValue'
,
query
:
'fakeValue'
,
...
@@ -83,6 +84,7 @@ describe('annotator/config/index', () => {
...
@@ -83,6 +84,7 @@ describe('annotator/config/index', () => {
focus
:
null
,
focus
:
null
,
group
:
'fakeValue'
,
group
:
'fakeValue'
,
notebookAppUrl
:
'fakeValue'
,
notebookAppUrl
:
'fakeValue'
,
profileAppUrl
:
'fakeValue'
,
onLayoutChange
:
null
,
onLayoutChange
:
null
,
openSidebar
:
true
,
// coerced
openSidebar
:
true
,
// coerced
query
:
'fakeValue'
,
query
:
'fakeValue'
,
...
@@ -115,6 +117,7 @@ describe('annotator/config/index', () => {
...
@@ -115,6 +117,7 @@ describe('annotator/config/index', () => {
focus
:
'fakeValue'
,
focus
:
'fakeValue'
,
group
:
'fakeValue'
,
group
:
'fakeValue'
,
notebookAppUrl
:
'fakeValue'
,
notebookAppUrl
:
'fakeValue'
,
profileAppUrl
:
'fakeValue'
,
onLayoutChange
:
'fakeValue'
,
onLayoutChange
:
'fakeValue'
,
openSidebar
:
true
,
// coerced
openSidebar
:
true
,
// coerced
query
:
'fakeValue'
,
query
:
'fakeValue'
,
...
@@ -171,6 +174,7 @@ describe('annotator/config/index', () => {
...
@@ -171,6 +174,7 @@ describe('annotator/config/index', () => {
focus
:
null
,
focus
:
null
,
group
:
null
,
group
:
null
,
notebookAppUrl
:
null
,
notebookAppUrl
:
null
,
profileAppUrl
:
null
,
onLayoutChange
:
null
,
onLayoutChange
:
null
,
openSidebar
:
false
,
openSidebar
:
false
,
query
:
null
,
query
:
null
,
...
@@ -255,6 +259,10 @@ describe('annotator/config/index', () => {
...
@@ -255,6 +259,10 @@ describe('annotator/config/index', () => {
'usernameUrl'
,
'usernameUrl'
,
],
],
},
},
{
app
:
'profile'
,
expectedKeys
:
[
'profileAppUrl'
],
},
].
forEach
(
test
=>
{
].
forEach
(
test
=>
{
it
(
`ignores values not belonging to "
${
test
.
app
}
" context`
,
()
=>
{
it
(
`ignores values not belonging to "
${
test
.
app
}
" context`
,
()
=>
{
const
config
=
getConfig
(
test
.
app
,
'WINDOW'
);
const
config
=
getConfig
(
test
.
app
,
'WINDOW'
);
...
...
src/annotator/config/test/settings-test.js
View file @
8775ce22
...
@@ -35,6 +35,16 @@ describe('annotator/config/settingsFrom', () => {
...
@@ -35,6 +35,16 @@ describe('annotator/config/settingsFrom', () => {
});
});
});
});
describe
(
'#profileAppUrl'
,
()
=>
{
it
(
'calls urlFromLinkTag with appropriate params'
,
()
=>
{
assert
.
equal
(
settingsFrom
(
window
).
profileAppUrl
,
'http://example.com/app.html'
);
assert
.
calledWith
(
fakeUrlFromLinkTag
,
window
,
'profile'
,
'html'
);
});
});
describe
(
'#sidebarAppUrl'
,
()
=>
{
describe
(
'#sidebarAppUrl'
,
()
=>
{
it
(
'calls urlFromLinkTag with appropriate params'
,
()
=>
{
it
(
'calls urlFromLinkTag with appropriate params'
,
()
=>
{
assert
.
equal
(
assert
.
equal
(
...
...
src/boot/boot.js
View file @
8775ce22
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
* @typedef AnnotatorConfig
* @typedef AnnotatorConfig
* @prop {string} assetRoot - The root URL to which URLs in `manifest` are relative
* @prop {string} assetRoot - The root URL to which URLs in `manifest` are relative
* @prop {string} notebookAppUrl - The URL of the sidebar's notebook
* @prop {string} notebookAppUrl - The URL of the sidebar's notebook
* @prop {string} profileAppUrl - The URL of the sidebar's user profile view
* @prop {string} sidebarAppUrl - The URL of the sidebar's HTML page
* @prop {string} sidebarAppUrl - The URL of the sidebar's HTML page
* @prop {Record<string,string>} manifest -
* @prop {Record<string,string>} manifest -
* A mapping from canonical asset path to cache-busted asset path
* A mapping from canonical asset path to cache-busted asset path
...
@@ -154,6 +155,9 @@ export function bootHypothesisClient(doc, config) {
...
@@ -154,6 +155,9 @@ export function bootHypothesisClient(doc, config) {
// Register the URL of the notebook app which the Hypothesis client should load.
// Register the URL of the notebook app which the Hypothesis client should load.
injectLink
(
doc
,
'notebook'
,
'html'
,
config
.
notebookAppUrl
);
injectLink
(
doc
,
'notebook'
,
'html'
,
config
.
notebookAppUrl
);
// Register the URL of the user profile app which the Hypothesis client should load.
injectLink
(
doc
,
'profile'
,
'html'
,
config
.
profileAppUrl
);
// Preload the styles used by the shadow roots of annotator UI elements.
// Preload the styles used by the shadow roots of annotator UI elements.
preloadURL
(
doc
,
'style'
,
assetURL
(
config
,
'styles/annotator.css'
));
preloadURL
(
doc
,
'style'
,
assetURL
(
config
,
'styles/annotator.css'
));
...
...
src/boot/index.js
View file @
8775ce22
...
@@ -39,6 +39,9 @@ if (isBrowserSupported()) {
...
@@ -39,6 +39,9 @@ if (isBrowserSupported()) {
const
notebookAppUrl
=
processUrlTemplate
(
const
notebookAppUrl
=
processUrlTemplate
(
annotatorConfig
.
notebookAppUrl
||
'__NOTEBOOK_APP_URL__'
annotatorConfig
.
notebookAppUrl
||
'__NOTEBOOK_APP_URL__'
);
);
const
profileAppUrl
=
processUrlTemplate
(
annotatorConfig
.
profileAppUrl
||
'__PROFILE_APP_URL__'
);
const
sidebarAppUrl
=
processUrlTemplate
(
const
sidebarAppUrl
=
processUrlTemplate
(
annotatorConfig
.
sidebarAppUrl
||
'__SIDEBAR_APP_URL__'
annotatorConfig
.
sidebarAppUrl
||
'__SIDEBAR_APP_URL__'
);
);
...
@@ -46,6 +49,7 @@ if (isBrowserSupported()) {
...
@@ -46,6 +49,7 @@ if (isBrowserSupported()) {
assetRoot
,
assetRoot
,
manifest
,
manifest
,
notebookAppUrl
,
notebookAppUrl
,
profileAppUrl
,
sidebarAppUrl
,
sidebarAppUrl
,
});
});
}
}
...
...
src/sidebar/services/router.js
View file @
8775ce22
/**
/**
* @typedef {'annotation'|'notebook'|'stream'|'sidebar'} RouteName
* @typedef {'annotation'|'notebook'|'
profile'|'
stream'|'sidebar'} RouteName
* @typedef {Record<string,string>} RouteParams
* @typedef {Record<string,string>} RouteParams
*/
*/
...
@@ -58,6 +58,9 @@ export class RouterService {
...
@@ -58,6 +58,9 @@ export class RouterService {
case
'notebook'
:
case
'notebook'
:
route
=
'notebook'
;
route
=
'notebook'
;
break
;
break
;
case
'user-profile'
:
route
=
'profile'
;
break
;
case
'stream'
:
case
'stream'
:
route
=
'stream'
;
route
=
'stream'
;
break
;
break
;
...
@@ -90,6 +93,9 @@ export class RouterService {
...
@@ -90,6 +93,9 @@ export class RouterService {
case
'notebook'
:
case
'notebook'
:
url
=
'/notebook'
;
url
=
'/notebook'
;
break
;
break
;
case
'profile'
:
url
=
'/user-profile'
;
break
;
case
'stream'
:
case
'stream'
:
url
=
'/stream'
;
url
=
'/stream'
;
break
;
break
;
...
...
src/sidebar/services/test/router-test.js
View file @
8775ce22
...
@@ -15,6 +15,11 @@ const fixtures = [
...
@@ -15,6 +15,11 @@ const fixtures = [
route
:
'notebook'
,
route
:
'notebook'
,
params
:
{},
params
:
{},
},
},
{
path
:
'/user-profile'
,
route
:
'profile'
,
params
:
{},
},
{
{
path
:
'/a/foo'
,
path
:
'/a/foo'
,
route
:
'annotation'
,
route
:
'annotation'
,
...
...
src/sidebar/store/modules/route.js
View file @
8775ce22
import
{
createStoreModule
,
makeAction
}
from
'../create-store'
;
import
{
createStoreModule
,
makeAction
}
from
'../create-store'
;
/**
/**
* @typedef {'annotation'|'notebook'|'sidebar'|'stream'} RouteName
* @typedef {'annotation'|'notebook'|'
profile'|'
sidebar'|'stream'} RouteName
*/
*/
const
initialState
=
{
const
initialState
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment