From 91dad73a4e5f7b0bad6f3ab9808da6daa9aef2ce Mon Sep 17 00:00:00 2001 From: tmont Date: Thu, 3 Mar 2011 04:14:32 +0000 Subject: [PATCH] fixed a few null reference errors caused by the absence of quotes --- Src/VideoGameQuotes.Api/Quote.cs | 2 +- Src/VideoGameQuotes.Web/Global.asax.cs | 12 +++--------- .../Views/Quote/QuoteOfTheDay.ascx | 2 ++ 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Src/VideoGameQuotes.Api/Quote.cs b/Src/VideoGameQuotes.Api/Quote.cs index a127345..8bf62ee 100644 --- a/Src/VideoGameQuotes.Api/Quote.cs +++ b/Src/VideoGameQuotes.Api/Quote.cs @@ -168,7 +168,7 @@ namespace VideoGameQuotes.Api { } 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)); } diff --git a/Src/VideoGameQuotes.Web/Global.asax.cs b/Src/VideoGameQuotes.Web/Global.asax.cs index 526def0..3c26a8a 100644 --- a/Src/VideoGameQuotes.Web/Global.asax.cs +++ b/Src/VideoGameQuotes.Web/Global.asax.cs @@ -1,12 +1,11 @@ using System.Web.Mvc; using System.Web.Routing; -using Lucene.Net.Index; using Microsoft.Practices.Unity; using Portoa.Search; using Portoa.Web; using Portoa.Web.Models; -using Portoa.Web.Routing; using Portoa.Web.Security; +using Portoa.Web.SmartCasing; using Portoa.Web.Unity; using UnityGenerics; using VideoGameQuotes.Api; @@ -23,8 +22,6 @@ namespace VideoGameQuotes.Web { .Add>() .Add() .Add(); - - ViewEngines.Engines.Add(Container.Resolve()); } protected override void ConfigureUnity() { @@ -44,13 +41,10 @@ namespace VideoGameQuotes.Web { } protected override void AfterStartUp() { + EnableSmartCasing(); Container.Resolve>().BuildIndex(); } - protected override void OnApplicationEnd() { - Container.Resolve().Close(); - } - protected override void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("media/{*anything}"); @@ -72,7 +66,7 @@ namespace VideoGameQuotes.Web { 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", "{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("default", "{controller}", new { controller = "Home", action = "Index" }); } diff --git a/Src/VideoGameQuotes.Web/Views/Quote/QuoteOfTheDay.ascx b/Src/VideoGameQuotes.Web/Views/Quote/QuoteOfTheDay.ascx index e97f54b..21ff816 100644 --- a/Src/VideoGameQuotes.Web/Views/Quote/QuoteOfTheDay.ascx +++ b/Src/VideoGameQuotes.Web/Views/Quote/QuoteOfTheDay.ascx @@ -1,6 +1,8 @@ <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> <%@ Import Namespace="VideoGameQuotes.Api" %> +<% if (Model == null) { return; } %> +