From 2a22f6d2ceacf9712e1f785c68c5169b17bebd5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Sat, 24 May 2025 16:15:37 +0300 Subject: [PATCH] even stronger cachebusting --- app.lua | 2 ++ apps/mod.lua | 15 +++++++++++++++ views/base.etlua | 3 +-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app.lua b/app.lua index 361fe8b..4fd3cfa 100644 --- a/app.lua +++ b/app.lua @@ -13,6 +13,8 @@ app.layout = require "views.base" local function inject_constants(req) req.constants = constants + math.randomseed(os.time()) + req.__cachebust = math.random(99999) end local function inject_methods(req) diff --git a/apps/mod.lua b/apps/mod.lua index 01354c9..6a78caf 100644 --- a/apps/mod.lua +++ b/apps/mod.lua @@ -1,4 +1,5 @@ local app = require("lapis").Application() +local babycode = require("lib.babycode") local db = require("lapis.db") @@ -43,4 +44,18 @@ app:post("sort_topics", "/sort-topics", function(self) return {redirect_to = self:url_for("sort_topics")} end) +app:get("reparse_posts", "/reparse-posts", function(self) + db.query("BEGIN") + local hist = db.select("* FROM post_history") + for _, history in ipairs(hist) do + db.query( + "UPDATE post_history SET content = ? WHERE post_history.id = ?", + babycode.to_html(history.original_markup, require("lapis.html").escape), + history.id + ) + end + db.query("COMMIT") + return "ok" +end) + return app diff --git a/views/base.etlua b/views/base.etlua index cde8a6f..7adedd0 100644 --- a/views/base.etlua +++ b/views/base.etlua @@ -7,8 +7,7 @@ <% else %> Porom <% end %> - <% math.randomseed(os.time()) %> - + <% render("views.common.topnav") -%>