fixed a few null reference errors caused by the absence of quotes

This commit is contained in:
tmont 2011-03-03 04:14:32 +00:00
parent 32e647ee0c
commit 91dad73a4e
3 changed files with 6 additions and 10 deletions

View File

@ -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));
}

View File

@ -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<Region, FlagEnumModelBinder<Region>>()
.Add<BrowseModel, BrowseModelBinder>()
.Add<ApiModel, ApiModelBinder>();
ViewEngines.Engines.Add(Container.Resolve<SmartCaseViewEngine>());
}
protected override void ConfigureUnity() {
@ -44,13 +41,10 @@ namespace VideoGameQuotes.Web {
}
protected override void AfterStartUp() {
EnableSmartCasing();
Container.Resolve<ISearchIndexBuilder<Quote, int>>().BuildIndex();
}
protected override void OnApplicationEnd() {
Container.Resolve<IndexWriter>().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" });
}

View File

@ -1,6 +1,8 @@
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<VideoGameQuotes.Api.Quote>" %>
<%@ Import Namespace="VideoGameQuotes.Api" %>
<% if (Model == null) { return; } %>
<div class="quote-container">
<div class="quote-data clearfix">
<div class="quote-score-container">