From 21c1b5303c0ba6e7b301a8e3201780cf0a102f94 Mon Sep 17 00:00:00 2001 From: Pranshu Sharma Date: Mon, 2 Jun 2025 16:28:44 +1000 Subject: [PATCH 1/2] Added cache Only fork markdown tho, can't cache erb. Now also added a deploy script which runs erb --- app.rb | 5 ++++- deploy | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100755 deploy diff --git a/app.rb b/app.rb index 95cf1a1..3f5e0cb 100644 --- a/app.rb +++ b/app.rb @@ -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 diff --git a/deploy b/deploy new file mode 100755 index 0000000..cc529f8 --- /dev/null +++ b/deploy @@ -0,0 +1,4 @@ +#!/usr/bin/sh + + +RUBY_YJIT_ENABLE=1 rackup \ No newline at end of file From f0e0bf16dabdece3c26aea13da5abcd56fafbfbb Mon Sep 17 00:00:00 2001 From: Pranshu Sharma Date: Mon, 2 Jun 2025 16:43:12 +1000 Subject: [PATCH 2/2] Added todo list --- README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 637d779..e809cc1 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,16 @@ # perc -Better Werc \ No newline at end of file +Better Werc + + +# TODO + +- [ ] Documentation +- [ ] Adding expiry to cache files. +- [ ] Adding support for [Slim](https://slim-template.github.io/) Template +- [ ] Support for dirrent layout files for subdirectory. +- [ ] Adding search. From what I can find, there are several good tools aviable that + index the site, e.g. [sphinix](https://sphinxsearch.com/), [Apache + Lucene](https://lucene.apache.org/), and [Xapian](https://xapian.org/) + +