-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
211 lines (200 loc) · 7.36 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
var express = require("express");
var path = __dirname + '/';
var app = express();
var router = express.Router();
var hbs = require("express-handlebars");
var db = require('./js/db');
app.use(express.static(path + 'public'))
app.engine('hbs', hbs({
extname: 'hbs',
defaultLayout: 'main-layout',
layoutsDir: path + 'views/layouts/'
}));
app.set('views', path + 'views');
app.set('view engine', 'hbs');
/////
/// MISSOO
/////
router.get("/",function(req,res){
res.render('index', {layout: false});
});
router.get("/misso",function(req,res){
res.render('misso/sissejuhatus', {layout: 'misso-layout.hbs'});
});
router.get("/misso/sissejuhatus",function(req,res){
res.render('misso/sissejuhatus', {layout: 'misso-layout.hbs'});
});
router.get("/misso/lugu",function(req,res){
res.render('misso/lugu', {layout: 'misso-layout.hbs'});
});
router.get("/misso/pildid",function(req,res){
res.render('misso/pildid', {layout: 'misso-layout.hbs'});
});
router.get("/misso/kaardid",function(req,res){
res.render('misso/kaardid', {layout: 'misso-layout.hbs'});
});
router.get("/misso/isikud", function(req, res, next) {
db.getPeople("misso", function(err, people) {
if (err) return next(err);
res.render('misso/isikud', {layout: 'misso-layout.hbs', people} );
});
});
router.get("/misso/isik/:id_name", function(req, res, next) {
db.getPersonById(req.params.id_name, function(err, person) {
if (err) return next(err);
res.render('misso/isik', {layout: 'misso-layout.hbs', person} );
});
});
router.get('/misso/rjm',function(req,res){
res.render('misso/rjm', {layout: 'misso-layout.hbs'});
});
router.get('/misso/agendid',function(req,res){
res.render('misso/agendid', {layout: 'misso-layout.hbs'});
});
router.get('/misso/malestus',function(req,res){
res.render('misso/malestus', {layout: 'misso-layout.hbs'});
});
router.get('/misso/lingid',function(req,res){
res.render('misso/lingid', {layout: 'misso-layout.hbs'});
});
router.get('/misso/raudvassar',function(req,res){
res.render('misso/raudvassar', {layout: 'misso-layout.hbs'});
});
router.get('/misso/arvo-pilt',function(req,res){
res.render('misso/arvo-pilt', {layout: 'misso-layout.hbs'});
});
/////
/// ROUGE
/////
router.get('/rouge',function(req,res){
res.render('rouge/sissejuhatus', {layout: 'rouge-layout.hbs'});
});
router.get('/rouge/sissejuhatus',function(req,res){
res.render('rouge/sissejuhatus', {layout: 'rouge-layout.hbs'});
});
router.get('/rouge/metsavennad',function(req,res){
res.render('rouge/metsavennad', {layout: 'rouge-layout.hbs'});
});
router.get('/rouge/parteilased',function(req,res){
res.render('rouge/parteilased', {layout: 'rouge-layout.hbs'});
});
router.get('/rouge/elukaigud_metsaelu_alguseni',function(req,res){
res.render('rouge/elukaigud_metsaelu_alguseni', {layout: 'rouge-layout.hbs'});
});
router.get('/rouge/sundmused_uurimistoimikutes',function(req,res){
res.render('rouge/sundmused_uurimistoimikutes', {layout: 'rouge-layout.hbs'});
});
router.get('/rouge/elukaigud_metsaelu_lopuni',function(req,res){
res.render('rouge/elukaigud_metsaelu_lopuni', {layout: 'rouge-layout.hbs'});
});
router.get('/rouge/julgeoleku_tegutsemine',function(req,res){
res.render('rouge/julgeoleku_tegutsemine', {layout: 'rouge-layout.hbs'});
});
router.get('/rouge/propaganda_vs_toimikud',function(req,res){
res.render('rouge/propaganda_vs_toimikud', {layout: 'rouge-layout.hbs'});
});
router.get('/rouge/pildid',function(req,res){
res.render('rouge/pildid', {layout: 'rouge-layout.hbs'});
});
router.get('/rouge/kaardid',function(req,res){
res.render('rouge/kaardid', {layout: 'rouge-layout.hbs'});
});
router.get("/rouge/isikud", function(req, res, next) {
db.getPeople("rouge", function(err, people) {
if (err) return next(err);
res.render('rouge/isikud', {layout: 'rouge-layout.hbs', people} );
});
});
router.get("/rouge/isik/:id_name", function(req, res, next) {
db.getPersonById(req.params.id_name, function(err, person) {
if (err) return next(err);
res.render('rouge/isik', {layout: 'rouge-layout.hbs', person} );
});
});
router.get('/rouge/lingid',function(req,res){
res.render('rouge/lingid', {layout: 'rouge-layout.hbs'});
});
router.get('/rouge/aksel_sprenki_paevik',function(req,res){
res.render('rouge/aksel_sprenki_paevik', {layout: 'rouge-layout.hbs'});
});
router.get('/rouge/aksel_sprenki_paevik_umberkirjutis',function(req,res){
res.render('rouge/aksel_sprenki_paevik_umberkirjutis', {layout: 'rouge-layout.hbs'});
});
router.get('/rouge/koemetsa_hukkumine',function(req,res){
res.render('rouge/koemetsa_hukkumine', {layout: 'rouge-layout.hbs'});
});
router.get('/rouge/toomase_rahatasku',function(req,res){
res.render('rouge/toomase_rahatasku', {layout: 'rouge-layout.hbs'});
});
router.get('/rouge/pallo_luule',function(req,res){
res.render('rouge/pallo_luule', {layout: 'rouge-layout.hbs'});
});
router.get('/rouge/haanjamaa_monumendid',function(req,res){
res.render('rouge/haanjamaa_monumendid', {layout: 'rouge-layout.hbs'});
});
router.get('/rouge/morv_metsateel',function(req,res){
res.render('rouge/morv_metsateel', {layout: 'rouge-layout.hbs'});
});
router.get('/rouge/simo_pihlapuu_ulestahendused',function(req,res){
res.render('rouge/simo_pihlapuu_ulestahendused', {layout: 'rouge-layout.hbs'});
});
/////
/// LINNAMÄE-URVASTE-SANGASTE
/////
router.get('/sangaste',function(req,res){
res.render('sangaste/sissejuhatus', {layout: 'sangaste-layout.hbs'});
});
router.get('/sangaste/sissejuhatus',function(req,res){
res.render('sangaste/sissejuhatus', {layout: 'sangaste-layout.hbs'});
});
router.get('/sangaste/olud',function(req,res){
res.render('sangaste/olud', {layout: 'sangaste-layout.hbs'});
});
router.get('/sangaste/elukaigud_enne_1944',function(req,res){
res.render('sangaste/elukaigud_enne_1944', {layout: 'sangaste-layout.hbs'});
});
router.get('/sangaste/elukaigud_1945_1946',function(req,res){
res.render('sangaste/elukaigud_1945_1946', {layout: 'sangaste-layout.hbs'});
});
router.get('/sangaste/elukaigud_1947_1948',function(req,res){
res.render('sangaste/elukaigud_1947_1948', {layout: 'sangaste-layout.hbs'});
});
router.get('/sangaste/elukaigud_1949_1953',function(req,res){
res.render('sangaste/elukaigud_1949_1953', {layout: 'sangaste-layout.hbs'});
});
router.get('/sangaste/elukaigud_1954_1959',function(req,res){
res.render('sangaste/elukaigud_1954_1959', {layout: 'sangaste-layout.hbs'});
});
router.get('/sangaste/rjm',function(req,res){
res.render('sangaste/rjm', {layout: 'sangaste-layout.hbs'});
});
router.get('/sangaste/pildid',function(req,res){
res.render('sangaste/pildid', {layout: 'sangaste-layout.hbs'});
});
router.get('/sangaste/kaardid',function(req,res){
res.render('sangaste/kaardid', {layout: 'sangaste-layout.hbs'});
});
router.get("/sangaste/isikud", function(req, res, next) {
db.getPeople("sangaste", function(err, people) {
if (err) return next(err);
res.render('sangaste/isikud', {layout: 'sangaste-layout.hbs', people} );
});
});
router.get("/sangaste/isik/:id_name", function(req, res, next) {
db.getPersonById(req.params.id_name, function(err, person) {
if (err) return next(err);
res.render('sangaste/isik', {layout: 'sangaste-layout.hbs', person} );
});
});
router.get('/sangaste/lingid',function(req,res){
res.render('sangaste/lingid', {layout: 'sangaste-layout.hbs'});
});
app.use(function (err, req, res, next) {
console.error(err.stack)
res.status(500).send('Something broke!')
})
// START WEB SERVER
app.use("/",router);
app.listen(4000,function(){
console.log("Live at Port 4000");
});