Skip to content

Commit d0fc256

Browse files
authored
Merge pull request #2934 from SamantazFox/bump-kemal
Bump kemal dependency to v1.1.2
2 parents fa4ce6b + 4fd1631 commit d0fc256

File tree

8 files changed

+45
-14
lines changed

8 files changed

+45
-14
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ jobs:
3838
matrix:
3939
stable: [true]
4040
crystal:
41-
- 1.0.0
42-
- 1.1.1
4341
- 1.2.2
42+
- 1.3.2
43+
- 1.4.0
4444
include:
4545
- crystal: nightly
4646
stable: false

shard.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ shards:
1414

1515
exception_page:
1616
git: https://github.com/crystal-loot/exception_page.git
17-
version: 0.2.0
17+
version: 0.2.2
1818

1919
kemal:
2020
git: https://github.com/kemalcr/kemal.git
21-
version: 1.1.0
21+
version: 1.1.2
2222

2323
kilt:
2424
git: https://github.com/jeromegn/kilt.git

shard.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ dependencies:
1818
version: ~> 0.18.0
1919
kemal:
2020
github: kemalcr/kemal
21-
version: ~> 1.1.0
21+
version: ~> 1.1.2
22+
kilt:
23+
github: jeromegn/kilt
24+
version: ~> 0.6.1
2225
protodec:
2326
github: iv-org/protodec
2427
version: ~> 0.1.4

src/ext/kemal_content_for.cr

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Overrides for Kemal's `content_for` macro in order to keep using
2+
# kilt as it was before Kemal v1.1.1 (Kemal PR #618).
3+
4+
require "kemal"
5+
require "kilt"
6+
7+
macro content_for(key, file = __FILE__)
8+
%proc = ->() {
9+
__kilt_io__ = IO::Memory.new
10+
{{ yield }}
11+
__kilt_io__.to_s
12+
}
13+
14+
CONTENT_FOR_BLOCKS[{{key}}] = Tuple.new {{file}}, %proc
15+
nil
16+
end

src/invidious.cr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@
1616

1717
require "digest/md5"
1818
require "file_utils"
19+
20+
# Require kemal, kilt, then our own overrides
1921
require "kemal"
22+
require "kilt"
23+
require "./ext/kemal_content_for.cr"
24+
require "./ext/kemal_static_file_handler.cr"
25+
2026
require "athena-negotiation"
2127
require "openssl/hmac"
2228
require "option_parser"

src/invidious/helpers/macros.cr

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,19 @@ module JSON::Serializable
4848
end
4949
end
5050

51-
macro templated(filename, template = "template", navbar_search = true)
51+
macro templated(_filename, template = "template", navbar_search = true)
5252
navbar_search = {{navbar_search}}
53-
render "src/invidious/views/#{{{filename}}}.ecr", "src/invidious/views/#{{{template}}}.ecr"
53+
54+
{{ filename = "src/invidious/views/" + _filename + ".ecr" }}
55+
{{ layout = "src/invidious/views/" + template + ".ecr" }}
56+
57+
__content_filename__ = {{filename}}
58+
content = Kilt.render({{filename}})
59+
Kilt.render({{layout}})
5460
end
5561

5662
macro rendered(filename)
57-
render "src/invidious/views/#{{{filename}}}.ecr"
63+
Kilt.render("src/invidious/views/#{{{filename}}}.ecr")
5864
end
5965

6066
# Similar to Kemals halt method but works in a

src/invidious/views/components/item.ecr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@
5252
<% if !env.get("preferences").as(Preferences).thin_mode %>
5353
<div class="thumbnail">
5454
<img loading="lazy" class="thumbnail" src="/vi/<%= item.id %>/mqdefault.jpg"/>
55-
<% if plid = env.get?("remove_playlist_items") %>
56-
<form data-onsubmit="return_false" action="/playlist_ajax?action_remove_video=1&set_video_id=<%= item.index %>&playlist_id=<%= plid %>&referer=<%= env.get("current_page") %>" method="post">
55+
<% if plid_form = env.get?("remove_playlist_items") %>
56+
<form data-onsubmit="return_false" action="/playlist_ajax?action_remove_video=1&set_video_id=<%= item.index %>&playlist_id=<%= plid_form %>&referer=<%= env.get("current_page") %>" method="post">
5757
<input type="hidden" name="csrf_token" value="<%= HTML.escape(env.get?("csrf_token").try &.as(String) || "") %>">
5858
<p class="watched">
59-
<a data-onclick="remove_playlist_item" data-index="<%= item.index %>" data-plid="<%= plid %>" href="javascript:void(0)">
59+
<a data-onclick="remove_playlist_item" data-index="<%= item.index %>" data-plid="<%= plid_form %>" href="javascript:void(0)">
6060
<button type="submit" style="all:unset">
6161
<i class="icon ion-md-trash"></i>
6262
</button>
@@ -117,11 +117,11 @@
117117
</a>
118118
</p>
119119
</form>
120-
<% elsif plid = env.get? "add_playlist_items" %>
121-
<form data-onsubmit="return_false" action="/playlist_ajax?action_add_video=1&video_id=<%= item.id %>&playlist_id=<%= plid %>&referer=<%= env.get("current_page") %>" method="post">
120+
<% elsif plid_form = env.get? "add_playlist_items" %>
121+
<form data-onsubmit="return_false" action="/playlist_ajax?action_add_video=1&video_id=<%= item.id %>&playlist_id=<%= plid_form %>&referer=<%= env.get("current_page") %>" method="post">
122122
<input type="hidden" name="csrf_token" value="<%= HTML.escape(env.get?("csrf_token").try &.as(String) || "") %>">
123123
<p class="watched">
124-
<a data-onclick="add_playlist_item" data-id="<%= item.id %>" data-plid="<%= plid %>" href="javascript:void(0)">
124+
<a data-onclick="add_playlist_item" data-id="<%= item.id %>" data-plid="<%= plid_form %>" href="javascript:void(0)">
125125
<button type="submit" style="all:unset">
126126
<i class="icon ion-md-add"></i>
127127
</button>

0 commit comments

Comments
 (0)