mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-24 14:37:19 +00:00
HTML: Make template.ecr more resilient to errors
This commit is contained in:
parent
594f25141c
commit
72d2817c36
@ -1,8 +1,12 @@
|
|||||||
<%
|
|
||||||
locale = env.get("preferences").as(Preferences).locale
|
|
||||||
dark_mode = env.get("preferences").as(Preferences).dark_mode
|
|
||||||
%>
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<%-
|
||||||
|
user = env.get?("user").try &.as(IV::User)
|
||||||
|
prefs = env.get?("preferences").try &.as(Preferences)
|
||||||
|
|
||||||
|
locale = prefs.try &.locale || "en-US"
|
||||||
|
dark_mode = prefs.try &.dark_mode || "auto"
|
||||||
|
show_nick = prefs.try &.show_nick || false
|
||||||
|
-%>
|
||||||
<html lang="<%= locale %>">
|
<html lang="<%= locale %>">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
@ -40,7 +44,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="pure-u-1 pure-u-md-8-24 user-field">
|
<div class="pure-u-1 pure-u-md-8-24 user-field">
|
||||||
<% if env.get? "user" %>
|
<% if user %>
|
||||||
<div class="pure-u-1-4">
|
<div class="pure-u-1-4">
|
||||||
<a id="toggle_theme" href="/toggle_theme?referer=<%= env.get?("current_page") %>" class="pure-menu-heading" title="<%= translate(locale, "toggle_theme") %>">
|
<a id="toggle_theme" href="/toggle_theme?referer=<%= env.get?("current_page") %>" class="pure-menu-heading" title="<%= translate(locale, "toggle_theme") %>">
|
||||||
<% if dark_mode == "dark" %>
|
<% if dark_mode == "dark" %>
|
||||||
@ -52,7 +56,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="pure-u-1-4">
|
<div class="pure-u-1-4">
|
||||||
<a id="notification_ticker" title="<%= translate(locale, "Subscriptions") %>" href="/feed/subscriptions" class="pure-menu-heading">
|
<a id="notification_ticker" title="<%= translate(locale, "Subscriptions") %>" href="/feed/subscriptions" class="pure-menu-heading">
|
||||||
<% notification_count = env.get("user").as(Invidious::User).notifications.size %>
|
<% notification_count = user.try &.notifications.size || 0 %>
|
||||||
<% if CONFIG.enable_user_notifications && notification_count > 0 %>
|
<% if CONFIG.enable_user_notifications && notification_count > 0 %>
|
||||||
<span id="notification_count"><%= notification_count %></span> <i class="icon ion-ios-notifications"></i>
|
<span id="notification_count"><%= notification_count %></span> <i class="icon ion-ios-notifications"></i>
|
||||||
<% else %>
|
<% else %>
|
||||||
@ -65,11 +69,11 @@
|
|||||||
<i class="icon ion-ios-cog"></i>
|
<i class="icon ion-ios-cog"></i>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<% if env.get("preferences").as(Preferences).show_nick %>
|
<%- if show_nick -%>
|
||||||
<div class="pure-u-1-4" style="overflow: hidden; white-space: nowrap;">
|
<div class="pure-u-1-4" style="overflow: hidden; white-space: nowrap;">
|
||||||
<span id="user_name"><%= HTML.escape(env.get("user").as(Invidious::User).email) %></span>
|
<span id="user_name"><%= HTML.escape(user.try &.email) %></span>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<%- end -%>
|
||||||
<div class="pure-u-1-4">
|
<div class="pure-u-1-4">
|
||||||
<form action="/signout?referer=<%= env.get?("current_page") %>" method="post">
|
<form action="/signout?referer=<%= env.get?("current_page") %>" method="post">
|
||||||
<input type="hidden" name="csrf_token" value="<%= HTML.escape(env.get?("csrf_token").try &.as(String) || "") %>">
|
<input type="hidden" name="csrf_token" value="<%= HTML.escape(env.get?("csrf_token").try &.as(String) || "") %>">
|
||||||
@ -158,7 +162,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<script src="/js/handlers.js?v=<%= ASSET_COMMIT %>"></script>
|
<script src="/js/handlers.js?v=<%= ASSET_COMMIT %>"></script>
|
||||||
<script src="/js/themes.js?v=<%= ASSET_COMMIT %>"></script>
|
<script src="/js/themes.js?v=<%= ASSET_COMMIT %>"></script>
|
||||||
<% if env.get? "user" %>
|
<% if user %>
|
||||||
<script src="/js/sse.js?v=<%= ASSET_COMMIT %>"></script>
|
<script src="/js/sse.js?v=<%= ASSET_COMMIT %>"></script>
|
||||||
<script id="notification_data" type="application/json">
|
<script id="notification_data" type="application/json">
|
||||||
<%=
|
<%=
|
||||||
|
Loading…
Reference in New Issue
Block a user