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
Hide 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({
...
@@ -194,6 +194,7 @@ function HypothesisApp({
{
route
===
'annotation'
&&
(
{
route
===
'annotation'
&&
(
<
AnnotationViewerContent
onLogin
=
{
login
}
/
>
<
AnnotationViewerContent
onLogin
=
{
login
}
/
>
)}
)}
{
route
===
'notebook'
&&
<
StreamContent
/>
}
{
route
===
'stream'
&&
<
StreamContent
/>
}
{
route
===
'stream'
&&
<
StreamContent
/>
}
{
route
===
'sidebar'
&&
(
{
route
===
'sidebar'
&&
(
<
SidebarContent
onLogin
=
{
login
}
onSignUp
=
{
signUp
}
/
>
<
SidebarContent
onLogin
=
{
login
}
onSignUp
=
{
signUp
}
/
>
...
...
src/sidebar/components/test/hypothesis-app-test.js
View file @
9fdd66b0
...
@@ -115,6 +115,10 @@ describe('HypothesisApp', () => {
...
@@ -115,6 +115,10 @@ describe('HypothesisApp', () => {
route
:
'sidebar'
,
route
:
'sidebar'
,
contentComponent
:
'SidebarContent'
,
contentComponent
:
'SidebarContent'
,
},
},
{
route
:
'notebook'
,
contentComponent
:
'StreamContent'
,
},
{
{
route
:
'stream'
,
route
:
'stream'
,
contentComponent
:
'StreamContent'
,
contentComponent
:
'StreamContent'
,
...
...
src/sidebar/index.js
View file @
9fdd66b0
...
@@ -38,11 +38,6 @@ if (appConfig.googleAnalytics) {
...
@@ -38,11 +38,6 @@ if (appConfig.googleAnalytics) {
addAnalytics
(
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
// Install Preact renderer options to work around browser quirks
rendererOptions
.
setupBrowserFixes
();
rendererOptions
.
setupBrowserFixes
();
...
@@ -91,9 +86,9 @@ function autosave(autosaveService) {
...
@@ -91,9 +86,9 @@ function autosave(autosaveService) {
}
}
// @inject
// @inject
function
setupFrameSync
(
frameSync
)
{
function
setupFrameSync
(
frameSync
,
isSidebar
)
{
if
(
isSidebar
)
{
if
(
isSidebar
)
{
frameSync
.
connect
();
frameSync
.
connect
(
true
);
}
}
}
}
...
@@ -140,6 +135,12 @@ import { Injector } from '../shared/injector';
...
@@ -140,6 +135,12 @@ import { Injector } from '../shared/injector';
function
startApp
(
config
)
{
function
startApp
(
config
)
{
const
container
=
new
Injector
();
const
container
=
new
Injector
();
const
isSidebar
=
!
(
window
.
location
.
pathname
.
startsWith
(
'/stream'
)
||
window
.
location
.
pathname
.
startsWith
(
'/a/'
)
||
window
.
location
.
pathname
.
startsWith
(
'/notebook'
)
);
// Register services.
// Register services.
container
container
.
register
(
'analytics'
,
analyticsService
)
.
register
(
'analytics'
,
analyticsService
)
...
...
src/sidebar/services/router.js
View file @
9fdd66b0
...
@@ -15,11 +15,15 @@ export default function router($window, store) {
...
@@ -15,11 +15,15 @@ export default function router($window, store) {
const
params
=
queryString
.
parse
(
$window
.
location
.
search
);
const
params
=
queryString
.
parse
(
$window
.
location
.
search
);
let
route
;
let
route
;
switch
(
pathSegments
[
0
])
{
switch
(
pathSegments
[
0
])
{
case
'a'
:
case
'a'
:
route
=
'annotation'
;
route
=
'annotation'
;
params
.
id
=
pathSegments
[
1
]
||
''
;
params
.
id
=
pathSegments
[
1
]
||
''
;
break
;
break
;
case
'notebook'
:
route
=
'notebook'
;
break
;
case
'stream'
:
case
'stream'
:
route
=
'stream'
;
route
=
'stream'
;
break
;
break
;
...
@@ -47,6 +51,9 @@ export default function router($window, store) {
...
@@ -47,6 +51,9 @@ export default function router($window, store) {
url
=
`/a/
${
id
}
`
;
url
=
`/a/
${
id
}
`
;
}
}
break
;
break
;
case
'notebook'
:
url
=
'/notebook'
;
break
;
case
'stream'
:
case
'stream'
:
url
=
'/stream'
;
url
=
'/stream'
;
break
;
break
;
...
...
src/sidebar/services/test/router-test.js
View file @
9fdd66b0
...
@@ -7,6 +7,11 @@ const fixtures = [
...
@@ -7,6 +7,11 @@ const fixtures = [
route
:
'sidebar'
,
route
:
'sidebar'
,
params
:
{},
params
:
{},
},
},
{
path
:
'/notebook'
,
route
:
'notebook'
,
params
:
{},
},
{
{
path
:
'/a/foo'
,
path
:
'/a/foo'
,
route
:
'annotation'
,
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