Permalink
Browse files

move examples outside of the main project

  • Loading branch information...
1 parent 217001c commit 1aaea4afc8535eda04eefe56533bc53d0d5b948b @ben-lin ben-lin committed Sep 7, 2012
Showing with 4 additions and 2,014 deletions.
  1. +4 −0 examples/README.md
  2. +0 −5 examples/oauth-twitter/.gitignore
  3. +0 −3 examples/oauth-twitter/README.md
  4. +0 −52 examples/oauth-twitter/app/controllers/application.js
  5. +0 −8 examples/oauth-twitter/app/controllers/home.js
  6. +0 −54 examples/oauth-twitter/app/controllers/sessions.js
  7. +0 −22 examples/oauth-twitter/app/helpers/application.js
  8. 0 examples/oauth-twitter/app/libs/.gitkeep
  9. +0 −3 examples/oauth-twitter/app/locales/en/welcome.js
  10. +0 −9 examples/oauth-twitter/app/middlewares/csrf.js
  11. +0 −16 examples/oauth-twitter/app/middlewares/err404.js
  12. +0 −17 examples/oauth-twitter/app/middlewares/err500.js
  13. +0 −12 examples/oauth-twitter/app/middlewares/logger.js
  14. +0 −40 examples/oauth-twitter/app/middlewares/passport.js
  15. +0 −24 examples/oauth-twitter/app/middlewares/session.js
  16. 0 examples/oauth-twitter/app/models/.gitkeep
  17. +0 −29 examples/oauth-twitter/app/models/User.js
  18. +0 −9 examples/oauth-twitter/app/views/common/_nav.html
  19. +0 −1 examples/oauth-twitter/app/views/error/404.html
  20. +0 −1 examples/oauth-twitter/app/views/error/500.html
  21. +0 −6 examples/oauth-twitter/app/views/home/index.html
  22. +0 −35 examples/oauth-twitter/app/views/layouts/default.html
  23. +0 −33 examples/oauth-twitter/config/assets.yml
  24. +0 −41 examples/oauth-twitter/config/dev/config.yml
  25. +0 −26 examples/oauth-twitter/config/dev/express.js
  26. +0 −30 examples/oauth-twitter/config/prod/config.yml
  27. +0 −21 examples/oauth-twitter/config/prod/express.js
  28. +0 −7 examples/oauth-twitter/config/routes.js
  29. +0 −34 examples/oauth-twitter/config/test/config.yml
  30. +0 −25 examples/oauth-twitter/config/test/express.js
  31. +0 −40 examples/oauth-twitter/db/schema/index.js
  32. +0 −3 examples/oauth-twitter/doc/README.md
  33. 0 examples/oauth-twitter/log/monit.log
  34. 0 examples/oauth-twitter/log/nginx.log
  35. 0 examples/oauth-twitter/log/static.log
  36. 0 examples/oauth-twitter/log/upstart.log
  37. +0 −28 examples/oauth-twitter/package.json
  38. BIN examples/oauth-twitter/public/apple-touch-icon-114x114-precomposed.png
  39. BIN examples/oauth-twitter/public/apple-touch-icon-129x129-precomposed.png
  40. BIN examples/oauth-twitter/public/apple-touch-icon-57x57-precomposed.png
  41. BIN examples/oauth-twitter/public/apple-touch-icon-72x72-precomposed.png
  42. BIN examples/oauth-twitter/public/apple-touch-icon-precomposed.png
  43. BIN examples/oauth-twitter/public/apple-touch-icon.png
  44. 0 examples/oauth-twitter/public/assets/.gitignore
  45. +0 −41 examples/oauth-twitter/public/css/common/base.css
  46. +0 −19 examples/oauth-twitter/public/css/common/flash.css
  47. +0 −23 examples/oauth-twitter/public/css/common/footer.css
  48. +0 −18 examples/oauth-twitter/public/css/common/header.css
  49. +0 −27 examples/oauth-twitter/public/css/common/nav.css
  50. +0 −56 examples/oauth-twitter/public/css/common/reset.css
  51. +0 −46 examples/oauth-twitter/public/css/common/util.css
  52. BIN examples/oauth-twitter/public/favicon.ico
  53. 0 examples/oauth-twitter/public/img/.gitkeep
  54. BIN examples/oauth-twitter/public/img/sprite.png
  55. +0 −5 examples/oauth-twitter/public/js/common/ga.js
  56. +0 −1 examples/oauth-twitter/public/robots.txt
  57. +0 −1 examples/oauth-twitter/server.js
  58. 0 examples/oauth-twitter/test/.gitkeep
  59. 0 examples/oauth-twitter/tmp/.gitkeep
  60. +0 −5 examples/redis/.gitignore
  61. +0 −41 examples/redis/README.md
  62. +0 −52 examples/redis/app/controllers/application.js
  63. +0 −98 examples/redis/app/controllers/blogs.js
  64. +0 −8 examples/redis/app/controllers/welcome.js
  65. +0 −22 examples/redis/app/helpers/application.js
  66. 0 examples/redis/app/libs/.gitkeep
  67. +0 −28 examples/redis/app/libs/redis.js
  68. +0 −3 examples/redis/app/locales/en/welcome.js
  69. +0 −9 examples/redis/app/middlewares/csrf.js
  70. +0 −16 examples/redis/app/middlewares/err404.js
  71. +0 −17 examples/redis/app/middlewares/err500.js
  72. +0 −12 examples/redis/app/middlewares/logger.js
  73. +0 −24 examples/redis/app/middlewares/session.js
  74. +0 −21 examples/redis/app/models/Blog.js
  75. +0 −13 examples/redis/app/views/blogs/_form.html
  76. +0 −13 examples/redis/app/views/blogs/edit.html
  77. +0 −55 examples/redis/app/views/blogs/index.html
  78. +0 −11 examples/redis/app/views/blogs/new.html
  79. +0 −32 examples/redis/app/views/blogs/show.html
  80. +0 −14 examples/redis/app/views/common/_nav.html
  81. +0 −1 examples/redis/app/views/error/404.html
  82. +0 −1 examples/redis/app/views/error/500.html
  83. +0 −35 examples/redis/app/views/layouts/default.html
  84. +0 −6 examples/redis/app/views/welcome/index.html
  85. +0 −33 examples/redis/config/assets.yml
  86. +0 −45 examples/redis/config/dev/config.yml
  87. +0 −25 examples/redis/config/dev/express.js
  88. +0 −30 examples/redis/config/prod/config.yml
  89. +0 −21 examples/redis/config/prod/express.js
  90. +0 −4 examples/redis/config/routes.js
  91. +0 −34 examples/redis/config/test/config.yml
  92. +0 −25 examples/redis/config/test/express.js
  93. 0 examples/redis/db/migrate/.gitkeep
  94. +0 −36 examples/redis/db/schema/index.js
  95. +0 −3 examples/redis/doc/README.md
  96. 0 examples/redis/log/monit.log
  97. 0 examples/redis/log/nginx.log
  98. 0 examples/redis/log/static.log
  99. 0 examples/redis/log/upstart.log
  100. +0 −24 examples/redis/package.json
  101. BIN examples/redis/public/apple-touch-icon-114x114-precomposed.png
  102. BIN examples/redis/public/apple-touch-icon-129x129-precomposed.png
  103. BIN examples/redis/public/apple-touch-icon-57x57-precomposed.png
  104. BIN examples/redis/public/apple-touch-icon-72x72-precomposed.png
  105. BIN examples/redis/public/apple-touch-icon-precomposed.png
  106. BIN examples/redis/public/apple-touch-icon.png
  107. 0 examples/redis/public/assets/.gitignore
  108. +0 −41 examples/redis/public/css/common/base.css
  109. +0 −19 examples/redis/public/css/common/flash.css
  110. +0 −23 examples/redis/public/css/common/footer.css
  111. +0 −18 examples/redis/public/css/common/header.css
  112. +0 −27 examples/redis/public/css/common/nav.css
  113. +0 −56 examples/redis/public/css/common/reset.css
  114. +0 −46 examples/redis/public/css/common/util.css
  115. +0 −88 examples/redis/public/css/scaffold.css
  116. BIN examples/redis/public/favicon.ico
  117. 0 examples/redis/public/img/.gitkeep
  118. BIN examples/redis/public/img/sprite.png
  119. +0 −5 examples/redis/public/js/common/ga.js
  120. +0 −1 examples/redis/public/robots.txt
  121. +0 −1 examples/redis/server.js
  122. 0 examples/redis/test/.gitkeep
  123. 0 examples/redis/tmp/.gitkeep
  124. +0 −1 lib/cli/generators/templates/package.json
View
@@ -0,0 +1,4 @@
+# COKE Emaples
+
+- twitter oauth
+- redis witn mongodb
@@ -1,5 +0,0 @@
-.DS_Store
-.sass-cache
-node_modules
-logs/*
-*.gz
@@ -1,3 +0,0 @@
-# coke-oauth
-
-Start writing your project description here :)
@@ -1,52 +0,0 @@
-var Class = require( 'node.class' );
-
-module.exports = Class.extend({
-
- no_content : function ( err, req, res, next ){
- err && LOG.error( 500, res, err );
-
- req.flash( 'flash-error', req.msg + ' not found' );
- res.redirect( 'back' );
- },
-
- validation : function ( err, req, res, next ){
- if( err.name && err.name == 'ValidationError' ){
- var error;
- for( error in err.errors ){
- req.flash( 'flash-error', err.errors[ error ].message );
- }
-
- res.redirect( 'back' );
- LOG.error( 500, res, err );
-
- return;
- }
-
- next( err );
- },
-
- unique : function ( err, req, res, next ){
- if( err.name && err.name == 'MongoError' ){
- // respond with html page
- if( req.accepts( 'html' )){
- req.flash( 'flash-error', err.err );
- res.redirect( 'back' );
- LOG.error( 46, res, err );
-
- return;
- }
-
- // respond with json
- if( req.accepts( 'json' )){
- res.json({
- status : 46,
- body : 'The given field has been taken'
- });
-
- return;
- }
- }
-
- next( err );
- }
-});
@@ -1,8 +0,0 @@
-var Class = require( 'node.class' );
-
-module.exports = Class.extend({
-
- index : function ( req, res ){
- res.render( 'home/index' );
- }
-});
@@ -1,54 +0,0 @@
-var Application = require( CONTROLLER_DIR + 'application' );
-var passport = require( 'passport' );
-var mongoose = require( 'mongoose' );
-var User = Model( 'User' );
-
-module.exports = Application.extend({
-
- init : function ( before, after ){
- before( this.referer, { only : [ 'new' ]});
- before( this.failure_redirect, { only : [ 'create' ]});
- },
-
- referer : function ( req, res, next ){
- var referer = req.headers.referer ?
- req.headers.referer : '/';
-
- res.cookie( 'referer', referer );
- next();
- },
-
- failure_redirect : passport.authenticate( 'twitter', {
- failureRedirect : '/'
- }),
-
- 'new' : passport.authenticate( 'twitter' ),
-
- create : function ( req, res, next ){
- var referer = req.cookies.referer ?
- req.cookies.referer : '/';
-
- var args = {
- twitter_id : req.user.id,
- name : req.user.displayName,
- lang : req.user._json.lang,
- avatar : req.user._json.profile_image_url
- };
-
- User.create( args,
- // error
- function ( err ){
- LOG.error( 500, res, err );
- res.redirect( '/logout' );
- },
- // success
- function (){
- res.redirect( referer );
- });
- },
-
- destroy : function ( req, res, next ){
- req.logout();
- res.redirect( '/' );
- }
-});
@@ -1,22 +0,0 @@
-var moment = require( 'moment' );
-
-module.exports = function ( app ){
- app.helpers({
-
- selected : function ( target, current ){
- return target === current ? 'selected' : '';
- },
-
- val : function ( obj, prop ){
- return obj === undefined ? '' : obj[ prop ];
- },
-
- date : function ( date, format ){
- return moment( date ).format( format || 'MMM Do YYYY, h:m:s' );
- }
- });
-
- app.dynamicHelpers({
- messages : require( 'express-messages' )
- });
-};
No changes.
@@ -1,3 +0,0 @@
-module.exports = {
-
-};
@@ -1,9 +0,0 @@
-module.exports = function ( app, express ){
- app.dynamicHelpers({
- csrf : function ( req, res ){
- return req.session._csrf;
- }
- });
-
- return express.csrf();
-};
@@ -1,16 +0,0 @@
-module.exports = function err404( req, res, next ){
- res.status( 404 );
-
- // respond with html page
- if( req.accepts( 'html' )){
- return res.render( 'error/404' );
- }
-
- // respond with json
- if( req.accepts( 'json' )){
- return res.end();
- }
-
- // default to plain-text. send()
- res.type( 'txt' ).send( 'Not found' );
-};
@@ -1,17 +0,0 @@
-module.exports = function err500( err, req, res, next ){
- res.status( err.status || 500 );
- res.result = err;
-
- // respond with html page
- if( req.accepts( 'html' )){
- return res.render( 'error/500' );
- }
-
- // respond with json
- if( req.accepts( 'json' )){
- return res.end();
- }
-
- // default to plain-text. send()
- res.type( 'txt' ).send( 'Internal Server Error' );
-};
@@ -1,12 +0,0 @@
-module.exports = function request ( req, res, next ){
- var end = res.end;
- res.end = function ( chunk, encoding ){
- res.end = end;
- res.end( chunk, encoding );
- LOG.response( res.statusCode, res, res.result );
- };
-
- // log all request including error requests
- LOG.request( req );
- next();
-};
@@ -1,40 +0,0 @@
-var passport = require( 'passport' );
-var Strategy = require( 'passport-twitter' ).Strategy;
-var User = Model( 'User' );
-
-var config = CONF.passport;
-
-passport.serializeUser( function( user, next ){
- var id = user.id ?
- user.id : user.twitter_id;
-
- next( null, id );
-});
-
-passport.deserializeUser( function ( id, next ){
- User.findOne({
- twitter_id : id
- }, function ( err, user ){
- if( user ) return next( null, user );
-
- next( null, id );
- });
-});
-
-passport.use( new Strategy({
- consumerKey : config.twitter_consumer_key,
- consumerSecret : config.twitter_consumer_secret,
- callbackURL : config.callback_url
-}, function ( accessToken, refreshToken, profile, next ){
- process.nextTick( function () {
- return next( null, profile );
- });
-}));
-
-module.exports = function (){
- return function ( req, res, next ){
- passport.initialize()( req, res, function (){
- passport.session()( req, res, next );
- });
- };
-};
@@ -1,24 +0,0 @@
-var Store = require( 'connect-mongodb' );
-var session = CONF.session;
-var db = CONF.db;
-
-var opt = {
- db : UTILS.db()
-};
-
-if( session.collection ) opt.collection = session.collection;
-if( db.username ) opt.username = db.username;
-if( db.password ) opt.password = db.password;
-
-module.exports = function ( express ){
- return express.session({
- secret : session.secret,
- cookie : {
- maxAge : 3600000 // 60 minutes
- },
- store : new Store( opt ),
- fingerprint : function (){
- return '';
- }
- });
-};
No changes.
@@ -1,29 +0,0 @@
-module.exports = {
-
- statics : {
-
- create : function ( args, next, created ){
- var twitter_id = args.twitter_id;
- var self = this;
-
- this.findOne({
- twitter_id : twitter_id
- }, function ( err, user ){
- if( err ) return next( err );
- if( user ) return created( user );
-
- user = new self({
- twitter_id : twitter_id,
- name : args.name,
- lang : args.lang,
- avatar : args.avatar
- }).
- save( function ( err, user, count ){
- if( err ) return next( err );
-
- created( user );
- });
- });
- }
- }
-};
@@ -1,9 +0,0 @@
-<nav>
- <ul>
- <li>
- <h3>
- <a class="<?= it.selected( 'home', it.nav_selected ) ?>" href="/">Home</a>
- </h3>
- </li>
- </ul>
-</nav>
@@ -1 +0,0 @@
-<? it.title = 'Page Not Found'; ?>
@@ -1 +0,0 @@
-<? it.title = 'Shit happened'; ?>
@@ -1,6 +0,0 @@
-<? it.title = 'Welcome to coke-oauth'; ?>
-<? it.nav_selected = 'home'; ?>
-
-<h2>
- “ COKE is a lightweight node.js MVC framework that speeds up your web development. It’s simple, it’s modulized, it’s somking fast! ”
-</h2>
@@ -1,35 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <meta charset="utf-8" />
- <title><?= it.title ?></title>
- <meta name="keywords" content="<?= it.keywords || '' ?>" />
- <meta name="description" content="<?= it.description || '' ?>" />
- <meta name="viewport" content="width=device-width,initial-scale=1.0" />
- <?= it.css( it.styles ) ?>
- <!--[if lt IE 9]>
- <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
- <![endif]-->
- </head>
- <body>
- <div id="wrap">
- <div id="header">
- <header>
- <h1><?= it.title ?></h1>
- <a id="logo" href="/" rel="home" title="Go to home page">
- coke-oauth
- </a>
- </header>
- <?= it.partial( 'common/_nav' ) ?>
- </div>
- <div id="content" role="main">
- <?= it.messages() ?>
- <?= it.body ?>
- </div>
- <footer>
- Powered by <a id="logo-s" href="http://coke-js.org">COKE</a>
- </footer>
- </div>
- <?= it.js( it.scripts ) ?>
- </body>
-</html>
Oops, something went wrong.

0 comments on commit 1aaea4a

Please sign in to comment.