Implement rudimentary cache busting for lua docs
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
|
||||
{%
|
||||
math.randomseed(os.time())
|
||||
|
||||
local baseUrl = ldoc.css:gsub("ldoc.css", "")
|
||||
local repo = "https://github.com/evilfactory/LuaCsForBarotrauma"
|
||||
local pageTitle = mod and (ldoc.display_name(mod) .. " - " .. ldoc.title) or ldoc.title
|
||||
@@ -13,6 +15,13 @@ function ldoc.url(path)
|
||||
return baseUrl .. path
|
||||
end
|
||||
|
||||
function ldoc.asset_url(path)
|
||||
local uuid = string.gsub("xxxxxxx", "x", function(c)
|
||||
return string.format("%x", math.random(0, 0xf))
|
||||
end)
|
||||
return baseUrl .. path .. "?v=" .. uuid
|
||||
end
|
||||
|
||||
function ldoc.realm_icon(realm)
|
||||
return "<span class=\"realm " .. (realm or "") .. "\"></span>"
|
||||
end
|
||||
@@ -97,8 +106,8 @@ end
|
||||
{% end %}
|
||||
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Code+Pro" />
|
||||
<link rel="stylesheet" href="{* ldoc.css *}" />
|
||||
<link rel="stylesheet" href="{* ldoc.url('highlight.css') *}" />
|
||||
<link rel="stylesheet" href="{* ldoc.asset_url("ldoc.css") *}" />
|
||||
<link rel="stylesheet" href="{* ldoc.asset_url("highlight.css") *}" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -120,8 +129,8 @@ end
|
||||
</article>
|
||||
</main>
|
||||
|
||||
<script type="text/javascript" src="{* ldoc.url('app.js') *}"></script>
|
||||
<script type="text/javascript" src="{* ldoc.url('highlight.min.js') *}"></script>
|
||||
<script type="text/javascript" src="{* ldoc.asset_url("app.js") *}"></script>
|
||||
<script type="text/javascript" src="{* ldoc.asset_url("highlight.min.js") *}"></script>
|
||||
<script type="text/javascript">
|
||||
var elements = document.querySelectorAll("pre code")
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import http.server
|
||||
from http.server import SimpleHTTPRequestHandler
|
||||
import argparse
|
||||
|
||||
def Route(s):
|
||||
@@ -14,9 +15,21 @@ parser.add_argument("root", type=str)
|
||||
parser.add_argument("--port", type=int, default=8000)
|
||||
parser.add_argument("--route", type=Route, dest="routes", action="extend", nargs="*")
|
||||
|
||||
class RequestHandler(http.server.SimpleHTTPRequestHandler):
|
||||
class RequestHandler(SimpleHTTPRequestHandler):
|
||||
base_dir = None
|
||||
routes = []
|
||||
|
||||
def end_headers(self):
|
||||
self.send_header("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||
self.send_header("Pragma", "no-cache")
|
||||
self.send_header("Expires", "0")
|
||||
SimpleHTTPRequestHandler.end_headers(self)
|
||||
|
||||
def do_GET(self):
|
||||
if '?' in self.path:
|
||||
self.path = self.path.split('?')[0]
|
||||
SimpleHTTPRequestHandler.do_GET(self)
|
||||
|
||||
def translate_path(self, path):
|
||||
path.lstrip()
|
||||
for prefix, rootDir in self.routes:
|
||||
|
||||
Reference in New Issue
Block a user