'use strict';
var Posts = module.parent.parent.require('./posts');
var Settings = module.parent.parent.require('./settings');
var Meta = module.parent.parent.require('./meta');
var Controllers = {};

Controllers.getPost = function(req, res, next){
	var allowOrigin = mySettings.origins.split(',').map(function(value){
		return value.trim();
	});
	if(allowOrigin.includes(req.headers.origin) || mySettings.onlyxhr=="off"){
		res.header("Access-Control-Allow-Origin", req.headers.origin);
		res.header("Access-Control-Allow-Headers", "X-Requested-With");
		Posts.getPostData(req.params.pid,function(err,result){
			res.send(result);
		});
	}else{
		res.send("permission denied");
	}
};

Controllers.renderAdminPage = function (req, res, next) {
	res.render('admin/plugins/ccmtpostinfo', {});
};

Controllers.categoriesPage = function(req, res, next){
	var defaultSetting = {};
	var mySettings = Meta.settings.get('ccmtpostinfo', function(err,mySettings){
		if(err)
		console.log("err:",err);
		res.render('plugins/ccmtpostinfo/categories', mySettings);
	});
}
module.exports = Controllers;


@@ -237,24 +237,123 @@
 res, next)%7B%0A
+%09Meta.settings.get('ccmtpostinfo', function(err,mySettings)%7B%0A%09%09if(err)%0A%09%09console.log(%22err:%22,err);%0A%09
 %09var allowOr
@@ -412,16 +412,17 @@
 lue)%7B%0A%09%09
+%09
 return v
@@ -434,21 +434,23 @@
 trim();%0A
+%09
 %09%7D);%0A
+%09
 %09if(allo
@@ -517,16 +517,17 @@
 %22off%22)%7B%0A
+%09
 %09%09res.he
@@ -581,24 +581,25 @@
 .origin);%0A%09%09
+%09
 res.header(%22
@@ -650,16 +650,17 @@
 With%22);%0A
+%09
 %09%09Posts.
@@ -707,24 +707,25 @@
 result)%7B%0A%09%09%09
+%09
 res.send(res
@@ -732,20 +732,22 @@
 ult);%0A%09%09
+%09
 %7D);%0A
+%09
 %09%7Delse%7B%0A
@@ -748,16 +748,17 @@
 else%7B%0A%09%09
+%09
 res.send
@@ -785,14 +785,19 @@
 );%0A%09
-%7D
+%09%7D%0A%09%7D);
 %0A%7D;%0A
-%0A
 Cont
@@ -900,17 +900,16 @@
 %7B%7D);%0A%7D;%0A
-%0A
 Controll

add err handle againy