Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring - Easier rebranding of the site #1700

Merged
merged 10 commits into from
Nov 7, 2013
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,11 @@ $RECYCLE.BIN/
.DS_Store

# NuGetGallery Specific Ignores
src/NuGetGallery/App_Data/
!src/NuGetGallery/App_Data/Files/
src/NuGetGallery/App_Data/Files/
!src/NuGetGallery/App_Data/Files/Content
src/NuGetGallery/App_Data/Files/Packages
src/NuGetGallery/App_Data/Files/Downloads
src/NuGetGallery/App_Data/Files/Uploads
src/NuGetGallery/App_Data/Mail
src/NuGetGallery/App_Data/Lucene
!src/NuGetGallery/Views/Packages/
!src/NuGetGallery.Operations/Tasks/Backups/
!src/NuGetGallery.Cloud/*Content/bin
Expand All @@ -168,4 +169,4 @@ build/artifacts/
!*.Local*.cscfg

# Exclude Azure Publish Profiles
*.pubxml
*.pubxml
1 change: 1 addition & 0 deletions NuGetGallery.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
# Visual Studio 2012
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{96E4AFF8-D3A1-4102-ADCF-05F186F916A9}"
ProjectSection(SolutionItems) = preProject
.nuget\packages.config = .nuget\packages.config
Expand Down
6 changes: 6 additions & 0 deletions src/NuGetGallery/Admin.HomeController.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ protected RedirectToRouteResult RedirectToAction(ActionResult result) {
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionNamesClass {
public readonly string Index = "Index";
public readonly string Throw = "Throw";
}


Expand All @@ -69,6 +70,11 @@ public override System.Web.Mvc.ActionResult Index() {
return callInfo;
}

public override System.Web.Mvc.ActionResult Throw() {
var callInfo = new T4MVC_ActionResult(Area, Name, ActionNames.Throw);
return callInfo;
}

}
}

Expand Down
4 changes: 2 additions & 2 deletions src/NuGetGallery/App_Code/ViewHelpers.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
var ver = ApplicationVersionHelper.GetVersion();

<p id="releaseTag">
This is the NuGet Gallery.
This is the @(ConfigurationManager.AppSettings["Gallery.Brand"].Trim()).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only reads from web.config, not CSCFG. Can you add "Brand" as a string property to IAppConfiguration? Then it will be autopopulated and will be available in ConfigurationService.Current (you can use Container.Kernel.Get<...> in the ViewHelpers since we don't unit test them anyway)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll do it that way.

@if (ver.Present)
{
if(!String.IsNullOrEmpty(ver.ShortCommit)) {
Expand Down Expand Up @@ -181,4 +181,4 @@
@Analytics.GetGoogleHtml(propertyId)
}
}
}
}
5 changes: 0 additions & 5 deletions src/NuGetGallery/App_Data/Files/Content/FrontPage-About.md

This file was deleted.

This file was deleted.

46 changes: 46 additions & 0 deletions src/NuGetGallery/App_Data/Files/Content/Home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<section class="featured">
<div>
<h1>What is NuGet?</h1>
<p>NuGet is the package manager for the Microsoft development platform including .NET. The NuGet client tools provide the ability to produce and consume packages. The NuGet Gallery is the central package repository used by all package authors and consumers.</p>
<a class="install" href="http://docs.nuget.org/docs/start-here/installing-nuget">Install NuGet</a>
</div>
<img src="content/Logos/hero.png" alt="Manage NuGet Packages Dialog Window" />
</section>

<section class="aggstats">
<span class="stat">
<span id="UniquePackages" class="num"></span> unique packages
</span>
<span class="stat">
<span id="Downloads" class="num"></span>total package downloads
</span>
<span class="stat">
<span id="TotalPackages" class="num"></span>total packages
</span>
</section>

<section class="aggstatserr">
<span class="err">an error occurred while retrieving statistics</span>
</section>

<section class="release">
<h2>Developer Environment</h2>
<p>This is a developer environment!
If you want to show a custom message here, either change the App_Data\Files\Content\Home.html file,
or if you are using the AzureStorageBlob package store type, upload a Home.md or Home.html to the "content"
container of your blob storage account.</p>
</section>

<section class="info">
<h3>About</h3>
<p>When you use NuGet to install a package, it copies the library files to your solution and automatically updates your project
(add references, change config files, etc.). If you remove a package, NuGet reverses whatever changes it made so that
no clutter is left.</p>
</section>

<h3>Important Notice</h3>
<p>You can develop your own package and share it via the NuGet Gallery. Read the documentation for more details on
<a href="http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package"
title="Creating and submitting a package">how to create and publish a package</a>.
If you don't plan on submitting a package, there's no need to register.</p>

2 changes: 1 addition & 1 deletion src/NuGetGallery/App_Data/Files/Content/Terms-Of-Use.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ Outercurve is based in the United States. Outercurve makes no claims that the Co
The Web site may contain links to sites owned or operated by independent third parties. These links are provided for your convenience and reference only. We do not control such sites and, therefore, we are not responsible for any content posted on these sites. The fact that Outercurve offers such links should not be construed in any way as an endorsement, authorization, or sponsorship of that site, its content or the companies or products referenced therein, and Outercurve reserves the right to note its lack of affiliation, sponsorship, or endorsement on this site. If you decide to access any of the third party sites linked to the Web site, you do this entirely at your own risk. Because some sites employ automated search results or otherwise link you to sites containing information that may be deemed inappropriate or offensive, Outercurve cannot be held responsible for the accuracy, copyright compliance, legality, or decency of material contained in third party sites, and you hereby irrevocably waive any claim against us with respect to such sites.

## Notification Of Possible Copyright Infringement.
Notification Of Possible Copyright Infringement. In the event you believe that material or content published on the site may infringe on your copyright or that of another, please utilize the ‘Report Abuse’ link on the Web site, including details of the possible infringement in the abuse report.
Notification Of Possible Copyright Infringement. In the event you believe that material or content published on the site may infringe on your copyright or that of another, please utilize the ‘Report Abuse’ link on the Web site, including details of the possible infringement in the abuse report.
10 changes: 5 additions & 5 deletions src/NuGetGallery/App_Offline-Planned.htm
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@

#logo { font-size: 3em; }

hgroup { margin-bottom: 10px; }
.hgroup { margin-bottom: 10px; }

hgroup h1,
hgroup h2 { margin: 0; }
.hgroup h1,
.hgroup h2 { margin: 0; }

#layout-footer {
clear: both;
Expand Down Expand Up @@ -138,10 +138,10 @@
</header>
<div id="body">
<div>
<hgroup>
<div class="hgroup">
<h1>NuGet.org is currently offline</h1>
<h2>We will be back Shortly</h2>
</hgroup>
</div>
<p>
We are working to make the NuGet Gallery even more awesome and we’ll be back soon. You can
<a href="http://status.nuget.org">check our status page</a> for recognized outages,
Expand Down
10 changes: 5 additions & 5 deletions src/NuGetGallery/App_Offline-Unplanned.htm
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@

#logo { font-size: 3em; }

hgroup { margin-bottom: 10px; }
.hgroup { margin-bottom: 10px; }

hgroup h1,
hgroup h2 { margin: 0; }
.hgroup h1,
.hgroup h2 { margin: 0; }

#layout-footer {
clear: both;
Expand Down Expand Up @@ -138,10 +138,10 @@
</header>
<div id="body">
<div>
<hgroup>
<div class="hgroup">
<h1>NuGet.org is currently offline</h1>
<h2>We will be back Shortly</h2>
</hgroup>
</div>
<p>
The NuGet Gallery is having some trouble, but we're on the case. You can
<a href="http://status.nuget.org">check our status page</a> for recognized outages,
Expand Down
46 changes: 43 additions & 3 deletions src/NuGetGallery/App_Start/AppActivator.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Data.Entity;
using System.Diagnostics;
using System.IO;
using System.Security.Claims;
using System.Web.Helpers;
using System.Web.Mvc;
Expand Down Expand Up @@ -37,6 +38,9 @@ public static void PreStart()
{
AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;

ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(CreateViewEngine());

NinjectPreStart();
ElmahPreStart();
GlimpsePreStart();
Expand Down Expand Up @@ -70,6 +74,34 @@ public static void Stop()
NinjectStop();
}

private static RazorViewEngine CreateViewEngine()
{
var ret = new RazorViewEngine();

ret.AreaMasterLocationFormats =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've used the "assignment-returns-assigned-value" trick myself but I generally prefer to use a variable instead, unless I really want a one-liner. Since this is broken over many lines already, I don't see a huge readability benefit in using it here.

Having said that, don't bother changing it just to fix this issue. If you're going in to this code again anyway, maybe change it to a variable?

ret.AreaViewLocationFormats =
ret.AreaPartialViewLocationFormats =
new string[]
{
"~/Areas/{2}/Views/{1}/{0}.cshtml",
"~/Branding/Views/Shared/{0}.cshtml",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was under the impression our idea was ~/Branding/NuGet and ~/Branding/SomeOtherBrand as root folders, and a config setting to choose which folder to use. That way, the other brand's fork only has additions, rather than modifications...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been imagining brands aren't going to live in the same branch/repository, so there's no real need to support them side by side like you mention. It's still only additions, since the Branding folders start off as empty.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we'd need a separate fork for NuGet.org? Or do you imagine that NuGet.org wouldn't have anything in its branding folder at all?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NuGet.org brand is the default, for simplicity.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that should work

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do it, Notify me befor u start or I’ll think you’re a bug

From: Andrew Nurse [mailto:[email protected]]
Sent: Tuesday, October 29, 2013 2:21 PM
To: NuGet/NuGetGallery
Subject: Re: [NuGetGallery] Refactoring - Easier rebranding of the site (#1700)

In src/NuGetGallery/App_Start/AppActivator.cs:

@@ -70,6 +74,34 @@ public static void Stop()
NinjectStop();
}

  •    private static RazorViewEngine CreateViewEngine()
    
  •    {
    
  •        var ret = new RazorViewEngine();
    
  •        ret.AreaMasterLocationFormats = 
    
  •            ret.AreaViewLocationFormats =
    
  •            ret.AreaPartialViewLocationFormats =
    
  •            new string[]
    
  •        {
    
  •            "~/Areas/{2}/Views/{1}/{0}.cshtml",
    
  •            "~/Branding/Views/Shared/{0}.cshtml",
    

I was under the impression our idea was ~/Branding/NuGet and ~/Branding/MSNuGet as root folders, and a config setting to choose which folder to use. That way, the MSNuGet changes were almost entirely additions, rather than modifications...


Reply to this email directly or view it on GitHub https://github.com/NuGet/NuGetGallery/pull/1700/files#r7291277 . https://github.com/notifications/beacon/S8T8wH2zNx3-MnRGiPRbwsBXeo0VN1iB_I3SKqTp8XPu7g-q6LtrRM7XJmP9HRKM.gif

"~/Areas/{2}/Views/Shared/{0}.cshtml",
};

ret.MasterLocationFormats =
ret.ViewLocationFormats =
ret.PartialViewLocationFormats =
new string[]
{
"~/Branding/Views/{1}/{0}.cshtml",
"~/Views/{1}/{0}.cshtml",
"~/Branding/Views/Shared/{0}.cshtml",
"~/Views/Shared/{0}.cshtml",
};

return ret;
}

private static void GlimpsePreStart()
{
DynamicModuleUtility.RegisterModule(typeof(Glimpse.AspNet.HttpModule));
Expand Down Expand Up @@ -105,10 +137,18 @@ private static void BundlingPostStart()
.Include("~/Scripts/modernizr-{version}.js");
BundleTable.Bundles.Add(modernizrBundle);

var stylesBundle = new StyleBundle("~/Content/css")
.Include("~/Content/site.css");
BundleTable.Bundles.Add(stylesBundle);
Bundle stylesBundle = new StyleBundle("~/Content/css");
foreach (string filename in new[] {
"Site.css",
"Layout.css",
"PageStylings.css",
})
{
stylesBundle = stylesBundle.Include("~/Content/" + filename);
stylesBundle = stylesBundle.Include("~/Branding/Content/" + filename);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment on branding subfolders as above.

}

BundleTable.Bundles.Add(stylesBundle);
}

private static void ElmahPreStart()
Expand Down
5 changes: 5 additions & 0 deletions src/NuGetGallery/App_Start/Routes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public static void RegisterRoutes(RouteCollection routes)
"policies/{action}",
new { controller = MVC.Pages.Name });

routes.MapRoute(
RouteName.Pages,
"pages/{pageName}",
new { controller = MVC.Pages.Name, action = "Page" });

var packageListRoute = routes.MapRoute(
RouteName.ListPackages,
"packages",
Expand Down
3 changes: 3 additions & 0 deletions src/NuGetGallery/Branding/Views/_ViewStart.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@{
Layout = "~/views/Shared/Layout.cshtml";
}
62 changes: 62 additions & 0 deletions src/NuGetGallery/Branding/Views/web.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0"?>

<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>

<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="NuGetGallery.Views.NuGetViewBase">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="Microsoft.Web.Helpers" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.Optimization" />
<add namespace="NuGetGallery"/>
<add namespace="NuGetGallery.Helpers"/>
</namespaces>
</pages>
</system.web.webPages.razor>

<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>

<system.web>
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>

<!--
Enabling request validation in view pages would cause validation to occur
after the input has already been processed by the controller. By default
MVC performs request validation before a controller processes the input.
To change this behavior apply the ValidateInputAttribute to a
controller or action.
-->
<pages
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>

<system.webServer>
<validation validateIntegratedModeConfiguration="false" />

<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
</configuration>
5 changes: 5 additions & 0 deletions src/NuGetGallery/Configuration/AppConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public class AppConfiguration : IAppConfiguration
[DefaultValue(LuceneIndexLocation.AppData)]
public LuceneIndexLocation LuceneIndexLocation { get; set; }

/// <summary>
/// Gets the site brand name i.e. 'NuGet Gallery' by default. Cobranding feature.
/// </summary>
public string Brand { get; set; }

/// <summary>
/// Gets the gallery owner name and email address
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/NuGetGallery/Configuration/ConfigurationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private T ResolveConfigObject<T>(T instance, string prefix)
}
}

if (value != null)
if (!String.IsNullOrEmpty(value))
{
if (property.PropertyType.IsAssignableFrom(typeof(string)))
{
Expand Down
5 changes: 5 additions & 0 deletions src/NuGetGallery/Configuration/IAppConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public interface IAppConfiguration
/// </summary>
string FileStorageDirectory { get; set; }

/// <summary>
/// Gets the site brand name i.e. 'NuGet Gallery' by default. Cobranding feature.
/// </summary>
string Brand { get; set; }

/// <summary>
/// Gets the gallery owner name and email address
/// </summary>
Expand Down
5 changes: 1 addition & 4 deletions src/NuGetGallery/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@ public static class Constants

public static class ContentNames
{
public static readonly string FrontPageAnnouncement = "FrontPage-Announcement";
public static readonly string FrontPageAbout = "FrontPage-About";

public static readonly string Home = "Home";
public static readonly string Alert = "Alert";

public static readonly string TermsOfUse = "Terms-Of-Use";
public static readonly string PrivacyPolicy = "Privacy-Policy";
}
Expand Down
Binary file not shown.
Binary file removed src/NuGetGallery/Content/Images/treeview/file.gif
Binary file not shown.
Binary file not shown.
Binary file removed src/NuGetGallery/Content/Images/treeview/folder.gif
Binary file not shown.
Binary file removed src/NuGetGallery/Content/Images/treeview/minus.gif
Binary file not shown.
Binary file removed src/NuGetGallery/Content/Images/treeview/plus.gif
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading