Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P5745
(An Untitled Masterwork)
Active
Public
Actions
Authored by
Paladox
on Jul 13 2017, 4:17 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F8736937:
Jul 13 2017, 8:06 PM
2017-07-13 20:06:56 (UTC+0)
F8736706:
Jul 13 2017, 7:58 PM
2017-07-13 19:58:10 (UTC+0)
F8736669:
Jul 13 2017, 7:55 PM
2017-07-13 19:55:46 (UTC+0)
F8736439:
Jul 13 2017, 7:43 PM
2017-07-13 19:43:37 (UTC+0)
F8736298:
Jul 13 2017, 7:36 PM
2017-07-13 19:36:50 (UTC+0)
F8736226:
Jul 13 2017, 7:34 PM
2017-07-13 19:34:32 (UTC+0)
F8736067:
Jul 13 2017, 7:29 PM
2017-07-13 19:29:43 (UTC+0)
F8735903:
Jul 13 2017, 7:19 PM
2017-07-13 19:19:30 (UTC+0)
View All 13 Files
Subscribers
None
<?php
class
CustomGithubDownloadLinks
{
static
function
getMirrorURI
(
$repo
)
{
$uris
=
$repo
->
getURIs
();
foreach
(
$uris
as
$uri
)
{
if
(
$uri
->
getIsDisabled
())
{
continue
;
}
if
(
$uri
->
getEffectiveIoType
()
==
PhabricatorRepositoryURI
::
IO_MIRROR
&&
strpos
(
$uri
->
getDisplayURI
(),
'github'
)
!==
false
)
{
return
$uri
;
}
}
return
false
;
}
static
function
AddActionLinksToTop
(
$repository
,
$identifier
,
$color
)
{
global
$github_download_zip_button
,
$github_download_tar_button
;
$uri
=
self
::
getMirrorURI
(
$repository
);
if
(!
$uri
)
{
return
;
}
$uri
=
$uri
->
getURI
();
if
(
$color
==
'grey'
)
{
$colors
=
PHUIButtonView
::
GREY
;
}
elseif
(
$color
==
'green'
)
{
$colors
=
PHUIButtonView
::
GREEN
;
}
$github_download_zip_button
=
id
(
new
PHUIButtonView
())
->
setTag
(
'a'
)
->
setText
(
pht
(
'Download zip (from Github)'
))
->
setColor
(
$colors
)
->
setIcon
(
'fa-download'
)
->
setHref
(
$uri
.
'/archive/'
.
$identifier
.
'.zip'
);
$github_download_tar_button
=
id
(
new
PHUIButtonView
())
->
setTag
(
'a'
)
->
setText
(
pht
(
'Download gz (from Github)'
))
->
setColor
(
$colors
)
->
setIcon
(
'fa-download'
)
->
setHref
(
$uri
.
'/archive/'
.
$identifier
.
'.tar.gz'
);
}
static
function
addActionsToTop
(
$drequest
,
$color
)
{
$repository
=
$drequest
->
getRepository
();
try
{
if
(
$drequest
->
getSymbolicType
()
==
'tag'
)
{
$download
=
$drequest
->
getSymbolicCommit
();
}
elseif
(
$drequest
->
getSymbolicType
()
==
'commit'
)
{
$download
=
$drequest
->
getStableCommit
();
}
else
{
$download
=
$drequest
->
getBranch
();
}
}
catch
(
Exception
$e
)
{
return
''
;
}
return
self
::
AddActionLinksToTop
(
$repository
,
$download
,
$color
);
}
}
Event Timeline
Paladox
created this paste.
Jul 13 2017, 4:17 PM
2017-07-13 16:17:52 (UTC+0)
Paladox
edited the content of this paste.
(Show Details)
Jul 13 2017, 4:22 PM
2017-07-13 16:22:24 (UTC+0)
Paladox
edited the content of this paste.
(Show Details)
Paladox
edited the content of this paste.
(Show Details)
Jul 13 2017, 4:31 PM
2017-07-13 16:31:13 (UTC+0)
Paladox
edited the content of this paste.
(Show Details)
Jul 13 2017, 5:22 PM
2017-07-13 17:22:49 (UTC+0)
Paladox
edited the content of this paste.
(Show Details)
Jul 13 2017, 7:19 PM
2017-07-13 19:19:30 (UTC+0)
Paladox
edited the content of this paste.
(Show Details)
Jul 13 2017, 7:29 PM
2017-07-13 19:29:43 (UTC+0)
Paladox
edited the content of this paste.
(Show Details)
Jul 13 2017, 7:34 PM
2017-07-13 19:34:32 (UTC+0)
Paladox
edited the content of this paste.
(Show Details)
Jul 13 2017, 7:36 PM
2017-07-13 19:36:50 (UTC+0)
Paladox
edited the content of this paste.
(Show Details)
Jul 13 2017, 7:43 PM
2017-07-13 19:43:37 (UTC+0)
Paladox
edited the content of this paste.
(Show Details)
Jul 13 2017, 7:55 PM
2017-07-13 19:55:46 (UTC+0)
Paladox
edited the content of this paste.
(Show Details)
Jul 13 2017, 7:58 PM
2017-07-13 19:58:10 (UTC+0)
Paladox
edited the content of this paste.
(Show Details)
Jul 13 2017, 8:06 PM
2017-07-13 20:06:56 (UTC+0)
Log In to Comment