-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix] replace embedded HTML by data_src #882
Conversation
ca40537
to
6df5295
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comments
IMO embedded is not clear, at least when we look at the {% if result.data_src -%}
<div id="result-media-{{ index }}" class="embedded-content invisible">
<iframe data-src="{{result.data_src}}" frameborder="0" allowfullscreen></iframe>
</div>
{%- endif %}
{% if result.audio_src -%}
<div id="result-media-{{ index }}" class="audio-control">
<audio controls><source src="{{result.audio_src}}"></audio>
</div>
{%- endif %} ... where we have an embedded That's why I was looking for a name that better fits to the template. I don't know if |
what about
|
Embedded HTML breaks SearXNG architecture. To modularize, HTML is generated in the templates (oscar & simple) and result parameter 'embedded' is replaced by 'data_src', an URL for embedded content (<iframe>). Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
To test you need to redirect embeded videos (e.g.) from youtube to a invidios instance. Search for videos using engine `!youtube lebowski`. The result URLs and the embeded videos should link to the invidios instance. Here is an example of such a `hostname_replace` configuration:: hostname_replace: # youtube --> Invidious '(.*\.)?youtube-nocookie\.com': 'invidio.xamh.de' '(.*\.)?youtube\.com$': 'invidio.xamh.de' '(.*\.)?invidious\.snopyta\.org$': 'invidio.xamh.de' '(.*\.)?vid\.puffyan\.us': 'invidio.xamh.de' '(.*\.)?invidious\.kavin\.rocks$': 'invidio.xamh.de' '(.*\.)?inv\.riverside\.rocks$': 'invidio.xamh.de' Closes: searxng#873 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
… audio_src Embedded HTML breaks SearXNG architecture. To modularize, HTML is generated in the templates (oscar & simple) and result parameter 'embedded' is replaced by 'data_src' (and 'audio_src'), an URL for embedded content (<iframe>). Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Suggested-by: @dalf searxng#882 (comment) Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Suggested-by: @dalf searxng#882 (comment) Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Rename result field data_src to iframe_src Suggested-by: @dalf searxng#882 (comment) Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
I renamed data_src to iframe_src in 9c46856
I don't want the layout hard coded by the engines / therefore I added 1d72ada @dalf: thanks for your review and helping comments .. I fixed all your requests or leaved a comment at least. PR is now ready for the next review cycle .. |
Rename result field data_src to iframe_src Suggested-by: @dalf searxng#882 (comment) Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Not all configurable aspects can be compiled into `css/searxng.min.css`, some kind of custom-layer to CSS is needed. One example is discussed in [1], the layout of embedded content like audio or movie players. In the `css/searxng.min.css` we can layout the players SearXNG knows, but what when some SearXNG admin wants to replace/redirect embedded content to a different player with a different layout by using the hostname-replace plugin? This is where css/custom.css comes into play, in which the admin is able to set CSS layout for such a different player (URL/hostname) that is unknown to the SearXNG project. [1] searxng#882 (review) Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After few days rereading the code, I end up to think there is no need to for a custom.less file (for now).
The code inside this file can simplified, see the comments.
After that, I think the PR is ready.
@@ -1,4 +1,4 @@ | |||
iframe.soundcloud\.com { | |||
iframe.w\.soundcloud\.com { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The host names and other CSS class names are overlapping. While the chance there is an actual overlap is small, it would be better to avoid to take the risk.
It is possible to use CSS attribute selector: https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors
iframe[src^="https://w.soundcloud.com"] {
height: 120px;
}
iframe[src^="https://www.deezer.com"] {
// The real size is 92px, but 94px are needed to avoid an inner scrollbar of
// the embedded HTML.
height: 94px;
}
iframe[src^="https://www.mixcloud.com"] {
// the embedded player from mixcloud has some quirks: initial there is an
// issue with an image URL that is blocked since it is an a Cross-Origin
// request. The alternative text (<img alt='Mixcloud Logo'> then cause an
// scrollbar in the inner of the iframe we can't avoid. Another quirk comes
// when pressing the play button, somtimes the shown player has an height of
// 200px, somtimes 250px.
height: 250px;
}
So there is no need
- to add
kwargs['urlparse'] = urllib.parse.urlparse
- to call
urlparse
fromvideo.html
anddefault.html
(iframe and audio element).
( changes done in commit 1d72ada )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, implemented in 8acf540
searx/plugins/hostname_replace.py
Outdated
result[parsed] = result[parsed]._replace(netloc=pattern.sub(replacement, result[parsed].netloc)) | ||
result['url'] = urlunparse(result[parsed]) | ||
|
||
if not replacement: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently it is okay.
However, some engines return YouTube videos (like qwant, google video, bing video ?)
Currently the iframe_src
attribute is not set for these engines.
If in the future, this is attribute is set , this condition is going to prevent the hostname replacement in the iframe_src
attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rewrote this commit, see 795e8af
This is a rewrite of the hostname_replace.py that: - don't stop to replace URL in fields ('data_src', 'audio_src') if there isn't a 'parsed_url', - adds a comment about keep or remove a result from the result list - adds a loop over ['data_src', 'audio_src'] instead of doubling code lines Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Suggested-by: @dalf searxng#882 (comment) Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Suggested-by: @dalf searxng#882 (comment) Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Rename result field data_src to iframe_src Suggested-by: @dalf searxng#882 (comment) Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit sets appropriate height of the (embedded) player from: - soundcloud - mixcloud - deezer Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
@dalf I dropped several commits and rewrote others, all I changed is documented in the answers to your comments above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this contribution.
It fixes an long standing issue.
In addition to the test described, I have check this configuration:
hostname_replace:
'(.*\.)?youtube-nocookie\.com': false
👍 it works
What does this PR do?
[mod] result_templates/videos.html replace embedded HTML by data_src
[mod] result_templates/default.html replace embedded HTML by data_src
Embedded HTML breaks SearXNG architecture. To modularize, HTML is generated in
the templates (oscar & simple) and result parameter 'embedded' is replaced by
'data_src', an URL for embedded content (<iframe>).
[mod] hostname_replace: replace hostnames in result's data_src param
How to test this PR locally?
The (iframe & audio) templates of the following engines has been touched (oscar & simple theme)
To test you need to redirect embedded videos (e.g.) from youtube to a invidios
instance. Search for videos using engine
!youtube lebowski
. The result URLsand the embedded videos should link to the invidios instance.
Here is an example of such a
hostname_replace
configuration::Related issues
Closes: #873