Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9123187
badges.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
badges.js
View Options
/**
* Copyright (C) 2019-2020 The Software Heritage developers
* See the AUTHORS file at the top-level directory of this distribution
* License: GNU Affero General Public License version 3, or any later version
* See top-level LICENSE file for more information
*/
export
function
showBadgeInfoModal
(
objectType
,
objectSWHID
)
{
let
badgeImageUrl
;
let
badgeLinkUrl
;
if
(
objectType
===
'origin'
)
{
badgeImageUrl
=
Urls
.
swh_badge
(
objectType
,
objectSWHID
);
badgeLinkUrl
=
`
${
Urls
.
browse_origin
()
}
?origin_url=
${
objectSWHID
}
`
;
}
else
{
const
pos
=
objectSWHID
.
indexOf
(
';'
);
if
(
pos
!==
-
1
)
{
const
objectSWHIDNoContext
=
objectSWHID
.
slice
(
0
,
pos
);
badgeImageUrl
=
Urls
.
swh_badge_swhid
(
objectSWHIDNoContext
);
$
(
'.swhid'
).
each
((
i
,
swhid
)
=>
{
if
(
swhid
.
id
===
objectSWHIDNoContext
)
{
badgeLinkUrl
=
swhid
.
pathname
;
}
});
}
else
{
badgeImageUrl
=
Urls
.
swh_badge_swhid
(
objectSWHID
);
badgeLinkUrl
=
Urls
.
browse_swhid
(
objectSWHID
);
}
}
const
absoluteBadgeImageUrl
=
`
${
window
.
location
.
origin
}${
badgeImageUrl
}
`
;
const
absoluteBadgeLinkUrl
=
`
${
window
.
location
.
origin
}${
badgeLinkUrl
}
`
;
const
html
=
`
<a href="
${
absoluteBadgeLinkUrl
}
">
<img class="swh-badge" src="
${
absoluteBadgeImageUrl
}
">
</a>
<div>
<label>HTML</label>
<pre class="swh-badge-html"><a href="
${
absoluteBadgeLinkUrl
}
">
<img src="
${
absoluteBadgeImageUrl
}
">
</a></pre>
</div>
<div>
<label>Markdown</label>
<pre class="swh-badge-md">[](
${
absoluteBadgeLinkUrl
}
)</pre>
</div>
<div>
<label>reStructuredText</label>
<pre class="swh-badge-rst">.. image::
${
absoluteBadgeImageUrl
}
:target:
${
absoluteBadgeLinkUrl
}
</pre>
</div>`
;
swh
.
webapp
.
showModalHtml
(
'Software Heritage badge integration'
,
html
);
}
File Metadata
Details
Attached
Mime Type
text/html
Expires
Sat, Jun 21, 5:08 PM (2 w, 7 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3337885
Attached To
rDWAPPS Web applications
Event Timeline
Log In to Comment