Frictionless development for ASP.NET MVC single page web apps. Prototypical and dynamic capabilities brought to C#.
Single page web apps are becoming the norm as opposed to the exception. And with that comes a large part of your code base existing on the client side with a lot of JavaScript, JSON and async HTTP. Oak gives you a way to quickly build these kind of apps by:
gem install bundler (used for continuous testing) gem install warmup (used for solution generation)
using a command prompt that supports ruby (be sure to run the command prompt as an administrator): warmup http://github.com/amirrajan/loam Blog (creates a .Net solution) === OR if you want a solution that includes UI Automation === warmup http://github.com/amirrajan/walkingskeleton Blog cd Blog rake (builds the .net app) rake server (starts iis express) start Blog.sln (opens the solution)watchr dotnet.watchr.rbsidekick.bat (starts your feedback loop)
Oak comes with an interactive tutorial. Once you have taken the steps above, go to http://localhost:3000 and try out Oak interactively.
To get the most out of the Interactive Tutorial, take the time to install Growl for Windows with a nice notification theme:
Oak has an addicting development life cycle that incorporates rapid application development, fast feedback loops, testing, and UI automation. Watch the video to see Oak in action:
Oak has a dynamic entity model called Cambium which is amicable to dynamic strcuctures (ie JavaScript classes). Cambium makes validating, detecting changes, saving, retrieving, and defining associations ridiculously easy. Check out the Sample Apps and the Wiki for more info. Here is a sneak peek at what Cambium can do:
dynamic blog = new Blog(); //new up a blog, validate
blog.Name = "";
blog.IsValid(); //this would be false
blog.FirstError(); //this would return "Name is Required"
public class Blog : DynamicModel
{
//validation, name is required
IEnumerable<dynamic> Validates() {
yield return new Presense("Name");
}
Blogs blogs = new Blogs();
public Blog(object dto) : base(dto) { }
public Blog() : base() { }
}
The Camtasia Studio video content presented here requires JavaScript to be enabled and the latest version of the Adobe Flash Player. If you are using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Adobe Flash Player by downloading here.
Blogs blogs = new Blogs(); //data access by convention
Comments comments = new Comments(); //data access by convention
dynamic blog = new Blog();
blog.Name = "Blog Name";
blog.Id = blogs.Insert(blog); //inserts into the database returns an Id
var comment = blog.Comments().New(new { Body = "new comment" });
comments.Insert(comment); //inserts comment into database
public class Blogs : DynamicRepository
{
public Blogs() { Projection = d => new Blog(d); }
}
public class Comments : DynamicRepository { }
public class Blog : DynamicModel
{
//a blog has many comments
IEnumerable<dynamic> Associates() {
yield return HasMany(comments);
}
Comments comments = new Comments();
public Blog(object dto) : base(dto) { }
public Blog() : base() { }
}
The Camtasia Studio video content presented here requires JavaScript to be enabled and the latest version of the Adobe Flash Player. If you are using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Adobe Flash Player by downloading here.
Schema generation should be simple. Period. Here's what simple looks like:
var seed = new Seed();
//create blogs table
seed.CreateTable("Blogs",
seed.Id(),
//seed.Id() is an alias for
//new { Id = "int", Identity = true, PrimaryKey = "true" }
new { Name = "nvarchar(255)" },
new { Body = "nvarchar(max)", Default = "Lorem Ipsum" }
).ExecuteNonQuery();
//Seed's CreateTable method returns a string that's valid sql,
//ExecuteNonQuery will execute that string
//create comments table
seed.CreateTable("Comments",
seed.Id(),
new { BlogId = "int", ForeignKey = "Blogs(Id)"
new { Body = "nvarchar(max)", Nullable = false }
).ExecuteNonQuery();
//ad hoc
"drop table Foobar".ExecuteNonQuery();
Oak is bootstrapped with NSpec and SpecWatchr. Driving out your implementation with tests ensures that you have a maintainable code base.
The Camtasia Studio video content presented here requires JavaScript to be enabled and the latest version of the Adobe Flash Player. If you are using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Adobe Flash Player by downloading here.
Oak is bootstrapped with a UI automation framework called canopy. With the increased use of client side javascript, UI automation tools are absolutely necessary. Canopy gives you a terse DSL written in F#. Very easy to pick up!
open canopy start "firefox" url "http://google.com" "input[type='text']" << "hello world" click "input[type='button']"
Oak comes installed with a suite of rake scripts that will build your solution, deploy your web app, run NSpec tests and run UI automation tests. These scripts can be leveraged directly by your build servers. Using a command prompt that supports ruby (be sure to run the command prompt as an administrator), you can type any of the following commands:
rake builds and deploys your application rake server starts up iis express pointing to your deploy directory rake simulate_load_balance sets up iis express in a round robin load balanced configuration rake reset regenerates your schema rake sample inserts sample data into your db to help with development rake export exports your schema to a set of sql scripts rake tests runs all tests rake ui runs ui automation
Oak comes bootstrapped with a suite of rake scripts that help you scaffold common files in your solution. These scripts can be leveraged by you to quickly generate classes. Using a command prompt that supports ruby (be sure to run the command prompt as an administrator), you can type any of the following commands:
all scripts are customizable and are located in scaffold.rb
rake gen:controller[name]
adds a controller class to your mvc project
rake gen:model[name]
adds a dynamic model class to your mvc project
rake gen:repo[name]
adds a dynamic repository class to your mvc project
rake gen:script[name]
adds javascript file to your mvc project
rake gen:test[name]
adds a test file to your test project
rake gen:view[controller_and_name]
adds cshtml to your mvc project
This is..you guessed it...a blogging app. It's a really minimal implementation. Look at the other sample apps for a deeper dive into Oak.
git clone https://github.com/amirrajan/Oak.git (or download the zip) cd "Oak\Sample Apps\DynamicBlog" start DynamicBlog.sln
rake (builds and deploys the application) rake create_db (creates your databases) rake tests (all tests should pass) rake server (this will start up iis express) rake reset (resets the database schema with no data) rake sample (adds sample data to the database) start http://localhost:3000
This is a really simple app that adds and updates records to a single table over ajax. It's a really minimal server side implementation for a number of JavaScript front end frameworks:
git clone https://github.com/amirrajan/Oak.git (or download the zip) cd "Oak\Sample Apps\Peeps" start Peeps.sln
rake (builds and deploys the application) rake create_db (creates your databases) rake server (this will start up iis express) rake reset (resets the database schema with no data) start http://localhost:3000
You may want to look at the Task Rabbits sample app for a deeper dive.
This is a web based version of the game BattleShip. Open up two browsers and start playing!
git clone https://github.com/amirrajan/Oak.git (or download the zip) cd "Oak\Sample Apps\BattleShip" start BattleShip.sln
rake (builds and deploys the application) rake create_db (creates your databases) rake tests (all tests should pass) rake server (this will start up iis express) rake reset (resets the database schema with no data) rake sample (adds sample data to the database) start http://localhost:3000
This is a web application that shows how you can integrate Oak with some popular JavaScript frameworks such as :
git clone https://github.com/amirrajan/Oak.git (or download the zip) cd "Oak\Sample Apps\TaskRabbits" start TaskRabbits.sln
rake (builds and deploys the application) rake create_db (creates your databases) rake server (this will start up iis express) rake ui (runs ui tests, it requires FireFox and Selenium IDE) rake reset (resets the database schema with no data) rake sample (adds sample data to the database) start http://localhost:3000
This is a web application that tracks consultants and when they roll off of a client engagement. Consulting companies like Improving Enterprises would use this app to manage their resource pool.
git clone https://github.com/amirrajan/Oak.git (or download the zip) cd "Oak\Sample Apps\Crib" start Crib.sln
bundle install rake (builds and deploys the application) rake create_db (creates your databases) rake tests (all tests should pass) rake server (this will start up iis express) rake reset (resets the database schema with no data) rake sample (adds sample data to the database) start http://localhost:3000
This is a web application that uses Oak to implement a REST api using Oak. A simple todo list that allows you to add items, remove them, and mark things as done.
git clone https://github.com/amirrajan/Oak.git (or download the zip) cd "Oak\Sample Apps\TodoApp" start TodoApp.sln
rake (builds and deploys the application) rake create_db (creates your databases) rake server (this will start up iis express) rake tests (all tests should pass, requires server to be started) rake reset (resets the database schema with no data) rake sample (adds sample data to the database) start http://localhost:3000
This is a full blown reference implementation that uses all aspects of Oak. Borrowed Games is a single page web app that allows a circle of friends to borrow games from each other. This site is deployed and in production at http://borrowedgames.com.
git clone https://github.com/amirrajan/Oak.git (or download the zip) cd "Oak\Sample Apps\BorrowedGames" start BorrowedGames.sln
bundle install rake (builds and deploys the application) rake create_db (creates your databases) rake regen_db (this generates the schema for the db) rake tests (all tests should pass) rake server (this will start up iis express) rake ui (runs ui tests, it requires FireFox and Selenium IDE) rake reset (deletes all records in the db) rake sample (adds sample data to the database) start http://localhost:3000