Commit 0baacf99 authored by Matija Obreza's avatar Matija Obreza

Merge branch '377-ssr-redirect-species-names' into 'master'

Resolve "SSR redirect: Species names"

Closes #377

See merge request genesys-pgr/genesys-ui!380
parents 15abd814 dd27681b
......@@ -14,6 +14,7 @@ import sitemap from './sitemap';
import i18nServer from '../i18n/i18n-server';
import httpProxy from './middleware/httpProxy';
import AccessionService from 'service/genesys/AccessionService';
import AccessionFilter from 'model/accession/AccessionFilter';
const i18nextMiddleware = require('i18next-express-middleware'); // has no proper import yet
const app = express();
......@@ -74,6 +75,59 @@ app.use('/proxy', httpProxy);
app.use(/^\/manifest.json$/, (req, res) => {
res.status(403).set('Content-Type', 'text/plain').send('Access denied.');
});
app.use(':lang(/[a-z]{2})?/acn/t/:genus([^/]+):species(/*)?', (req, res, next) => {
const lang = req.params.lang;
const genus = req.params.genus;
const species = req.params.species ? req.params.species.substring(1) : undefined;
if (species && species !== '') {
console.log(`Server redirect ${config.frontendPath}${lang}/acn/t/${genus}/${species} to ${config.frontendPath}${lang || ''}/a/species/${genus} ${species}`);
res.redirect(301, `${config.frontendPath}${lang || ''}/a/species/${genus} ${species}`);
} else {
console.log(`Server redirect ${config.frontendPath}${lang}/acn/t/${genus} to ${config.frontendPath}${lang || ''}/a/genus/${genus}`);
res.redirect(301, `${config.frontendPath}${lang || ''}/a/genus/${genus}`);
}
});
app.use(':lang(/[a-z]{2})?/a/genus/:genus(*)', (req, res, next) => {
const lang = req.params.lang;
const genus = req.params.genus;
const filter: AccessionFilter = {
taxonomy: { genus: [ genus ] },
};
console.log(`Handling /a/genus/${genus}`, filter);
return AccessionService.listOverview(filter)
.then((overview) => {
// console.log(overview);
console.log(`Server redirect ${config.frontendPath}${lang || ''}/a/genus/${genus} to ${config.frontendPath}${lang || ''}/a/overview/${overview.filterCode}`);
res.redirect(302, `${config.frontendPath}${lang || ''}/a/overview/${overview.filterCode}`);
}).catch((e) => {
console.log('Error redirecting', e);
next();
});
});
app.use(':lang(/[a-z]{2})?/a/species/:genusSpecies(*)', (req, res, next) => {
const lang = req.params.lang;
const genusSpecies = req.params.genusSpecies;
const filter: AccessionFilter = {
taxonomy: { genusSpecies: [ genusSpecies ] },
};
console.log(`Handling /a/species/${genusSpecies}`, filter);
return AccessionService.listOverview(filter)
.then((overview) => {
// console.log(overview);
console.log(`Server redirect ${config.frontendPath}${lang || ''}/a/species/${genusSpecies} to ${config.frontendPath}${lang || ''}/a/overview/${overview.filterCode}`);
res.redirect(302, `${config.frontendPath}${lang || ''}/a/overview/${overview.filterCode}`);
}).catch((e) => {
console.log('Error redirecting', e);
next();
});
});
// Serve Git commithash
app.use(/^\/COMMITHASH$/, express.static(path.join('../assets'), {
etag: true,
......
......@@ -36,7 +36,6 @@ class AccessionFilter {
public pdci?: NumberFilter;
public sampStat?: number[];
public seqNo?: NumberFilter;
public taxa?: TaxonomyFilter;
public uuid?: string[];
public version?: number[];
public sgsv?: boolean;
......
......@@ -29,7 +29,6 @@ const styles = (theme) => ({
/* tslint:disable */
drawer: {
boxShadow: '-4px 0px 2px -1px rgba(0, 0, 0, 0.2)',
position: 'sticky' as 'sticky',
top: '72px',
zIndex: 10,
......@@ -52,7 +51,13 @@ const styles = (theme) => ({
},
[theme.breakpoints.down('xs')]: {
maxWidth: '100%',
}
},
'html[dir="ltr"] &' : {
boxShadow: '4px 0px 2px -1px rgba(0, 0, 0, 0.2)',
},
'html[dir="rtl"] &' : {
boxShadow: '-4px 0px 2px -1px rgba(0, 0, 0, 0.2)',
},
},
drawerAlwaysCollapsible: {
maxWidth: '90%!important',
......@@ -69,6 +74,12 @@ const styles = (theme) => ({
},
drawerRight: {
right: '0',
'html[dir="ltr"] &' : {
boxShadow: '-4px 0px 2px -1px rgba(0, 0, 0, 0.2)',
},
'html[dir="rtl"] &' : {
boxShadow: '4px 0px 2px -1px rgba(0, 0, 0, 0.2)',
},
},
drawerCollapsed: {
[theme.breakpoints.down('sm')]: {
......
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