Full static content (css,js) versioning.

pull/6/head
kay.one 13 years ago
parent 25ecd45d9b
commit 9f07d7c27a

@ -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("<script type='text/javascript' src='{0}?{1}'></script>", relativePath, _versionString));
}
public static MvcHtmlString IncludeCss(this HtmlHelper helper, string filename)
{
var relativePath = "/Content/" + filename;
VerifyFile(helper, relativePath);
return MvcHtmlString.Create(String.Format("<link type='text/css' rel='stylesheet' href='{0}?{1}'/>", 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);
}
}
}
}
}

@ -218,6 +218,7 @@
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
<Compile Include="Helpers\HtmlIncludeExtentions.cs" />
<Compile Include="Helpers\ValueExtension.cs" />
<Compile Include="Helpers\DescriptionExtension.cs" />
<Compile Include="Helpers\HtmlPrefixScopeExtensions.cs" />

@ -1,9 +1,10 @@
@section TitleContent{
@using NzbDrone.Web.Helpers
@section TitleContent{
Add Series
}
@section Scripts
{
<script type="text/javascript" src="../../Scripts/NzbDrone/addSeries.js"></script>
@Html.IncludeScript("NzbDrone/addSeries.js")
}
@{Html.RenderAction("RootDir");}
<div class="jquery-accordion">
@ -17,4 +18,4 @@ Add Series
<div>
@{ Html.RenderAction("ExistingSeries", "AddSeries"); }
</div>
</div>
</div>

@ -1,5 +1,6 @@
@model List<NzbDrone.Web.Models.HistoryModel>
@using NzbDrone.Web.Models
@using NzbDrone.Web.Helpers
@section TitleContent{
History
}
@ -9,7 +10,10 @@ History
<li>@Ajax.ActionLink("Purge History", "Purge", "History", new AjaxOptions { OnSuccess = "reloadHistoryGrid" })</li>
</ul>
}
<link href="../../Content/Grid.css" rel="stylesheet" type="text/css" />
@section HeaderContent
{
@Html.IncludeCss("Grid.css")
}
<div class="grid-container">
@{Html.Telerik().Grid<HistoryModel>().Name("history")
.TableHtmlAttributes(new { @class = "Grid" })
@ -49,7 +53,6 @@ History
c.PageSize(20).Position(GridPagerPosition.Bottom).Style(GridPagerStyles.NextPrevious))
.Render();}
</div>
<script type="text/javascript">
deleteHistoryRowUrl = '../History/Delete';
redownloadUrl = '../History/Redownload';

@ -1,9 +1,13 @@
@model List<MissingEpisodeModel>
@using NzbDrone.Web.Helpers
@using NzbDrone.Web.Models;
@section TitleContent{
Missing
}
<link href="../../Content/Grid.css" rel="stylesheet" type="text/css" />
@section HeaderContent
{
@Html.IncludeCss("Grid.css")
}
@section ActionMenu{
<ul class="sub-menu">
<li>@Ajax.ActionLink("Start RSS Sync", "RssSync", "Command", null, null)</li>

@ -1,9 +1,13 @@
@model SeriesModel
@using NzbDrone.Web.Helpers
@using NzbDrone.Web.Models
@section TitleContent{
@Model.Title
}
<link href="../../Content/Grid.css" rel="stylesheet" type="text/css" />
@section HeaderContent
{
@Html.IncludeCss("Grid.css")
}
<style>
.seasonToggleTopGroup
{
@ -131,7 +135,7 @@
.Render();
}
@section Scripts{
<script src="../../Scripts/NzbDrone/seriesDetails.js" type="text/javascript"></script>
@Html.IncludeScript("NzbDrone/seriesDetails.js")
<script type="text/javascript">
seriesId = @Model.SeriesId;
</script>

@ -1,11 +1,13 @@
@using NzbDrone.Web.Helpers;
@using NzbDrone.Web.Models;
@model NzbDrone.Web.Models.SeriesModel
@{
Layout = null;
}
<link rel="stylesheet" type="text/css" href="../../../Content/Settings.css" />
@section HeaderContent
{
@Html.IncludeCss("Settings.css")
}
<div id="stylized" style="border-color: transparent;">
<div class="settingsForm clearfix">

@ -2,8 +2,8 @@
@model NzbDrone.Web.Models.IndexerSettingsModel
@{ Layout = "~/Views/Shared/_RefrenceLayout.cshtml"; }
@section HeaderContent{
<link rel="stylesheet" type="text/css" href="../../Content/Settings.css" />
<link rel="stylesheet" type="text/css" href="../../Content/IndexerSettings.css" />
@Html.IncludeCss("Settings.css")
@Html.IncludeCss("IndexerSettings.css")
<style>
.indexerPanel
{

@ -2,7 +2,7 @@
@model NzbDrone.Web.Models.EpisodeNamingModel
@{ Layout = "~/Views/Shared/_RefrenceLayout.cshtml"; }
@section HeaderContent{
<link rel="stylesheet" type="text/css" href="../../Content/Settings.css" />
@Html.IncludeCss("Settings.css")
<style>
#examples
{
@ -73,7 +73,6 @@
}
</div>
@section Scripts{
<script type="text/javascript">
$(document).ready(function () {
createExamples();

@ -1,6 +1,4 @@
@model NzbDrone.Core.Repository.NewznabDefinition
@using System.Collections
@using NzbDrone.Core.Repository.Quality
@using NzbDrone.Web.Helpers
@{
Layout = null;

@ -1,7 +1,8 @@
@model NzbDrone.Web.Models.NotificationSettingsModel
@using NzbDrone.Web.Helpers
@model NzbDrone.Web.Models.NotificationSettingsModel
@{ Layout = "~/Views/Shared/_RefrenceLayout.cshtml"; }
@section HeaderContent{
<link rel="stylesheet" type="text/css" href="../../Content/Settings.css" />
@Html.IncludeCss("Settings.css")
<style>
.notifier
{

@ -3,8 +3,8 @@
@model NzbDrone.Web.Models.QualityModel
@{ Layout = "~/Views/Shared/_RefrenceLayout.cshtml"; }
@section HeaderContent{
<link rel="stylesheet" type="text/css" href="../../Content/Settings.css" />
<link href="../../Content/QualitySettings.css" rel="stylesheet" type="text/css" />
@Html.IncludeCss("Settings.css")
@Html.IncludeCss("QualitySettings.css")
}
<div id="stylized">
@using (Html.BeginForm("SaveQuality", "Settings", FormMethod.Post, new { id = "QualityForm", name = "QualityForm" }))
@ -17,7 +17,8 @@
</div>
<div class="jquery-accordion">
<h3><a href="#">Sizes</a></h3>
<h3>
<a href="#">Sizes</a></h3>
<div class="sliders">
<div class="slider-container">
<b>SDTV</b>
@ -68,7 +69,8 @@
</span>
</div>
</div>
<h3><a href="#">Profiles</a></h3>
<h3>
<a href="#">Profiles</a></h3>
<div id="profileContainer">
<div id="profileHeader">
<a id="addItem" href="@Url.Action("AddProfile", "Settings")">
@ -86,19 +88,19 @@
<br />
<button type="submit" class="save_button" disabled="disabled">Save</button>
<button type="submit" class="save_button" disabled="disabled">
Save</button>
}
</div>
@section Scripts{
<script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script>
@Html.IncludeScript("MicrosoftAjax.js")
<script type="text/javascript">
var deleteQualityProfileUrl = '@Url.Action("DeleteQualityProfile", "Settings")';
$('.quality-selectee').livequery(function () {
$(this).button();
});
$(document).ready(function () {
setupSliders();
});

@ -2,7 +2,7 @@
@model NzbDrone.Web.Models.SabnzbdSettingsModel
@{ Layout = "~/Views/Shared/_RefrenceLayout.cshtml"; }
@section HeaderContent{
<link rel="stylesheet" type="text/css" href="../../Content/Settings.css" />
@Html.IncludeCss("Settings.css")
}
<div id="stylized">
@using (Html.BeginForm("SaveSabnzbd", "Settings", FormMethod.Post, new { id = "SabForm", name = "SabForm", @class = "settingsForm" }))

@ -3,7 +3,7 @@
@{ Layout = "~/Views/Shared/_RefrenceLayout.cshtml"; }
@section HeaderContent{
<link rel="stylesheet" type="text/css" href="../../Content/Settings.css" />
@Html.IncludeCss("Settings.css")
}
<div id="stylized">
@using (Html.BeginForm("SaveSystem", "Settings", FormMethod.Post, new { id = "SystemForm", name = "SystemForm", @class = "settingsForm" }))

@ -1,39 +1,40 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
@using NzbDrone.Web.Helpers
@using Telerik.Web.Mvc.UI
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<link rel="SHORTCUT ICON" href="../../favicon.ico" />
<title>NzbDrone</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link type="text/css" rel="stylesheet" href="../../Content/2011.3.1115/telerik.common.min.css" />
<link type="text/css" rel="stylesheet" href="../../Content/2011.3.1115/telerik.sitefinity.min.css" />
<link type="text/css" rel="stylesheet" href="../../Content/jQueryUI/jquery-ui-1.8.16.custom.css" />
<link type="text/css" rel="stylesheet" href="../../Content/jquery.gritter.css" />
<link type="text/css" rel="stylesheet" href="../../Content/NzbDrone.css" />
<link type="text/css" rel="stylesheet" href="../../Content/ActionButton.css" />
<link type="text/css" rel="stylesheet" href="../../Content/overrides.css" />
<link type="text/css" rel="stylesheet" href="../../Content/Menu.css" />
<link type="text/css" rel="stylesheet" href="../../Content/Messages.css" />
@Html.IncludeCss("2011.3.1115/telerik.common.min.css")
@Html.IncludeCss("2011.3.1115/telerik.sitefinity.min.css")
@Html.IncludeCss("jQueryUI/jquery-ui-1.8.16.custom.css")
@Html.IncludeCss("jquery.gritter.css")
@Html.IncludeCss("NzbDrone.css")
@Html.IncludeCss("ActionButton.css")
@Html.IncludeCss("overrides.css")
@Html.IncludeCss("Menu.css")
@Html.IncludeCss("Messages.css")
@RenderSection("HeaderContent", required: false)
</head>
<body>
@RenderBody()
@(Html.Telerik().ScriptRegistrar().jQuery(true))
<script type="text/javascript" src="../../Scripts/jquery-ui-1.8.16.min.js"></script>
<script type="text/javascript" src="../../Scripts/jquery.livequery.js"></script>
<script type="text/javascript" src="../../Scripts/MicrosoftAjax.js"></script>
<script type="text/javascript" src="../../Scripts/MicrosoftMvcAjax.js"></script>
<script type="text/javascript" src="../../Scripts/jquery.gritter.js"></script>
<script type="text/javascript" src="../../Scripts/jquery.form.js"></script>
<script type="text/javascript" src="../../Scripts/jquery-tgc-countdown-1.0.js"></script>
<script type="text/javascript" src="../../Scripts/jquery.watermark.min.js"></script>
<script type="text/javascript" src="../../Scripts/jquery.hotkeys.js"></script>
<script type="text/javascript" src="../../Scripts/doTimeout.js"></script>
<script type="text/javascript" src="../../Scripts/NzbDrone/episodeSearch.js"></script>
<script type="text/javascript" src="../../Scripts/NzbDrone/AutoComplete.js"></script>
<script type="text/javascript" src="../../Scripts/NzbDrone/LocalSearch.js"></script>
<script type="text/javascript" src="../../Scripts/NzbDrone/Notification.js"></script>
<script type="text/javascript" src="../../Scripts/NzbDrone/AutoBind.js"></script>
@Html.IncludeScript("jquery-ui-1.8.16.min.js")
@Html.IncludeScript("jquery.livequery.js")
@Html.IncludeScript("MicrosoftAjax.js")
@Html.IncludeScript("MicrosoftMvcAjax.js")
@Html.IncludeScript("jquery.gritter.js")
@Html.IncludeScript("jquery.form.js")
@Html.IncludeScript("jquery-tgc-countdown-1.0.js")
@Html.IncludeScript("jquery.watermark.min.js")
@Html.IncludeScript("jquery.hotkeys.js")
@Html.IncludeScript("doTimeout.js")
@Html.IncludeScript("NzbDrone/episodeSearch.js")
@Html.IncludeScript("NzbDrone/AutoComplete.js")
@Html.IncludeScript("NzbDrone/LocalSearch.js")
@Html.IncludeScript("NzbDrone/Notification.js")
@Html.IncludeScript("NzbDrone/AutoBind.js")
@RenderSection("Scripts", required: false)
</body>
</html>

@ -1,9 +1,13 @@
@model List<NzbDrone.Web.Models.UpcomingEpisodeModel>
@model List<UpcomingEpisodeModel>
@using NzbDrone.Web.Helpers
@using NzbDrone.Web.Models
@section TitleContent{
Upcoming
}
<link href="../../Content/Grid.css" rel="stylesheet" type="text/css" />
@section HeaderContent
{
@Html.IncludeCss("Grid.css")
}
@section ActionMenu{
<ul class="sub-menu">
<li>@Ajax.ActionLink("Start RSS Sync", "RssSync", "Command", null, null)</li>

Loading…
Cancel
Save