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
b14859ec
Unverified
Commit
b14859ec
authored
Jul 17, 2018
by
Sheetal Umesh Kumar
Committed by
GitHub
Jul 17, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #748 from hypothesis/share-links
Convert share dialog links to use bouncer instead of via.
parents
25d7ca13
ab9beb74
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
32 deletions
+18
-32
share-dialog.js
src/sidebar/components/share-dialog.js
+7
-14
share-dialog-test.js
src/sidebar/components/test/share-dialog-test.js
+5
-12
share-dialog.html
src/sidebar/templates/share-dialog.html
+6
-6
No files found.
src/sidebar/components/share-dialog.js
View file @
b14859ec
'use strict'
;
var
VIA_PREFIX
=
'https://via.hypothes.is/'
;
// @ngInject
function
ShareDialogController
(
$scope
,
$element
,
analytics
,
store
)
{
var
self
=
this
;
function
update
Via
Link
(
frames
)
{
function
update
SharePage
Link
(
frames
)
{
if
(
!
frames
.
length
)
{
self
.
via
PageLink
=
''
;
self
.
share
PageLink
=
''
;
return
;
}
// Check to see if we are on a via page. If so, we just return the URI.
if
(
frames
[
0
].
uri
.
indexOf
(
VIA_PREFIX
)
===
0
)
{
self
.
viaPageLink
=
frames
[
0
].
uri
;
}
else
{
self
.
viaPageLink
=
VIA_PREFIX
+
frames
[
0
].
uri
;
}
self
.
sharePageLink
=
'https://hyp.is/go?url='
+
encodeURIComponent
(
frames
[
0
].
uri
);
}
var
viaInput
=
$element
[
0
].
querySelector
(
'.js-via
'
);
via
Input
.
focus
();
via
Input
.
select
();
var
shareLinkInput
=
$element
[
0
].
querySelector
(
'.js-share-link
'
);
shareLink
Input
.
focus
();
shareLink
Input
.
select
();
$scope
.
$watch
(
function
()
{
return
store
.
frames
();
},
update
Via
Link
);
update
SharePage
Link
);
$scope
.
onShareClick
=
function
(
target
){
if
(
target
){
...
...
src/sidebar/components/test/share-dialog-test.js
View file @
b14859ec
...
...
@@ -23,20 +23,13 @@ describe('shareDialog', function () {
angular
.
mock
.
module
(
'h'
);
});
it
(
'generates new
via
link'
,
function
()
{
it
(
'generates new
share
link'
,
function
()
{
var
element
=
util
.
createDirective
(
document
,
'shareDialog'
,
{});
fakeStore
.
frames
.
returns
([{
uri
:
'http://example.com'
}]);
var
uri
=
'http://example.com'
;
fakeStore
.
frames
.
returns
([{
uri
}]);
element
.
scope
.
$digest
();
assert
.
equal
(
element
.
ctrl
.
viaPageLink
,
'https://via.hypothes.is/http://example.com'
);
});
it
(
'does not generate new via link if already on via'
,
function
()
{
var
element
=
util
.
createDirective
(
document
,
'shareDialog'
,
{});
fakeStore
.
frames
.
returns
([{
uri
:
'https://via.hypothes.is/http://example.com'
,
}]);
element
.
scope
.
$digest
();
assert
.
equal
(
element
.
ctrl
.
viaPageLink
,
'https://via.hypothes.is/http://example.com'
);
assert
.
equal
(
element
.
ctrl
.
sharePageLink
,
'https://hyp.is/go?url='
+
encodeURIComponent
(
uri
));
});
it
(
'tracks the target being shared'
,
function
(){
...
...
src/sidebar/templates/share-dialog.html
View file @
b14859ec
...
...
@@ -9,27 +9,27 @@
</ul>
<div
class=
"tab-content"
>
<p>
Share the link below to show anyone these annotations and invite them to contribute their own.
</p>
<p><input
class=
"js-
via
form-input"
<p><input
class=
"js-
share-link
form-input"
type=
"text"
ng-value=
"vm.
via
PageLink"
ng-value=
"vm.
share
PageLink"
readonly
/></p>
<p
class=
"share-link-icons"
>
<a
href=
"https://twitter.com/intent/tweet?url={{vm.
via
PageLink | urlEncode}}&hashtags=annotated"
<a
href=
"https://twitter.com/intent/tweet?url={{vm.
share
PageLink | urlEncode}}&hashtags=annotated"
target=
"_blank"
title=
"Tweet link"
class=
"share-link-icon h-icon-twitter"
ng-click=
"onShareClick('twitter')"
></a>
<a
href=
"https://www.facebook.com/sharer/sharer.php?u={{vm.
via
PageLink | urlEncode}}"
<a
href=
"https://www.facebook.com/sharer/sharer.php?u={{vm.
share
PageLink | urlEncode}}"
target=
"_blank"
title=
"Share on Facebook"
class=
"share-link-icon h-icon-facebook"
ng-click=
"onShareClick('facebook')"
></a>
<a
href=
"https://plus.google.com/share?url={{vm.
via
PageLink | urlEncode}}"
<a
href=
"https://plus.google.com/share?url={{vm.
share
PageLink | urlEncode}}"
target=
"_blank"
title=
"Post on Google Plus"
class=
"share-link-icon h-icon-google-plus"
ng-click=
"onShareClick('googlePlus')"
></a>
<a
href=
"mailto:?subject=Let's%20Annotate&body={{vm.
via
PageLink}}"
<a
href=
"mailto:?subject=Let's%20Annotate&body={{vm.
share
PageLink}}"
target=
"_blank"
title=
"Share via email"
class=
"share-link-icon h-icon-mail"
...
...
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