summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsyeopite <syeopite@syeopite.dev>2024-12-19 13:18:04 -0800
committersyeopite <syeopite@syeopite.dev>2025-01-29 11:49:45 -0800
commit05c5448bc137a7798450dec71b0750841bac2c5e (patch)
tree4e5ccab1d1f919dd3050b48e25a299117bbc70e7 /src
parent164d764d553921e6ee98facda241f13c2103ec90 (diff)
downloadinvidious-05c5448bc137a7798450dec71b0750841bac2c5e.tar.gz
invidious-05c5448bc137a7798450dec71b0750841bac2c5e.tar.bz2
invidious-05c5448bc137a7798450dec71b0750841bac2c5e.zip
Update Kemal to 1.6.0 and remove Kilt
Kilt is unmaintained and the ECR templating logic has been natively integrated into Kemal with the issues previously seen having been resolved. This commit is mostly a precursor to support the next Kemal release which will add the ability to create error handlers for raised exceptions. See https://github.com/kemalcr/kemal/pull/688
Diffstat (limited to 'src')
-rw-r--r--src/ext/kemal_content_for.cr16
-rw-r--r--src/ext/kemal_static_file_handler.cr2
-rw-r--r--src/invidious.cr8
-rw-r--r--src/invidious/helpers/macros.cr5
4 files changed, 6 insertions, 25 deletions
diff --git a/src/ext/kemal_content_for.cr b/src/ext/kemal_content_for.cr
deleted file mode 100644
index a4f3fd96..00000000
--- a/src/ext/kemal_content_for.cr
+++ /dev/null
@@ -1,16 +0,0 @@
-# Overrides for Kemal's `content_for` macro in order to keep using
-# kilt as it was before Kemal v1.1.1 (Kemal PR #618).
-
-require "kemal"
-require "kilt"
-
-macro content_for(key, file = __FILE__)
- %proc = ->() {
- __kilt_io__ = IO::Memory.new
- {{ yield }}
- __kilt_io__.to_s
- }
-
- CONTENT_FOR_BLOCKS[{{key}}] = Tuple.new {{file}}, %proc
- nil
-end
diff --git a/src/ext/kemal_static_file_handler.cr b/src/ext/kemal_static_file_handler.cr
index eb068aeb..a5f42261 100644
--- a/src/ext/kemal_static_file_handler.cr
+++ b/src/ext/kemal_static_file_handler.cr
@@ -71,7 +71,7 @@ def send_file(env : HTTP::Server::Context, file_path : String, data : Slice(UInt
filesize = data.bytesize
attachment(env, filename, disposition)
- Kemal.config.static_headers.try(&.call(env.response, file_path, filestat))
+ Kemal.config.static_headers.try(&.call(env, file_path, filestat))
file = IO::Memory.new(data)
if env.request.method == "GET" && env.request.headers.has_key?("Range")
diff --git a/src/invidious.cr b/src/invidious.cr
index b422dcbb..629e6e59 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -17,10 +17,8 @@
require "digest/md5"
require "file_utils"
-# Require kemal, kilt, then our own overrides
+# Require kemal, then our own overrides
require "kemal"
-require "kilt"
-require "./ext/kemal_content_for.cr"
require "./ext/kemal_static_file_handler.cr"
require "http_proxy"
@@ -221,8 +219,8 @@ error 500 do |env, ex|
error_template(500, ex)
end
-static_headers do |response|
- response.headers.add("Cache-Control", "max-age=2629800")
+static_headers do |env|
+ env.response.headers.add("Cache-Control", "max-age=2629800")
end
# Init Kemal
diff --git a/src/invidious/helpers/macros.cr b/src/invidious/helpers/macros.cr
index 43e7171b..84847321 100644
--- a/src/invidious/helpers/macros.cr
+++ b/src/invidious/helpers/macros.cr
@@ -55,12 +55,11 @@ macro templated(_filename, template = "template", navbar_search = true)
{{ layout = "src/invidious/views/" + template + ".ecr" }}
__content_filename__ = {{filename}}
- content = Kilt.render({{filename}})
- Kilt.render({{layout}})
+ render {{filename}}, {{layout}}
end
macro rendered(filename)
- Kilt.render("src/invidious/views/#{{{filename}}}.ecr")
+ render("src/invidious/views/#{{{filename}}}.ecr")
end
# Similar to Kemals halt method but works in a