Implements the alternate style sheet publication

* style.css: this floating breaks my dark style

* Global.asax: the application object is now compiled at runtime,
its code is in App_Code

* YavscHelpers.cs: Implements a method helping to refer on themed
  stylesheets,
presenting the "alternate" stylesheet usage.

* App.master: Uses the new Helper function to refer on the
main style sheet `style.css`

* Web.config: * no more default controller, instead, modify the app
  code
* the client side javascript validation is custommized, and we do not
  need the M$ js for now

* Web.csproj: Global.asax.cs becomes a content, compiled at runtime,
  found in ~/App_Code

* Global.asax.cs: Now compiles at runtime.

* Makefile: adds my deployment targets
This commit is contained in:
Paul Schneider 2015-11-18 12:33:19 +01:00
commit 47285f8b83
10 changed files with 108 additions and 21 deletions

View file

@ -16,6 +16,7 @@ using System.Web.Script.Serialization;
using System.Web.Mvc;
using System.Text.RegularExpressions;
using Yavsc.Model.Messaging;
using System.Linq;
namespace Yavsc.Helpers
{
@ -338,7 +339,63 @@ namespace Yavsc.Helpers
}
return new MvcHtmlString(strwr.ToString());
}
/// <summary>
/// The available themes.
/// </summary>
public static string[] AvailableThemes = {
"clear", "dark", "blue", "green"
};
/// <summary>
/// Themes the CSS links.
/// </summary>
/// <returns>The CSS links.</returns>
/// <param name="html">Html.</param>
/// <param name="theme">Theme.</param>
/// <param name="baseName">Base name.</param>
public static IHtmlString ThemeCSSLinks (
this System.Web.Mvc.HtmlHelper html, string theme, string baseName) {
if (!AvailableThemes.Contains (theme))
throw new ArgumentException ("The given theme is not configured: " +
theme);
if (string.IsNullOrWhiteSpace(baseName))
throw new ArgumentException ("Specify a base name");
StringWriter strwr = new StringWriter ();
HtmlTextWriter writer = new HtmlTextWriter(strwr);
// refer to the global style
writer.AddAttribute ("rel", "stylesheet");
writer.AddAttribute ("title", theme);
writer.AddAttribute ("href",
string.Format(
"/App_Themes/{1}.css",
theme,baseName));
writer.RenderBeginTag ("link");
// refer to the themed style
writer.AddAttribute ("rel", "stylesheet");
writer.AddAttribute ("title", theme);
writer.AddAttribute ("href",
string.Format(
"/App_Themes/{0}/{1}.css",
theme,baseName));
writer.RenderBeginTag ("link");
// refer to alternate styles
foreach (string atheme in AvailableThemes) {
if (atheme != theme) {
writer.AddAttribute ("rel", "alternate stylesheet");
writer.AddAttribute ("title", atheme);
writer.AddAttribute ("href",
string.Format (
"/App_Themes/{0}/{1}.css",
atheme, baseName));
writer.RenderBeginTag ("link");
}
}
return new MvcHtmlString(strwr.ToString());
}
}
}