Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

#44 - Enable SEO features

  • Loading branch information...
commit 057e21f8581996f50853838d55ba61dbe96a7f44 1 parent 3083871
@neojp authored
Showing with 16 additions and 9 deletions.
  1. +1 −0  config.json.sample
  2. +1 −5 public/robots.txt
  3. +14 −4 src/app.coffee
View
1  config.json.sample
@@ -16,6 +16,7 @@
"info": {
"name": "L4C.me",
+ "title": "The document title on the homepage",
"description": "A photo sharing service made with love ♥"
},
View
6 public/robots.txt
@@ -1,5 +1 @@
-User-agent: Twitterbot
-Disallow:
-
-User-agent: *
-Disallow: /
+User-agent: *
View
18 src/app.coffee
@@ -1,6 +1,8 @@
# Module dependencies
_ = underscore = require 'underscore'
_.str = underscore.str = require 'underscore.string'
+_.mixin _.str.exports()
+
invoke = require 'invoke'
express = require 'express'
nodejs_url = require 'url'
@@ -126,7 +128,7 @@ app.all '*', middleware.redirect_subdomain, middleware.remove_trailing_slash, (r
res.locals
_: underscore
body_class: ''
- document_description: config.info.description
+ document_description: ''
document_image: url_domain + '/images/logo.png'
document_title: config.info.name
document_url: url_domain
@@ -193,6 +195,8 @@ app.get '/fotos/:sort?', (req, res, next) ->
photos: photos
sort: sort
total: count
+ document_description: if req.originalUrl == '/' then config.info.description else res.local 'document_description'
+ document_title: if req.originalUrl == '/' then config.info.title else res.local 'document_title'
res.render 'gallery', { layout: false }
@@ -573,12 +577,18 @@ app.get '/:user/:slug', (req, res, next) ->
next err
.end null, (data) ->
- photo.prev = data[2][0]
- photo.next = data[2][1]
+ photo.prev = data[2][0]
+ photo.next = data[2][1]
+ description = _(photo.description)
+ .chain()
+ .clean() # remove whitespace and break lines
+ .escapeHTML() # escape all HTML tags
+ .prune(150) # fancier version of truncate, doesn't return cut-off words
+ .value()
res.locals
body_class: 'small-header user single' + if photo.image.panorama then ' panorama' else ''
- document_descrition: photo.description || ''
+ document_description: description || ''
document_image: "#{url_domain}/uploads/#{photo._id}_m.#{photo.image.ext}"
document_title: photo.name
document_url: "#{url_domain}/#{username}/#{photo._id}"
Please sign in to comment.
Something went wrong with that request. Please try again.