Add meta description tags

This commit is contained in:
Andrew Miner
2015-05-30 18:22:17 -07:00
parent ade6ed0814
commit bdec1643f8
9 changed files with 64 additions and 11 deletions
+8 -1
View File
@@ -115,7 +115,14 @@ exports.ProductionEnvs = [ 'staging', 'production' ]
exports.RequiredMods = [ 'minecraft' ]
exports.Text = Text = {}
Text.title = 'The Ultimate Minecraft Crafting Guide'
Text.browseDescription = _.template 'Browse through complete item listings for over a dozen top mods and use the interactive crafting planner for step-by-step instructions'
Text.configDescription = _.template 'Configure the interactive crafting planner for your exact modpack and get step-by-step instructions for any item in your world'
Text.craftDescription = _.template 'Build anything in your Minecraft mod pack with a full list of materials and step-by-step instructions using our interactive crafting planner'
Text.homeDescription = _.template 'Find everything you need to know about your Minecraft mod pack and use the interactive crafting planner for step-by-step instructions and full lists of materials'
Text.itemDescription = _.template 'Make <%= itemName %> and the rest of <%= modName %> easy and use the interactive crafting planner for step-by-step instructions'
Text.modDescription = _.template 'Make <%= modName %> easy with tutorials, videos, and a full item listing along with an interactive crafting planner for step-by-step instructions'
Text.title = _.template 'Minecraft Crafting Guide'
Text.titleWithText = _.template '<%= text %> | Minecraft Crafting Guide'
exports.Url = Url = {}
Url.crafting = _.template "/craft/<%= inventoryText %>"
@@ -10,6 +10,7 @@ ModController = require './mod_controller'
PageController = require './page_controller'
{Duration} = require '../constants'
{Event} = require '../constants'
{Text} = require '../constants'
########################################################################################################################
@@ -25,6 +26,9 @@ module.exports = class BrowsePageController extends PageController
# PageController Overrides #####################################################################
getMetaDescription: ->
return Text.browseDescription()
getTitle: ->
return 'Browse'
@@ -8,6 +8,7 @@ All rights reserved.
AdsenseController = require './adsense_controller'
PageController = require './page_controller'
ModPackController = require './mod_pack_controller'
{Text} = require '../constants'
########################################################################################################################
@@ -24,6 +25,9 @@ module.exports = class ConfigurePageController extends PageController
# PageController Overrides #####################################################################
getMetaDescription: ->
return Text.configDescription()
getTitle: ->
return "Configure"
@@ -12,6 +12,7 @@ PageController = require './page_controller'
StepController = require './step_controller'
_ = require 'underscore'
{Event} = require '../constants'
{Text} = require '../constants'
{Url} = require '../constants'
########################################################################################################################
@@ -74,6 +75,9 @@ module.exports = class CraftPageController extends PageController
# PageController Overrides #####################################################################
getMetaDescription: ->
return Text.craftDescription()
getTitle: ->
return 'Craft'
@@ -8,6 +8,7 @@ All rights reserved.
AdsenseController = require './adsense_controller'
PageController = require './page_controller'
_ = require 'underscore'
{Text} = require '../constants'
########################################################################################################################
@@ -17,6 +18,11 @@ module.exports = class HomeController extends PageController
options.templateName = 'home_page'
super options
# PageController Overrides #####################################################################
getMetaDescription: ->
return Text.homeDescription()
# BaseController Overrides #####################################################################
onDidRender: ->
@@ -56,8 +56,17 @@ module.exports = class ItemPageController extends PageController
# PageController Overrides #####################################################################
getMetaDescription: ->
if @model.item?
display = @modPack.findItemDisplay @model.item.slug
return Text.itemDescription display
else
return null
getTitle: ->
return @model.item?.name
return unless @model.item?
display = @modPack.findItemDisplay @model.item.slug
return "#{display.itemName} from #{display.modName}"
# BaseController Overrides #####################################################################
@@ -61,6 +61,10 @@ module.exports = class ModPageController extends PageController
# PageController Overrides #####################################################################
getMetaDescription: ->
return unless @model?
return Text.modDescription modName:@model.name
getTitle: ->
return @model?.name
+21 -6
View File
@@ -18,6 +18,10 @@ module.exports = class PageController extends BaseController
# Public Methods ###############################################################################
getMetaDescription: ->
# subclasses should override this to return the page-specific text for the meta description tag
return null
getTitle: ->
# subclasses should override this to return the page-specific portion of the title
return null
@@ -25,14 +29,25 @@ module.exports = class PageController extends BaseController
# BaseController Overrides #####################################################################
refresh: ->
@_refreshMetaDescription()
@_refreshTitle()
super
# Private Methods ##############################################################################
_refreshMetaDescription: ->
description = @getMetaDescription()
description ?= ''
if description.length > 0
$('meta[name="description"]').remove()
$('head').append "<meta name=\"description\" content=\"#{description}\">"
_refreshTitle: ->
title = @getTitle()
title = if title? then title.trim() else ''
if title.length > 0
title += " | #{Text.title}"
$('title').html Text.titleWithText text:title
else
title = Text.title
$('title').html title
super
$('title').html Text.title()
+1 -1
View File
@@ -8,7 +8,7 @@
.view__header
h1
a.logo(href="/"): img(src="/images/workbench_front.png")
p Crafting Guide for Minecraft
p Minecraft Crafting Guide
.addthis_sharing_toolbox
.divider.bottom