Added "Read More" button for video descriptions

This commit is contained in:
sh4dowb 2019-11-11 19:06:06 +03:00 committed by syeopite
parent 62e9e9a662
commit 533d0a1fd4
No known key found for this signature in database
GPG Key ID: 6FA616E5A5294A82
5 changed files with 26 additions and 1 deletions

View File

@ -50,6 +50,7 @@ struct ConfigPreferences
property thin_mode : Bool = false property thin_mode : Bool = false
property unseen_only : Bool = false property unseen_only : Bool = false
property video_loop : Bool = false property video_loop : Bool = false
property extend_desc : Bool = false
property volume : Int32 = 100 property volume : Int32 = 100
def to_tuple def to_tuple

View File

@ -78,6 +78,7 @@ struct Preferences
property thin_mode : Bool = CONFIG.default_user_preferences.thin_mode property thin_mode : Bool = CONFIG.default_user_preferences.thin_mode
property unseen_only : Bool = CONFIG.default_user_preferences.unseen_only property unseen_only : Bool = CONFIG.default_user_preferences.unseen_only
property video_loop : Bool = CONFIG.default_user_preferences.video_loop property video_loop : Bool = CONFIG.default_user_preferences.video_loop
property extend_desc : Bool = CONFIG.default_user_preferences.extend_desc
property volume : Int32 = CONFIG.default_user_preferences.volume property volume : Int32 = CONFIG.default_user_preferences.volume
module BoolToString module BoolToString

View File

@ -242,6 +242,7 @@ struct VideoPreferences
property speed : Float32 | Float64 property speed : Float32 | Float64
property video_end : Float64 | Int32 property video_end : Float64 | Int32
property video_loop : Bool property video_loop : Bool
property extend_desc : Bool
property video_start : Float64 | Int32 property video_start : Float64 | Int32
property volume : Int32 property volume : Int32
end end
@ -1050,6 +1051,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
@ -1068,6 +1070,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
@ -1085,6 +1088,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
@ -1095,6 +1099,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"
@ -1141,6 +1146,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

@ -106,6 +106,12 @@
<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

@ -228,7 +228,18 @@
</p> </p>
<div> <div>
<% if video.description.size < 200 || params.extend_desc %>
<%= video.description_html %> <%= 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>