handle page title and mobile title updates

This commit is contained in:
Connor Turland 2017-03-15 22:02:58 -04:00
parent bc67644ba9
commit 4d3741c3b4
5 changed files with 34 additions and 12 deletions

View file

@ -5,7 +5,7 @@
# %>
<script>
<% content_for :title, "Explore My Maps | Metamaps" %>
<% content_for :title, "My Maps | Metamaps" %>
<% content_for :mobile_title, "My Maps" %>
Metamaps.currentPage = "mine";

View file

@ -5,7 +5,7 @@
# %>
<script>
<% content_for :title, "Explore Shared Maps | Metamaps" %>
<% content_for :title, "Shared Maps | Metamaps" %>
<% content_for :mobile_title, "Shared With Me" %>
Metamaps.currentPage = "shared";

View file

@ -46,7 +46,6 @@ const ReactApp = {
handleUpdate: function(location) {
const self = ReactApp
const pathname = this.state.location.pathname
// TODO: also handle page title updates
switch (pathname.split('/')[1]) {
case '':
if (Active.Mapper && Active.Mapper.id) {

View file

@ -16,15 +16,37 @@ const ExploreMaps = {
mapper: null,
updateFromPath: function(path) {
const self = ExploreMaps
const test = path.split('/')[1]
const section = path.split('/')[2]
const id = path.split('/')[3]
const [_unused, generalSection, specificSection, id] = path.split('/')
if (test === 'explore') {
const capitalize = section.charAt(0).toUpperCase() + section.slice(1)
if (generalSection === 'explore') {
const capitalize = specificSection.charAt(0).toUpperCase() + specificSection.slice(1)
self.setCollection(DataModel.Maps[capitalize])
} else if (test === '') {
switch (capitalize) {
case 'Active':
document.title = 'Explore Active Maps | Metamaps'
ReactApp.mobileTitle='Recently Active'
break
case 'Featured':
document.title = 'Explore Featured Maps | Metamaps'
ReactApp.mobileTitle='Featured Maps'
break
case 'Starred':
document.title = 'Starred Maps | Metamaps'
ReactApp.mobileTitle='Starred Maps'
break
case 'Shared':
document.title = 'Shared Maps | Metamaps'
ReactApp.mobileTitle='Shared With Me'
break
case 'Mine':
document.title = 'My Maps | Metamaps'
ReactApp.mobileTitle = 'My Maps'
break
}
} else if (generalSection === '') {
self.setCollection(DataModel.Maps.Active)
document.title = 'Explore Active Maps | Metamaps'
ReactApp.mobileTitle='Recently Active'
}
if (id) {
@ -98,6 +120,8 @@ const ExploreMaps = {
url: '/users/' + self.collection.mapperId + '/details.json',
success: function(response) {
self.mapper = response
document.title = self.mapper.name + ' | Metamaps'
ReactApp.mobileTitle = self.mapper.name
self.render()
},
error: function() {

View file

@ -25,13 +25,12 @@ class App extends Component {
}
static childContextTypes = {
currentUser: PropTypes.object,
location: PropTypes.object
}
getChildContext () {
const { route, location } = this.props
return {currentUser: route.currentUser, location}
const { location } = this.props
return {location}
}
render () {