Added "Read More" button for video descriptions

This commit is contained in:
sh4dowb 2019-11-11 19:06:06 +03:00
parent 79da61782b
commit 39289e64b7
No known key found for this signature in database
GPG Key ID: C063256324758B9D
6 changed files with 31 additions and 1 deletions

View File

@ -1934,6 +1934,10 @@ post "/preferences" do |env|
video_loop ||= "off" video_loop ||= "off"
video_loop = video_loop == "on" video_loop = video_loop == "on"
extend_desc = env.params.body["extend_desc"]?.try &.as(String)
extend_desc ||= "off"
extend_desc = extend_desc == "on"
annotations = env.params.body["annotations"]?.try &.as(String) annotations = env.params.body["annotations"]?.try &.as(String)
annotations ||= "off" annotations ||= "off"
annotations = annotations == "on" annotations = annotations == "on"
@ -2052,6 +2056,7 @@ post "/preferences" do |env|
thin_mode: thin_mode, thin_mode: thin_mode,
unseen_only: unseen_only, unseen_only: unseen_only,
video_loop: video_loop, video_loop: video_loop,
extend_desc: extend_desc,
volume: volume, volume: volume,
}.to_json).to_json }.to_json).to_json

View File

@ -149,6 +149,7 @@ struct ConfigPreferences
thin_mode: {type: Bool, default: false}, thin_mode: {type: Bool, default: false},
unseen_only: {type: Bool, default: false}, unseen_only: {type: Bool, default: false},
video_loop: {type: Bool, default: false}, video_loop: {type: Bool, default: false},
extend_desc: {type: Bool, default: false},
volume: {type: Int32, default: 100}, volume: {type: Int32, default: 100},
}) })
end end

View File

@ -92,6 +92,7 @@ struct Preferences
thin_mode: {type: Bool, default: CONFIG.default_user_preferences.thin_mode}, thin_mode: {type: Bool, default: CONFIG.default_user_preferences.thin_mode},
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},
extend_desc: {type: Bool, default: CONFIG.default_user_preferences.extend_desc},
volume: {type: Int32, default: CONFIG.default_user_preferences.volume}, volume: {type: Int32, default: CONFIG.default_user_preferences.volume},
}) })
end end

View File

@ -240,6 +240,7 @@ struct VideoPreferences
speed: (Float32 | Float64), speed: (Float32 | Float64),
video_end: (Float64 | Int32), video_end: (Float64 | Int32),
video_loop: Bool, video_loop: Bool,
extend_desc: Bool,
video_start: (Float64 | Int32), video_start: (Float64 | Int32),
volume: Int32, volume: Int32,
}) })
@ -1298,6 +1299,7 @@ def process_video_params(query, preferences)
related_videos = query["related_videos"]?.try { |q| (q == "true" || q == "1").to_unsafe } related_videos = query["related_videos"]?.try { |q| (q == "true" || q == "1").to_unsafe }
speed = query["speed"]?.try &.rchop("x").to_f? speed = query["speed"]?.try &.rchop("x").to_f?
video_loop = query["loop"]?.try { |q| (q == "true" || q == "1").to_unsafe } video_loop = query["loop"]?.try { |q| (q == "true" || q == "1").to_unsafe }
extend_desc = query["extend_desc"]?.try { |q| (q == "true" || q == "1").to_unsafe }
volume = query["volume"]?.try &.to_i? volume = query["volume"]?.try &.to_i?
if preferences if preferences
@ -1315,6 +1317,7 @@ def process_video_params(query, preferences)
related_videos ||= preferences.related_videos.to_unsafe related_videos ||= preferences.related_videos.to_unsafe
speed ||= preferences.speed speed ||= preferences.speed
video_loop ||= preferences.video_loop.to_unsafe video_loop ||= preferences.video_loop.to_unsafe
extend_desc ||= preferences.extend_desc.to_unsafe
volume ||= preferences.volume volume ||= preferences.volume
end end
@ -1331,6 +1334,7 @@ def process_video_params(query, preferences)
related_videos ||= CONFIG.default_user_preferences.related_videos.to_unsafe related_videos ||= CONFIG.default_user_preferences.related_videos.to_unsafe
speed ||= CONFIG.default_user_preferences.speed speed ||= CONFIG.default_user_preferences.speed
video_loop ||= CONFIG.default_user_preferences.video_loop.to_unsafe video_loop ||= CONFIG.default_user_preferences.video_loop.to_unsafe
extend_desc ||= CONFIG.default_user_preferences.extend_desc.to_unsafe
volume ||= CONFIG.default_user_preferences.volume volume ||= CONFIG.default_user_preferences.volume
annotations = annotations == 1 annotations = annotations == 1
@ -1341,6 +1345,7 @@ def process_video_params(query, preferences)
local = local == 1 local = local == 1
related_videos = related_videos == 1 related_videos = related_videos == 1
video_loop = video_loop == 1 video_loop = video_loop == 1
extend_desc = extend_desc == 1
if CONFIG.disabled?("dash") && quality == "dash" if CONFIG.disabled?("dash") && quality == "dash"
quality = "high" quality = "high"
@ -1386,6 +1391,7 @@ def process_video_params(query, preferences)
speed: speed, speed: speed,
video_end: video_end, video_end: video_end,
video_loop: video_loop, video_loop: video_loop,
extend_desc: extend_desc,
video_start: video_start, video_start: video_start,
volume: volume, volume: volume,
) )

View File

@ -101,6 +101,12 @@ function update_value(element) {
<input name="annotations" id="annotations" type="checkbox" <% if preferences.annotations %>checked<% end %>> <input name="annotations" id="annotations" type="checkbox" <% if preferences.annotations %>checked<% end %>>
</div> </div>
<div class="pure-control-group">
<label for="extend_desc"><%= translate(locale, "Automatically extend video descriptions: ") %></label>
<input name="extend_desc" id="extend_desc" type="checkbox" <% if preferences.extend_desc %>checked<% end %>>
</div>
<legend><%= translate(locale, "Visual preferences") %></legend> <legend><%= translate(locale, "Visual preferences") %></legend>
<div class="pure-control-group"> <div class="pure-control-group">

View File

@ -187,7 +187,18 @@ var video_data = {
</p> </p>
<div> <div>
<%= video.description_html %> <% if video.description.size < 200 || params.extend_desc %>
<%= video.description_html %>
<% else %>
<div style="overflow: hidden;height: 8.3em;" id="descriptionWrapper">
<%= video.description_html %>
</div>
<div class="pure-u-23-24">
<p>
<a href="javascript:void(0)" onclick="read_more_description(this)"><%= translate(locale, "Read more") %></a>
</p>
</div>
<% end %>
</div> </div>
<hr> <hr>