Commit f44d0a3c authored by NGPixel's avatar NGPixel

feat: URL trailing slashes remove + All pages basepath

parent db16eb72
...@@ -8,12 +8,14 @@ This project adheres to [Semantic Versioning](http://semver.org/). ...@@ -8,12 +8,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- **Auth**: Can now specify Read Access by default for all providers (except Local) - **Auth**: Can now specify Read Access by default for all providers (except Local)
- **View**: MathML and TeX math equations support - **View**: MathML and TeX math equations support
- **Configuration Wizard**: Added Public Access option - **Configuration Wizard**: Added Public Access option
- **Misc**: Heroku support
- **Navigation**: All Pages section - **Navigation**: All Pages section
- **UI**: Beatiful new logo! - **UI**: Beatiful new logo!
### Changed ### Changed
- **Auth**: Provider Strategies are now only loaded if enabled - **Auth**: Provider Strategies are now only loaded if enabled
- **System**: Updated dependencies - **Misc**: Trailing slashes in URL are now removed
- **Misc**: Updated dependencies
- **UI**: Footer is now always at the bottom of the page (but not fixed) - **UI**: Footer is now always at the bottom of the page (but not fixed)
### Fixed ### Fixed
......
...@@ -32,7 +32,11 @@ module.exports = (alerts, socket) => { ...@@ -32,7 +32,11 @@ module.exports = (alerts, socket) => {
} }
}, },
mounted: function () { mounted: function () {
this.fetch('') let basePath = window.location.pathname.slice(0, -4)
if (basePath.length > 1) {
basePath = basePath.slice(1)
}
this.fetch(basePath)
} }
}) })
} }
......
...@@ -351,6 +351,12 @@ module.exports = (port, spinner) => { ...@@ -351,6 +351,12 @@ module.exports = (port, spinner) => {
}) })
}) })
).then(() => { ).then(() => {
if (process.env.IS_HEROKU) {
return fs.outputJsonAsync('./app/heroku.json', { configured: true })
} else {
return true
}
}).then(() => {
res.json({ ok: true }) res.json({ ok: true })
}).catch(err => { }).catch(err => {
res.json({ ok: false, error: err.message }) res.json({ ok: false, error: err.message })
......
...@@ -137,8 +137,12 @@ router.put('/create/*', (req, res, next) => { ...@@ -137,8 +137,12 @@ router.put('/create/*', (req, res, next) => {
/** /**
* View tree view of all pages * View tree view of all pages
*/ */
router.get('/all', (req, res, next) => { router.use((req, res, next) => {
res.render('pages/all') if (_.endsWith(req.url, '/all')) {
res.render('pages/all')
} else {
next()
}
}) })
// ========================================== // ==========================================
......
'use strict'
const _ = require('lodash')
/**
* SEO Middleware
*
* @param {Express Request} req Express request object
* @param {Express Response} res Express response object
* @param {Function} next next callback function
* @return {any} void
*/
module.exports = function (req, res, next) {
if (req.path.length > 1 && _.endsWith(req.path, '/')) {
let query = req.url.slice(req.path.length) || ''
res.redirect(301, req.path.slice(0, -1) + query)
} else {
return next()
}
}
...@@ -111,6 +111,12 @@ app.use(passport.initialize()) ...@@ -111,6 +111,12 @@ app.use(passport.initialize())
app.use(passport.session()) app.use(passport.session())
// ---------------------------------------- // ----------------------------------------
// SEO
// ----------------------------------------
app.use(mw.seo)
// ----------------------------------------
// Localization Engine // Localization Engine
// ---------------------------------------- // ----------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment