Added cache

Only fork markdown tho, can't cache erb.

Now also added a deploy script which runs erb
This commit is contained in:
Pranshu Sharma 2025-06-02 16:28:44 +10:00
parent 50152e4abf
commit 21c1b5303c
2 changed files with 8 additions and 1 deletions

5
app.rb
View file

@ -147,14 +147,17 @@ class Sidebar
end
$sidebar = Sidebar.new
$files_cache = {}
def pview(file)
body = ""
cont = File.read(file) or return "Not found"
if (file =~ /\.erb$/)
# We can't cache erb
tp = ERB.new(cont)
body = tp.result(binding)
elsif (file =~ /\.md$/)
body = $markdown.render cont
# But we can cache markdown
body = ($files_cache[file] ||= $markdown.render cont)
end
put_in_layout(body)
end

4
deploy Executable file
View file

@ -0,0 +1,4 @@
#!/usr/bin/sh
RUBY_YJIT_ENABLE=1 rackup