Remove robot meta on note edit page and html template, add prevent crawling header to enhance note privacy

This commit is contained in:
Cheng-Han, Wu 2016-06-21 21:37:56 +08:00
parent 949f26a0d1
commit ad6982e77e
4 changed files with 2 additions and 19 deletions

View File

@ -123,7 +123,6 @@ function responseHackMD(res, note) {
url: config.serverurl, url: config.serverurl,
title: title, title: title,
useCDN: config.usecdn, useCDN: config.usecdn,
robots: (meta && meta.robots) || false, //default allow robots
facebook: config.facebook, facebook: config.facebook,
twitter: config.twitter, twitter: config.twitter,
github: config.github, github: config.github,
@ -135,7 +134,8 @@ function responseHackMD(res, note) {
res.writeHead(200, { res.writeHead(200, {
'Content-Type': 'text/html; charset=UTF-8', 'Content-Type': 'text/html; charset=UTF-8',
'Cache-Control': 'private', 'Cache-Control': 'private',
'Content-Length': buf.length 'Content-Length': buf.length,
'X-Robots-Tag': 'noindex, nofollow' // prevent crawling
}); });
res.end(buf); res.end(buf);
} }

View File

@ -81,29 +81,17 @@ function slugifyWithUTF8(text) {
//parse meta //parse meta
function parseMeta(md, edit, view, toc, tocAffix) { function parseMeta(md, edit, view, toc, tocAffix) {
var robots = null;
var lang = null; var lang = null;
var dir = null; var dir = null;
var breaks = true; var breaks = true;
var spellcheck = false; var spellcheck = false;
if (md && md.meta) { if (md && md.meta) {
var meta = md.meta; var meta = md.meta;
robots = meta.robots;
lang = meta.lang; lang = meta.lang;
dir = meta.dir; dir = meta.dir;
breaks = meta.breaks; breaks = meta.breaks;
spellcheck = meta.spellcheck; spellcheck = meta.spellcheck;
} }
//robots meta
var robotsMeta = $('meta[name=robots]');
if (robots) {
if (robotsMeta.length > 0)
robotsMeta.attr('content', robots);
else
$('head').prepend('<meta name="robots" content="' + robots + '">')
}
else
robotsMeta.remove();
//text language //text language
if (lang) { if (lang) {
view.attr('lang', lang); view.attr('lang', lang);
@ -504,7 +492,6 @@ function exportToHTML(view) {
html: src[0].outerHTML, html: src[0].outerHTML,
toc: toc.html(), toc: toc.html(),
'toc-affix': tocAffix.html(), 'toc-affix': tocAffix.html(),
robots: (md && md.meta && md.meta.robots) ? '<meta name="robots" content="' + md.meta.robots + '">' : null,
lang: (md && md.meta && md.meta.lang) ? 'lang="' + md.meta.lang + '"' : 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 dir: (md && md.meta && md.meta.dir) ? 'dir="' + md.meta.dir + '"' : null
}; };

View File

@ -4,9 +4,6 @@
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black"> <meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes">
<% if(typeof robots !== 'undefined' && robots) { %>
<meta name="robots" content="<%- robots %>">
<% } %>
<title><%- title %></title> <title><%- title %></title>
<link rel="icon" type="image/png" href="<%- url %>/favicon.png"> <link rel="icon" type="image/png" href="<%- url %>/favicon.png">
<link rel="apple-touch-icon" href="<%- url %>/apple-touch-icon.png"> <link rel="apple-touch-icon" href="<%- url %>/apple-touch-icon.png">

View File

@ -9,7 +9,6 @@
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black"> <meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes">
{{{robots}}}
<title> <title>
{{title}} {{title}}
</title> </title>