Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"no-undef": 2,
"no-shadow": [1, {"hoist": "functions", "allow": ["e"] }],
"no-use-before-define": [2, "nofunc"],
"no-unused-vars": [1, {"vars": "all", "args": "none"}]
"no-unused-vars": [1, {"vars": "all", "args": "none"}],
"no-dupe-keys": 2,
"no-redeclare": 2
},
"env": {
"node": true
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ gulp.task('fetchPublicFromClient', () => {

gulp.task('apidoc', () => {

const cmd = 'node_modules/apidoc/bin/apidoc -i src -o public/apidoc';
const cmd = 'node_modules/apidoc-support-socketio/bin/apidoc-support-socketio -i src -o public/apidoc';
console.log( cmd );
syncExec( cmd );

Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "corco",
"version": "0.1.0",
"name": "parallels-comments",
"version": "0.2.0",
"private": true,
"scripts": {
"apidoc": "node_modules/apidoc/bin/apidoc -i src -o public/apidoc",
"apidoc": "node_modules/apidoc-support-socketio/bin/apidoc-support-socketio -i src -o public/apidoc",
"start": "node starter",
"restart": "node starter --restart"
},
Expand All @@ -14,6 +14,8 @@
"debug": "~2.2.0",
"express": "~4.12.4",
"jade": "~1.9.2",
"log4js": "^0.6.30",
"log4js-extend": "^0.1.2",
"morgan": "~1.5.3",
"node-sass": "^3.4.2",
"node-svn-ultimate": "^1.0.2",
Expand All @@ -26,7 +28,7 @@
"yargs": "^3.31.0"
},
"devDependencies": {
"apidoc": "^0.14.0",
"apidoc-support-socketio": "^0.2.3",
"babel-preset-es2015": "^6.3.13",
"babel-register": "^6.3.13",
"del": "^2.2.0",
Expand Down
2 changes: 1 addition & 1 deletion pm2script.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name" : "corco-server",
"name" : "paralalles-comments",
//"args" : ["--toto=heya coco", "-d", "1"],

"cwd" : "src/",
Expand Down
67 changes: 67 additions & 0 deletions public/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

<!doctype html>
<html>
<head>

<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<title>{{title}}</title>

<link rel="stylesheet" href="css/normalize.css">
</head>

<body>

<a href="#aaa">aaa</a>
<a href="#bbb">bbb</a>
<a href="#ccc">ccc</a>
<div id="remove">remove</div>

<form action="sub.html" method="get" target="sub">
<input type="submit" value="go iframe" />
</form>

<iframe id="sub" name="sub"></iframe>


<script type="text/javascript" src="http://code.jquery.com/jquery-1.12.0.min.js"></script>
<script>

function remove() {
//$('iframe').remove();
//$('iframe').attr("src", "" );
var frame = document.getElementById("sub");
//frameDoc = frame.contentWindow.document;
//frameDoc.close();
frameDoc = frame.contentDocument || frame.contentWindow.document;
frameDoc.documentElement.innerHTML = "";
}

console.log('hi');
$('#remove').on('click', function() {
remove();
});
var frame = window.frames["sub"];

var h = [];
$('iframe').on('load', function() {
//h.push( iframe.location.href );
console.log( 'hfffi' );
console.log( frame.window.location.href );
console.log( frame.window.history.length );
});
$('iframe').on('unload', function() {
//h.push( iframe.location.href );
console.log( 'unload' );
});

// 솔루션
//얼마나 forward 이동했는지 기록.
//forward 이동한만큼 back( 이동한만큼 )
//load 이벤트가 받으면 iframe 삭제

</script>
</body>

</html>
27 changes: 27 additions & 0 deletions public/sub.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

<!doctype html>
<html ng-app="corco">
<head>

<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<title>{{title}}</title>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.12.0.min.js"></script>
<link rel="stylesheet" href="css/normalize.css">
</head>

<body>

<form action="sub2.html" method="get">
<input type="submit" value="sub2" />
</form>
<script>
//$('form').submit();

</script>

</body>

</html>
24 changes: 24 additions & 0 deletions public/sub2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

<!doctype html>
<html ng-app="corco">
<head>

<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<title>{{title}}</title>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.12.0.min.js"></script>
<link rel="stylesheet" href="css/normalize.css">
</head>

<body>

sub2
sub2
sub2
sub2

</body>

</html>
20 changes: 0 additions & 20 deletions src/_apidoc.js

This file was deleted.

3 changes: 2 additions & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());

app.use('/', router);
app.use('/', router );
app.use('/', docRouter );

//app.use(express.static( path.join(__dirname, 'public')));
app.use(express.static( process.env.PUBLIC_PATH ));
console.log( process.env.PUBLIC_PATH );

// catch 404 and forward to error handler
app.use(function(req, res, next) {
Expand Down
10 changes: 8 additions & 2 deletions src/bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@
* Module dependencies.
*/

process.env.DEVELOPMENT = JSON.parse( process.env.DEVELOPMENT );
process.env.PRODUCTION = JSON.parse( process.env.PRODUCTION );
try {
process.env.DEVELOPMENT = JSON.parse( process.env.DEVELOPMENT );
process.env.PRODUCTION = JSON.parse( process.env.PRODUCTION );
} catch( err ) {

process.env.DEVELOPMENT = true;
process.env.PRODUCTION = false;
}

if( process.env.DEVELOPMENT ) {
require("babel-register");
Expand Down
88 changes: 62 additions & 26 deletions src/controller/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,35 @@
* @apiError (errorCode) { string } NO_ERROR success
*/

var _ = require('underscore');
var express = require('express');
var router = express.Router();
var logger = require('tracer').colorConsole();
var log4js = require('log4js');
var log4js_extend = require("log4js-extend");
log4js_extend(log4js, {
path: __dirname,
format: "at @name (@file:@line:@column)"
});
var logger = log4js.getLogger();

var DOC_DIR_PATH = process.env.DOC_DIR_PATH;
var fileManager = require('./fileManager/index');
fileManager.initRootPath( DOC_DIR_PATH );

function getErrorWillSendClient( err ) {

err = _.pick( err, 'errorCode' );
if( _.isEmpty( err ) ) {
err = { errorCode: 'UNKNOWN_ERROR' };
}

return err;
}

/**
* @api {post} /getDocList getDocList
* @api {post} /readDocList readDocList
* @apiGroup Doc
* @apiName getDocList
* @apiName readDocList
* @apiDescription READ the all doc list
* @apiVersion 0.1.0
* @apiUse CommonResult
Expand All @@ -36,83 +54,101 @@ fileManager.initRootPath( DOC_DIR_PATH );
* fileList: ["test1.corco","test2.corco"]
* }
*
* @apiSampleRequest /getDocList
* @apiSampleRequest /readDocList
*/
router.post('/getDocList', (req, res, next) => {
router.post('/readDocList', (req, res, next) => {

fileManager.loadFileList().then( ( fileList ) => {
res.send( fileList );
});
});

/**
* @api {get} /corcoFile/:fileName GET /corcoFile/:fileName
* @apiGroup CorcoFile
* @apiName GET /corcoFile/:fileName
* @api {post} /readDoc readDoc
* @apiGroup Doc
* @apiName readDoc
* @apiDescription READ the contents of specific filename
* @apiVersion 0.1.0
*
* @apiSuccess { string } raw The contents of corcoFile
* @apiParam { string } fileName fileName
*
* @apiSuccessExample Example data on success:
* {
* raw: "corco_question\n질문합니다!\ncorco_answer\n답변합니다"
* }
*
* @apiSampleRequest /corcoFile/test.corco
* @apiSampleRequest /readDoc
* @apiSampleRequestParam fileName="test.corco"
*/
router.get('/:fileName', (req, res, next) => {
router.post('/readDoc', (req, res, next) => {

const fileName = req.body.fileName;

logger.debug('get /corcoFile/'+req.params.fileName);
logger.debug( fileName );
logger.debug('post /readDoc/'+fileName);
//var filePath = path.join( CORCO_SVN_PATH, req.params.fileName );
fileManager.loadFile( req.params.fileName ).then( ( fileContent ) => {

fileManager.loadFile( fileName ).then( ( fileContent ) => {
res.send({ raw: fileContent });
});
});


/**
* @api {post} /corcoFile/:fileName POST /corcoFile/:fileName
* @apiGroup CorcoFile
* @apiName POST /corcoFile
* @api {post} /createDoc createDoc
* @apiGroup Doc
* @apiName createDoc
* @apiDescription CREATE a new corco file
* @apiVersion 0.1.0
*
* @apiParam { string } fileName The contents of corcoFile want to be save
* @apiParam { string } raw The contents of corcoFile want to be save
*
* @apiSuccess { string } errorCode A result of the request
* @apiSuccessExample Example data on success:
* { errorCode: "NO_ERROR" }
*
* @apiSampleRequest /corcoFile/test.corco
* @apiSampleRequest /createDoc
* @apiSampleRequestParam fileName="test4.corco"
* @apiSampleRequestParam raw="test test test"
*/
router.post('/:fileName', (req, res, next) => {
router.post('/createDoc', (req, res, next) => {

console.log('wef');
fileManager.saveFile( req.params.fileName, req.body.raw ).then( () => {
logger.info( req.body );
fileManager.createFile( req.body.fileName, req.body.raw ).then( () => {
res.send({ errorCode: 'NO_ERROR' });
}).catch( ( err ) => {

logger.error( err );
res.send( getErrorWillSendClient( err ) );
});
});

/**
* @api {put} /corcoFile/:fileName PUT /corcoFile/:fileName
* @apiGroup CorcoFile
* @apiName PUT /corcoFile
* @api {post} /updateDoc updateDoc
* @apiGroup Doc
* @apiName updateDoc
* @apiDescription UPDATE a exist corco file
* @apiVersion 0.1.0
*
* @apiParam { string } fileName fileName
* @apiParam { string } raw The contents of corcoFile want to be save
*
* @apiSuccess { string } errorCode A result of the request
* @apiSuccessExample Example data on success:
* { errorCode: "NO_ERROR" }
*
* @apiSampleRequest /corcoFile/test.corco
* @apiSampleRequest /updateDoc
* @apiSampleRequestParam fileName="test4.corco"
* @apiSampleRequestParam raw="test test test"
*/
router.put('/:fileName', (req, res, next) => {
router.post('/updateDoc', (req, res, next) => {

fileManager.saveFile( req.params.fileName, req.body.raw ).then( () => {
fileManager.updateFile( req.body.fileName, req.body.raw ).then( () => {
res.send({ errorCode: 'NO_ERROR' });
}).catch( ( err ) => {
logger.error( err );
res.send( getErrorWillSendClient( err ) );
});
});

Expand Down
Loading