-
Notifications
You must be signed in to change notification settings - Fork 644
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
Changes from 5 commits
f1fe697
a2eab3a
875c3f8
3889272
bba051d
b3470af
63bff1c
3afbcb7
aec9ea9
aa29b7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
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> | ||
|
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; | ||
|
@@ -37,6 +38,9 @@ public static void PreStart() | |
{ | ||
AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier; | ||
|
||
ViewEngines.Engines.Clear(); | ||
ViewEngines.Engines.Add(CreateViewEngine()); | ||
|
||
NinjectPreStart(); | ||
ElmahPreStart(); | ||
GlimpsePreStart(); | ||
|
@@ -70,6 +74,34 @@ public static void Stop() | |
NinjectStop(); | ||
} | ||
|
||
private static RazorViewEngine CreateViewEngine() | ||
{ | ||
var ret = new RazorViewEngine(); | ||
|
||
ret.AreaMasterLocationFormats = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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... There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NuGet.org brand is the default, for simplicity. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, that should work There was a problem hiding this comment. Choose a reason for hiding this commentThe 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]] In src/NuGetGallery/App_Start/AppActivator.cs:
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... — |
||
"~/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)); | ||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@{ | ||
Layout = "~/views/Shared/Layout.cshtml"; | ||
} |
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> |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.