Permalink
Browse files

centralize view/area path definition patterns

add css application in lieu of jquery buttonification
update to use consistently upper case Object for expression functions
added MapMvcAttributeRoutes as test/functionality for third party widgets
  • Loading branch information...
ninianne98 committed Oct 14, 2017
1 parent fb00726 commit eb96b1b5c77445a986ca6df73fee7f0035a32305
@@ -23,6 +23,7 @@ public class RouteConfig {
public const string AdminCtrlr = "CmsAdmin";
public static void RegisterRoutes(RouteCollection routes) {
routes.MapMvcAttributeRoutes();
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
Assembly _assembly = Assembly.GetExecutingAssembly();
@@ -97,6 +97,18 @@
@CarrotCakeHtml.RenderOpenGraph()
@CarrotCakeHtml.IncludeHead()
<script type="text/javascript">
$(document).ready(function () {
$("input:button, input:submit, input:reset, button").removeClass('button').addClass('button');
});
$(document).ajaxComplete(function (event, xhr, settings) {
$("input:button, input:submit, input:reset, button").removeClass('button').addClass('button');
});
</script>
</head>
<body class="@bodyCssClass">
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
/*
* CarrotCake CMS (MVC5)
* http://www.carrotware.com/
*
* Copyright 2015, Samantha Copeland
* Dual licensed under the MIT or GPL Version 3 licenses.
*
* Date: August 2015
*/
namespace Carrotware.CMS.Interface {
public class BaseWidgetAreaAttrRouteReg : BaseWidgetAreaReg {
public override void RegisterArea(AreaRegistrationContext context) {
context.Routes.MapMvcAttributeRoutes();
base.RegisterArea(context);
}
}
}
@@ -44,12 +44,16 @@ public BaseWidgetAreaReg(string areaName)
}
public override void RegisterArea(AreaRegistrationContext context) {
context.MapRoute(
string nsp = typeof(BaseWidgetAreaReg).Namespace;
if (this.AreaName.ToLowerInvariant() != nsp.ToLowerInvariant()) {
context.MapRoute(
name: this.AreaName + "_Default",
url: this.AreaName + "/{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
namespaces: _namespaces.ToArray()
);
}
}
}
}
@@ -113,6 +113,7 @@
<ItemGroup>
<Compile Include="AdminModuleData.cs" />
<Compile Include="BaseWidgetAreaReg.cs" />
<Compile Include="BaseWidgetAreaAttrRouteReg.cs" />
<Compile Include="ViewEngines\CarrotViewEngineWidgetAdmin.cs" />
<Compile Include="ViewEngines\CarrotViewEngineWidget.cs" />
<Compile Include="ViewEngines\CarrotViewEngineBase.cs" />
@@ -26,6 +26,36 @@ public abstract class CarrotViewEngineBase : RazorViewEngine {
this.AreaPartialViewLocationFormats = areas;
}
protected enum ViewPathType {
Area,
View,
}
protected string[] GetPaths(ViewPathType vpt) {
string[] viewPaths = null;
string prefix = String.Empty;
switch (vpt) {
case ViewPathType.Area:
prefix = "~/Areas/::KEY::/Views/";
break;
case ViewPathType.View:
prefix = "~/Views/::KEY::/";
break;
}
viewPaths = new[] {
prefix + "{0}.cshtml",
prefix + "{0}.vbhtml",
prefix + "{1}/{0}.cshtml",
prefix + "{1}/{0}.vbhtml",
prefix + "Shared/{0}.cshtml",
prefix + "Shared/{0}.vbhtml"};
return viewPaths;
}
protected virtual string ReplacePath(ControllerContext controllerContext, string viewPath) {
return "~/Views/Shared/__";
}
@@ -30,21 +30,9 @@ public class CarrotViewEngineDyn : CarrotViewEngineBase {
public CarrotViewEngineDyn()
: base() {
string[] views = new[] {
"~/Views/::KEY::/{0}.cshtml",
"~/Views/::KEY::/{0}.vbhtml",
"~/Views/::KEY::/{1}/{0}.cshtml",
"~/Views/::KEY::/{1}/{0}.vbhtml",
"~/Views/::KEY::/Shared/{0}.cshtml",
"~/Views/::KEY::/Shared/{0}.vbhtml"};
string[] views = GetPaths(ViewPathType.View);
string[] areas = new[] {
"~/Areas/::KEY::/Views/{0}.cshtml",
"~/Areas/::KEY::/Views/{0}.vbhtml",
"~/Areas/::KEY::/Views/{1}/{0}.cshtml",
"~/Areas/::KEY::/Views/{1}/{0}.vbhtml",
"~/Areas/::KEY::/Views/Shared/{0}.cshtml",
"~/Areas/::KEY::/Views/Shared/{0}.vbhtml"};
string[] areas = GetPaths(ViewPathType.Area);
this.LoadPaths(views, areas);
}
@@ -18,21 +18,9 @@ public class CarrotViewEngineWidget : CarrotViewEngineBase {
public CarrotViewEngineWidget()
: base() {
string[] views = new[] {
"~/Views/::KEY::/{0}.cshtml",
"~/Views/::KEY::/{0}.vbhtml",
"~/Views/::KEY::/{1}/{0}.cshtml",
"~/Views/::KEY::/{1}/{0}.vbhtml",
"~/Views/::KEY::/Shared/{0}.cshtml",
"~/Views/::KEY::/Shared/{0}.vbhtml"};
string[] views = GetPaths(ViewPathType.View);
string[] areas = new[] {
"~/Areas/::KEY::/Views/{0}.cshtml",
"~/Areas/::KEY::/Views/{0}.vbhtml",
"~/Areas/::KEY::/Views/{1}/{0}.cshtml",
"~/Areas/::KEY::/Views/{1}/{0}.vbhtml",
"~/Areas/::KEY::/Views/Shared/{0}.cshtml",
"~/Areas/::KEY::/Views/Shared/{0}.vbhtml"};
string[] areas = GetPaths(ViewPathType.Area);
this.LoadPaths(views, areas);
}
@@ -18,21 +18,9 @@ public class CarrotViewEngineWidgetAdmin : CarrotViewEngineBase {
public CarrotViewEngineWidgetAdmin()
: base() {
string[] views = new[] {
"~/Views/::KEY::/{0}.cshtml",
"~/Views/::KEY::/{0}.vbhtml",
"~/Views/::KEY::/{1}/{0}.cshtml",
"~/Views/::KEY::/{1}/{0}.vbhtml",
"~/Views/::KEY::/Shared/{0}.cshtml",
"~/Views/::KEY::/Shared/{0}.vbhtml"};
string[] views = GetPaths(ViewPathType.View);
string[] areas = new[] {
"~/Areas/::KEY::/Views/{0}.cshtml",
"~/Areas/::KEY::/Views/{0}.vbhtml",
"~/Areas/::KEY::/Views/{1}/{0}.cshtml",
"~/Areas/::KEY::/Views/{1}/{0}.vbhtml",
"~/Areas/::KEY::/Views/Shared/{0}.cshtml",
"~/Areas/::KEY::/Views/Shared/{0}.vbhtml"};
string[] areas = GetPaths(ViewPathType.Area);
this.LoadPaths(views, areas);
}
@@ -9,6 +9,7 @@
namespace Northwind {
public class RouteConfig {
public static void RegisterRoutes(RouteCollection routes) {
routes.MapMvcAttributeRoutes();
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
Assembly _assembly = Assembly.GetExecutingAssembly();
@@ -1,12 +1,7 @@
using Carrotware.CMS.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Northwind {
public class NorthRegistration : BaseWidgetAreaReg {
public class NorthRegistration : BaseWidgetAreaAttrRouteReg {
}
}
@@ -10,6 +10,7 @@ namespace CarrotCake.CMS.Plugins.CalendarModule {
public class RouteConfig {
public static void RegisterRoutes(RouteCollection routes) {
routes.MapMvcAttributeRoutes();
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
Assembly _assembly = Assembly.GetExecutingAssembly();
@@ -1,9 +1,7 @@
using Carrotware.CMS.Interface;
using System;
namespace CarrotCake.CMS.Plugins.CalendarModule {
public class CalendarModuleRegistration : BaseWidgetAreaReg {
public class CalendarModuleRegistration : BaseWidgetAreaAttrRouteReg {
}
}
@@ -10,6 +10,7 @@ namespace CarrotCake.CMS.Plugins.FAQ2 {
public class RouteConfig {
public static void RegisterRoutes(RouteCollection routes) {
routes.MapMvcAttributeRoutes();
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
Assembly _assembly = Assembly.GetExecutingAssembly();
@@ -1,7 +1,4 @@
using Carrotware.CMS.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
namespace CarrotCake.CMS.Plugins.FAQ2.Code {
@@ -10,6 +10,7 @@ namespace CarrotCake.CMS.Plugins.PhotoGallery {
public class RouteConfig {
public static void RegisterRoutes(RouteCollection routes) {
routes.MapMvcAttributeRoutes();
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
Assembly _assembly = Assembly.GetExecutingAssembly();
@@ -1,7 +1,4 @@
using Carrotware.CMS.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
namespace CarrotCake.CMS.Plugins.PhotoGallery.Code {
@@ -88,7 +88,7 @@ public static class CarrotWeb {
return grid;
}
public static string DisplayNameFor<T>(Expression<Func<T, object>> expression) {
public static string DisplayNameFor<T>(Expression<Func<T, Object>> expression) {
string propertyName = String.Empty;
PropertyInfo propInfo = null;
Type type = null;
@@ -21,15 +21,15 @@ public PagedData()
: base() {
}
public void InitOrderByDescending(Expression<Func<T, object>> field) {
public void InitOrderByDescending(Expression<Func<T, Object>> field) {
InitOrderBy(field, false);
}
public void InitOrderBy(Expression<Func<T, object>> field) {
public void InitOrderBy(Expression<Func<T, Object>> field) {
InitOrderBy(field, true);
}
public void InitOrderBy(Expression<Func<T, object>> field, bool ascending) {
public void InitOrderBy(Expression<Func<T, Object>> field, bool ascending) {
MemberExpression memberExpression = field.Body as MemberExpression ??
((UnaryExpression)field.Body).Operand as MemberExpression;
@@ -132,7 +132,7 @@ orderby i.Name
return String.Empty;
}
public static PropertyInfo PropInfoFromExpression<T>(this T source, Expression<Func<T, object>> expression) {
public static PropertyInfo PropInfoFromExpression<T>(this T source, Expression<Func<T, Object>> expression) {
string propertyName = String.Empty;
PropertyInfo propInfo = null;

0 comments on commit eb96b1b

Please sign in to comment.