diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2015-11-07 18:22:05 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2015-11-07 18:22:05 +0100 |
commit | e85782f7da44267e11714a63567feb7e0127126e (patch) | |
tree | 75b385cd609180bdec773f028e423408e0b79819 /routes | |
parent | 34ca3b5225479a5da986c86ee4c42a73ae6df5ad (diff) | |
download | PeerTube-e85782f7da44267e11714a63567feb7e0127126e.tar.gz PeerTube-e85782f7da44267e11714a63567feb7e0127126e.tar.zst PeerTube-e85782f7da44267e11714a63567feb7e0127126e.zip |
Views refractoring
Diffstat (limited to 'routes')
-rw-r--r-- | routes/api/v1/index.js | 12 | ||||
-rw-r--r-- | routes/index.js | 22 | ||||
-rw-r--r-- | routes/views.js | 24 |
3 files changed, 35 insertions, 23 deletions
diff --git a/routes/api/v1/index.js b/routes/api/v1/index.js index 9a4ec8438..f5504ad85 100644 --- a/routes/api/v1/index.js +++ b/routes/api/v1/index.js | |||
@@ -1,10 +1,12 @@ | |||
1 | ;(function () { | 1 | ;(function () { |
2 | 'use strict' | 2 | 'use strict' |
3 | 3 | ||
4 | var api = {} | 4 | var express = require('express') |
5 | api.videos = require('./videos') | 5 | var router = express.Router() |
6 | api.remoteVideos = require('./remoteVideos') | ||
7 | api.pods = require('./pods') | ||
8 | 6 | ||
9 | module.exports = api | 7 | router.use('/videos', require('./videos')) |
8 | router.use('/remotevideos', require('./remoteVideos')) | ||
9 | router.use('/pods', require('./pods')) | ||
10 | |||
11 | module.exports = router | ||
10 | })() | 12 | })() |
diff --git a/routes/index.js b/routes/index.js index 690913a84..ecca80721 100644 --- a/routes/index.js +++ b/routes/index.js | |||
@@ -1,24 +1,10 @@ | |||
1 | ;(function () { | 1 | ;(function () { |
2 | 'use strict' | 2 | 'use strict' |
3 | 3 | ||
4 | function getPartial (req, res) { | 4 | var routes = { |
5 | var directory = req.params.directory | 5 | api: require('./api/' + global.API_VERSION), |
6 | var name = req.params.name | 6 | views: require('./views') |
7 | |||
8 | res.render('partials/' + directory + '/' + name) | ||
9 | } | ||
10 | |||
11 | function getIndex (req, res) { | ||
12 | res.render('index') | ||
13 | } | 7 | } |
14 | 8 | ||
15 | var express = require('express') | 9 | module.exports = routes |
16 | var middleware = require('../middlewares') | ||
17 | |||
18 | var router = express.Router() | ||
19 | |||
20 | router.get('/partials/:directory/:name', middleware.cache(), getPartial) | ||
21 | router.get(/^\/(index)?$/, middleware.cache(), getIndex) | ||
22 | |||
23 | module.exports = router | ||
24 | })() | 10 | })() |
diff --git a/routes/views.js b/routes/views.js new file mode 100644 index 000000000..690913a84 --- /dev/null +++ b/routes/views.js | |||
@@ -0,0 +1,24 @@ | |||
1 | ;(function () { | ||
2 | 'use strict' | ||
3 | |||
4 | function getPartial (req, res) { | ||
5 | var directory = req.params.directory | ||
6 | var name = req.params.name | ||
7 | |||
8 | res.render('partials/' + directory + '/' + name) | ||
9 | } | ||
10 | |||
11 | function getIndex (req, res) { | ||
12 | res.render('index') | ||
13 | } | ||
14 | |||
15 | var express = require('express') | ||
16 | var middleware = require('../middlewares') | ||
17 | |||
18 | var router = express.Router() | ||
19 | |||
20 | router.get('/partials/:directory/:name', middleware.cache(), getPartial) | ||
21 | router.get(/^\/(index)?$/, middleware.cache(), getIndex) | ||
22 | |||
23 | module.exports = router | ||
24 | })() | ||