Created a per-post hitcount as well a writedata() function that can
write to a particular index or to a whole data type
This commit is contained in:
@@ -12,7 +12,7 @@ const router = express.Router();
|
||||
router.get("/", (req,res) => {
|
||||
// Increment the hitcount
|
||||
if (config.enable_hitcount) {
|
||||
func.increment_hitcount()
|
||||
data.increment_hitcount()
|
||||
}
|
||||
|
||||
res.render("pages/timeline",
|
||||
@@ -62,6 +62,9 @@ router.get("/user/:username", (req, res) => {
|
||||
router.get("/post/:post_index", (req, res) => {
|
||||
const postID = parseInt(req.params.post_index)
|
||||
let post = data.getdata('posts', postID)
|
||||
if (config.enable_hitcount) {
|
||||
data.increment_hitcount(postID)
|
||||
}
|
||||
if (post == 1) { // data.getdata returns error code 1 if nothing is available
|
||||
res.render("partials/message", {
|
||||
message: locale.post_doesnt_exist,
|
||||
|
||||
Reference in New Issue
Block a user