fixed a few null reference errors caused by the absence of quotes
This commit is contained in:
parent
32e647ee0c
commit
91dad73a4e
@ -168,7 +168,7 @@ namespace VideoGameQuotes.Api {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static string GetUrlFriendlyText(this Quote quote) {
|
public static string GetUrlFriendlyText(this Quote quote) {
|
||||||
var text = urlFriendlyRegex.Replace(quote.Text.Replace(" ", "_").Replace("\n", ""), "");
|
var text = urlFriendlyRegex.Replace(quote.Text.ToLowerInvariant().Replace(" ", "-").Replace("\n", ""), "");
|
||||||
return text.Substring(0, Math.Min(text.Length, 50));
|
return text.Substring(0, Math.Min(text.Length, 50));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using System.Web.Routing;
|
using System.Web.Routing;
|
||||||
using Lucene.Net.Index;
|
|
||||||
using Microsoft.Practices.Unity;
|
using Microsoft.Practices.Unity;
|
||||||
using Portoa.Search;
|
using Portoa.Search;
|
||||||
using Portoa.Web;
|
using Portoa.Web;
|
||||||
using Portoa.Web.Models;
|
using Portoa.Web.Models;
|
||||||
using Portoa.Web.Routing;
|
|
||||||
using Portoa.Web.Security;
|
using Portoa.Web.Security;
|
||||||
|
using Portoa.Web.SmartCasing;
|
||||||
using Portoa.Web.Unity;
|
using Portoa.Web.Unity;
|
||||||
using UnityGenerics;
|
using UnityGenerics;
|
||||||
using VideoGameQuotes.Api;
|
using VideoGameQuotes.Api;
|
||||||
@ -23,8 +22,6 @@ namespace VideoGameQuotes.Web {
|
|||||||
.Add<Region, FlagEnumModelBinder<Region>>()
|
.Add<Region, FlagEnumModelBinder<Region>>()
|
||||||
.Add<BrowseModel, BrowseModelBinder>()
|
.Add<BrowseModel, BrowseModelBinder>()
|
||||||
.Add<ApiModel, ApiModelBinder>();
|
.Add<ApiModel, ApiModelBinder>();
|
||||||
|
|
||||||
ViewEngines.Engines.Add(Container.Resolve<SmartCaseViewEngine>());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ConfigureUnity() {
|
protected override void ConfigureUnity() {
|
||||||
@ -44,13 +41,10 @@ namespace VideoGameQuotes.Web {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected override void AfterStartUp() {
|
protected override void AfterStartUp() {
|
||||||
|
EnableSmartCasing();
|
||||||
Container.Resolve<ISearchIndexBuilder<Quote, int>>().BuildIndex();
|
Container.Resolve<ISearchIndexBuilder<Quote, int>>().BuildIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnApplicationEnd() {
|
|
||||||
Container.Resolve<IndexWriter>().Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void RegisterRoutes(RouteCollection routes) {
|
protected override void RegisterRoutes(RouteCollection routes) {
|
||||||
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
||||||
routes.IgnoreRoute("media/{*anything}");
|
routes.IgnoreRoute("media/{*anything}");
|
||||||
@ -72,7 +66,7 @@ namespace VideoGameQuotes.Web {
|
|||||||
routes.MapSmartRoute("search", "Search/{*searchQuery}", new { controller = "Quote", action = "Search" });
|
routes.MapSmartRoute("search", "Search/{*searchQuery}", new { controller = "Quote", action = "Search" });
|
||||||
routes.MapSmartRoute("quote-task", "Quote/{action}/{id}", new { controller = "Quote" }, new { action = "Edit", id = @"\d+" });
|
routes.MapSmartRoute("quote-task", "Quote/{action}/{id}", new { controller = "Quote" }, new { action = "Edit", id = @"\d+" });
|
||||||
routes.MapSmartRoute("quote", "{action}", new { controller = "Quote" }, new { action = "Submit|Recent|Random|Vote|Flag" });
|
routes.MapSmartRoute("quote", "{action}", new { controller = "Quote" }, new { action = "Submit|Recent|Random|Vote|Flag" });
|
||||||
routes.MapSmartRoute("dismiss-flag", "DismissFlag", new { controller = "Quote", action = "DismissFlag" });
|
routes.MapSmartRoute("dismiss-flag", "dismiss-flag", new { controller = "Quote", action = "DismissFlag" });
|
||||||
routes.MapSmartRoute("individual-quote", "Quote/{id}/{*text}", new { controller = "Quote", action = "Quote" }, new { id = @"\d+" });
|
routes.MapSmartRoute("individual-quote", "Quote/{id}/{*text}", new { controller = "Quote", action = "Quote" }, new { id = @"\d+" });
|
||||||
routes.MapSmartRoute("default", "{controller}", new { controller = "Home", action = "Index" });
|
routes.MapSmartRoute("default", "{controller}", new { controller = "Home", action = "Index" });
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<VideoGameQuotes.Api.Quote>" %>
|
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<VideoGameQuotes.Api.Quote>" %>
|
||||||
<%@ Import Namespace="VideoGameQuotes.Api" %>
|
<%@ Import Namespace="VideoGameQuotes.Api" %>
|
||||||
|
|
||||||
|
<% if (Model == null) { return; } %>
|
||||||
|
|
||||||
<div class="quote-container">
|
<div class="quote-container">
|
||||||
<div class="quote-data clearfix">
|
<div class="quote-data clearfix">
|
||||||
<div class="quote-score-container">
|
<div class="quote-score-container">
|
||||||
|
Loading…
Reference in New Issue
Block a user