Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

icecream

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

icecream - npm Package Compare versions

Comparing version 0.2.5 to 0.2.7

icecream/generators/generator.js

10

icecream/controller.js

@@ -0,1 +1,11 @@

/**
* Copyright (c) 2012, Zhiyu Zheng. All rights reserved.
* Licensed under the MIT License
*
* Hosted On Github :
* http://github.com/zhiyu/icecream
*
*/
var utils = require('./utils');

@@ -2,0 +12,0 @@ var View = require('./view');

39

icecream/dispatcher.js

@@ -0,1 +1,11 @@

/**
* Copyright (c) 2012, Zhiyu Zheng. All rights reserved.
* Licensed under the MIT License
*
* Hosted On Github :
* http://github.com/zhiyu/icecream
*
*/
var path = require('path');

@@ -8,9 +18,7 @@ var urlHelper = require("url");

var Dispatcher = module.exports = function Dispatcher(){
this.context = icecream;
var dispatcher = module.exports = {
context : icecream
}
var prototype = Dispatcher.prototype;
prototype.dispatch = function(req, res){
dispatcher.dispatch = function(req, res){
if(this.isAction(req)){

@@ -23,3 +31,3 @@ this.doAction(req,res);

prototype.getExt = function(req){
dispatcher.getExt = function(req){
var url = req.url.indexOf('?')!=-1?req.url.split('?')[0]:req.url;

@@ -29,3 +37,4 @@ return path.extname(url);

prototype.doAction = function(req,res){
dispatcher.doAction = function(req,res){
res.setHeader("Content-Type", "text/html; charset=" + this.context.get("encoding"));
var errMessage = null;

@@ -75,3 +84,3 @@

prototype.doResource = function(req,res){
dispatcher.doResource = function(req,res){
var url = req.url;

@@ -104,3 +113,3 @@ var ext = path.extname(url);

prototype.getController = function(url){
dispatcher.getController = function(url){
var controller = null;

@@ -129,3 +138,3 @@ var controllerName = this.getControllerName(url);

prototype.getControllerName = function(url){
dispatcher.getControllerName = function(url){
var name;

@@ -142,3 +151,3 @@ if(this.isDefaultController(url)){

prototype.getControllerFile = function(url){
dispatcher.getControllerFile = function(url){
var file;

@@ -155,3 +164,3 @@ if(this.isDefaultController(url)){

prototype.getAction = function(url){
dispatcher.getAction = function(url){
var action = this.context.get('defaultAction');

@@ -164,3 +173,3 @@ if(url.lastIndexOf("/") != (url.length-1)){

prototype.isAction = function(req){
dispatcher.isAction = function(req){
var ext = this.getExt(req);

@@ -170,8 +179,8 @@ return ext == this.context.get('suffix');

prototype.isDefaultController = function(url){
dispatcher.isDefaultController = function(url){
return url.lastIndexOf('/')==0;
}
prototype.shouldReloadController = function(file){
dispatcher.shouldReloadController = function(file){
return this.context.get('debug')==true || this.context.getObject("controllers", file) == undefined;
}

@@ -0,1 +1,11 @@

/**
* Copyright (c) 2012, Zhiyu Zheng. All rights reserved.
* Licensed under the MIT License
*
* Hosted On Github :
* http://github.com/zhiyu/icecream
*
*/
var common = module.exports = {}

@@ -2,0 +12,0 @@

@@ -0,1 +1,11 @@

/**
* Copyright (c) 2012, Zhiyu Zheng. All rights reserved.
* Licensed under the MIT License
*
* Hosted On Github :
* http://github.com/zhiyu/icecream
*
*/
var Log = module.exports = {}

@@ -2,0 +12,0 @@

@@ -1,13 +0,21 @@

var path = require('path');
var urlHelper = require("url");
var fs = require('fs');
var connect = require('connect')
var http = require('http');
var Dispatcher = require('./dispatcher');
var cluster = require('cluster');
var utils = require('./utils');
var wrench = require('wrench');
var log4js = require('log4js');
var logger = log4js.getLogger();
/**
* Copyright (c) 2012, Zhiyu Zheng. All rights reserved.
* Licensed under the MIT License
*
* Hosted On Github :
* http://github.com/zhiyu/icecream
*
*/
var path = require('path'),
urlHelper = require("url"),
fs = require('fs'),
connect = require('connect'),
http = require('http'),
cluster = require('cluster'),
utils = require('./utils'),
wrench = require('wrench'),
logger = require('log4js').getLogger();
var icecream = module.exports = {

@@ -17,11 +25,33 @@ version : JSON.parse(fs.readFileSync(__dirname + '/../package.json', 'utf8')).version

/**
* Create Server
*
* @method createServer
* @params {Object} options options for icecream
* @return {Object} connect server object
*/
icecream.createServer = function(options){
this.options = options;
this.init();
this.server = connect();
//set global object
global.icecream = this;
//init icecream
this.init(options);
//create server
this.server = connect();
this.server.use(connect.query());
this.server.use(connect.bodyParser());
return this;
}
icecream.init = function(){
global.icecream = this;
/**
* Init default settings
*
* @method init
* @param {Object} options options for icecream
* @return {void}
*/
icecream.init = function(options){
//init global variables
this.engines = {};

@@ -31,6 +61,7 @@ this.config = {};

//default settings for icecream
this.set('defaultEngine', 'ejs');
this.set('sysDir', __dirname);
this.set('appDir', path.dirname(process.argv[1])+"/app/");
this.set('appRoot', path.dirname(process.argv[1])+"/");
this.set('sysDir', __dirname);
this.set('appDir', path.dirname(process.argv[1])+"/app/");
this.set('appRoot', path.dirname(process.argv[1])+"/");
this.set('defaultController', 'page');

@@ -41,16 +72,16 @@ this.set('defaultAction', 'index');

this.set('suffix', '');
//user settings for icecream
for(var i in options){
this.set(i, options[i]);
}
//set template engines
this.engine('jade', require('jade').renderFile);
this.engine('ejs', require('ejs').renderFile);
for(var i in this.options){
this.set(i, this.options[i]);
}
this.dispatcher = new Dispatcher();
//load components
this.loadLibraries();
this.loadHelpers();
this.loadLanguages();
}

@@ -65,10 +96,9 @@

var self = this;
this.server.use(connect.query());
this.server.use(connect.bodyParser());
var dispatcher = require('./dispatcher');
this.server.use(function(req, res){
res.setHeader("Content-Type", "text/html; charset=" + self.get("encoding"));
self.dispatcher.dispatch(req, res);
dispatcher.dispatch(req, res);
});
//set cluser
if (this.get("cluster")==true && cluster.isMaster) {

@@ -115,2 +145,11 @@ logger.info("cluster enabled...");

/**
* Get Object From Cache
*
* @method getObject
*
* @param {String} cache
* @param {String} key
* @return {Object}
*/
icecream.getObject = function(cache, key){

@@ -128,10 +167,2 @@ if(!this.caches[cache])

icecream.template = function(type, args){
if(type === 'app'){
var parent = process.cwd();
var name = args.shift();
wrench.copyDirSyncRecursive(__dirname+"/templates", parent+"/"+name);
}
}
icecream.loadLibraries = function(){

@@ -192,2 +223,9 @@ var self = this;

/**
* Load Language Files
*
* @method loadLanguages
*
* @return {void}
*/
icecream.loadLanguages = function(){

@@ -194,0 +232,0 @@ var self = this;

@@ -0,1 +1,11 @@

/**
* Copyright (c) 2012, Zhiyu Zheng. All rights reserved.
* Licensed under the MIT License
*
* Hosted On Github :
* http://github.com/zhiyu/icecream
*
*/
var Validator = module.exports = function(){}

@@ -2,0 +12,0 @@

@@ -0,1 +1,11 @@

/**
* Copyright (c) 2012, Zhiyu Zheng. All rights reserved.
* Licensed under the MIT License
*
* Hosted On Github :
* http://github.com/zhiyu/icecream
*
*/
module.exports = {

@@ -2,0 +12,0 @@ ".css" : "text/css",

@@ -0,1 +1,11 @@

/**
* Copyright (c) 2012, Zhiyu Zheng. All rights reserved.
* Licensed under the MIT License
*
* Hosted On Github :
* http://github.com/zhiyu/icecream
*
*/
var utils = module.exports = {}

@@ -2,0 +12,0 @@

@@ -0,1 +1,11 @@

/**
* Copyright (c) 2012, Zhiyu Zheng. All rights reserved.
* Licensed under the MIT License
*
* Hosted On Github :
* http://github.com/zhiyu/icecream
*
*/
var View = module.exports = function(){}

@@ -2,0 +12,0 @@ View.prototype.render = function(path, engine, options, callback){

{
"name": "icecream",
"version": "0.2.5",
"version": "0.2.7",
"description": "rapid web framework for nodejs",

@@ -5,0 +5,0 @@ "homepage": "http://github.com/zhiyu/icecream",

@@ -1,23 +0,3 @@

beforeFilter(function(){
this.validator = load('validator');
action("index", function(){
render('index');
});
action("index", function(){
validator.select("12345").length(6);
test_global();
render();
});
action("test", function(){
send("test");
});
action("set_lang", function(){
session("lang", "zh_CN");
render('index');
});
action("del_lang", function(){
session("lang", "");
render('index');
});
module.exports = {
"AppName":"icecream"
"AppName":"Pomelo Ext"
}
module.exports = {
"AppName":"冰激凌"
"AppName":"Pomelo Ext"
}
var connect = require('../node_modules/connect');
var icecream = require('icecream');
var app = require('../icecream/');
icecream.createServer();
icecream.set("appDir", __dirname +'/app');
icecream.set("debug", true);
icecream.set("cluster", true);
icecream.use(connect.cookieParser());
icecream.use(connect.session({ secret:'DFJLK8DFGJ933JKLFGJ2'}));
app.createServer();
icecream.share({
app.share({
hello:function(){

@@ -17,3 +12,3 @@ this.send("hello");

icecream.global({
app.global({
test_global:function(){

@@ -24,2 +19,2 @@ console.log("test global");

icecream.listen(3000);
app.listen(3000);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc