Skip to content

Commit

Permalink
Merge pull request #1253 from aparajita/better-theme-template
Browse files Browse the repository at this point in the history
Improvements to the ThemeDescriptor capp template
  • Loading branch information
aparajita committed Apr 6, 2012
2 parents c2f20c2 + 4d50eea commit 159c5c7
Show file tree
Hide file tree
Showing 6 changed files with 199 additions and 39 deletions.
12 changes: 6 additions & 6 deletions Tools/capp/Resources/Templates/ThemeDescriptor/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CPApplicationDelegateClass</key>
<string>BKShowcaseController</string>
<key>CPBundleName</key>
<string>__project.name__</string>
<key>CPPrincipalClass</key>
<string>CPApplication</string>
<key>CPApplicationDelegateClass</key>
<string>BKShowcaseController</string>
<key>CPBundleName</key>
<string>__project.name__</string>
<key>CPPrincipalClass</key>
<string>CPApplication</string>
</dict>
</plist>
186 changes: 172 additions & 14 deletions Tools/capp/Resources/Templates/ThemeDescriptor/Jakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,187 @@
* Jakefile
* __project.name__
*
* Created by __user.name__ on __project.date__.
* Copyright __project.year__, __organization.name__ All rights reserved.
* Created by __user.name__ on __project.date__
* Copyright __project.year__, __organization.name__. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

var ENV = require("system").env,
//===========================================================
// DO NOT REMOVE
//===========================================================

var SYS = require("system"),
ENV = SYS.env,
FILE = require("file"),
task = require("jake").task,
FileList = require("jake").FileList,
OS = require("os");


//===========================================================
// USER CONFIGURABLE VARIABLES
//===========================================================

/*
The directory in which the project will be built. By default
it is built in a "Build" directory within the project directory.
To use your $CAPP_BUILD directory, change the declaration to:
var buildDir = ENV["CAPP_BUILD"];
*/
var buildDir = "Build";


//===========================================================
// AUTOMATICALLY GENERATED
//
// Do not edit! (unless you know what you are doing)
//===========================================================

var stream = require("narwhal/term").stream,
JAKE = require("jake"),
task = JAKE.task,
FileList = JAKE.FileList,
CLEAN = require("jake/clean").CLEAN,
CLOBBER = require("jake/clean").CLOBBER,
blend = require("cappuccino/jake").blend,
configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug";
configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug",
productName = "__project.nameasidentifier__",
debugBlendKitPath = FILE.join("Frameworks", "Debug", "BlendKit"),
releaseBlendKitPath = FILE.join("Frameworks", "BlendKit"),
buildPath = FILE.canonical(FILE.join(buildDir, productName + ".build"));

blend (productName + ".blend", function(themeBlendTask)
{
themeBlendTask.setBuildIntermediatesPath(FILE.join(buildPath, configuration))
themeBlendTask.setBuildPath(FILE.join(buildDir, configuration));

blend ("__project.nameasidentifier__.blend", function(__project.nameasidentifier__Task)
themeBlendTask.setThemeDescriptors(new FileList("ThemeDescriptors.j"));
themeBlendTask.setIdentifier("__project.identifier__");
themeBlendTask.setResources(new FileList("Resources/*"));
});

task ("debug", function()
{
ENV["CONFIGURATION"] = "Debug";
JAKE.subjake(["."], "build", ENV);

symlinkBlendKit(debugBlendKitPath);
});

task ("release", function()
{
__project.nameasidentifier__Task.setBuildIntermediatesPath(FILE.join("Build", "__project.nameasidentifier__.build", configuration))
__project.nameasidentifier__Task.setBuildPath(FILE.join("Build", configuration));
ENV["CONFIGURATION"] = "Release";
JAKE.subjake(["."], "build", ENV);

__project.nameasidentifier__Task.setThemeDescriptors(new FileList("ThemeDescriptors.j"));
__project.nameasidentifier__Task.setIdentifier("com.280n.__project.identifier__");
__project.nameasidentifier__Task.setResources(new FileList("Resources/*"));
symlinkBlendKit(releaseBlendKitPath);
});

task ("default", ["release"]);

task ("build", [productName + ".blend"]);

task ("all", ["debug", "release"]);

task ("test", ["debug"], function()
{
OS.system(["open", "index-debug.html"]);
});

task ("default", ["__project.nameasidentifier__.blend"]);
task ("test-release", ["release"], function()
{
OS.system(["open", "index.html"]);
});

CLEAN.include(buildPath);
CLOBBER.include(buildDir);

task ("help", function()
{
var app = JAKE.application().name();

colorPrint("--------------------------------------------------------------------------", "bold+green");
colorPrint("__project.name__ - Theme Blend", "bold+green");
colorPrint("--------------------------------------------------------------------------", "bold+green");

describeTask(app, "debug", "Builds a debug version at " + FILE.join(buildDir, "Debug"));
describeTask(app, "release", "Builds a release version at " + FILE.join(buildDir, "Release"));
describeTask(app, "all", "Builds a debug and release version");
describeTask(app, "test", "Builds a debug version, symlinks to the installed BlendKit framework,\nand opens the theme showcase in the default browser");
describeTask(app, "test-release", "Builds a release version, symlinks to the installed BlendKit framework,\nand opens the theme showcase in the default browser");
describeTask(app, "clean", "Removes the intermediate build files");
describeTask(app, "clobber", "Removes the intermediate build files and the built theme");

colorPrint("--------------------------------------------------------------------------", "bold+green");
});

var describeTask = function(application, task, description)
{
colorPrint("\n" + application + " " + task, "violet");
description.split("\n").forEach(function(line)
{
print(" " + line);
});
}

var symlinkBlendKit = function(destinationPath)
{
if (FILE.exists(destinationPath))
return;

var blendKitPath = null,
path = FILE.join(SYS.prefix, "packages", "cappuccino", "Frameworks", "BlendKit");

if (FILE.isDirectory(path))
blendKitPath = path;

if (!blendKitPath)
{
cappBuild = ENV["CAPP_BUILD"];

if (cappBuild)
{
var buildTypes = ["Release", "Debug"];

for (var i = 0; i < buildTypes.length; ++i)
{
var path = FILE.join(cappBuild, buildTypes[i], "BlendKit");

if (FILE.isDirectory(path))
{
blendKitPath = path;
break;
}
}
}
}

if (blendKitPath)
FILE.symlink(blendKitPath, destinationPath);
}

var colorPrint = function(message, color)
{
var matches = color.match(/(bold(?: |\+))?(.+)/);

if (!matches)
return;

message = "\0" + matches[2] + "(" + message + "\0)";

task ("build", ["default"]);
if (matches[1])
message = "\0bold(" + message + "\0)";

stream.print(message);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
* ThemeDescriptors.j
* __project.name__
*
* Created by __user.name__ on __project.date__.
* Copyright __project.year__, __organization.name__ All rights reserved.
* Created by __user.name__ on __project.date__
* Copyright __project.year__, __organization.name__. All rights reserved.
*/

@import <BlendKit/BKThemeDescriptor.j>


@implementation __project.nameasidentifier__ThemeDescriptor : BKThemeDescriptor
{
}

+ (CPString)themeName
{
Expand All @@ -21,15 +19,15 @@
+ (CPButton)themedButton
{
var button = [[CPButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 20.0)];

[button setValue:[CPColor blueColor] forThemeAttribute:@"bezel-color"];
[button setValue:[CPColor greenColor] forThemeAttribute:@"bezel-color" inState:CPThemeStateHighlighted];

[button setValue:[CPColor redColor] forThemeAttribute:@"text-color"];
[button setValue:[CPColor yellowColor] forThemeAttribute:@"text-color" inState:CPThemeStateHighlighted];

[button setTitle:@"Yikes!"];

return button;
}

Expand Down
16 changes: 10 additions & 6 deletions Tools/capp/Resources/Templates/ThemeDescriptor/index-debug.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
index-debug.html
__project.name__
Created by __user.name__ on __project.date__.
Copyright __project.year__, __organization.name__ All rights reserved.
Created by __user.name__ on __project.date__
Copyright __project.year__, __organization.name__. All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1" />
Expand All @@ -26,7 +26,7 @@
OBJJ_MAIN_FILE = "main.j";
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"];
</script>

<script type="text/javascript" src="Frameworks/Debug/Objective-J/Objective-J.js" charset="UTF-8"></script>

<script type="text/javascript">
Expand All @@ -36,7 +36,7 @@

// Uncomment to enable printing of backtraces on exceptions:
//objj_msgSend_decorate(objj_backtrace_decorator);

// Uncomment to supress exceptions that take place inside a message
//objj_msgSend_decorate(objj_supress_exceptions_decorator)

Expand All @@ -52,8 +52,12 @@
// Uncomment to enable a specific logger:
//CPLogRegister(CPLogConsole);
//CPLogRegister(CPLogPopup);

// Tag view DOM elements with a "data-cappuccino-view" attribute that contains
// the class name of the view that created them. Comment this or set to false to disable.
appkit_tag_dom_elements = true;
</script>

<style type="text/css">
body{margin:0; padding:0;}
#container {position: absolute; top:50%; left:50%;}
Expand All @@ -79,7 +83,7 @@
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading __project.name__...</p></div>");
</script>

<noscript>
<div id="container">
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
Expand Down
8 changes: 4 additions & 4 deletions Tools/capp/Resources/Templates/ThemeDescriptor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
index.html
__project.name__
Created by __user.name__ on __project.date__.
Copyright __project.year__, __organization.name__ All rights reserved.
Created by __user.name__ on __project.date__
Copyright __project.year__, __organization.name__. All rights reserved.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1" />
Expand All @@ -25,7 +25,7 @@
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
</script>

<script type="text/javascript" src="Frameworks/Objective-J/Objective-J.js" charset="UTF-8"></script>

<style type="text/css">
Expand Down Expand Up @@ -53,7 +53,7 @@
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading __project.name__...</p></div>");
</script>

<noscript>
<div id="container">
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
Expand Down
6 changes: 3 additions & 3 deletions Tools/capp/Resources/Templates/ThemeDescriptor/main.j
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* main.j
* __Product__
* __project.name__
*
* Created by __Me__ on __Date__.
* Copyright 2008 __MyCompanyName__. All rights reserved.
* Created by __user.name__ on __project.date__
* Copyright __project.year__, __organization.name__. All rights reserved.
*/

@import <Foundation/Foundation.j>
Expand Down

0 comments on commit 159c5c7

Please sign in to comment.