zeal 0.1.10

An MVC web development framework.


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

zeal.d

Zeal attempts to create a more rich web development as an MVC framework layer over Vibe. The primary goal is to provide features typical to other powerful and successful frameworks such as Rails or Cake.

Installation

  • Install Ruby and RubyGems if you don't already have them. Sorry to say that, at least for now, this is a strict requirement.
  • Install the Sass Ruby gem, required for sass-vibe on which Zeal depends:
  • gem install sass
  • Add to your package.json file under "dependencies":
  • "zeal": ">=0.1.10"
  • Run vibe once to install Zeal and its dependencies.
  • Copy the files from modules/zeal/template to your application. Examine them and modify as desired.

Usage

Zeal follows its own conventions, including a flavor of the Model-View-Controller pattern.

Models

TO BE WRITTEN

Views

At this time, Zeal simply uses the "Diet" template system provided by Vibe, without any modification or extension. However, there are future plans to enhance this system slightly.

Controllers

Similar to other MVC frameworks, you will define controller objects which manage all requests. Supposing you wanted to manage a resource called thing, you would create the file source/controllers/things.d and edit it similar to the following (each action is optional):

module controllers.things;

import controllers.application;

final class ThingsController : ApplicationController {

	void new_ ( Request req, Response res ) { /*...*/ }
	
	void create ( Request req, Response res ) { /*...*/ }
	
	void index ( Request req, Response res ) { /*...*/ }
	
	void show ( Request req, Response res ) { /*...*/ }
	
	void edit ( Request req, Response res ) { /*...*/ }
	
	void update ( Request req, Response res ) { /*...*/ }
	
	void destroy ( Request req, Response res ) { /*...*/ }

}

Then to route this resource, you would edit your app.d module:

module app;

import zeal.d;

static this () {
	auto app = ZealApplication();
	
	with ( app.router ) {
		resource!"things";
	}
}

Or you could instead specify it in the config module (provided by the Zeal template):

enum resources = [ "things" ];

And that's it! Your ThingsController will be automatically instantiated and the actions it defines are routed in the appropriate RESTful manner due to mysterious elven magic. For example, a request like GET /things would be routed to ThingsController.index.

Stylesheets

Zeal pulls in the sass-vibe module, and as such lets you define stylesheets as SCSS scripts. The template includes the file assets/styles/application.scss to get you started.

Future Directions

The following are definitely on the agenda.

  • Implementing Models as a database abstraction, with validations, named scopes, and other useful features.
  • Responding with different formats based on request URL (similar to the respond_to call in Rails). Could be done either via delegation or via a more elaborate naming convention (a la using showForJson, for example, to respond to the request GET /things/123.json.)

The following are just possibilities for now.

  • Adding support for Coffee scripts, possibly as a separate module (similar to how Sass was implemented).
  • Extending controllers and views to semi-automate the passing of variables from the controller into the view template.
Authors:
Christopher Nicholson-Sauls
Dependencies:
sass-vibe
Versions:
0.1.10 2012-May-31
0.1.9 2012-May-21
~master 2012-May-31
Show all 3 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 217 downloads total

Score:
1.7