diff --git a/NzbDrone.Web/Helpers/HtmlIncludeExtentions.cs b/NzbDrone.Web/Helpers/HtmlIncludeExtentions.cs new file mode 100644 index 000000000..a52492617 --- /dev/null +++ b/NzbDrone.Web/Helpers/HtmlIncludeExtentions.cs @@ -0,0 +1,47 @@ +using System; +using System.IO; +using System.Linq; +using System.Web.Mvc; +using NzbDrone.Common; + +namespace NzbDrone.Web.Helpers +{ + public static class HtmlIncludeExtentions + { + private static string _versionString; + private static bool _isProduction; + + static HtmlIncludeExtentions() + { + _versionString = new EnviromentProvider().Version.ToString().Replace('.', '_'); + _isProduction = EnviromentProvider.IsProduction; + } + + public static MvcHtmlString IncludeScript(this HtmlHelper helper, string filename) + { + var relativePath = "/Scripts/" + filename; + VerifyFile(helper, relativePath); + return MvcHtmlString.Create(String.Format("", relativePath, _versionString)); + } + + public static MvcHtmlString IncludeCss(this HtmlHelper helper, string filename) + { + var relativePath = "/Content/" + filename; + VerifyFile(helper, relativePath); + return MvcHtmlString.Create(String.Format("", relativePath, _versionString)); + } + + private static void VerifyFile(HtmlHelper helper, string filename) + { + if (!_isProduction) + { + var path = helper.ViewContext.RequestContext.HttpContext.Server.MapPath(filename); + + if (!File.Exists(path)) + { + throw new FileNotFoundException("static file not found " + path, path); + } + } + } + } +} \ No newline at end of file diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index a702f568a..d55a95896 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -218,6 +218,7 @@ Global.asax + diff --git a/NzbDrone.Web/Views/AddSeries/Index.cshtml b/NzbDrone.Web/Views/AddSeries/Index.cshtml index 93441fd34..290003cbf 100644 --- a/NzbDrone.Web/Views/AddSeries/Index.cshtml +++ b/NzbDrone.Web/Views/AddSeries/Index.cshtml @@ -1,9 +1,10 @@ -@section TitleContent{ +@using NzbDrone.Web.Helpers +@section TitleContent{ Add Series } @section Scripts { - + @Html.IncludeScript("NzbDrone/addSeries.js") } @{Html.RenderAction("RootDir");}
@@ -17,4 +18,4 @@ Add Series
@{ Html.RenderAction("ExistingSeries", "AddSeries"); }
-
\ No newline at end of file + diff --git a/NzbDrone.Web/Views/History/Index.cshtml b/NzbDrone.Web/Views/History/Index.cshtml index 8d967d1b9..7c584b00e 100644 --- a/NzbDrone.Web/Views/History/Index.cshtml +++ b/NzbDrone.Web/Views/History/Index.cshtml @@ -1,5 +1,6 @@ @model List @using NzbDrone.Web.Models +@using NzbDrone.Web.Helpers @section TitleContent{ History } @@ -9,7 +10,10 @@ History
  • @Ajax.ActionLink("Purge History", "Purge", "History", new AjaxOptions { OnSuccess = "reloadHistoryGrid" })
  • } - +@section HeaderContent +{ + @Html.IncludeCss("Grid.css") +}
    @{Html.Telerik().Grid().Name("history") .TableHtmlAttributes(new { @class = "Grid" }) @@ -49,7 +53,6 @@ History c.PageSize(20).Position(GridPagerPosition.Bottom).Style(GridPagerStyles.NextPrevious)) .Render();}
    - + @Html.IncludeScript("NzbDrone/seriesDetails.js") diff --git a/NzbDrone.Web/Views/Series/EditorTemplates/SeriesModel.cshtml b/NzbDrone.Web/Views/Series/EditorTemplates/SeriesModel.cshtml index ce12e42bf..10089f079 100644 --- a/NzbDrone.Web/Views/Series/EditorTemplates/SeriesModel.cshtml +++ b/NzbDrone.Web/Views/Series/EditorTemplates/SeriesModel.cshtml @@ -1,11 +1,13 @@ @using NzbDrone.Web.Helpers; -@using NzbDrone.Web.Models; @model NzbDrone.Web.Models.SeriesModel @{ Layout = null; } - +@section HeaderContent +{ + @Html.IncludeCss("Settings.css") +}
    diff --git a/NzbDrone.Web/Views/Settings/Indexers.cshtml b/NzbDrone.Web/Views/Settings/Indexers.cshtml index eeb50cd19..d4ffe53b0 100644 --- a/NzbDrone.Web/Views/Settings/Indexers.cshtml +++ b/NzbDrone.Web/Views/Settings/Indexers.cshtml @@ -2,8 +2,8 @@ @model NzbDrone.Web.Models.IndexerSettingsModel @{ Layout = "~/Views/Shared/_RefrenceLayout.cshtml"; } @section HeaderContent{ - - + @Html.IncludeCss("Settings.css") + @Html.IncludeCss("IndexerSettings.css")