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:
@@ -8,6 +8,7 @@
|
|||||||
"date-fns": "^4.1.0",
|
"date-fns": "^4.1.0",
|
||||||
"ejs": "^3.1.10",
|
"ejs": "^3.1.10",
|
||||||
"express": "^5.1.0",
|
"express": "^5.1.0",
|
||||||
|
"express-router": "^0.0.1",
|
||||||
"markdown-it": "^14.1.0",
|
"markdown-it": "^14.1.0",
|
||||||
"mysql": "^2.18.1",
|
"mysql": "^2.18.1",
|
||||||
"package.json": "^2.0.1"
|
"package.json": "^2.0.1"
|
||||||
|
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('view engine', 'ejs');
|
||||||
app.set('views', '../views')
|
app.set('views', '../views')
|
||||||
|
|
||||||
////////////////////// SYNDICATION ////////////////////////
|
// Express JS routes
|
||||||
// global RSS protocol gets
|
var syndication_route = require('./routes/syndication.js');
|
||||||
app.get("/rss", (req,res) => {
|
//var route2 = require('./routes/rout');
|
||||||
if (config.rss == false) {
|
app.use('/', syndication_route);
|
||||||
res.render("partials/message", {
|
//app.use('/route2', route2);
|
||||||
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,
|
|
||||||
})
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
///////////////////// Page index's ///////////////////////
|
///////////////////// Page index's ///////////////////////
|
||||||
app.get("/index/pages", (req,res) => {
|
app.get("/index/pages", (req,res) => {
|
||||||
|
Reference in New Issue
Block a user