From 533d0a1fd4661ff85b8b3d82edf34cef581fd79c Mon Sep 17 00:00:00 2001 From: sh4dowb Date: Mon, 11 Nov 2019 19:06:06 +0300 Subject: [PATCH 1/6] Added "Read More" button for video descriptions --- src/invidious/helpers/helpers.cr | 1 + src/invidious/users.cr | 1 + src/invidious/videos.cr | 6 ++++++ src/invidious/views/preferences.ecr | 6 ++++++ src/invidious/views/watch.ecr | 13 ++++++++++++- 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr index 3767cb50..12fac04c 100644 --- a/src/invidious/helpers/helpers.cr +++ b/src/invidious/helpers/helpers.cr @@ -50,6 +50,7 @@ struct ConfigPreferences property thin_mode : Bool = false property unseen_only : Bool = false property video_loop : Bool = false + property extend_desc : Bool = false property volume : Int32 = 100 def to_tuple diff --git a/src/invidious/users.cr b/src/invidious/users.cr index 8fef64a0..e4ebb4d1 100644 --- a/src/invidious/users.cr +++ b/src/invidious/users.cr @@ -78,6 +78,7 @@ struct Preferences property thin_mode : Bool = CONFIG.default_user_preferences.thin_mode property unseen_only : Bool = CONFIG.default_user_preferences.unseen_only 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 module BoolToString diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index 38646311..2f90669c 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -242,6 +242,7 @@ struct VideoPreferences property speed : Float32 | Float64 property video_end : Float64 | Int32 property video_loop : Bool + property extend_desc : Bool property video_start : Float64 | Int32 property volume : Int32 end @@ -1050,6 +1051,7 @@ def process_video_params(query, preferences) related_videos = query["related_videos"]?.try { |q| (q == "true" || q == "1").to_unsafe } speed = query["speed"]?.try &.rchop("x").to_f? 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? if preferences @@ -1068,6 +1070,7 @@ def process_video_params(query, preferences) related_videos ||= preferences.related_videos.to_unsafe speed ||= preferences.speed video_loop ||= preferences.video_loop.to_unsafe + extend_desc ||= preferences.extend_desc.to_unsafe volume ||= preferences.volume end @@ -1085,6 +1088,7 @@ def process_video_params(query, preferences) related_videos ||= CONFIG.default_user_preferences.related_videos.to_unsafe speed ||= CONFIG.default_user_preferences.speed 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 annotations = annotations == 1 @@ -1095,6 +1099,7 @@ def process_video_params(query, preferences) local = local == 1 related_videos = related_videos == 1 video_loop = video_loop == 1 + extend_desc = extend_desc == 1 if CONFIG.disabled?("dash") && quality == "dash" quality = "high" @@ -1141,6 +1146,7 @@ def process_video_params(query, preferences) speed: speed, video_end: video_end, video_loop: video_loop, + extend_desc: extend_desc, video_start: video_start, volume: volume, }) diff --git a/src/invidious/views/preferences.ecr b/src/invidious/views/preferences.ecr index c1f10818..40350583 100644 --- a/src/invidious/views/preferences.ecr +++ b/src/invidious/views/preferences.ecr @@ -106,6 +106,12 @@ checked<% end %>> +
+ + checked<% end %>> +
+ + <%= translate(locale, "Visual preferences") %>
diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index a86e23b2..788b0dcb 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -228,7 +228,18 @@

- <%= video.description_html %> + <% if video.description.size < 200 || params.extend_desc %> + <%= video.description_html %> + <% else %> +
+ <%= video.description_html %> +
+ + <% end %>

From c5fae8426358c511bb8b66f01c931094e7418812 Mon Sep 17 00:00:00 2001 From: syeopite Date: Fri, 2 Apr 2021 01:03:26 -0700 Subject: [PATCH 2/6] Add functionality to read more button --- assets/css/default.css | 25 +++++++++++++++++++++++++ src/invidious/views/watch.ecr | 26 +++++++++++++++++++------- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/assets/css/default.css b/assets/css/default.css index a725b456..919f13ec 100644 --- a/assets/css/default.css +++ b/assets/css/default.css @@ -669,3 +669,28 @@ See https://stackoverflow.com/a/34372979 for more info */ hr { margin: auto 0 auto 0; } + +/* Description Expandsion Styling*/ +#description-box { + display: flex; + flex-direction: column; +} + +#readmorebutton { + display: none +} + +#readmorebutton ~ div { + overflow: hidden; + height: 8.3em; +} + +#readmorebutton:checked ~ div { + overflow: unset; + height: 100%; +} + +#readmorebutton + label { + order: 1; + margin-top: 20px; +} diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index 788b0dcb..90a20335 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -25,6 +25,19 @@ <%= rendered "components/player_sources" %> <%= HTML.escape(video.title) %> - Invidious + + + <% end %>