Exemple #1
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            // TODO: allow user to configure a default page so we're not hardcoding here
            routes.MapRoute(
                name: "Default1",
                url: "",
                defaults: new { controller = "Home", action = "ViewPage", page = "Index" }
            );

            // enumerate all controllers which implement 'GenericPageController' and register them here
            // TODO: find a better solution that doesn't involve third party code
            var controllers = new Areas.PlexAdmin.Controllers.ControllerController();
            controllers.Index()
                .Where(c => c.IsPageController)
                .ToList()
                .ForEach(c=>{
                    routes.MapRoute(
                        name: "PlexCMS_" + c.ID,
                        url: c.ID + "/{page}",
                        defaults: new { controller = c.ID, action = "ViewPage", page = "Index" }
                    );
                });

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
Exemple #2
0
 public PageController()
 {
     LayoutRegex = new Regex(@"^\s*Layout = "".*/_(?<layout>[^_\.]*)\.cshtml"";" + Environment.NewLine, RegexOptions.Compiled | RegexOptions.Multiline);
     PageSectionRegex = new Regex(@"@section[\s]*(?<section>[^\s]*)[\s\{]*(?<modules>[^\}]*)\}", RegexOptions.Compiled);
     PageModuleRegex = new Regex(@"Html.Partial\(""Modules/_(?<module>[^""]*)"".*\)", RegexOptions.Compiled);
     TitleRegex = new Regex(@"^\s*ViewBag\.Title\s*=\s*""(?<title>[^""]*)""\s*;" + Environment.NewLine, RegexOptions.Compiled | RegexOptions.Multiline);
     Controllers = new ControllerController();
     Layouts = new LayoutController();
     viewsFilepath = Path.GetFullPath(HttpRuntime.BinDirectory + @"..\Views\");
 }