Skip to content

Commit

Permalink
added output directory option
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith committed Jul 19, 2012
1 parent 1d4d101 commit ee8280c
Show file tree
Hide file tree
Showing 24 changed files with 417 additions and 48 deletions.
55 changes: 55 additions & 0 deletions Demo/assets/coffeeScriptTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

/* -------------------------------------------------------------------------
* !!! AUTOMATICALLY GENERATED CODE !!!
* -------------------------------------------------------------------------
* This file was automatically generated by the OrangeBits compiler.
* Compiled on: 7/19/2012 1:39:40 PM
* Compiled by: REDMOND\justbe
* Source: C:\Users\justbe\Dropbox\Code\OrangeBits\Demo\ignore\coffeeScriptTest.coffee
* -------------------------------------------------------------------------*/


var cubes, list, math, num, number, opposite, race, square;
var __slice = Array.prototype.slice;

number = 42;

opposite = true;

if (opposite) number = -42;

square = function(x) {
return x * x;
};

list = [1, 2, 3, 4, 5];

math = {
root: Math.sqrt,
square: square,
cube: function(x) {
return x * square(x);
}
};

race = function() {
var runners, winner;
winner = arguments[0], runners = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
return print(winner, runners);
};

if (typeof elvis !== "undefined" && elvis !== null) alert("I knew it!");

cubes = (function() {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = list.length; _i < _len; _i++) {
num = list[_i];
_results.push(math.cube(num));
}
return _results;
})();

setTimeout(function() {
return document.getElementsByClassName('coffeeBox')[0].innerHTML = 'hello from the world of coffeeScript!!!';
}, 1500);
17 changes: 17 additions & 0 deletions Demo/assets/sassTest.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

/* -------------------------------------------------------------------------
* !!! AUTOMATICALLY GENERATED CODE !!!
* -------------------------------------------------------------------------
* This file was automatically generated by the OrangeBits compiler.
* Compiled on: 7/19/2012 1:39:30 PM
* Compiled by: REDMOND\justbe
* Source: C:\Users\justbe\Dropbox\Code\OrangeBits\Demo\ignore\sassTest.sass
* -------------------------------------------------------------------------*/


.sassBox {
background-color: #caeef2;
border-color: #3bbfce;
color: #2ca2af;
padding: 8px;
margin: 8px; }
1 change: 1 addition & 0 deletions Demo/assets/sassTest.min.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.sassBox{background-color:#caeef2;border-color:#3bbfce;color:#2ca2af;padding:8px;margin:8px}
1 change: 1 addition & 0 deletions Demo/coffeeScriptTest.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ setTimeout(() ->
document.getElementsByClassName('coffeeBox')[0].innerHTML = 'hello from the world of coffeeScript!!!'
, 1500);


35 changes: 35 additions & 0 deletions Demo/ignore/coffeeScriptTest.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Assignment:
number = 42
opposite = true

# Conditions:
number = -42 if opposite

# Functions:
square = (x) -> x * x

# Arrays:
list = [1, 2, 3, 4, 5]

# Objects:
math =
root: Math.sqrt
square: square
cube: (x) -> x * square x

# Splats:
race = (winner, runners...) ->
print winner, runners

# Existence:
alert "I knew it!" if elvis?

# Array comprehensions:
cubes = (math.cube num for num in list)


# show off some coffee in the browser test
setTimeout(() ->
document.getElementsByClassName('coffeeBox')[0].innerHTML = 'hello from the world of coffeeScript!!!'
, 1500);

10 changes: 10 additions & 0 deletions Demo/ignore/sassTest.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
$blue: #3bbfce
$margin: 16px

.sassBox
background-color: lighten($blue, 35%)
border-color: $blue
color: darken($blue, 9%)
padding: $margin / 2
margin: $margin / 2

10 changes: 10 additions & 0 deletions Demo/ignore/scssTest.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
$red: #FF0000;
$margin: 16px;

.scssBox {
background-color: lighten($red, 45%);
border-color: $red;
color: darken($red, 9%);
padding: $margin / 2;
margin: $margin / 2;
}
5 changes: 4 additions & 1 deletion Demo/lessTest.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* !!! AUTOMATICALLY GENERATED CODE !!!
* -------------------------------------------------------------------------
* This file was automatically generated by the OrangeBits compiler.
* Compiled on: 7/19/2012 9:37:48 AM
* Compiled on: 7/19/2012 11:18:35 AM
* Compiled by: REDMOND\justbe
* Source: C:\Users\justbe\Dropbox\Code\OrangeBits\Demo\lessTest.less
* -------------------------------------------------------------------------*/
Expand All @@ -23,3 +23,6 @@
padding: 8px;
margin: 8px;
}
.spaceTest {
font-family: MuseoSans- 500, "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, "Lucida Grande", sans-serif;
}
5 changes: 5 additions & 0 deletions Demo/lessTest.less
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@
padding: @margin / 2;
margin: @margin / 2;
}


.spaceTest {
font-family: MuseoSans-500, "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, "Lucida Grande", sans-serif;
}
2 changes: 1 addition & 1 deletion Demo/lessTest.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions OrangeBits/Compilers/OrangeCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,13 @@ public static CompileResults Process(OrangeJob job)
if (String.IsNullOrEmpty(job.Path))
throw new Exception("The path passed to Orange Compiler must be a valid LESS, CoffeeScript, or Sass file");

// get the file extension
FileInfo f = new FileInfo(job.Path);
string outPath = job.Path.Substring(0, job.Path.LastIndexOf('.'));

FileInfo f = new FileInfo(job.Path);

// OutputPath can be relative - calculate the correct absolute path
var targetFile = Path.Combine(job.OutputPath, Path.GetFileName(job.Path));
string outPath = targetFile.Substring(0, targetFile.LastIndexOf('.'));

string outExt = "";
switch (job.Type)
{
Expand Down
6 changes: 3 additions & 3 deletions OrangeBits/OrangeBits.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="dotless.ClientOnly">
<HintPath>..\packages\DotlessClientOnly.1.3.0.4\lib\dotless.ClientOnly.dll</HintPath>
<Reference Include="dotless.ClientOnly, Version=1.3.0.5, Culture=neutral, PublicKeyToken=96b446c9e63eae34, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\DotlessClientOnly.1.3.0.5\lib\dotless.ClientOnly.dll</HintPath>
</Reference>
<Reference Include="EcmaScript.NET">
<HintPath>..\packages\YUICompressor.NET.2.0.0.0\lib\NET20\EcmaScript.NET.dll</HintPath>
Expand Down Expand Up @@ -112,7 +113,6 @@
<Compile Include="DelegateCommand.cs" />
<Compile Include="OrangeJob.cs" />
<Compile Include="PrefUtility.cs" />
<Compile Include="PrefKeys.cs" />
<Compile Include="UI\OptionsUI.xaml.cs">
<DependentUpon>OptionsUI.xaml</DependentUpon>
</Compile>
Expand Down
1 change: 1 addition & 0 deletions OrangeBits/OrangeJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public enum JobSource
public JobType Type { get; set; }
public JobSource Source { get; set; }
public string Path { get; set; }
public string OutputPath { get; set; }
public DateTime Time { get; set; }

public OrangeJob()
Expand Down
15 changes: 0 additions & 15 deletions OrangeBits/PrefKeys.cs

This file was deleted.

38 changes: 27 additions & 11 deletions OrangeBits/PrefUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public string getPathKey(string path, string propertyName)
/// <param name="item"></param>
/// <param name="prop"></param>
/// <returns></returns>
public bool? GetPref(string itemPath, string prop, bool def)
public object GetPref(string itemPath, string prop, object def)
{
var path = itemPath;
do
Expand All @@ -79,8 +79,14 @@ public string getPathKey(string path, string propertyName)
if (this.SitePreferences.ContainsValue(key))
{
var value = this.SitePreferences.GetValue(key);
if (value != null)
return bool.Parse(value);
if (value != null)
{
if (def.GetType() == typeof(bool))
{
return bool.Parse(value);
}
return value.ToString();
}
}

if (path.ToLowerInvariant() == this.SitePath.ToLowerInvariant())
Expand Down Expand Up @@ -157,12 +163,12 @@ public void LoadOptions(OptionViewModel vm)
foreach (var prop in props)
{
// what's the default value for this property?
bool def = (bool)(prop.GetCustomAttributes(typeof(DefaultValueAttribute), false)[0] as DefaultValueAttribute).Value;
bool? firstValue = null;
object def = (prop.GetCustomAttributes(typeof(DefaultValueAttribute), false)[0] as DefaultValueAttribute).Value;
object firstValue = null;

foreach (var path in vm.Paths)
{
bool? prefValue = this.GetPref(path, prop.Name, def);
object prefValue = this.GetPref(path, prop.Name, def);
if (firstValue == null)
firstValue = prefValue;

Expand Down Expand Up @@ -197,11 +203,21 @@ public void SaveOptions(OptionViewModel vm)
foreach (var prop in props)
{
var key = this.getPathKey(path, prop.Name);
var value = prop.GetValue(vm, null) as bool?;
if (value.HasValue)
{
this.SitePreferences.SetValue(key, value.Value.ToString());
}
var value = prop.GetValue(vm, null);
if (prop.PropertyType == typeof(bool?))
{
if ((value as bool?).HasValue)
{
this.SitePreferences.SetValue(key, (value as bool?).Value.ToString());
}
}
else
{
if (value != null)
{
this.SitePreferences.SetValue(key, value.ToString());
}
}
}
}
this.SitePreferences.Save();
Expand Down
3 changes: 3 additions & 0 deletions OrangeBits/UI/OptionViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public string CombinedPath

[DefaultValue(false)]
public bool? AutoMinifyJS { get; set; }

[DefaultValue(@".\")]
public string OutputPath { get; set; }

#endregion

Expand Down
18 changes: 17 additions & 1 deletion OrangeBits/UI/OptionsUI.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:r="clr-namespace:OrangeBits.UI"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
d:DesignHeight="500" d:DesignWidth="500">
<UserControl.Resources>
<Style TargetType="r:OrangeCheckbox">
<Setter Property="Margin" Value="5" />
Expand All @@ -30,6 +30,22 @@
<r:OrangeCheckbox IsThreeState="True" Content="Auto Compile CoffeeScript" IsChecked="{Binding Path=AutoCompileCoffee}" ToolTip="Automatically compile all *.coffe files as they are changed" />
<r:OrangeCheckbox IsThreeState="True" Content="Auto Minify CSS" IsChecked="{Binding Path=AutoMinifyCSS}" ToolTip="Automatically minify all *.css files as they are changed" />
<r:OrangeCheckbox IsThreeState="True" Content="Auto Minify JS" IsChecked="{Binding Path=AutoMinifyJS}" ToolTip="Automatically compile all *.js files as they are changed" />

<Label Content="Output Path:" Margin="0 10 0 0 "/>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox Margin="3" Text="{Binding Path=OutputPath}" Grid.Column="0" Grid.Row="0" />
<!--<Button Content="..." Grid.Column="1" />-->
</Grid>



</StackPanel>
</GroupBox>
<CheckBox Content="Overwrite child settings" IsChecked="{Binding Path=OverwriteChildSettings}" ToolTip="Overwrite any options set on child nodes in the file tree" Margin="0 10 0 0" />
Expand Down
Loading

0 comments on commit ee8280c

Please sign in to comment.