Work Share
by luckydrq
Topic 1
A project called Lego
So..What is Lego
It devides a page into pieces
And..it is implemented by the back end,not the front end
How?
It goes like this:
<body bx-app>
<div class="span5">
#mosaic("ceiling")
</div>
...
</body>
What does #mosaic mean?
It is syntax of Velocity
#macro( mosaic $name $index $spm)
#set( $namespace = $pageAttribute.get('namespace') )
#set( $id = $name + ($index || '') )
...
<div id="$id" class="$css" bx-name="$namespace/$name" data-spm="$!{spm}">#parse($vm)</div>
#end
Uh..you may get confused.
Let me explain...
We call it a "Component"
How it works?
KISSY, Brix
=>
JSON
=>
dataApi
====> Awsome!
====> Awsome!
Some problems
Discussion:
1、Page memory
2、Resource manage
Topic 2
Concurrent tasks in Mosaic daemon
It is a node.js app that is used to deal with the published components.
When a client starts to publish a component, the package will be gzipped and sent to the server via Http-Post.
The server will do the following staffs when receiving a request:
1、Ungzip the files
2、Concat and minify js and css files for deploying
3、Upload to CDN
4、Update local repository
Every step is a promise
Well..time to explain
If concurrent requests arrive, only one can be resolved. Others will be rejected.
That's not pretty!
Concurrency is not a problem for node.js since its nature of evented IO
However, the tasks in our project need to execute sequence by sequence to some point, such as uploading to CDN
So, we need to analyze each step of a task to study the possibility of concurrency and also find out which one is time-consuming
Discusstion
Topic 3
Introduction of Node-inspector
Node-inspector is a tool which allows debuging node.js apps in browser
It's convinient and simple
First of all, install globally:
npm install node-inspector --global
Assume that i have a simple app.js:
var http = require('http')
var express = require('express')
var app = express()
app.use('/hello', function(req, res){
var s = "hello world"
res.end(s)
})
http.createServer(app).listen(7000)
Then take following steps:
1、cd path/of/app
2、node --debug-brk app.js
After that, the terminal shows "debugger listening on port 5858"
Open the link in a tab of chrome:
It stops at the first line, set breaks and click to skip(press F8 in windows)
Well..it works!
Thank you