Skip to content

Commit

Permalink
Extract fields so no duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
timja committed Nov 25, 2019
1 parent ae4ee5c commit a40b229
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
3 changes: 3 additions & 0 deletions app/commons/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ export function cleanTitle(title) {
.replace(' for Jenkins','')
.replace('Hudson ','');
}

export const defaultPluginSiteTitle = 'Jenkins Plugins';
export const pluginSiteTitleSuffix = 'Jenkins plugin';
3 changes: 2 additions & 1 deletion app/components/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Views from './Views';
import { actions } from '../actions';
import { isFiltered, showFilter, showResults, view } from '../selectors';
import { createSelector } from 'reselect';
import { defaultPluginSiteTitle } from '../commons/helper';

class Main extends React.PureComponent {

Expand Down Expand Up @@ -78,7 +79,7 @@ class Main extends React.PureComponent {

render() {
if (typeof document !== 'undefined') {
document.title = 'Jenkins Plugins';
document.title = defaultPluginSiteTitle;
}

return (
Expand Down
4 changes: 2 additions & 2 deletions app/components/PluginDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import moment from 'moment';
import LineChart from './LineChart';
import NotFound from './NotFound';
import Spinner from './Spinner';
import { cleanTitle } from '../commons/helper';
import { cleanTitle, pluginSiteTitleSuffix } from '../commons/helper';
import { firstVisit, isFetchingPlugin, labels, plugin } from '../selectors';
import { actions } from '../actions';
import { createSelector } from 'reselect';
Expand Down Expand Up @@ -312,7 +312,7 @@ class PluginDetail extends React.PureComponent {
}

if (typeof document !== 'undefined') {
document.title = `${cleanTitle(plugin.title)} - Jenkins plugin`;
document.title = `${cleanTitle(plugin.title)} - ${pluginSiteTitleSuffix}`;
}
const beforeClose = this.closeDialog;
return (
Expand Down
6 changes: 3 additions & 3 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import fs from 'fs';
import unirest from 'unirest';
import cheerio from 'cheerio';
import schedule from 'node-schedule';
import { cleanTitle } from './app/commons/helper';
import { cleanTitle, defaultPluginSiteTitle, pluginSiteTitleSuffix } from './app/commons/helper';

const app = express();
const port = 5000;
Expand All @@ -36,7 +36,7 @@ app.use(jsPath, express.static('./dist/client'));
app.engine('hbs', exphbs({extname: '.hbs'}));
app.set('view engine', 'hbs');

const defaultPluginSiteTitle = 'Jenkins Plugins';

const defaultPluginSiteDescription = 'Jenkins – an open source automation server which enables developers around the world to reliably build, test, and deploy their software';
const defaultPluginOpenGraphImage = 'https://jenkins.io/images/logo-title-opengraph.png'

Expand Down Expand Up @@ -120,7 +120,7 @@ app.get('*', (req, res, next) => {
const pluginSiteApiVersion = store.getState().data.info.commit.substring(0, 7);
const reduxState = JSON.stringify(store.getState()).replace(/</g, '\\x3c');
const pluginNotFound = req.url !== '/' && store.getState().ui.plugin === null;
const title = store.getState().ui.plugin && store.getState().ui.plugin.title ? `${cleanTitle(store.getState().ui.plugin.title)} - Jenkins plugin` : defaultPluginSiteTitle;
const title = store.getState().ui.plugin && store.getState().ui.plugin.title ? `${cleanTitle(store.getState().ui.plugin.title)} - ${pluginSiteTitleSuffix}` : defaultPluginSiteTitle;
const description = store.getState().ui.plugin && store.getState().ui.plugin.excerpt ? store.getState().ui.plugin.excerpt : defaultPluginSiteDescription;
const opengraphImage = defaultPluginOpenGraphImage; // TODO WEBSITE-645 add support for plugins to provide their own OG imag

Expand Down

0 comments on commit a40b229

Please sign in to comment.