public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (property == null) { return; } EditorGUI.BeginChangeCheck(); Less greaterAttribute = (Less)attribute; int intThreshold = greaterAttribute.intThreshold; EditorGUI.PropertyField(position, property, label); if (property.propertyType == SerializedPropertyType.Integer) { if (property.intValue >= intThreshold) { property.intValue = intThreshold - 1; } } if (EditorGUI.EndChangeCheck()) { property.serializedObject.ApplyModifiedProperties(); } }
public override Task Invoke(IOwinContext context) { var path = FileSystem.MapPath(_options.BasePath, context.Request.Path.Value); var ext = Path.GetExtension(path); if (CanHandle(ext)) { Trace.WriteLine("Invoke LessMiddleware"); context.Response.StatusCode = 200; context.Response.ContentType = MimeTypeService.GetMimeType(".css"); var rawLess = File.ReadAllText(path); var compressed = Less.Parse(rawLess, new DotlessConfiguration { MinifyOutput = true }); context.Response.Write(compressed); return(Globals.CompletedTask); } return(Next.Invoke(context)); }
public static void ToSql(Less expression, StringBuilder builder) { if (null == expression) { throw new ArgumentNullException("expression"); } if (null == builder) { throw new ArgumentNullException("builder"); } if (expression.Operands.Count > 0) { IToken operand1 = expression.Operands .First(); IToken operand2 = expression.Operands .ElementAtOrDefault(1); if (null != operand1 && null != operand2) { operand1.ToSql(builder); builder.Append(" < "); operand2.ToSql(builder); } } }
public void Process(BundleContext context, BundleResponse response) { Directory.SetCurrentDirectory(_path); response.Content = Less.Parse(response.Content); response.ContentType = "text/css"; }
public override ASTNode VisitComparisson([NotNull] CoolParser.ComparissonContext context) { ComparisonOperation operators; switch (context.op.Text) { case "<=": operators = new LessEqual(context); break; case "<": operators = new Less(context); break; case "=": operators = new EqualNode(context); break; default: throw new NotSupportedException(); } operators.LeftOperand = Visit(context.expression(0)) as ExpressionNode; // LEFT EXPRESSION operators.RightOperand = Visit(context.expression(1)) as ExpressionNode; //RIGHT EXPRESSION return(operators); }
private void ProcessLess() { string blockId = BlockId.ToString(); string lessLocation = "~/Themes/" + base.RockPage.Site.Theme + "/Styles/" + blockId + "/"; Environment.CurrentDirectory = Server.MapPath(lessLocation); string bootstrapLocation = lessLocation + "bootstrap.less"; var bootstrapMapped = Server.MapPath(bootstrapLocation); var bootstrapFile = File.ReadAllText(bootstrapMapped); var bootstrapCSS = Less.Parse(bootstrapFile); SavePageFile(bootstrapCSS, "bootstrap.css"); string themeLocation = lessLocation + "theme.less"; var themeMapped = Server.MapPath(themeLocation); var themeFile = File.ReadAllText(themeMapped); var themeCSS = Less.Parse(themeFile); SavePageFile(themeCSS, "theme.css"); RemoveCacheItem(blockId + "bootstrap.css"); RemoveCacheItem(blockId + "theme.css"); }
/// <summary> /// Simply compile LESS files into CSS files (adds .css extension) /// </summary> /// <param name="sourcePath">Path of the root folder to search for LESS files</param> public static void CompileAll(string sourcePath) { string[] files = Directory.GetFiles(sourcePath, "*.less", SearchOption.AllDirectories); Parallel.ForEach(files, f => { var compiledLESS = File.ReadAllText(f); compiledLESS = Regex.Replace(compiledLESS, @"@import\s*""(?<Path>.*?)""\s*;\s*", (m) => { var reference = m.Groups["Path"].Value; if (!String.IsNullOrEmpty(reference) && !Path.IsPathRooted(reference)) { reference = Path.Combine(new FileInfo(f).Directory.FullName, reference); } StyleCompiler.ImportedFiles.Add(reference); return(String.Format("@import \"{0}\";\r\n", reference)); } , RegexOptions.IgnoreCase); compiledLESS = Less.Parse(compiledLESS, Config); File.WriteAllText(f + ".css", compiledLESS); }); }
public static bool Convert(string file) { string outputfilepath = file.Replace(".less", ".lw.css"); Thread.Sleep(750); string parsed; try { parsed = Less.Parse(File.ReadAllText(file)); } catch (Exception exception) { Console.WriteLine(FileError, exception.Message, Path.GetFileName(file)); return(false); } if (String.IsNullOrEmpty(parsed)) { Console.WriteLine(FileEmpty); return(false); } else { File.WriteAllText(outputfilepath, parsed); return(true); } }
public void Visit(Less n) { Helpers.Write("("); n.LeftExpression.Accept(this); Helpers.Write(" < "); n.RightExpression.Accept(this); Helpers.Write(")"); }
public void Process(BundleContext context, BundleResponse response) { var config = new DotlessConfiguration(); // config.Plugins.Add(new BuildNumberPluginConfigurator()); response.Content = Less.Parse(response.Content, config); response.ContentType = "text/css"; }
public void Visit(Less bin) { var left = bin.Left; var right = bin.Right; PrepareBinaryOperation(left, right); EmitStackDown("clt"); }
public void BinaryLessTest() { Less op = new Less(); Assert.AreEqual(f, new BinaryStatement(op, oneIntn, zeroIntn).Evaluate(varTable)); Assert.AreEqual(t, new BinaryStatement(op, minusOneIntn, zeroIntn).Evaluate(varTable)); Assert.AreEqual(f, new BinaryStatement(op, halfFloatn, zeroFloatn).Evaluate(varTable)); Assert.AreEqual(f, new BinaryStatement(op, zeroFloatn, zeroFloatn).Evaluate(varTable)); }
public void OnContentLoaded(CombinatorResource resource) { if (Path.GetExtension(resource.AbsoluteUrl.ToString()).ToLowerInvariant() != ".less") { return; } resource.Content = Less.Parse(resource.Content); }
public void Process(BundleContext context, BundleResponse response) { var oldPath = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(this.path); response.Content = Less.Parse(response.Content); Directory.SetCurrentDirectory(oldPath); response.ContentType = "text/css"; }
public void BinaryLessErrorTest() { Less op = new Less(); Assert.Throws <System.InvalidOperationException>(() => new BinaryStatement(op, oneFloatn, zeroIntn).Evaluate(varTable)); Assert.Throws <System.InvalidOperationException>(() => new BinaryStatement(op, abn, an).Evaluate(varTable)); Assert.Throws <System.InvalidOperationException>(() => new BinaryStatement(op, tn, fn).Evaluate(varTable)); Assert.Throws <System.InvalidOperationException>(() => new BinaryStatement(op, oneFloatn, tn).Evaluate(varTable)); Assert.Throws <System.InvalidOperationException>(() => new BinaryStatement(op, fn, zeroIntn).Evaluate(varTable)); }
public string Visit(Less node) { var result = ""; result += Visit((dynamic)node[0]) + "\n" + Visit((dynamic)node[1]) + "\n" + "\tclt\n"; return(result); }
///<summary> ///Compiles less file into multiple css files if total number of css selectors is > 4095. ///<para>Creates "ie9" folder at the same level as less file and puts css files in there. ///The output "style.css" will import other css files.</para> ///<param name="absolutePath">Absolute path to less file.</param> /// </summary> public static string CompileLess(string absolutePath) { Trace.WriteLine("Compilation process started..."); var files_list = new List <string>(); var dotlessConfig = new dotless.Core.configuration.DotlessConfiguration(); //dotlessConfig.Web = true; dotlessConfig.RootPath = "../"; var fileLocation = absolutePath; var relDir = absolutePath.Substring(0, absolutePath.LastIndexOf("\\")); var currentDir = relDir; var count = 0; if (File.Exists(fileLocation)) { using (var file = new System.IO.StreamReader(fileLocation)) { Directory.SetCurrentDirectory(currentDir); string parsed = Less.Parse(file.ReadToEnd(), dotlessConfig); parsed = RemoveComments(parsed); var rules = Regex.Matches(parsed, RULES_REGEX); foreach (var rule in rules) { var value = rule.ToString(); count += value.Split(',').Count(); } //replace with "count > RULES_LIMIT" later if (count > RULES_LIMIT) { var tmp = ""; var file_and_contents_dic = new Dictionary <string, string>(); var styleSheet = new Stylesheet(); var medias = GetMedias(parsed, out tmp); var reminder_rules = GetRules(tmp, RULES_REGEX); styleSheet.Medias = medias; styleSheet.Rules = reminder_rules; var rules_files = MakeFilesFromRules(reminder_rules); var media_files = MakeFilesFromMedia(medias); rules_files.AddRange(media_files); var files = BuildFileNames(rules_files); files_list = files.Keys.ToList(); AssembleFiles(files, currentDir, relDir); } file.Close(); } Trace.WriteLine("Compilation process ended. File is closed."); } return(string.Format("{0}/ie9/style.css", relDir)); }
public void Process(BundleContext context, BundleResponse response) { var compiled = Less.Parse(response.Content); if (string.IsNullOrEmpty(compiled)) { throw new Exception("less文件中语法有错误!"); } response.Content = compiled; response.ContentType = "text/css"; }
//----------------------------------------------------------- public string Visit(Less node) { var label = GenerateLabel(); return(String.Format( "\t\tldc.i4 42\n\t\t{0}\n\t\t{1}\n\t\tblt '{2}'\n\t\tpop\n\t\tldc.i4.0\n\t'{2}':\n", Visit((dynamic)node[0]), Visit((dynamic)node[1]), label )); }
public ActionResult Css(Guid id) { var style = _styleRepo.GetBy(s => s.Id == id); if (style == null) { throw new HttpException((int)HttpStatusCode.NotFound, "Resource not found"); } return(Content(Less.Parse(style.Css), "text/css")); }
//check public string Visit(Less node) { var label = GenerateLabel(); return(putS(Indentar() + "ldc.i4.0") + VisitChildren(node) + putS(Indentar() + "bge '" + label + "'") + putS(Indentar() + "pop") + putS(Indentar() + "ldc.i4 42") + putS(Indentar() + label + ":")); }
public void Check_Whether_First_Is_Less_Than_Second(object param1, object param2, bool expected) { // given var sut = new Less(param1, param2); // when var result = Evaluator.Evaluate(sut); // then Assert.Equal(expected, result); }
public static string Transform(string content) { var config = new DotlessConfiguration { ImportAllFilesAsLess = true, CacheEnabled = false, Debug = true, LessSource = typeof(VirtualFileReader), Logger = typeof(LessLogger) }; return(Less.Parse(content, config)); }
public static void ConvertAllLessFiles(this DirectoryInfo directory) { directory.GetFiles("*.less", SearchOption.AllDirectories) .ForEach(file => { var cssFile = Path.ChangeExtension(file.FullName, "css"); Log.Debug("[ConvertAllLessFiles] Converting {0} to {1} ", file.FullName, cssFile); var output = Less.Parse(file.ReadAllText()); File.WriteAllText(cssFile, output); file.Delete(); }); }
public void Process(BundleContext context, BundleResponse response) { var config = new DotlessConfiguration(); config.MinifyOutput = false; config.ImportAllFilesAsLess = true; config.CacheEnabled = false; config.LessSource = typeof(VirtualFileReader); response.Content = Less.Parse(response.Content, config); response.ContentType = "text/css"; }
protected void btnConvert_Click(object sender, EventArgs e) { DotlessConfiguration config = DotlessConfiguration.GetDefaultWeb(); config.CacheEnabled = false; config.DisableUrlRewriting = true; config.DisableParameters = true; config.MapPathsToWeb = false; config.MinifyOutput = false; config.HandleWebCompression = false; txtOutput.Text = Less.Parse(txtInput.Text, config); }
/// <summary> /// Serves as a hash of this type. /// </summary> /// <returns>A hash code for the current instance.</returns> public override int GetHashCode() { return (Width.GetHashCode() ^ Height.GetHashCode() ^ X.GetHashCode() ^ Y.GetHashCode() ^ IsPercentage.GetHashCode() ^ IgnoreAspectRatio.GetHashCode() ^ Less.GetHashCode() ^ Greater.GetHashCode() ^ FillArea.GetHashCode() ^ LimitPixels.GetHashCode()); }
/// <inheritdoc /> public override async ItemExecutionPromise Render(IByteCounterStream outputStream, ContextObject context, ScopeData scopeData) { using (var tempStream = outputStream.GetSubStream()) { await MorestachioDocument.ProcessItemsAndChildren(Children, tempStream, context, scopeData); var lessCode = tempStream.Read(); outputStream.Write(Less.Parse(lessCode, new DotlessConfiguration() { CacheEnabled = false, })); } return(Enumerable.Empty <DocumentItemExecution>()); }
public string Visit(Less node) { var result = ""; result += "\t\tldc.i4 42\n"; result += Visit((dynamic)node[0]); result += Visit((dynamic)node[1]); var labelSuccess = GenerateLabel(); result += "\t\tblt " + labelSuccess + "\n"; result += "\t\tpop\n"; result += "\t\tldc.i4 0\n"; result += "\t\t" + labelSuccess + ":\n"; return(result); }
public void Visit(Less n) { Helpers.WriteLine($"{_tab}{n.Text} [{n.Location.StartLine}, {n.Location.StartColumn}]"); Tab(); Helpers.WriteLine($"{_tab}Left"); Tab(); n.LeftExpression.Accept(this); Untab(); Helpers.WriteLine($"{_tab}Right"); Tab(); n.RightExpression.Accept(this); Untab(); Untab(); }
public static void ToSql(Less expression, StringBuilder builder) { if (null == expression) throw new ArgumentNullException("expression"); if (null == builder) throw new ArgumentNullException("builder"); if (expression.Operands.Count > 0) { IToken operand1 = expression.Operands .First(); IToken operand2 = expression.Operands .ElementAtOrDefault(1); if (null != operand1 && null != operand2) { operand1.ToSql(builder); builder.Append(" < "); operand2.ToSql(builder); } } }