Ejemplo n.º 1
0
        private string CssPathWithoutVersion(ModuleRouteLibrary moduleRouteLibrary, string fileName)
        {
            fileName = Path.GetFileNameWithoutExtension(fileName);
            var virtualPath = moduleRouteLibrary.CssFile(fileName);

            return(virtualPath);
        }
Ejemplo n.º 2
0
        public IEnumerable <AdminModule> GetModules()
        {
            foreach (var userArea in _userAreaRepository.GetAll())
            {
                var routeLibrary = new ModuleRouteLibrary(SlugFormatter.ToSlug(userArea.Name) + "-users");

                var module = new AdminModule()
                {
                    AdminModuleCode = "COFUSR" + userArea.UserAreaCode,
                    Title           = userArea.Name + " Users",
                    Description     = "Manage users in the " + userArea.Name + " user area.",
                    MenuCategory    = AdminModuleMenuCategory.Settings,
                    PrimaryOrdering = AdminModuleMenuPrimaryOrdering.Secondry,
                    Url             = routeLibrary.CreateAngularRoute()
                };

                if (userArea is CofoundryAdminUserArea)
                {
                    module.RestrictedToPermission = new CofoundryUserAdminModulePermission();
                }
                else
                {
                    module.RestrictedToPermission = new NonCofoundryUserAdminModulePermission();
                }

                yield return(module);
            }
        }
Ejemplo n.º 3
0
 public ModuleStaticContentRouteLibrary(
     ModuleRouteLibrary moduleRouteLibrary
     )
 {
     _moduleRouteLibrary = moduleRouteLibrary;
     EmbeddedResourceRegistrationPath = _moduleRouteLibrary.ResourcePrefix + "content";
 }
Ejemplo n.º 4
0
 public ModuleJsRouteLibrary(
     ModuleRouteLibrary moduleRouteLibrary
     )
 {
     _moduleRouteLibrary     = moduleRouteLibrary;
     AngularModuleIdentifier = TextFormatter.Camelize(moduleRouteLibrary.ModuleFolderName);
     AngularModuleName       = "cms." + AngularModuleIdentifier;
     JsFolderPath            = _moduleRouteLibrary.ResourcePrefix + "js";
     MvcViewFolderPath       = _moduleRouteLibrary.ResourcePrefix + "mvc/views";
 }
Ejemplo n.º 5
0
        public AngularScriptRoutes(ModuleRouteLibrary moduleRouteLibrary)
        {
            AngularModuleIdentifier = TextFormatter.Camelize(moduleRouteLibrary.ModuleFolderName);
            AngularModuleName       = "cms." + AngularModuleIdentifier;

            var jsPrefix = moduleRouteLibrary.ModuleFolderName.ToLowerInvariant();

            MainScriptName     = jsPrefix;
            TemplateScriptName = jsPrefix + "_templates";
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Gets a collection of css tags for all the files in the css
        /// directory of the specified route library.
        /// </summary>
        /// <param name="moduleRouteLibrary">Route library containg the path to find css files in.</param>
        public IEnumerable <HtmlString> CssTagsForDirectory(ModuleRouteLibrary moduleRouteLibrary)
        {
            var directoryScripts = _staticResourceFileProvider
                                   .GetDirectoryContents(moduleRouteLibrary.CssDirectory())
                                   .Select(f => ReduceResourceName(f.Name))
                                   .Distinct();

            var formattedScripts = directoryScripts
                                   .Select(f => CssTag(moduleRouteLibrary, "css/" + f));

            return(formattedScripts);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Returns a script tag with an application relative path to a js file in the conventional
        /// '[modulepath]/Content/js' directory if it exists, otherwise an empty HtmlString is returned.
        /// The path is automatically versioned e.g. 'myfile.js?v=uniquehash. The renderer first checks
        /// for a minified file by appending '_min' to the filename and will use that file unless
        /// DebugSettings.UseUncompressedResources is set to true.
        /// </summary>
        /// <param name="moduleRouteLibrary">Route library for the module to render the script for.</param>
        /// <param name="fileName">The javascript filename without a .js extension.</param>
        public HtmlString ScriptTagIfExists(ModuleRouteLibrary moduleRouteLibrary, string fileName)
        {
            var jsPath = JsPathWithoutVersion(moduleRouteLibrary, fileName);

            if (!FileExists(jsPath))
            {
                return(HtmlString.Empty);
            }

            var jsPathWithVersion = _staticFilePathFormatter.AppendVersion(jsPath);

            return(FormatScriptTag(jsPathWithVersion));
        }
        public void RegisterRoutes(RouteCollection routes)
        {
            var controllerNamespace = new string[] { typeof(CustomEntityModuleController).Namespace };

            foreach (var definition in _customEntityModuleDefinition)
            {
                var routePrefix    = SlugFormatter.ToSlug(definition.NamePlural);
                var routeLibrary   = new ModuleRouteLibrary(routePrefix);
                var jsRouteLibrary = new ModuleJsRouteLibrary(routeLibrary);

                routes.MapRoute(
                    "Custom Entity Admin Module - " + definition.NamePlural,
                    RouteConstants.AdminAreaPrefix + "/" + routePrefix,
                    new { controller = "CustomEntityModule", action = "Index", definition = definition, Area = RouteConstants.AdminAreaName },
                    controllerNamespace
                    );
            }
        }
Ejemplo n.º 9
0
        public void RegisterRoutes(RouteCollection routes)
        {
            var controllerNamespace = new string[] { typeof(StandardModuleController).Namespace };

            foreach (var registration in _standardAdminModuleRegistrations)
            {
                ModuleRouteLibrary routeLibrary = GetRouteLibrary(registration);

                var jsRouteLibrary = new ModuleJsRouteLibrary(routeLibrary);

                routes.MapRoute(
                    "Cofoundry Admin Module - " + registration.RoutePrefix,
                    RouteConstants.AdminAreaPrefix + "/" + registration.RoutePrefix,
                    new { controller = "StandardModule", action = "Index", routeLibrary = routeLibrary, Area = RouteConstants.AdminAreaName },
                    controllerNamespace
                    );
            }
        }
Ejemplo n.º 10
0
        public void RegisterRoutes(RouteCollection routes)
        {
            var controllerNamespace = new string[] { typeof(UsersRouteRegistration).Namespace };

            foreach (var userArea in _userAreaRepository.GetAll())
            {
                var routePrefix    = SlugFormatter.ToSlug(userArea.Name);
                var routeLibrary   = new ModuleRouteLibrary(routePrefix);
                var jsRouteLibrary = new ModuleJsRouteLibrary(routeLibrary);

                routes.MapRoute(
                    "Users Cofoundry Admin Module - " + userArea.Name,
                    RouteConstants.AdminAreaPrefix + "/" + routePrefix + "-users",
                    new { controller = "UsersModule", action = "Index", userArea = userArea, Area = RouteConstants.AdminAreaName },
                    controllerNamespace
                    );
            }
        }
        public IEnumerable <AdminModule> GetModules()
        {
            foreach (var definition in _customEntityModuleDefinition)
            {
                var routeLibrary = new ModuleRouteLibrary(SlugFormatter.ToSlug(definition.NamePlural));

                var module = new AdminModule()
                {
                    AdminModuleCode = definition.CustomEntityDefinitionCode,
                    Description     = definition.Description,
                    MenuCategory    = AdminModuleMenuCategory.ManageSite,
                    PrimaryOrdering = AdminModuleMenuPrimaryOrdering.Tertiary,
                    Title           = definition.NamePlural,
                    Url             = routeLibrary.CreateAngularRoute()
                };

                yield return(module);
            }
        }
Ejemplo n.º 12
0
        private ModuleRouteLibrary GetRouteLibrary(IStandardAngularModuleRegistration registration)
        {
            ModuleRouteLibrary routeLibrary;

            if (registration is IInternalAngularModuleRegistration)
            {
                // Internal modules are in a different folder format to prevent name clashes
                routeLibrary = new ModuleRouteLibrary(registration.RoutePrefix, RouteConstants.InternalModuleResourcePathPrefix);
            }
            else if (registration is IPluginAngularModuleRegistration)
            {
                // Internal modules are in a different folder format to prevent name clashes
                routeLibrary = new ModuleRouteLibrary(registration.RoutePrefix, RouteConstants.PluginModuleResourcePathPrefix);
            }
            else
            {
                routeLibrary = new ModuleRouteLibrary(registration.RoutePrefix);
            }

            return(routeLibrary);
        }
Ejemplo n.º 13
0
        private void AddScript(
            List <string> scriptToAddTo,
            ModuleRouteLibrary moduleRouteLibrary,
            string fileName,
            bool checkIfResourceExists = false
            )
        {
            HtmlString script;

            if (checkIfResourceExists)
            {
                script = _staticResourceReferenceRenderer.ScriptTagIfExists(moduleRouteLibrary, fileName);
            }
            else
            {
                script = _staticResourceReferenceRenderer.ScriptTag(moduleRouteLibrary, fileName);
            }
            if (script != null)
            {
                scriptToAddTo.Add(script.ToString());
            }
        }
Ejemplo n.º 14
0
        private string JsPathWithoutVersion(ModuleRouteLibrary moduleRouteLibrary, string fileName)
        {
            fileName = Path.GetFileNameWithoutExtension(fileName);
            string virtualPath = null;

            // check for a minified resource first
            if (!_debugSettings.UseUncompressedResources)
            {
                var minPath = moduleRouteLibrary.JsFile(fileName + "_min");

                if (FileExists(minPath))
                {
                    virtualPath = minPath;
                }
            }

            if (virtualPath == null)
            {
                virtualPath = moduleRouteLibrary.JsFile(fileName);
            }

            return(virtualPath);
        }
Ejemplo n.º 15
0
 public VisualEditorJsRouteLibrary(
     ModuleRouteLibrary moduleRouteLibrary
     )
     : base(moduleRouteLibrary)
 {
 }
Ejemplo n.º 16
0
 public SharedJsRouteLibrary(
     ModuleRouteLibrary moduleRouteLibrary
     )
     : base(moduleRouteLibrary)
 {
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Returns a script tag with an application relative path to a js file in the conventional
        /// '[modulepath]/Content/js' directory. The path is automatically versioned e.g. 'myfile.js?v=uniquehash.
        /// The renderer first checks for a minified file by appending '_min' to the filename and
        /// will use that file unless DebugSettings.UseUncompressedResources is set to true.
        /// </summary>
        /// <param name="moduleRouteLibrary">Route library for the module to render the script for.</param>
        /// <param name="fileName">The javascript filename without a .js extension.</param>
        public HtmlString ScriptTag(ModuleRouteLibrary moduleRouteLibrary, string fileName)
        {
            var jsPath = JsPath(moduleRouteLibrary, fileName);

            return(FormatScriptTag(jsPath));
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Returns an application relative path to a css file in the conventional
        /// '[modulepath]/Content/css' directory. The path is automatically versioned e.g. 'myfile.css?v=uniquehash.
        /// The renderer first checks for a minified file by appending '_min' to the filename and
        /// will use that file unless DebugSettings.UseUncompressedResources is set to true.
        /// </summary>
        /// <param name="moduleRouteLibrary">Route library for the module to render the stylesheet for.</param>
        /// <param name="fileName">The stylesheet filename without a .css extension.</param>
        public string CssPath(ModuleRouteLibrary moduleRouteLibrary, string fileName)
        {
            var virtualPath = CssPathWithoutVersion(moduleRouteLibrary, fileName);

            return(_staticFilePathFormatter.AppendVersion(virtualPath));
        }
Ejemplo n.º 19
0
        public ActionResult Index(ModuleRouteLibrary routeLibrary)
        {
            var jsRouteLibrary = new ModuleJsRouteLibrary(routeLibrary);

            return(View("~/Framework/StandardAngularModules/Routes/index.cshtml", jsRouteLibrary));
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Returns a link tag containing an application relative path to a css file in the conventional
        /// '[modulepath]/Content/css' directory. The path is automatically versioned e.g. 'myfile.css?v=uniquehash.
        /// The renderer first checks for a minified file by appending '_min' to the filename and
        /// will use that file unless DebugSettings.UseUncompressedResources is set to true.
        /// </summary>
        /// <param name="moduleRouteLibrary"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public HtmlString CssTag(ModuleRouteLibrary moduleRouteLibrary, string fileName)
        {
            var cssPath = CssPath(moduleRouteLibrary, fileName);

            return(FormatCssTag(cssPath));
        }
Ejemplo n.º 21
0
 public AuthJSRouteLibrary(
     ModuleRouteLibrary moduleRouteLibrary
     )
     : base(moduleRouteLibrary)
 {
 }