Merge pull request #2934 from SamantazFox/bump-kemal

Bump kemal dependency to v1.1.2
This commit is contained in:
Samantaz Fox 2022-04-17 00:12:00 +02:00 committed by GitHub
commit d0fc2569ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 45 additions and 14 deletions

View File

@ -38,9 +38,9 @@ jobs:
matrix:
stable: [true]
crystal:
- 1.0.0
- 1.1.1
- 1.2.2
- 1.3.2
- 1.4.0
include:
- crystal: nightly
stable: false

View File

@ -14,11 +14,11 @@ shards:
exception_page:
git: https://github.com/crystal-loot/exception_page.git
version: 0.2.0
version: 0.2.2
kemal:
git: https://github.com/kemalcr/kemal.git
version: 1.1.0
version: 1.1.2
kilt:
git: https://github.com/jeromegn/kilt.git

View File

@ -18,7 +18,10 @@ dependencies:
version: ~> 0.18.0
kemal:
github: kemalcr/kemal
version: ~> 1.1.0
version: ~> 1.1.2
kilt:
github: jeromegn/kilt
version: ~> 0.6.1
protodec:
github: iv-org/protodec
version: ~> 0.1.4

View File

@ -0,0 +1,16 @@
# 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

View File

@ -16,7 +16,13 @@
require "digest/md5"
require "file_utils"
# Require kemal, kilt, then our own overrides
require "kemal"
require "kilt"
require "./ext/kemal_content_for.cr"
require "./ext/kemal_static_file_handler.cr"
require "athena-negotiation"
require "openssl/hmac"
require "option_parser"

View File

@ -48,13 +48,19 @@ module JSON::Serializable
end
end
macro templated(filename, template = "template", navbar_search = true)
macro templated(_filename, template = "template", navbar_search = true)
navbar_search = {{navbar_search}}
render "src/invidious/views/#{{{filename}}}.ecr", "src/invidious/views/#{{{template}}}.ecr"
{{ filename = "src/invidious/views/" + _filename + ".ecr" }}
{{ layout = "src/invidious/views/" + template + ".ecr" }}
__content_filename__ = {{filename}}
content = Kilt.render({{filename}})
Kilt.render({{layout}})
end
macro rendered(filename)
render "src/invidious/views/#{{{filename}}}.ecr"
Kilt.render("src/invidious/views/#{{{filename}}}.ecr")
end
# Similar to Kemals halt method but works in a

View File

@ -52,11 +52,11 @@
<% if !env.get("preferences").as(Preferences).thin_mode %>
<div class="thumbnail">
<img loading="lazy" class="thumbnail" src="/vi/<%= item.id %>/mqdefault.jpg"/>
<% if plid = env.get?("remove_playlist_items") %>
<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">
<% if plid_form = env.get?("remove_playlist_items") %>
<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">
<input type="hidden" name="csrf_token" value="<%= HTML.escape(env.get?("csrf_token").try &.as(String) || "") %>">
<p class="watched">
<a data-onclick="remove_playlist_item" data-index="<%= item.index %>" data-plid="<%= plid %>" href="javascript:void(0)">
<a data-onclick="remove_playlist_item" data-index="<%= item.index %>" data-plid="<%= plid_form %>" href="javascript:void(0)">
<button type="submit" style="all:unset">
<i class="icon ion-md-trash"></i>
</button>
@ -117,11 +117,11 @@
</a>
</p>
</form>
<% elsif plid = env.get? "add_playlist_items" %>
<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">
<% elsif plid_form = env.get? "add_playlist_items" %>
<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">
<input type="hidden" name="csrf_token" value="<%= HTML.escape(env.get?("csrf_token").try &.as(String) || "") %>">
<p class="watched">
<a data-onclick="add_playlist_item" data-id="<%= item.id %>" data-plid="<%= plid %>" href="javascript:void(0)">
<a data-onclick="add_playlist_item" data-id="<%= item.id %>" data-plid="<%= plid_form %>" href="javascript:void(0)">
<button type="submit" style="all:unset">
<i class="icon ion-md-add"></i>
</button>