Skip to content

Commit

Permalink
Merge pull request #669 from thanhson1085/master
Browse files Browse the repository at this point in the history
Add sitemap, meta page
  • Loading branch information
thanhson1085 authored Jun 13, 2019
2 parents 573919a + ae9691a commit 4386bbb
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 30 deletions.
2 changes: 2 additions & 0 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ import Eth from '@ledgerhq/hw-app-eth'
import TrezorConnect from 'trezor-connect'
import Transaction from 'ethereumjs-tx'
import * as HDKey from 'ethereumjs-wallet/hdkey'
import Meta from 'vue-meta'

Vue.use(Meta)
Vue.use(BootstrapVue)
Vue.use(VueClipboards)

Expand Down
6 changes: 6 additions & 0 deletions app/components/candidates/View.vue
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,12 @@ import store from 'store'
export default {
name: 'App',
metaInfo: {
title: 'Candidate Details | TomoMaster',
meta: [
{ name: 'description', content: 'Staking TomoChain Masternode to get the reward every epochs. You can use mobile, desktop, hardware wallet - ledger nano, trezor to stake TomoChain' } // eslint-disable-line
]
},
components: {
chart: Chart
},
Expand Down
6 changes: 6 additions & 0 deletions app/components/voters/View.vue
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ import moment from 'moment'
export default {
name: 'App',
metaInfo: {
title: 'Staker Details | TomoMaster',
meta: [
{ name: 'description', content: 'Staking history, Reward history, Masternode list, Transaction list. You can use mobile, desktop, hardware wallet - ledger nano, trezor to stake TomoChain' } // eslint-disable-line
]
},
data () {
return {
candidateFields: [
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta content="width=device-width,initial-scale=1,minimal-ui" name="viewport">
<meta content="Tomomaster - Providing a professional UI which allows coin-holders to vote for masternodes, decentralized governance and explore masternode performance statistics" name="description">
<meta content="Tomomaster - Providing a professional UI which allows coin-holders to stake for masternodes, decentralized governance and explore masternode performance statistics" name="description">
<title>TomoMaster - TomoChain Governance DApp</title>
<link type="image/x-icon" rel="shortcut icon" href="/app/assets/img/favicon_48x48.ico">
</head>
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(docs))

// apis
app.use(require('./apis'))
app.use(require('./middlewares/sitemap'))

// error handler
app.use(require('./middlewares/error'))
Expand Down
31 changes: 31 additions & 0 deletions middlewares/sitemap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const express = require('express')
const router = express.Router()
const db = require('../models/mongodb')
const _ = require('lodash')

router.get('/sitemap.xml', async (req, res) => {
const domain = 'https://master.tomochain.com'
let routes = (await db.Candidate.find()
.sort({ capacityNumber: -1 })
.limit(500).lean().exec()).map(c => {
return `${domain}/candidate/${c.candidate}`
})
routes = _.concat(routes, (await db.Voter.find()
.sort({ capacityNumber: -1 })
.limit(2000).lean().exec()).map(v => {
return `${domain}/voter/${v.voter}`
}))
const lastmod = (new Date()).toISOString()
const list = routes
.map(route => `<url><loc>${route}</loc><lastmod>${lastmod}</lastmod></url>`)
.join('\r')

routes = _.concat(routes, `${domain}`)

res.header('Content-Type', 'application/xml')
/* eslint-disable */
return res.send(`<?xml version="1.0" encoding="UTF-8"?><urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">${list}</urlset>`)
/* eslint-enable no-alert */
})

module.exports = router
Loading

0 comments on commit 4386bbb

Please sign in to comment.