From ad6982e77e1948bd7b74538af0c5a24120a38370 Mon Sep 17 00:00:00 2001 From: "Cheng-Han, Wu" Date: Tue, 21 Jun 2016 21:37:56 +0800 Subject: [PATCH] Remove robot meta on note edit page and html template, add prevent crawling header to enhance note privacy --- lib/response.js | 4 ++-- public/js/extra.js | 13 ------------- public/views/head.ejs | 3 --- public/views/html.hbs | 1 - 4 files changed, 2 insertions(+), 19 deletions(-) diff --git a/lib/response.js b/lib/response.js index 3064d32..5d7fc0a 100644 --- a/lib/response.js +++ b/lib/response.js @@ -123,7 +123,6 @@ function responseHackMD(res, note) { url: config.serverurl, title: title, useCDN: config.usecdn, - robots: (meta && meta.robots) || false, //default allow robots facebook: config.facebook, twitter: config.twitter, github: config.github, @@ -135,7 +134,8 @@ function responseHackMD(res, note) { res.writeHead(200, { 'Content-Type': 'text/html; charset=UTF-8', 'Cache-Control': 'private', - 'Content-Length': buf.length + 'Content-Length': buf.length, + 'X-Robots-Tag': 'noindex, nofollow' // prevent crawling }); res.end(buf); } diff --git a/public/js/extra.js b/public/js/extra.js index 48e474a..953770b 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -81,29 +81,17 @@ function slugifyWithUTF8(text) { //parse meta function parseMeta(md, edit, view, toc, tocAffix) { - var robots = null; var lang = null; var dir = null; var breaks = true; var spellcheck = false; if (md && md.meta) { var meta = md.meta; - robots = meta.robots; lang = meta.lang; dir = meta.dir; breaks = meta.breaks; spellcheck = meta.spellcheck; } - //robots meta - var robotsMeta = $('meta[name=robots]'); - if (robots) { - if (robotsMeta.length > 0) - robotsMeta.attr('content', robots); - else - $('head').prepend('') - } - else - robotsMeta.remove(); //text language if (lang) { view.attr('lang', lang); @@ -504,7 +492,6 @@ function exportToHTML(view) { html: src[0].outerHTML, toc: toc.html(), 'toc-affix': tocAffix.html(), - robots: (md && md.meta && md.meta.robots) ? '' : null, lang: (md && md.meta && md.meta.lang) ? 'lang="' + md.meta.lang + '"' : null, dir: (md && md.meta && md.meta.dir) ? 'dir="' + md.meta.dir + '"' : null }; diff --git a/public/views/head.ejs b/public/views/head.ejs index 3dcf486..70f6455 100644 --- a/public/views/head.ejs +++ b/public/views/head.ejs @@ -4,9 +4,6 @@ -<% if(typeof robots !== 'undefined' && robots) { %> - -<% } %> <%- title %> diff --git a/public/views/html.hbs b/public/views/html.hbs index 33fbd53..f6e5749 100644 --- a/public/views/html.hbs +++ b/public/views/html.hbs @@ -9,7 +9,6 @@ - {{{robots}}} {{title}}