Added cache
Only fork markdown tho, can't cache erb. Now also added a deploy script which runs erb
This commit is contained in:
parent
50152e4abf
commit
21c1b5303c
2 changed files with 8 additions and 1 deletions
5
app.rb
5
app.rb
|
@ -147,14 +147,17 @@ class Sidebar
|
||||||
end
|
end
|
||||||
|
|
||||||
$sidebar = Sidebar.new
|
$sidebar = Sidebar.new
|
||||||
|
$files_cache = {}
|
||||||
def pview(file)
|
def pview(file)
|
||||||
body = ""
|
body = ""
|
||||||
cont = File.read(file) or return "Not found"
|
cont = File.read(file) or return "Not found"
|
||||||
if (file =~ /\.erb$/)
|
if (file =~ /\.erb$/)
|
||||||
|
# We can't cache erb
|
||||||
tp = ERB.new(cont)
|
tp = ERB.new(cont)
|
||||||
body = tp.result(binding)
|
body = tp.result(binding)
|
||||||
elsif (file =~ /\.md$/)
|
elsif (file =~ /\.md$/)
|
||||||
body = $markdown.render cont
|
# But we can cache markdown
|
||||||
|
body = ($files_cache[file] ||= $markdown.render cont)
|
||||||
end
|
end
|
||||||
put_in_layout(body)
|
put_in_layout(body)
|
||||||
end
|
end
|
||||||
|
|
4
deploy
Executable file
4
deploy
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/sh
|
||||||
|
|
||||||
|
|
||||||
|
RUBY_YJIT_ENABLE=1 rackup
|
Loading…
Add table
Add a link
Reference in a new issue