WIP skinning, adds initial version of SkinManifestParser + some minor updates to skinning bl

[TFS Changeset #80670]
This commit is contained in:
starfighter83
2010-11-26 13:59:08 +00:00
parent aafbb3bfb0
commit 1d182bdc41
4 changed files with 97 additions and 4 deletions

View File

@@ -8,11 +8,20 @@ namespace umbraco.cms.businesslogic.skinning
public class CssVariable
{
public string Name { get; set; }
public string DefaultValue { get; set; }
public List<CssVariableProperty> Properties { get; set; }
public CssVariable(string Name)
public CssVariable(string name)
{
this.Name = Name;
this.Name = name;
Properties = new List<CssVariableProperty>();
}
public CssVariable(string name, string defaultValue)
{
this.Name = name;
this.DefaultValue = defaultValue;
Properties = new List<CssVariableProperty>();
}
}

View File

@@ -10,9 +10,9 @@ namespace umbraco.cms.businesslogic.skinning
public string Name { get; set; }
public List<string> Selectors { get; set; }
public CssVariableProperty(string Name)
public CssVariableProperty(string name)
{
this.Name = Name;
this.Name = name;
Selectors = new List<string>();
}
}

View File

@@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace umbraco.cms.businesslogic.skinning.utils
{
//will be used to parse a skin manifest during installation
//in case the skin is using css variables
public class SkinManifestParser
{
public string SkinFilePath;
public SkinManifestParser()
{
}
public void ProcessSkinFile(string path)
{
SkinFilePath = path;
List<CssVariable> cssVariables = new List<CssVariable>();
//get all variables
CssParser parser = new CssParser();
//add stylesheet contents
//parser.AddStyleSheet(@"C:\www\contour.local\1.0.3825.19924\build\css\runway.css");
//build collection of properties and selectors for each variable
// - Var 1 - Property - Selector
// - Selector
// - Selector
// - Property - Selector
// - Selector
foreach (var ruleSet in parser.Styles)
{
string Selectors = ruleSet.Key;
foreach (var declaration in ruleSet.Value.Attributes)
{
var property = declaration.Key;
var value = declaration.Value;
foreach (CssVariable cssvar in cssVariables)
{
if (value.Contains(cssvar.Name))
{
//add property
CssVariableProperty prop =
cssvar.Properties.Find(delegate(CssVariableProperty p) { return p.Name == property; });
if (prop == null)
prop = new CssVariableProperty(property);
//add selector
//maybe split up the Selectors, since they can contain multiple
//also
String sel = prop.Selectors.Find(delegate(string s) { return s == Selectors; });
if (string.IsNullOrEmpty(sel))
prop.Selectors.Add(Selectors);
if (!cssvar.Properties.Contains(prop))
cssvar.Properties.Add(prop);
}
}
}
}
//modify tasks that are using a variable
//create default version of css (replace variables with default value)
//save skin manifest
}
}
}

View File

@@ -236,6 +236,7 @@
<Compile Include="businesslogic\skinning\tasks\ModifyTemplate.cs" />
<Compile Include="businesslogic\skinning\TaskType.cs" />
<Compile Include="businesslogic\skinning\utils\CssParser.cs" />
<Compile Include="businesslogic\skinning\utils\SkinManifestParser.cs" />
<Compile Include="businesslogic\Tags\Tag.cs" />
<Compile Include="businesslogic\task\Tasks.cs" />
<Compile Include="businesslogic\web\DocumentVersionList.cs" />