public IActionResult Index(HtmlMinificationViewModel model)
        {
            if (ModelState.IsValid)
            {
                model = _minificationService.Minify(model);

                ModelState.Clear();
            }

            return(View(model));
        }
Exemple #2
0
        public HtmlMinificationViewModel GetInitializationData()
        {
            var settings = Mapper.Map <HtmlMinificationSettingsViewModel>(new HtmlMinificationSettings());
            var model    = new HtmlMinificationViewModel
            {
                SourceCode = string.Empty,
                Settings   = settings,
                Result     = null
            };

            return(model);
        }
Exemple #3
0
        public HtmlMinificationViewModel Minify(HtmlMinificationViewModel model)
        {
            string cssMinifierName = model.Settings.CssMinifierName;
            string jsMinifierName  = model.Settings.JsMinifierName;

            var          settings    = Mapper.Map <HtmlMinificationSettings>(model.Settings);
            ICssMinifier cssMinifier = _cssMinifierFactory.CreateMinifier(cssMinifierName);
            IJsMinifier  jsMinifier  = _jsMinifierFactory.CreateMinifier(jsMinifierName);

            var htmlMinifier = new HtmlMinifier(settings, cssMinifier, jsMinifier);
            var result       = htmlMinifier.Minify(model.SourceCode, true);

            model.Result = Mapper.Map <MarkupMinificationResultViewModel>(result);

            return(model);
        }