mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
first pass at subfolder
This commit is contained in:
18
app.js
18
app.js
@@ -2,6 +2,7 @@
|
||||
var fs = require('fs'),
|
||||
path = require('path'),
|
||||
utils = require('./public/src/utils.js'),
|
||||
url = require('url'),
|
||||
args = {};
|
||||
|
||||
// Runtime environment
|
||||
@@ -21,6 +22,8 @@ fs.readFile(path.join(__dirname, 'config.json'), function(err, data) {
|
||||
global.config = JSON.parse(data);
|
||||
global.config.url = global.config.base_url + (global.config.use_port ? ':' + global.config.port : '') + '/';
|
||||
global.config.upload_url = global.config.url + 'uploads/';
|
||||
|
||||
|
||||
console.log('Info: Base Configuration OK.');
|
||||
|
||||
var meta = require('./src/meta.js');
|
||||
@@ -71,11 +74,13 @@ fs.readFile(path.join(__dirname, 'config.json'), function(err, data) {
|
||||
default_categories = JSON.parse(default_categories);
|
||||
|
||||
for (var category in default_categories) {
|
||||
console.log(category);
|
||||
admin.categories.create(default_categories[category]);
|
||||
}
|
||||
});
|
||||
|
||||
// Hardcoding uid 1 as an admin
|
||||
|
||||
console.log('Info: Hardcoding uid 1 as an admin');
|
||||
var user = require('./src/user.js');
|
||||
user.makeAdministrator(1);
|
||||
} else {
|
||||
@@ -123,11 +128,17 @@ fs.readFile(path.join(__dirname, 'config.json'), function(err, data) {
|
||||
if (!secret) secret = utils.generateUUID();
|
||||
if (!bcrypt_rounds) bcrypt_rounds = 10;
|
||||
|
||||
var urlObject = url.parse(base_url);
|
||||
var relative_path = urlObject.pathname;
|
||||
var host = urlObject.host;
|
||||
var protocol = urlObject.protocol;
|
||||
|
||||
var fs = require('fs'),
|
||||
path = require('path'),
|
||||
config = {
|
||||
secret: secret,
|
||||
base_url: base_url,
|
||||
relative_path: relative_path,
|
||||
port: port,
|
||||
use_port: use_port,
|
||||
upload_path: '/public/uploads/',
|
||||
@@ -162,10 +173,11 @@ fs.readFile(path.join(__dirname, 'config.json'), function(err, data) {
|
||||
// Client-side config
|
||||
fs.writeFile(path.join(__dirname, 'public', 'config.json'), JSON.stringify({
|
||||
socket: {
|
||||
address: base_url,
|
||||
address: protocol + '//' + host,
|
||||
port: port
|
||||
},
|
||||
api_url: base_url + (use_port ? ':' + port : '') + '/api/'
|
||||
api_url: protocol + '//' + host + (use_port ? ':' + port : '') + relative_path + '/api/',
|
||||
relative_path: relative_path
|
||||
}, null, 4));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
"socket.io": "0.9.14",
|
||||
"redis": "0.8.3",
|
||||
"express": "3.2.0",
|
||||
"express-namespace": "0.1.1",
|
||||
"connect": "2.7.6",
|
||||
"emailjs": "0.3.4",
|
||||
"cookie": "0.0.6",
|
||||
|
||||
@@ -43,7 +43,7 @@ var ajaxify = {};
|
||||
if (quiet !== true) {
|
||||
window.history.pushState({
|
||||
"url": url
|
||||
}, url, "/" + url);
|
||||
}, url, RELATIVE_PATH + '/' + url);
|
||||
}
|
||||
|
||||
jQuery('#footer, #content').fadeOut(100);
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
var socket,
|
||||
config,
|
||||
app = {},
|
||||
API_URL = null;
|
||||
API_URL = null,
|
||||
RELATIVE_PATH = null;
|
||||
|
||||
// todo: cleanup,etc
|
||||
(function() {
|
||||
|
||||
$.ajax({
|
||||
url: '/config.json?v=' + new Date().getTime(),
|
||||
url: '/forum/config.json?v=' + new Date().getTime(),
|
||||
success: function(data) {
|
||||
API_URL = data.api_url;
|
||||
RELATIVE_PATH = data.relative_path;
|
||||
|
||||
config = data;
|
||||
socket = io.connect(config.socket.address + (config.socket.port ? ':' + config.socket.port : ''));
|
||||
@@ -244,6 +246,7 @@ var socket,
|
||||
}
|
||||
}, false);
|
||||
|
||||
$.getScript(RELATIVE_PATH + '/src/forum/footer.js');
|
||||
|
||||
addTouchEvents();
|
||||
});
|
||||
|
||||
@@ -86,9 +86,12 @@
|
||||
}
|
||||
|
||||
function loadClient() {
|
||||
jQuery.when(jQuery.getJSON('/templates/config.json'), jQuery.getJSON('/api/get_templates_listing')).done(function(config_data, templates_data) {
|
||||
jQuery.when(jQuery.getJSON(RELATIVE_PATH + '/templates/config.json'), jQuery.getJSON(RELATIVE_PATH + '/api/get_templates_listing')).done(function(config_data, templates_data) {
|
||||
config = config_data[0];
|
||||
available_templates = templates_data[0];
|
||||
|
||||
|
||||
|
||||
templates.ready();
|
||||
});
|
||||
}
|
||||
@@ -131,7 +134,7 @@
|
||||
var timestamp = new Date().getTime(); //debug
|
||||
|
||||
if (!templates[tpl_url]) {
|
||||
jQuery.get('/templates/' + tpl_url + '.tpl?v=' + timestamp, function(html) {
|
||||
jQuery.get(RELATIVE_PATH + '/templates/' + tpl_url + '.tpl?v=' + timestamp, function(html) {
|
||||
var template = function() {
|
||||
this.toString = function() {
|
||||
return this.html;
|
||||
@@ -153,7 +156,10 @@
|
||||
}());
|
||||
|
||||
(function() {
|
||||
console.log(API_URL,api_url);
|
||||
jQuery.get(API_URL + api_url, function(data) {
|
||||
|
||||
|
||||
if(!data) {
|
||||
ajaxify.go('404');
|
||||
return;
|
||||
@@ -170,6 +176,7 @@
|
||||
|
||||
function parse_template() {
|
||||
if (!templates[tpl_url] || !template_data) return;
|
||||
template_data['relative_path'] = RELATIVE_PATH || global.config.relative_path;
|
||||
|
||||
document.getElementById('content').innerHTML = templates[tpl_url].parse(template_data);
|
||||
|
||||
|
||||
@@ -101,4 +101,4 @@
|
||||
<input type="hidden" template-variable="theirid" value="{theirid}" />
|
||||
<input type="hidden" template-type="boolean" template-variable="isFollowing" value="{isFollowing}" />
|
||||
|
||||
<script type="text/javascript" src="/src/forum/account.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/account.js"></script>
|
||||
@@ -170,4 +170,4 @@
|
||||
<input type="hidden" template-variable="gravatarpicture" value="{gravatarpicture}" />
|
||||
<input type="hidden" template-variable="uploadedpicture" value="{uploadedpicture}" />
|
||||
|
||||
<script type="text/javascript" src="/src/forum/accountedit.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/accountedit.js"></script>
|
||||
@@ -73,7 +73,7 @@
|
||||
</div>
|
||||
<div class="block-content">
|
||||
<!-- BEGIN active_users -->
|
||||
<a href="/users/{active_users.userslug}"><img title="{active_users.username}" src="/graph/users/{active_users.username}/picture" class="img-polaroid" /></a>
|
||||
<a href="/users/{active_users.userslug}"><img title="{active_users.username}" src="../../graph/users/{active_users.username}/picture" class="img-polaroid" /></a>
|
||||
<!-- END active_users -->
|
||||
</div>
|
||||
</div>
|
||||
@@ -83,7 +83,7 @@
|
||||
</div>
|
||||
<div class="block-content">
|
||||
<!-- BEGIN moderators -->
|
||||
<a href="/users/{moderators.userslug}"><img title="{moderators.username}" src="/graph/users/{moderators.username}/picture" class="img-polaroid" /></a>
|
||||
<a href="/users/{moderators.userslug}"><img title="{moderators.username}" src="../../graph/users/{active_users.username}/picture" class="img-polaroid" /></a>
|
||||
<!-- END moderators -->
|
||||
</div>
|
||||
</div>
|
||||
@@ -94,4 +94,5 @@
|
||||
<input type="hidden" template-variable="twitter-intent-url" value="{twitter-intent-url}" />
|
||||
<input type="hidden" template-variable="facebook-share-url" value="{facebook-share-url}" />
|
||||
<input type="hidden" template-variable="google-share-url" value="{google-share-url}" />
|
||||
<script type="text/javascript" src="/src/forum/category.js"></script>
|
||||
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/category.js"></script>
|
||||
@@ -41,4 +41,4 @@
|
||||
<input type="hidden" template-variable="theirid" value="{theirid}" />
|
||||
<input type="hidden" template-variable="followersCount" value="{followersCount}" />
|
||||
|
||||
<script type="text/javascript" src="/src/forum/followers.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/followers.js"></script>
|
||||
@@ -45,4 +45,4 @@
|
||||
<input type="hidden" template-variable="theirid" value="{theirid}" />
|
||||
<input type="hidden" template-variable="followingCount" value="{followingCount}" />
|
||||
|
||||
<script type="text/javascript" src="/src/forum/following.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/following.js"></script>
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
<button id="mobile-menu-btn" type="button" class="btn btn-none"><i class="icon-th icon-2x"></i></button>
|
||||
<button id="mobile-post-btn" type="button" class="btn btn-none"><i class="icon-plus icon-2x"></i></button>
|
||||
</div>
|
||||
<script type="text/javascript" src="/src/forum/footer.js"></script>
|
||||
|
||||
<!-- END Forum Info -->
|
||||
</body>
|
||||
|
||||
@@ -9,27 +9,27 @@
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<link href="{cssSrc}" rel="stylesheet" media="screen">
|
||||
<link href="/vendor/bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
|
||||
<link rel="stylesheet" href="/vendor/fontawesome/css/font-awesome.min.css">
|
||||
<link href="{relative_path}/vendor/bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
|
||||
<link rel="stylesheet" href="{relative_path}/vendor/fontawesome/css/font-awesome.min.css">
|
||||
<script type="text/javascript" src="http://code.jquery.com/jquery.js"></script>
|
||||
<script type="text/javascript" src="/vendor/jquery/js/jquery-ui-1.10.3.custom.min.js"></script>
|
||||
<script type="text/javascript" src="/vendor/bootstrap/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="/socket.io/socket.io.js"></script>
|
||||
<script type="text/javascript" src="/src/app.js"></script>
|
||||
<script src="/vendor/requirejs/require.js"></script>
|
||||
<script src="/vendor/bootbox/bootbox.min.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/vendor/jquery/js/jquery-ui-1.10.3.custom.min.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/vendor/bootstrap/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/socket.io/socket.io.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/src/app.js"></script>
|
||||
<script src="{relative_path}/vendor/requirejs/require.js"></script>
|
||||
<script src="{relative_path}/vendor/bootbox/bootbox.min.js"></script>
|
||||
<script>
|
||||
require.config({
|
||||
baseUrl: "/src/modules",
|
||||
baseUrl: "{relative_path}/src/modules",
|
||||
waitSeconds: 3
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript" src="/src/templates.js"></script>
|
||||
<script type="text/javascript" src="/src/ajaxify.js"></script>
|
||||
<script type="text/javascript" src="/src/jquery.form.js"></script>
|
||||
<script type="text/javascript" src="/src/utils.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/src/templates.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/src/ajaxify.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/src/jquery.form.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/src/utils.js"></script>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="/css/nodebb.css" />
|
||||
<link rel="stylesheet" type="text/css" href="{relative_path}/css/nodebb.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
@@ -27,4 +27,4 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="/src/forum/login.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/login.js"></script>
|
||||
@@ -27,7 +27,7 @@
|
||||
<div class="span12 topic-row img-polaroid">
|
||||
<div class="latest-post visible-desktop">
|
||||
<div class="pull-right">
|
||||
<img style="width: 48px; height: 48px; /*temporary*/" src="../../graph/users/{topics.teaser_username}/picture" />
|
||||
<img style="width: 48px; height: 48px; /*temporary*/" src="graph/users/{topics.teaser_username}/picture" />
|
||||
<p><strong>{topics.teaser_username}</strong>: {topics.teaser_text}</p>
|
||||
<span>posted {topics.teaser_timestamp} ago</span>
|
||||
</div>
|
||||
@@ -49,4 +49,4 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="/src/forum/recent.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/recent.js"></script>
|
||||
@@ -20,4 +20,4 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="/src/forum/register.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/register.js"></script>
|
||||
@@ -14,4 +14,4 @@
|
||||
<button class="btn btn-primary" id="reset" type="submit">Reset Password</button>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="/src/forum/reset.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/reset.js"></script>
|
||||
@@ -22,4 +22,4 @@
|
||||
<input type="hidden" template-variable="reset_code" value="{reset_code}" />
|
||||
|
||||
|
||||
<script type="text/javascript" src="/src/forum/reset_code.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/reset_code.js"></script>
|
||||
@@ -140,4 +140,4 @@
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="/src/forum/topic.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/topic.js"></script>
|
||||
@@ -36,4 +36,4 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="/src/forum/users.js"></script>
|
||||
<script type="text/javascript" src="{relative_path}/src/forum/users.js"></script>
|
||||
@@ -309,7 +309,7 @@ var RDB = require('./redis.js'),
|
||||
}
|
||||
|
||||
Categories.getCategories = function(cids, callback, current_user) {
|
||||
if (cids.length === 0) {
|
||||
if (!cids || cids.length === 0) {
|
||||
callback({'categories' : []});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -14,10 +14,9 @@ var utils = require('./../public/src/utils.js'),
|
||||
User.create = function(username, password, email, callback) {
|
||||
username = username.trim(), email = email.trim();
|
||||
|
||||
// @todo return a proper error? use node-validator?
|
||||
// @todo use node-validator?
|
||||
if(!utils.isEmailValid(email) || !utils.isUserNameValid(username) || !utils.isPasswordValid(password)) {
|
||||
console.log('Invalid email/username/password!');
|
||||
callback(null, 0);
|
||||
callback('Invalid email/username/password!', 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,13 +24,13 @@ var utils = require('./../public/src/utils.js'),
|
||||
|
||||
User.exists(userslug, function(exists) {
|
||||
if(exists) {
|
||||
callback(null, 0);
|
||||
callback('Username taken!', 0);
|
||||
return;
|
||||
}
|
||||
|
||||
User.isEmailAvailable(email, function(available) {
|
||||
if(!available) {
|
||||
callback(null, 0);
|
||||
callback('Email taken!', 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
157
src/webserver.js
157
src/webserver.js
@@ -1,4 +1,5 @@
|
||||
var express = require('express'),
|
||||
express_namespace = require('express-namespace'),
|
||||
WebServer = express(),
|
||||
server = require('http').createServer(WebServer),
|
||||
RedisStore = require('connect-redis')(express),
|
||||
@@ -26,16 +27,18 @@ var express = require('express'),
|
||||
|
||||
app.build_header = function(res) {
|
||||
return templates['header'].parse({
|
||||
cssSrc: global.config['theme:src'] || '/vendor/bootstrap/css/bootstrap.min.css',
|
||||
cssSrc: global.config['theme:src'] || global.config.relative_path + '/vendor/bootstrap/css/bootstrap.min.css',
|
||||
title: global.config['title'] || 'NodeBB',
|
||||
csrf:res.locals.csrf_token
|
||||
csrf:res.locals.csrf_token,
|
||||
relative_path: global.config.relative_path
|
||||
});
|
||||
};
|
||||
|
||||
// Middlewares
|
||||
app.use(express.favicon(path.join(__dirname, '../', 'public', 'favicon.ico')));
|
||||
app.use(require('less-middleware')({ src: path.join(__dirname, '../', 'public') }));
|
||||
app.use(express.static(path.join(__dirname, '../', 'public')));
|
||||
//app.use(express.static(path.join(__dirname, '../', 'public')));
|
||||
app.use(global.config.relative_path, express.static(path.join(__dirname, '../', 'public')));
|
||||
app.use(express.bodyParser()); // Puts POST vars in request.body
|
||||
app.use(express.cookieParser()); // If you want to parse cookies (res.cookies)
|
||||
app.use(express.compress());
|
||||
@@ -108,11 +111,7 @@ var express = require('express'),
|
||||
res.json('500', { error: err.message });
|
||||
});
|
||||
|
||||
auth.create_routes(app);
|
||||
admin.create_routes(app);
|
||||
userRoute.create_routes(app);
|
||||
installRoute.create_routes(app);
|
||||
testBed.create_routes(app);
|
||||
|
||||
|
||||
app.create_route = function(url, tpl) { // to remove
|
||||
return '<script>templates.ready(function(){ajaxify.go("' + url + '", null, "' + tpl + '");});</script>';
|
||||
@@ -141,7 +140,16 @@ var express = require('express'),
|
||||
}());
|
||||
|
||||
// Complex Routes
|
||||
app.namespace(global.config.relative_path, function() {
|
||||
|
||||
auth.create_routes(app);
|
||||
admin.create_routes(app);
|
||||
userRoute.create_routes(app);
|
||||
installRoute.create_routes(app);
|
||||
testBed.create_routes(app);
|
||||
|
||||
app.get('/', function(req, res) {
|
||||
console.log('going in home');
|
||||
categories.getAllCategories(function(returnData) {
|
||||
res.send(
|
||||
app.build_header(res) +
|
||||
@@ -152,6 +160,7 @@ var express = require('express'),
|
||||
}, 0);
|
||||
});
|
||||
|
||||
|
||||
app.get('/topic/:topic_id/:slug?', function(req, res) {
|
||||
var tid = req.params.topic_id;
|
||||
if (tid.match('.rss')) {
|
||||
@@ -214,6 +223,75 @@ var express = require('express'),
|
||||
res.send(app.build_header(res) + '<script>templates.ready(function(){ajaxify.go("confirm/' + req.params.code + '");});</script>' + templates['footer']);
|
||||
});
|
||||
|
||||
app.get('/api/:method', api_method);
|
||||
app.get('/api/:method/:id', api_method);
|
||||
// ok fine MUST ADD RECURSION style. I'll look for a better fix in future but unblocking baris for this:
|
||||
app.get('/api/:method/:id/:section?', api_method);
|
||||
app.get('/api/:method/:id*', api_method);
|
||||
|
||||
app.get('/cid/:cid', function(req, res) {
|
||||
categories.getCategoryData(req.params.cid, function(data){
|
||||
if(data)
|
||||
res.send(data);
|
||||
else
|
||||
res.send(404, "Category doesn't exist!");
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/tid/:tid', function(req, res) {
|
||||
topics.getTopicData(req.params.tid, function(data){
|
||||
if(data)
|
||||
res.send(data);
|
||||
else
|
||||
res.send(404, "Topic doesn't exist!");
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/pid/:pid', function(req, res) {
|
||||
posts.getPostData(req.params.pid, function(data){
|
||||
if(data)
|
||||
res.send(data);
|
||||
else
|
||||
res.send(404, "Post doesn't exist!");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
//START TODO: MOVE TO GRAPH.JS
|
||||
|
||||
app.get('/graph/users/:username/picture', function(req, res) {
|
||||
user.get_uid_by_username(req.params.username, function(uid) {
|
||||
if (uid == null) {
|
||||
res.json({
|
||||
status: 0
|
||||
});
|
||||
return;
|
||||
}
|
||||
user.getUserField(uid, 'picture', function(picture) {
|
||||
if (picture == null) res.redirect('http://www.gravatar.com/avatar/a938b82215dfc96c4cabeb6906e5f953&default=identicon');
|
||||
res.redirect(picture);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
//END TODO: MOVE TO GRAPH.JS
|
||||
|
||||
app.get('/test', function(req, res) {
|
||||
|
||||
console.log('derp');
|
||||
user.get_userslugs_by_uids([1,2], function(data) {
|
||||
res.send(data);
|
||||
});
|
||||
|
||||
/* categories.getCategoryById(1,1, function(data) {
|
||||
res.send(data);
|
||||
},1);*/
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// These functions are called via ajax once the initial page is loaded to populate templates with data
|
||||
function api_method(req, res) {
|
||||
var uid = (req.user) ? req.user.uid : 0;
|
||||
@@ -342,73 +420,10 @@ var express = require('express'),
|
||||
}
|
||||
}
|
||||
|
||||
app.get('/api/:method', api_method);
|
||||
app.get('/api/:method/:id', api_method);
|
||||
// ok fine MUST ADD RECURSION style. I'll look for a better fix in future but unblocking baris for this:
|
||||
app.get('/api/:method/:id/:section?', api_method);
|
||||
app.get('/api/:method/:id*', api_method);
|
||||
|
||||
app.get('/cid/:cid', function(req, res) {
|
||||
categories.getCategoryData(req.params.cid, function(data){
|
||||
if(data)
|
||||
res.send(data);
|
||||
else
|
||||
res.send(404, "Category doesn't exist!");
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/tid/:tid', function(req, res) {
|
||||
topics.getTopicData(req.params.tid, function(data){
|
||||
if(data)
|
||||
res.send(data);
|
||||
else
|
||||
res.send(404, "Topic doesn't exist!");
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/pid/:pid', function(req, res) {
|
||||
posts.getPostData(req.params.pid, function(data){
|
||||
if(data)
|
||||
res.send(data);
|
||||
else
|
||||
res.send(404, "Post doesn't exist!");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
app.get('/test', function(req, res) {
|
||||
|
||||
console.log('derp');
|
||||
user.get_userslugs_by_uids([1,2], function(data) {
|
||||
res.send(data);
|
||||
});
|
||||
|
||||
/* categories.getCategoryById(1,1, function(data) {
|
||||
res.send(data);
|
||||
},1);*/
|
||||
|
||||
});
|
||||
|
||||
|
||||
//START TODO: MOVE TO GRAPH.JS
|
||||
|
||||
app.get('/graph/users/:username/picture', function(req, res) {
|
||||
user.get_uid_by_username(req.params.username, function(uid) {
|
||||
if (uid == null) {
|
||||
res.json({
|
||||
status: 0
|
||||
});
|
||||
return;
|
||||
}
|
||||
user.getUserField(uid, 'picture', function(picture) {
|
||||
if (picture == null) res.redirect('http://www.gravatar.com/avatar/a938b82215dfc96c4cabeb6906e5f953&default=identicon');
|
||||
res.redirect(picture);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
//END TODO: MOVE TO GRAPH.JS
|
||||
}(WebServer));
|
||||
|
||||
server.listen(config.port);
|
||||
|
||||
Reference in New Issue
Block a user