Skip to content

Commit

Permalink
Added simple server and project structure was changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
devalexqt committed Dec 10, 2014
1 parent 3b1279e commit 1527ca0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


PageManager it's Javascript page system management in browser. Simple but powerful script wath work in all modern desktop and mobile browser and allow to create page management in webview. This script will be ideal for mobile application that using HTML5 code. With PageManager You can create amazing mobile application just in seconds! In other word it's quick start to create cordova html 5 application!
#Description
PageManager it's Javascript page system management in browser. Simple but powerful script wath work in all modern desktop and mobile browser and allow to create page management in webview. This script will be ideal for mobile application that using HTML5 code. With PageManager You can create amazing mobile application just in seconds! In other word it's quick start to create **cordova** html 5 application!

#Demo

Expand All @@ -15,12 +15,14 @@ cd js-page-manager/
npm install
```

* Run Node.js simple server wath using [less](http://lesscss.org/) pre-processor for css file and [swig](http://paularmstrong.github.io/swig/) html template engine.
* Run Node.js simple server that using [Less](http://lesscss.org/) as pre-processor for css file and [SWIG](http://paularmstrong.github.io/swig/) as html template engine.
```
node server.js
```
* Now visit to http://127.0.0.1/index.html

* **After You finishing development then You need to generate .css and .html file using Less and SWIG commands**


#Usage

Expand Down
14 changes: 8 additions & 6 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ var url = require("url")
var less = require('less')//css processor
var swig = require('swig')// html templete processor

var rootpath="./www/"

http.createServer(handler).listen(80)
swig.setDefaults({ cache: false,allowErrors: true });

console.log("==>Simple server for developing started on port 80. Now visit to http://127.0.0.1/ or http://127.0.0.1/index.html")
console.log("==>Simple server for developing started on port 80. Now visit to http://127.0.0.1/ or http://127.0.0.1/index.html \n Working directory: "+rootpath)

function handler(req,res){
console.log("==>New request: "+req.method+", "+req.url)
var url_parts=url.parse(req.url,true)
Expand All @@ -24,11 +26,11 @@ function handler(req,res){
//res.writeHead(200, headers);


var req_file="./www/"+url_parts.pathname
var extention=url_parts.pathname.split(".")
extention=extention[extention.length-1]
if(url_parts.pathname=="/"){url_parts.pathname="/index.html"}

if(req_file=="/"){req_file="/index.html"}
var req_file=rootpath+url_parts.pathname
var extention=req_file.split(".")
extention=extention[extention.length-1]

if (extention=="css"&&fs.existsSync(req_file.replace(".css",".less"))) {
req_file=req_file.replace(".css",".less")
Expand All @@ -48,7 +50,7 @@ function handler(req,res){
sendPage(data,"text/javascript")
}//if js
else if(extention=="less"){
less.render(data.toString(), function (err, data) {
less.render(data.toString(),{paths: rootpath}, function (err, data) {
if (err){console.log("==>cant parse less file, err: "+err);res.statusCode=404;res.end(); return};
sendPage(data.css,"text/css")//[css,imports]
})//less
Expand Down
2 changes: 1 addition & 1 deletion www/css/style.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//less
@import "/css/page-manager.less";
@import (less) "css/page-manager.less";
//colors
@color-green2: rgb(57,202,108);
@color-metal:rgba(117, 149, 164,1.0);//background
Expand Down

0 comments on commit 1527ca0

Please sign in to comment.