Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dux/node-lux
Micro node-js framework writter in coffee script, with cell based routing, templateing + promises
https://github.com/dux/node-lux
Last synced: about 2 months ago
JSON representation
Micro node-js framework writter in coffee script, with cell based routing, templateing + promises
- Host: GitHub
- URL: https://github.com/dux/node-lux
- Owner: dux
- License: mit
- Created: 2015-09-09T09:05:37.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-14T12:55:27.000Z (about 9 years ago)
- Last Synced: 2023-03-24T05:21:48.070Z (almost 2 years ago)
- Language: CoffeeScript
- Homepage:
- Size: 225 KB
- Stars: 2
- Watchers: 0
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# What?
Port of Ruby web framework Lux to JavaScript
Written in CoffeeScript
* full working app
* session
* models
* router
* controller/cell
* view render (haml)## install
npm install
npm run server
## rotuer looks like this
notite that user is loaded before routing starts
```
User = load_module 'models/user'module.exports = ->
# load user from session before routing
if @session.id
@locals.USER = User.get(@session.id)
root = @root_path.singularizereturn @cell('base').layout('root') if root == ''
return @cell('api').respond() if root == 'api'
return @cell('gallery').respond() if root == 'gallery'
return @cell('user').layout('login') if root == 'login'
return @cell('user').respond() if root == 'user'@cell('base').not_found()
```
## user_cell
This is complete user cell
```
Users = load_module 'models/user'module.exports = class UserCell extends load_module('cells/app_cell')
index: ->
@render users:Users.all()show: (id) ->
user = Users.get(id)
return @error "User with id #{id} is not found" unless user
@render user:user
login: ->
@render()profile: ->
@render_with_layout('user/profile')bye: ->
delete @page.session.id
@page.redirect('/')
return 'Redirecting to root...'
```