Skip to content

Commit

Permalink
Merge pull request #2073 from NuGet/anurse/1019-npedeeplink
Browse files Browse the repository at this point in the history
Fix #1019 by adding NPE Deep Link
  • Loading branch information
analogrelay committed Apr 21, 2014
2 parents d4967b5 + 009ac18 commit 6c17ba2
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/NuGetGallery/Content/Site.css
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ p.authors {
}

#sideColumn nav ul li {
margin: 0;
margin: 3px 0px 0px;
padding: 0;
}

Expand Down Expand Up @@ -1056,6 +1056,10 @@ a.btn {
box-sizing: border-box;
}

.btn.btn-small {
font-size: 10pt;
}

.btn.btn-inline {
display: inline-block;
}
Expand Down Expand Up @@ -1302,6 +1306,10 @@ ul.accordian {
display: none;
}

body.s-noclickonce .s-clickonce {
display: none;
}

/* Icons */
.nucon-nuget-w {
background: url('images/icons/nuget_32_mono_w.png');
Expand Down
28 changes: 27 additions & 1 deletion src/NuGetGallery/Scripts/nugetgallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
checkServiceStatus();

attachPlugins();

sniffClickonce();
});

// Add validator that ensures provided value is NOT equal to a specified value.
Expand All @@ -43,6 +45,21 @@
return s;
}

function hasMimeTypeSupport(desiredMime) {
var mimes = window.navigator.mimeTypes,
hasSupport = false;

for (var i = 0; i < mimes.length; i++) {
var mime = mimes[i];

if (mime.type == desiredMime) {
hasSupport = true;
}
}

return hasSupport;
};

// Attach script plugins
function attachPlugins() {
$('.s-toggle[data-show][data-hide]').delegate('', 'click', function (evt) {
Expand Down Expand Up @@ -71,7 +88,7 @@
evt.preventDefault();
}
});
if(!navigator.mimeTypes["application/x-shockwave-flash"]) {
if (!hasMimeTypeSupport("application/x-shockwave-flash")) {
$('.s-reqflash').remove();
}
$('.s-localtime[data-utc]').each(function () {
Expand All @@ -88,4 +105,13 @@
});
$('time.timeago').timeago();
}

function sniffClickonce() {
var userAgent = window.navigator.userAgent.toUpperCase(),
hasNativeDotNet = userAgent.indexOf('.NET CLR 3.5') >= 0;

if (hasNativeDotNet) {
$('body').removeClass('s-noclickonce');
}
}
})(window, jQuery);
14 changes: 14 additions & 0 deletions src/NuGetGallery/UrlExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Globalization;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
Expand All @@ -7,6 +8,8 @@ namespace NuGetGallery
{
public static class UrlExtensions
{
private const string PackageExplorerDeepLink = @"https://npe.codeplex.com/releases/clickonce/NuGetPackageExplorer.application?url={0}&id={1}&version={2}";

// Shorthand for current url
public static string Current(this UrlHelper url)
{
Expand Down Expand Up @@ -132,6 +135,17 @@ public static string PackageDownload(this UrlHelper url, int feedVersion, string
return version == null ? EnsureTrailingSlash(result) : result;
}

public static string ExplorerDeepLink(this UrlHelper url, int feedVersion, string id, string version)
{
string routeName = "v" + feedVersion + RouteName.DownloadPackage;
string protocol = url.RequestContext.HttpContext.Request.IsSecureConnection ? "https" : "http";
string urlResult = url.RouteUrl(routeName, new { Id = id }, protocol: protocol);

urlResult = EnsureTrailingSlash(urlResult);

return String.Format(CultureInfo.InvariantCulture, PackageExplorerDeepLink, urlResult, id, version);
}

public static string LogOn(this UrlHelper url)
{
return url.RouteUrl(RouteName.Authentication, new { action = "LogOn" });
Expand Down
1 change: 1 addition & 0 deletions src/NuGetGallery/Views/Packages/DisplayPackage.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
@if (User.Identity.IsAuthenticated)
{
<li><a href="@Url.PackageDownload(2, Model.Id, Model.Version)" title="Download the raw nupkg file.">Download</a></li>
<li><a class="s-clickonce" href="@Url.ExplorerDeepLink(2, Model.Id, Model.Version)" title="Explore the nupkg with the NuGet Package Explorer (IE only)">Open in Package Explorer</a></li>
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/NuGetGallery/Views/Shared/Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@RenderSection("TopScripts", required: false)
@ViewHelpers.ReleaseMeta()
</head>
<body>
<body class="s-noclickonce">
<div id="service-alert"></div>
<div id="outer-wrapper">
<div id="content-wrapper">
Expand Down

0 comments on commit 6c17ba2

Please sign in to comment.