ExpressJS routes in different files
ExpressJS routes for the syndication stuff is now in a seperate file, will now do the other routes. Signed-off-by: max <deadvey@localhost.localdomain>
This commit is contained in:
85
src/routes/syndication.js
Normal file
85
src/routes/syndication.js
Normal file
@@ -0,0 +1,85 @@
|
||||
const express = require('express');
|
||||
const config = require('../../config')
|
||||
const data = require('../data')
|
||||
const func = require('../functions')
|
||||
const router = express.Router();
|
||||
|
||||
////////////////////// SYNDICATION ////////////////////////
|
||||
// global RSS protocol gets
|
||||
router.get("/rss", (req,res) => {
|
||||
if (config.rss == false) {
|
||||
res.render("partials/message", {
|
||||
message: locale.rss_disabled,
|
||||
config,
|
||||
})
|
||||
}
|
||||
else {
|
||||
res.setHeader('content-type', 'application/rss+xml');
|
||||
res.render("syndication/global_rss", {
|
||||
config,
|
||||
posts: data.getdata('posts'),
|
||||
func,
|
||||
})
|
||||
};
|
||||
});
|
||||
// user RSS protocol gets
|
||||
router.get("/user/:username/rss", (req,res) => {
|
||||
const username = req.params.username;
|
||||
const userID = func.get_userID(username);
|
||||
if (config.rss == false) {
|
||||
res.render("partials/message", {
|
||||
message: locale.rss_disabled,
|
||||
config: config,
|
||||
})
|
||||
}
|
||||
else {
|
||||
res.setHeader('content-type', 'application/rss+xml');
|
||||
res.render("syndication/user_rss", {
|
||||
config,
|
||||
posts: data.getdata('posts'),
|
||||
func,
|
||||
userID,
|
||||
})
|
||||
};
|
||||
});
|
||||
// global ATOM protocol gets
|
||||
router.get("/atom", (req,res) => {
|
||||
if (config.atom == false) {
|
||||
res.render("partials/message", {
|
||||
message: locale.atom_disabled,
|
||||
config: config,
|
||||
})
|
||||
}
|
||||
else {
|
||||
res.setHeader('content-type', 'application/rss+xml');
|
||||
res.render("syndication/global_atom", {
|
||||
config,
|
||||
posts: data.getdata('posts'),
|
||||
func,
|
||||
getUnixTime,
|
||||
})
|
||||
};
|
||||
});
|
||||
// user ATOM protocol gets
|
||||
router.get("/user/:username/atom", (req,res) => {
|
||||
const username = req.params.username;
|
||||
const userID = func.get_userID(username);
|
||||
if (config.atom == false) {
|
||||
res.render("partials/message", {
|
||||
message: locale.atom_disabled,
|
||||
config: config,
|
||||
})
|
||||
}
|
||||
else {
|
||||
res.setHeader('content-type', 'application/rss+xml');
|
||||
res.render("syndication/user_atom", {
|
||||
config,
|
||||
posts: data.getdata('posts'),
|
||||
func,
|
||||
userID,
|
||||
getUnixTime,
|
||||
})
|
||||
};
|
||||
});
|
||||
|
||||
module.exports = router;
|
@@ -61,83 +61,12 @@ app.use(express.static(config.root_path));
|
||||
app.set('view engine', 'ejs');
|
||||
app.set('views', '../views')
|
||||
|
||||
////////////////////// SYNDICATION ////////////////////////
|
||||
// global RSS protocol gets
|
||||
app.get("/rss", (req,res) => {
|
||||
if (config.rss == false) {
|
||||
res.render("partials/message", {
|
||||
message: locale.rss_disabled,
|
||||
config: config,
|
||||
})
|
||||
}
|
||||
else {
|
||||
res.setHeader('content-type', 'application/rss+xml');
|
||||
res.render("syndication/global_rss", {
|
||||
config,
|
||||
posts,
|
||||
func,
|
||||
})
|
||||
};
|
||||
});
|
||||
// user RSS protocol gets
|
||||
app.get("/user/:username/rss", (req,res) => {
|
||||
const username = req.params.username;
|
||||
const userID = func.get_userID(username);
|
||||
if (config.rss == false) {
|
||||
res.render("partials/message", {
|
||||
message: locale.rss_disabled,
|
||||
config: config,
|
||||
})
|
||||
}
|
||||
else {
|
||||
res.setHeader('content-type', 'application/rss+xml');
|
||||
res.render("syndication/user_rss", {
|
||||
config,
|
||||
posts,
|
||||
func,
|
||||
userID,
|
||||
})
|
||||
};
|
||||
});
|
||||
// global ATOM protocol gets
|
||||
app.get("/atom", (req,res) => {
|
||||
if (config.atom == false) {
|
||||
res.render("partials/message", {
|
||||
message: locale.atom_disabled,
|
||||
config: config,
|
||||
})
|
||||
}
|
||||
else {
|
||||
res.setHeader('content-type', 'application/rss+xml');
|
||||
res.render("syndication/global_atom", {
|
||||
config,
|
||||
posts,
|
||||
func,
|
||||
getUnixTime,
|
||||
})
|
||||
};
|
||||
});
|
||||
// user ATOM protocol gets
|
||||
app.get("/user/:username/atom", (req,res) => {
|
||||
const username = req.params.username;
|
||||
const userID = func.get_userID(username);
|
||||
if (config.atom == false) {
|
||||
res.render("partials/message", {
|
||||
message: locale.atom_disabled,
|
||||
config: config,
|
||||
})
|
||||
}
|
||||
else {
|
||||
res.setHeader('content-type', 'application/rss+xml');
|
||||
res.render("syndication/user_atom", {
|
||||
config,
|
||||
posts,
|
||||
func,
|
||||
userID,
|
||||
getUnixTime,
|
||||
})
|
||||
};
|
||||
});
|
||||
// Express JS routes
|
||||
var syndication_route = require('./routes/syndication.js');
|
||||
//var route2 = require('./routes/rout');
|
||||
app.use('/', syndication_route);
|
||||
//app.use('/route2', route2);
|
||||
|
||||
|
||||
///////////////////// Page index's ///////////////////////
|
||||
app.get("/index/pages", (req,res) => {
|
||||
|
Reference in New Issue
Block a user