From eb0ffa83b6ed9f18ca27e98a2e959a41e75c43b9 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 17 Feb 2013 19:04:28 -0800 Subject: [PATCH] no more # in the url. --- NzbDrone.Api/FrontendModule/IndexModule.cs | 21 ++++++- NzbDrone.Backbone/Index.html | 61 +++++++++++-------- .../Mixins/backbone.marionette.templates.js | 6 +- NzbDrone.Backbone/NzbDrone.Backbone.csproj | 1 - NzbDrone.Backbone/Routing.js | 2 +- .../Shared/NotificationTemplate.html | 9 --- NzbDrone.Backbone/Shared/NotificationView.js | 2 +- 7 files changed, 62 insertions(+), 40 deletions(-) delete mode 100644 NzbDrone.Backbone/Shared/NotificationTemplate.html diff --git a/NzbDrone.Api/FrontendModule/IndexModule.cs b/NzbDrone.Api/FrontendModule/IndexModule.cs index 0ca2cae38..a89a18e5d 100644 --- a/NzbDrone.Api/FrontendModule/IndexModule.cs +++ b/NzbDrone.Api/FrontendModule/IndexModule.cs @@ -1,5 +1,7 @@ -using System.Linq; +using System; +using System.Linq; using Nancy; +using Nancy.Responses.Negotiation; namespace NzbDrone.Api.FrontendModule { @@ -7,7 +9,22 @@ namespace NzbDrone.Api.FrontendModule { public IndexModule() { - Get[@"/"] = x => View["NzbDrone.Backbone/index.html"]; + //Serve anything that doesn't have an extension + Get[@"/(.*)"] = x => Index(); + } + + private object Index() + { + if( + Request.Path.Contains(".") + || Request.Path.StartsWith("/static", StringComparison.CurrentCultureIgnoreCase) + || Request.Path.StartsWith("/api", StringComparison.CurrentCultureIgnoreCase)) + { + return new NotFoundResponse(); + } + + + return View["NzbDrone.Backbone/index.html"]; } } } \ No newline at end of file diff --git a/NzbDrone.Backbone/Index.html b/NzbDrone.Backbone/Index.html index f5e6ac95e..74e6300a3 100644 --- a/NzbDrone.Backbone/Index.html +++ b/NzbDrone.Backbone/Index.html @@ -9,14 +9,25 @@ - - - - + + + + - + -S +
- - - - - - - - - - - - + + + + + + + + + + + + @* - + *@ - + - - - + + + - - + + diff --git a/NzbDrone.Backbone/Mixins/backbone.marionette.templates.js b/NzbDrone.Backbone/Mixins/backbone.marionette.templates.js index d2253a0d4..ad0c71573 100644 --- a/NzbDrone.Backbone/Mixins/backbone.marionette.templates.js +++ b/NzbDrone.Backbone/Mixins/backbone.marionette.templates.js @@ -6,9 +6,13 @@ var template; console.log("Loading template '" + templateId + "'"); + + if (templateId.startsWith('#')) { + return $(templateId).html(); + } $.ajax({ - url:'static//' + templateId + '.html', + url:'/static/' + templateId + '.html', cache:false, async:false diff --git a/NzbDrone.Backbone/NzbDrone.Backbone.csproj b/NzbDrone.Backbone/NzbDrone.Backbone.csproj index b97f11184..fa66c4b84 100644 --- a/NzbDrone.Backbone/NzbDrone.Backbone.csproj +++ b/NzbDrone.Backbone/NzbDrone.Backbone.csproj @@ -129,7 +129,6 @@ - diff --git a/NzbDrone.Backbone/Routing.js b/NzbDrone.Backbone/Routing.js index 656d61ca9..5a7735475 100644 --- a/NzbDrone.Backbone/Routing.js +++ b/NzbDrone.Backbone/Routing.js @@ -16,7 +16,7 @@ NzbDrone.addInitializer(function () { NzbDrone.Router = new NzbDrone.Router(); - Backbone.history.start(); + Backbone.history.start({ pushState: true }); }); }); diff --git a/NzbDrone.Backbone/Shared/NotificationTemplate.html b/NzbDrone.Backbone/Shared/NotificationTemplate.html deleted file mode 100644 index 69d9faedb..000000000 --- a/NzbDrone.Backbone/Shared/NotificationTemplate.html +++ /dev/null @@ -1,9 +0,0 @@ -
- - {{title}} - {{#if isPreFormatted}} -
{{{preFormattedMessage}}}
- {{else}} - {{message}} - {{/if}} -
diff --git a/NzbDrone.Backbone/Shared/NotificationView.js b/NzbDrone.Backbone/Shared/NotificationView.js index 8c6f470c5..0db0a8a3a 100644 --- a/NzbDrone.Backbone/Shared/NotificationView.js +++ b/NzbDrone.Backbone/Shared/NotificationView.js @@ -1,7 +1,7 @@ define(['app', 'Shared/NotificationCollection'], function (app, notificationCollection) { var notificationItemView = Backbone.Marionette.ItemView.extend({ - template: 'Shared/NotificationTemplate', + template: '#notification-template', events: { 'click .x-close': 'kill'