这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@return42
Copy link
Member

@return42 return42 commented Jul 2, 2022

What does this PR do?

Fix issues with hostname_replace where URLs in answers and infobox not handled.

In preparation for the bugfix, the first commit mudularize & document searx.results.

- [mod] mudularize & document searx.results
- [fix] hostname_replace: modify URLs in the infobox

Why is this change important?

Modularize code, add documentation and fix an issue.

How to test this PR locally?

First check the documentation make docs.clean docs.live and visit pages:

  • dev/engine_overview.html (read "Making a Response")
  • src/searx.results.html

Second test hostname_replace plugin by redirecting youtube and twitter:

hostname_replace:
  # youtube --> Invidious

  '(.*\.)?youtube-nocookie\.com': 'invidio.xamh.de'
  '(.*\.)?youtube\.com$': 'invidio.xamh.de'

  # twitter --> nitter

  '(www\.)?twitter\.com$': 'nitter.net'

  # test "!cc 1 EUR to dollar" --> link should be removed

  '(.*\.)?duckduckgo\.com$': false

make a search, in the infobox the links should be redirected.

Related issues

Closes: #1348
Supersede: #1356

@return42
Copy link
Member Author

FYI: rebased PR's branch (82 commits)

Can we please force merge (review) of this PR? .. beside the bugfix in the second commit, the modularization and documentation from the first commit is a prerequisite for further development of the response types / thanks!

@return42
Copy link
Member Author

FYI rebased (0a11478 --> 7a48dc7) to solve conflict with current master.

@dalf
Copy link
Contributor

dalf commented Jul 26, 2022

After a long thinking, I'm "meh" about this PR:

  • why not use the TypedDict instead of documentation? I prefer code as documentation rather documentation that might get out of sync. We even imagine to have some dedicated classes ( here a prototype )
  • most of the functions inside the new modules could be methods (some as class methods). For example is_answer ... could be a static method, so it is super easy to add a new result type (see query.py and see line 241).
  • why "standard" result are not in a new module?
  • why not split this PR in two:
    • one to fix the hostname_replace on infoboxes
    • one where we take time to rewrite results.py
      ?

@return42
Copy link
Member Author

why not use the TypedDict instead of documentation? I prefer code as documentation

This is often what I hear .. but it fails in two ways ..

  • first, what when the code has a bug .. by saying the code is the documentation no one can check whats going wrong in the function.

  • how can code document the relation of objects to each other when the code uses ellipses / where is the "Interface" description of the result-types on which a UI developer can build up UI interface (HTML templates).

We have a templates .. these templates are undocumented, split up in files and macros .. and we have multiple result types .. how should a newbie understand all this? .. I toked me a week ore more to find all the relations and to write it down .. IMO the lack of so many needed documentation is the reason why this project is so hard to get into .. to be honest, several of your implementations I don't understand because there is no documentation .. that is why I ask dump questions like the one today #1559 .. just one small hint in a docstring of the method of the abstract class about what the meaning is of returning None is needed to save a lot of time and make things clear.

rather documentation that might get out of sync.

IDK a better way to document, the doc-strings are in the source code, a few lines above the code that implements what the doc-string described .. compile the docs make docs.live and open http://0.0.0.0:8000/src/searx.results.html to see what I mean.

@return42 return42 closed this Jul 26, 2022
dalf added a commit to dalf/searxng that referenced this pull request Jul 26, 2022
dalf added a commit to dalf/searxng that referenced this pull request Jul 26, 2022
@dalf dalf mentioned this pull request Jul 26, 2022
return42 pushed a commit to return42/searxng that referenced this pull request Aug 3, 2022
return42 pushed a commit to return42/searxng that referenced this pull request Aug 6, 2022
@return42 return42 reopened this Aug 6, 2022
The intention of this patch is to improve modularization & documentation of the
implementations about the *result* items.

  This patch does not contain any functional change!

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Closes: searxng#1348
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
@return42 return42 mentioned this pull request Aug 11, 2022
@return42 return42 marked this pull request as draft August 21, 2022 17:05
dalf added a commit to dalf/searxng that referenced this pull request Sep 23, 2022
@return42 return42 closed this Sep 27, 2022
dalf added a commit to dalf/searxng that referenced this pull request Jan 28, 2023
dalf added a commit to dalf/searxng that referenced this pull request Jan 28, 2023
return42 pushed a commit to dalf/searxng that referenced this pull request Feb 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Links in the infobox are not modified by hostname_replace

2 participants