Add toggleable preference for nickname display

This commit is contained in:
Mateusz Makowski 2020-02-13 21:19:37 +01:00
parent cb8b98f939
commit bb9c07aa93
7 changed files with 21 additions and 5 deletions

View File

@ -113,6 +113,7 @@
"Administrator preferences": "Administrator preferences", "Administrator preferences": "Administrator preferences",
"Default homepage: ": "Default homepage: ", "Default homepage: ": "Default homepage: ",
"Feed menu: ": "Feed menu: ", "Feed menu: ": "Feed menu: ",
"Show nickname on top: ": "Show nickname on top: ",
"Top enabled: ": "Top enabled: ", "Top enabled: ": "Top enabled: ",
"CAPTCHA enabled: ": "CAPTCHA enabled: ", "CAPTCHA enabled: ": "CAPTCHA enabled: ",
"Login enabled: ": "Login enabled: ", "Login enabled: ": "Login enabled: ",
@ -384,4 +385,4 @@
"Playlists": "Playlists", "Playlists": "Playlists",
"Community": "Community", "Community": "Community",
"Current version: ": "Current version: " "Current version: ": "Current version: "
} }

View File

@ -332,5 +332,6 @@
"Videos": "Filmy", "Videos": "Filmy",
"Playlists": "Playlisty", "Playlists": "Playlisty",
"Community": "Społeczność", "Community": "Społeczność",
"Current version: ": "Aktualna wersja: " "Current version: ": "Aktualna wersja: ",
"Show nickname on top: ": "Pokaż nazwę użytkownika na górze: "
} }

View File

@ -2042,6 +2042,10 @@ post "/preferences" do |env|
notifications_only ||= "off" notifications_only ||= "off"
notifications_only = notifications_only == "on" notifications_only = notifications_only == "on"
show_nick = env.params.body["show_nick"]?.try &.as(String)
show_nick ||= "off"
show_nick = show_nick == "on"
# Convert to JSON and back again to take advantage of converters used for compatability # Convert to JSON and back again to take advantage of converters used for compatability
preferences = Preferences.from_json({ preferences = Preferences.from_json({
annotations: annotations, annotations: annotations,
@ -2058,6 +2062,7 @@ post "/preferences" do |env|
locale: locale, locale: locale,
max_results: max_results, max_results: max_results,
notifications_only: notifications_only, notifications_only: notifications_only,
show_nick: show_nick,
player_style: player_style, player_style: player_style,
quality: quality, quality: quality,
default_home: default_home, default_home: default_home,

View File

@ -150,6 +150,7 @@ struct ConfigPreferences
unseen_only: {type: Bool, default: false}, unseen_only: {type: Bool, default: false},
video_loop: {type: Bool, default: false}, video_loop: {type: Bool, default: false},
volume: {type: Int32, default: 100}, volume: {type: Int32, default: 100},
show_nick: {type: Bool, default: true},
}) })
end end

View File

@ -93,6 +93,7 @@ struct Preferences
unseen_only: {type: Bool, default: CONFIG.default_user_preferences.unseen_only}, unseen_only: {type: Bool, default: CONFIG.default_user_preferences.unseen_only},
video_loop: {type: Bool, default: CONFIG.default_user_preferences.video_loop}, video_loop: {type: Bool, default: CONFIG.default_user_preferences.video_loop},
volume: {type: Int32, default: CONFIG.default_user_preferences.volume}, volume: {type: Int32, default: CONFIG.default_user_preferences.volume},
show_nick: {type: Bool, default: CONFIG.default_user_preferences.show_nick},
}) })
end end

View File

@ -161,6 +161,11 @@ function update_value(element) {
<% end %> <% end %>
</div> </div>
<div class="pure-control-group">
<label for="show_nick"><%= translate(locale, "Show nickname on top: ") %></label>
<input name="show_nick" id="show_nick" type="checkbox" <% if preferences.show_nick %>checked<% end %>>
</div>
<% if env.get? "user" %> <% if env.get? "user" %>
<legend><%= translate(locale, "Subscription preferences") %></legend> <legend><%= translate(locale, "Subscription preferences") %></legend>

View File

@ -66,9 +66,11 @@
<i class="icon ion-ios-cog"></i> <i class="icon ion-ios-cog"></i>
</a> </a>
</div> </div>
<div class="pure-u-1-4"> <% if env.get("preferences").as(Preferences).show_nick %>
<span id="user_name">Welcome, <%= env.get("user").as(User).email %></span> <div class="pure-u-1-4">
</div> <span id="user_name">Welcome, <%= env.get("user").as(User).email %></span>
</div>
<% 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="<%= URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "") %>"> <input type="hidden" name="csrf_token" value="<%= URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "") %>">