public void OnResultExecuting(ResultExecutingContext filterContext)
        {
            var viewResult = filterContext.Result as ViewResult;

            if (viewResult == null)
            {
                return;
            }

            _resourceManager.Require("stylesheet", ResourceManifest.CoreStyle).AtHead();

            // todo: (pekkah) read the theme from configuration (needs a UI)
            var currentTheme = _syntaxHighlighterService.GetCurrentTheme();

            _resourceManager.Require("stylesheet", currentTheme).AtHead();

            var coreScriptRequire = _resourceManager.Require("script", ResourceManifest.CoreScript).AtHead();

            _resourceManager.Require("script", ResourceManifest.ShAutoloaderScript).AtHead();
            _resourceManager.Require("script", ResourceManifest.AutoloaderScript).AtHead();

            // todo: (pekkah) there probably  is a much better way of getting the scripts path ?
            var coreScriptResource = _resourceManager.FindResource(coreScriptRequire);
            var appPath            = filterContext.HttpContext.Request.ApplicationPath;
            var coreScriptPath     = coreScriptResource.ResolveUrl(coreScriptRequire, appPath).Replace("shCore.js", "");

            // this will activate syntax highlighter using shAutoloader to dynamically load needed brushes.
            _resourceManager.RegisterFootScript(
                "<script type=\"text/javascript\">syntaxHighlight('$scripts$')</script>".Replace("$scripts$",
                                                                                                 coreScriptPath));
        }
示例#2
0
        public ActionResult ChangeTheme()
        {
            var themes = new List <string>();

            themes.AddRange(_syntaxHighlighterService.GetSupportedThemes());

            var currentTheme = _syntaxHighlighterService.GetCurrentTheme();

            var model = new IndexModel()
            {
                Theme  = currentTheme,
                Themes = themes
            };

            return(View(model));
        }