-
-
Save fuzzmz/b2e8221fa141d1e5756b to your computer and use it in GitHub Desktop.
Updated frontend.js file to expose the public API calls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var frontend = require('../controllers/frontend'), | |
config = require('../config'), | |
express = require('express'), | |
utils = require('../utils'), | |
api = require('../api'), | |
frontendRoutes; | |
frontendRoutes = function () { | |
var router = express.Router(), | |
subdir = config.paths.subdir; | |
// ### Admin routes | |
router.get(/^\/(logout|signout)\/$/, function redirect(req, res) { | |
/*jslint unparam:true*/ | |
res.set({'Cache-Control': 'public, max-age=' + utils.ONE_YEAR_S}); | |
res.redirect(301, subdir + '/ghost/signout/'); | |
}); | |
router.get(/^\/signup\/$/, function redirect(req, res) { | |
/*jslint unparam:true*/ | |
res.set({'Cache-Control': 'public, max-age=' + utils.ONE_YEAR_S}); | |
res.redirect(301, subdir + '/ghost/signup/'); | |
}); | |
// redirect to /ghost and let that do the authentication to prevent redirects to /ghost//admin etc. | |
router.get(/^\/((ghost-admin|admin|wp-admin|dashboard|signin|login)\/?)$/, function (req, res) { | |
/*jslint unparam:true*/ | |
res.redirect(subdir + '/ghost/'); | |
}); | |
// ### Frontend routes | |
router.get('/rss/', frontend.rss); | |
router.get('/rss/:page/', frontend.rss); | |
router.get('/feed/', function redirect(req, res) { | |
/*jshint unused:true*/ | |
res.set({'Cache-Control': 'public, max-age=' + utils.ONE_YEAR_S}); | |
res.redirect(301, subdir + '/rss/'); | |
}); | |
// Tags | |
router.get('/tag/:slug/rss/', frontend.rss); | |
router.get('/tag/:slug/rss/:page/', frontend.rss); | |
router.get('/tag/:slug/page/:page/', frontend.tag); | |
router.get('/tag/:slug/', frontend.tag); | |
// Authors | |
router.get('/author/:slug/rss/', frontend.rss); | |
router.get('/author/:slug/rss/:page/', frontend.rss); | |
router.get('/author/:slug/page/:page/', frontend.author); | |
router.get('/author/:slug/', frontend.author); | |
// Default | |
router.get('/page/:page/', frontend.homepage); | |
router.get('/', frontend.homepage); | |
router.get('*', frontend.single); | |
// Public posts API | |
router.get('/api/public/posts/:id', api.http(api.posts.readN)); | |
return router; | |
}; | |
module.exports = frontendRoutes; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment