eh, better as volflags

This commit is contained in:
ed 2022-03-20 05:45:07 +01:00
parent 515ac5d941
commit f3e8308718
9 changed files with 34 additions and 11 deletions

View file

@ -14,6 +14,7 @@ from datetime import datetime
from .__init__ import WINDOWS
from .util import (
IMPLICATIONS,
META_NOBOTS,
uncyg,
undot,
unhumanize,
@ -861,6 +862,19 @@ class AuthSrv(object):
if use:
vol.lim = lim
if self.args.no_robots:
for vol in vfs.all_vols.values():
# volflag "robots" overrides global "norobots", allowing indexing by search engines for this vol
if not vol.flags.get("robots"):
vol.flags["norobots"] = True
for vol in vfs.all_vols.values():
h = [vol.flags.get("html_head", self.args.html_head)]
if vol.flags.get("norobots"):
h.insert(0, META_NOBOTS)
vol.flags["html_head"] = "\n".join([x for x in h if x])
for vol in vfs.all_vols.values():
fk = vol.flags.get("fk")
if fk:

View file

@ -65,8 +65,11 @@ class HttpCli(object):
"Access-Control-Allow-Origin": "*",
"Cache-Control": "no-store; max-age=0",
}
h = self.args.html_head
if self.args.no_robots:
h = META_NOBOTS + (("\n" + h) if h else "")
self.out_headers["X-Robots-Tag"] = "noindex, nofollow"
self.html_head = h
def log(self, msg, c=0):
ptn = self.asrv.re_pwd
@ -95,7 +98,7 @@ class HttpCli(object):
if ka:
ka["ts"] = self.conn.hsrv.cachebuster()
ka["svcname"] = self.args.doctitle
ka["html_head"] = self.args.html_head
ka["html_head"] = self.html_head
return tpl.render(**ka)
return tpl
@ -1680,13 +1683,15 @@ class HttpCli(object):
boundary = "\roll\tide"
targs = {
"ts": self.conn.hsrv.cachebuster(),
"svcname": self.args.doctitle,
"html_head": self.html_head,
"edit": "edit" in self.uparam,
"title": html_escape(self.vpath, crlf=True),
"lastmod": int(ts_md * 1000),
"md_plug": "true" if self.args.emp else "false",
"md_chk_rate": self.args.mcr,
"md": boundary,
"ts": self.conn.hsrv.cachebuster(),
"arg_base": arg_base,
}
html = template.render(**targs).encode("utf-8", "replace")
@ -2069,6 +2074,12 @@ class HttpCli(object):
):
raise Pebkac(403)
self.html_head = vn.flags.get("html_head", "")
if vn.flags.get("norobots"):
self.out_headers["X-Robots-Tag"] = "noindex, nofollow"
else:
self.out_headers.pop("X-Robots-Tag", None)
is_dir = stat.S_ISDIR(st.st_mode)
if self.can_read:
th_fmt = self.uparam.get("th")

View file

@ -70,10 +70,6 @@ class SvcHub(object):
self.log("root", m, c=3)
if args.no_robots:
h = ['<meta name="robots" content="noindex, nofollow">', args.html_head]
args.html_head = "\n\t".join([x for x in h if x])
# initiate all services to manage
self.asrv = AuthSrv(self.args, self.log)
if args.ls:

View file

@ -71,6 +71,8 @@ SYMTIME = sys.version_info >= (3, 6) and os.supports_follow_symlinks
HTTP_TS_FMT = "%a, %d %b %Y %H:%M:%S GMT"
META_NOBOTS = '<meta name="robots" content="noindex, nofollow">'
HTTPCODE = {
200: "OK",
204: "No Content",