notherbase-fs 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/controllers/creation.js +37 -1
- package/package.json +1 -1
package/controllers/creation.js
CHANGED
|
@@ -11,7 +11,7 @@ export default class Creation {
|
|
|
11
11
|
this.router.get(`/the-front`, this.explore);
|
|
12
12
|
this.router.get(`/the-front/:frontDetail`, this.explore);
|
|
13
13
|
//pages
|
|
14
|
-
this.router.get(`/:page`, this.
|
|
14
|
+
this.router.get(`/:page`, this.page);
|
|
15
15
|
//explorer
|
|
16
16
|
this.router.get(`/:region/:area/:poi`, this.lock, this.explore);
|
|
17
17
|
this.router.get(`/:region/:area/:poi/:detail`, this.lock, this.explore);
|
|
@@ -85,4 +85,40 @@ export default class Creation {
|
|
|
85
85
|
res.status(500).end();
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
+
|
|
89
|
+
page = async (req, res, next) => {
|
|
90
|
+
let main = `${req.contentPath}`;
|
|
91
|
+
|
|
92
|
+
main += `/${req.params.page}/index.ejs`;
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
if (fs.existsSync(main)) {
|
|
96
|
+
let user = await req.db.User.recallOne(req.session.currentUser);
|
|
97
|
+
|
|
98
|
+
let userStuff = {
|
|
99
|
+
userID: null,
|
|
100
|
+
user: null
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
if (user) userStuff = {
|
|
104
|
+
userID: user.id,
|
|
105
|
+
user: user.memory.data
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
let context = {
|
|
109
|
+
...userStuff,
|
|
110
|
+
query: req.query,
|
|
111
|
+
dir: req.frontDir,
|
|
112
|
+
route: req.path
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
res.render(main, context);
|
|
116
|
+
}
|
|
117
|
+
else next();
|
|
118
|
+
}
|
|
119
|
+
catch(err) {
|
|
120
|
+
console.log(err);
|
|
121
|
+
res.status(500).end();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
88
124
|
}
|