2011-02-26 04:29:21 +00:00
|
|
|
|
using System.Web.Mvc;
|
2011-02-09 03:50:45 +00:00
|
|
|
|
using System.Web.Routing;
|
2011-02-25 23:36:21 +00:00
|
|
|
|
using Lucene.Net.Index;
|
2011-02-10 04:39:59 +00:00
|
|
|
|
using Microsoft.Practices.Unity;
|
2011-02-26 01:08:38 +00:00
|
|
|
|
using Portoa.Search;
|
2011-02-10 04:39:59 +00:00
|
|
|
|
using Portoa.Web;
|
2011-02-13 09:55:01 +00:00
|
|
|
|
using Portoa.Web.Models;
|
2011-03-02 20:18:33 +00:00
|
|
|
|
using Portoa.Web.Routing;
|
2011-02-17 20:55:47 +00:00
|
|
|
|
using Portoa.Web.Security;
|
2011-02-10 04:39:59 +00:00
|
|
|
|
using Portoa.Web.Unity;
|
2011-02-12 23:53:43 +00:00
|
|
|
|
using UnityGenerics;
|
2011-02-10 04:39:59 +00:00
|
|
|
|
using VideoGameQuotes.Api;
|
|
|
|
|
using VideoGameQuotes.Api.Persistence;
|
2011-02-16 02:48:11 +00:00
|
|
|
|
using VideoGameQuotes.Web.Controllers;
|
|
|
|
|
using VideoGameQuotes.Web.Models;
|
2011-02-10 04:39:59 +00:00
|
|
|
|
using VideoGameQuotes.Web.Security;
|
2011-02-12 23:53:43 +00:00
|
|
|
|
using VideoGameQuotes.Web.Services;
|
2011-02-09 03:50:45 +00:00
|
|
|
|
|
|
|
|
|
namespace VideoGameQuotes.Web {
|
2011-02-21 23:59:06 +00:00
|
|
|
|
public class MvcApplication : MvcApplicationBase<User> {
|
2011-02-13 09:55:01 +00:00
|
|
|
|
protected override void ConfigureModelBinders(ModelBinderDictionary binders) {
|
2011-02-16 02:48:11 +00:00
|
|
|
|
binders
|
2011-02-23 01:30:53 +00:00
|
|
|
|
.Add<Region, FlagEnumModelBinder<Region>>()
|
2011-02-16 02:48:11 +00:00
|
|
|
|
.Add<BrowseModel, BrowseModelBinder>()
|
|
|
|
|
.Add<ApiModel, ApiModelBinder>();
|
2011-03-02 23:39:17 +00:00
|
|
|
|
|
|
|
|
|
ViewEngines.Engines.Add(Container.Resolve<SmartCaseViewEngine>());
|
2011-02-13 09:55:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-02-26 04:29:21 +00:00
|
|
|
|
protected override void ConfigureUnity() {
|
2011-02-10 04:39:59 +00:00
|
|
|
|
Container
|
2011-02-21 23:59:06 +00:00
|
|
|
|
.RegisterType<VerifyUserAttribute>(new InjectionProperty<VerifyUserAttribute>(attr => attr.UserProvider))
|
2011-02-25 23:36:21 +00:00
|
|
|
|
.RegisterAndIntercept<ICurrentUserProvider<User>, SessionBasedUserProvider>()
|
|
|
|
|
.RegisterAndIntercept<IUserService, UserService>()
|
|
|
|
|
.RegisterAndIntercept<IAdministrationService, AdministrationService>()
|
|
|
|
|
.RegisterAndIntercept<IQuoteService, QuoteService>()
|
|
|
|
|
.RegisterAndIntercept<ISystemService, SystemService>()
|
|
|
|
|
.RegisterAndIntercept<ICategoryService, CategoryService>()
|
|
|
|
|
.RegisterAndIntercept<IPublisherService, PublisherService>()
|
|
|
|
|
.RegisterAndIntercept<IGameService, GameService>()
|
|
|
|
|
.RegisterAndIntercept<IApiService, ApiService>()
|
|
|
|
|
.RegisterAndIntercept<IAuthenticationService, FormsAuthenticationService>()
|
2011-03-01 07:13:57 +00:00
|
|
|
|
.RegisterAndIntercept<IUserRepository, UserRepository>();
|
2011-02-25 23:36:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-02-17 05:30:31 +00:00
|
|
|
|
protected override void AfterStartUp() {
|
2011-03-02 20:18:33 +00:00
|
|
|
|
Container.Resolve<ISearchIndexBuilder<Quote, int>>().BuildIndex();
|
2011-02-10 04:39:59 +00:00
|
|
|
|
}
|
2011-02-09 03:50:45 +00:00
|
|
|
|
|
2011-02-26 04:29:21 +00:00
|
|
|
|
protected override void OnApplicationEnd() {
|
|
|
|
|
Container.Resolve<IndexWriter>().Close();
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-10 04:39:59 +00:00
|
|
|
|
protected override void RegisterRoutes(RouteCollection routes) {
|
2011-02-09 03:50:45 +00:00
|
|
|
|
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
2011-02-10 04:39:59 +00:00
|
|
|
|
routes.IgnoreRoute("media/{*anything}");
|
2011-02-09 03:50:45 +00:00
|
|
|
|
|
2011-02-28 10:34:46 +00:00
|
|
|
|
routes.MapRoute("favicon", "favicon.ico", new { controller = "Home", action = "Favicon" });
|
|
|
|
|
|
2011-02-17 20:55:47 +00:00
|
|
|
|
//bullshit route so that RenderAction works
|
2011-03-02 20:18:33 +00:00
|
|
|
|
routes.MapSmartRoute("mainmenu", "home/mainmenu", new { controller = "Home", action = "MainMenu" });
|
|
|
|
|
routes.MapSmartRoute("quote-of-the-day", "quote/quoteoftheday", new { controller = "Quote", action = "QuoteOfTheDay" });
|
2011-02-17 20:55:47 +00:00
|
|
|
|
|
2011-03-02 20:18:33 +00:00
|
|
|
|
routes.MapSmartRoute("crud-default", "{controller}/{action}", null, new { controller = "system|publisher|game|category", action = "create|edit|delete" });
|
|
|
|
|
routes.MapSmartRoute("users-paged", "admin/users/{start}-{end}", new { controller = "Admin", action = "Users" }, new { start = @"\d+", end = @"\d+" });
|
|
|
|
|
routes.MapSmartRoute("admin", "admin/{action}", new { controller = "Admin", action = "Index" }, new { action = "users|create|flags|password" });
|
|
|
|
|
routes.MapSmartRoute("user-edit", "user/edit/{usernameOrIp}", new { controller = "User", action = "Edit", usernameOrIp = @"\w+" });
|
|
|
|
|
routes.MapSmartRoute("user-default", "user/{action}/{id}", new { controller = "User", action = "delete|ban", id = UrlParameter.Optional });
|
|
|
|
|
routes.MapSmartRoute("api", "api/{action}/{id}/{*criteria}", new { controller = "Api" }, new { action = "game|system|category|publisher|quote", id = @"\d+|all" });
|
|
|
|
|
routes.MapSmartRoute("home", "{action}", new { controller = "Home", action = "Index" }, new { action = "about|contact|login|logout" });
|
|
|
|
|
routes.MapSmartRoute("paged", "{action}/{page}", new { controller = "Quote", page = 1 }, new { action = "best|recent", page = @"\d+" });
|
|
|
|
|
routes.MapSmartRoute("browse", "browse/{*qualifiers}", new { controller = "Quote", action = "Browse" });
|
|
|
|
|
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", "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" });
|
2011-02-09 03:50:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|