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
9fdd66b0
Commit
9fdd66b0
authored
Nov 12, 2020
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Nov 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for `notebook` routing in sidebar
parent
33067d0d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
7 deletions
+25
-7
hypothesis-app.js
src/sidebar/components/hypothesis-app.js
+1
-0
hypothesis-app-test.js
src/sidebar/components/test/hypothesis-app-test.js
+4
-0
index.js
src/sidebar/index.js
+8
-7
router.js
src/sidebar/services/router.js
+7
-0
router-test.js
src/sidebar/services/test/router-test.js
+5
-0
No files found.
src/sidebar/components/hypothesis-app.js
View file @
9fdd66b0
...
...
@@ -194,6 +194,7 @@ function HypothesisApp({
{
route
===
'annotation'
&&
(
<
AnnotationViewerContent
onLogin
=
{
login
}
/
>
)}
{
route
===
'notebook'
&&
<
StreamContent
/>
}
{
route
===
'stream'
&&
<
StreamContent
/>
}
{
route
===
'sidebar'
&&
(
<
SidebarContent
onLogin
=
{
login
}
onSignUp
=
{
signUp
}
/
>
...
...
src/sidebar/components/test/hypothesis-app-test.js
View file @
9fdd66b0
...
...
@@ -115,6 +115,10 @@ describe('HypothesisApp', () => {
route
:
'sidebar'
,
contentComponent
:
'SidebarContent'
,
},
{
route
:
'notebook'
,
contentComponent
:
'StreamContent'
,
},
{
route
:
'stream'
,
contentComponent
:
'StreamContent'
,
...
...
src/sidebar/index.js
View file @
9fdd66b0
...
...
@@ -38,11 +38,6 @@ if (appConfig.googleAnalytics) {
addAnalytics
(
appConfig
.
googleAnalytics
);
}
const
isSidebar
=
!
(
window
.
location
.
pathname
.
startsWith
(
'/stream'
)
||
window
.
location
.
pathname
.
startsWith
(
'/a/'
)
);
// Install Preact renderer options to work around browser quirks
rendererOptions
.
setupBrowserFixes
();
...
...
@@ -91,9 +86,9 @@ function autosave(autosaveService) {
}
// @inject
function
setupFrameSync
(
frameSync
)
{
function
setupFrameSync
(
frameSync
,
isSidebar
)
{
if
(
isSidebar
)
{
frameSync
.
connect
();
frameSync
.
connect
(
true
);
}
}
...
...
@@ -140,6 +135,12 @@ import { Injector } from '../shared/injector';
function
startApp
(
config
)
{
const
container
=
new
Injector
();
const
isSidebar
=
!
(
window
.
location
.
pathname
.
startsWith
(
'/stream'
)
||
window
.
location
.
pathname
.
startsWith
(
'/a/'
)
||
window
.
location
.
pathname
.
startsWith
(
'/notebook'
)
);
// Register services.
container
.
register
(
'analytics'
,
analyticsService
)
...
...
src/sidebar/services/router.js
View file @
9fdd66b0
...
...
@@ -15,11 +15,15 @@ export default function router($window, store) {
const
params
=
queryString
.
parse
(
$window
.
location
.
search
);
let
route
;
switch
(
pathSegments
[
0
])
{
case
'a'
:
route
=
'annotation'
;
params
.
id
=
pathSegments
[
1
]
||
''
;
break
;
case
'notebook'
:
route
=
'notebook'
;
break
;
case
'stream'
:
route
=
'stream'
;
break
;
...
...
@@ -47,6 +51,9 @@ export default function router($window, store) {
url
=
`/a/
${
id
}
`
;
}
break
;
case
'notebook'
:
url
=
'/notebook'
;
break
;
case
'stream'
:
url
=
'/stream'
;
break
;
...
...
src/sidebar/services/test/router-test.js
View file @
9fdd66b0
...
...
@@ -7,6 +7,11 @@ const fixtures = [
route
:
'sidebar'
,
params
:
{},
},
{
path
:
'/notebook'
,
route
:
'notebook'
,
params
:
{},
},
{
path
:
'/a/foo'
,
route
:
'annotation'
,
...
...
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