git ssb

9+

cel / ssb-viewer



Commit 69a32cc3435ccd2d5b83ef5b83832745abe29af5

Add config for Disallow: / in robots.txt

cel committed on 4/27/2018, 5:12:22 AM
Parent: 86801890069c72884af76b73462e38b8b85697db

Files changed

index.jschanged
index.jsView
@@ -92,9 +92,9 @@
9292 switch (m[2]) {
9393 case '%': return serveId(req, res, m[1], m[3], m[5])
9494 case '@': return serveFeed(req, res, m[1], m[3], m[5])
9595 case '&': return serveBlob(req, res, sbot, m[1])
96- default: return servePath(req, res, m[4])
96 + default: return servePath(req, res, m[4], conf)
9797 }
9898 }
9999
100100 function serveFeed(req, res, feedId, ext) {
@@ -452,11 +452,11 @@
452452 case 'rss': return 'text/xml'
453453 }
454454 }
455455
456-function servePath(req, res, url) {
456 +function servePath(req, res, url, conf) {
457457 switch (url) {
458- case '/robots.txt': return res.end('User-agent: *')
458 + case '/robots.txt': return serveRobots(req, res, conf)
459459 }
460460 var m = /^(\/?[^\/]*)(\/.*)?$/.exec(url)
461461 switch (m[1]) {
462462 case '/static': return serveStatic(req, res, m[2])
@@ -490,8 +490,13 @@
490490 fs.createReadStream(file).pipe(res)
491491 })
492492 }
493493
494 +function serveRobots(req, res, conf) {
495 + res.end('User-agent: *'
496 + + (conf.disallowRobots ? '\nDisallow: /' : ''))
497 +}
498 +
494499 function prepend(fn, arg) {
495500 return function (read) {
496501 return function (abort, cb) {
497502 if (fn && !abort) {

Built with git-ssb-web