Skip to content
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

[to do ] add an embed http server in goldendict #229

Open
xiaoyifang opened this issue Nov 28, 2022 · 10 comments
Open

[to do ] add an embed http server in goldendict #229

xiaoyifang opened this issue Nov 28, 2022 · 10 comments
Labels
help wanted PR welcomed.

Comments

@xiaoyifang
Copy link
Owner

xiaoyifang commented Nov 28, 2022

like the implementation in kiwix
image

the benifit of this feature:

  1. can turn the goldendict into an online dictionary search engine. with the help such as ngnix ,can offer service to the internet users.
  2. can make command line implementation easier
    related to the issues like Run a WEB Service on localhost, other software can send HTTP request to query words goldendict/goldendict#618
    command line version goldendict/goldendict#37
@xiaoyifang xiaoyifang added the help wanted PR welcomed. label Nov 28, 2022
@xiaoyifang
Copy link
Owner Author

The "structured results" I mean something that can be provided as JSON/XML API:

Merriam-Webster's API doc: https://dictionaryapi.com/products/json <- this one is pretty good. Cambridge's API: https://dictionary-api.cambridge.org/api/specification

provide an unified structure is difficult and will cost too much effort and time . This can be set as an new feature alone.

about the embed http server, My initial purpose is to offer the search result through website. and can simply convert html to plain text to satisfy the CLI.

@xiaoyifang
Copy link
Owner Author

xiaoyifang commented Apr 27, 2023

a video demo?

Anyway this is great if this can be implemented , and should we switch GPL license to AGPL ,as GPL does not provide webservice protection.

With this and nginx, goldendict can be served as a common dictionary server.
and I think it can easily embed be as an external local service for other applications.

@xiaoyifang
Copy link
Owner Author

xiaoyifang commented Apr 27, 2023

Some steps(In future maybe):

@xiaoyifang
Copy link
Owner Author

@shenlebantongying
Copy link
Collaborator

I tried civetweb and made another one:

https://github.com/SourceReviver/civetweb_qt_demo

The code includes serving a QImage generated via libcairo.

We just need to reinvent qrc:// with http://

Video:

Peek 2023-04-28 08-08

civetweb is a fork of mangoose, but they are very different now. Mangoose only provides a mechanism to do multi threads, while civetweb manages threads on its own 😅.

@TAbdiukov
Copy link

TAbdiukov commented Jan 8, 2024

WOW I'm glad I discovered this issue thread. I've been waiting for this feature on official GoldenDict repo on and off for 5+ years!

I'm happy to help. Note that regarding GoldenDict, I know more from a user's (and not a developer's) perspective,

Some steps(In future maybe):

  1. change the goldendict's inner protocol to some common http url ,such as http://xxxxxx:/query?originurl=gdlookup:xxxxxx
  2. handle these http request and redirect to gd's inner process logic.

I think this idea stems from this comment of mine. Yes, GoldenDict (for PC at least) uses this gdlookup protocol. IMO, what's important is that:

  1. Its response is HTML, just like HTTP, it's (almost) the same as HTTP in a browser. In fact, GoldenDict for Android requires a WebView engine (either Android Stock or Google Chrome), so GoldenDict sort or internally uses browser functionality. It may require extra CSS and JS, but more or less, it's simple.
  2. Just feeding input to originurl can be a bad idea, because it would likely be possible to inject a command like gdlookup:xyz && cat /../../etc/passwd. Maybe some sanitization can be a good idea.

I know that there is an HTTP server implementation for another dictionary format, SLOB (Sorted BLOB, which is little known), you can check its implementation here, itkach/aard2-web . It uses Java.

Anyway, I'm subscribing to this issue, because I want to see this idea get implemented =)

@shenlebantongying
Copy link
Collaborator

shenlebantongying commented Jan 8, 2024

While I no longer have time to work on this, I think a reasonable path would be to decouple dict-related code into an independent module/library. Think about it, we can create a python binding to it, and creating a web interface would be as simple as dumping results into an HTML template.

#905

The design of existing code does not consider anything else other than working with the Qt GUI. It is a lot of labour work.

BTW, I highly doubt anyone would want to learn the unnecessary internal indexing implementation used by Goldedict. It has been good for years and does a good job for the original/first GD developer to practice implementing the algorithm after university, but why not use something that is well studied and well known, like sqlite. The core value of GD is obviously not implementing yet another mini database 😅

#562

Sorry for just talking and doing nothing, but I do think the above two issues have to be solved first, and the HTTP frontend would be as easy as writing a short script.

@kanjieater
Copy link

Also would like to express interest in this. I've been requesting a way to have a dictionary api locally since 2019 along with TAbdiukov 😅

@guitarlive722
Copy link

Some steps(In future maybe):

请问目前有实现计划吗?

@shenlebantongying shenlebantongying removed their assignment Jul 10, 2024
@xiaoyifang
Copy link
Owner Author

Maybe decouple this into serveral little projects/goals. Need time to rethink.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted PR welcomed.
Projects
None yet
Development

No branches or pull requests

5 participants