Commit Graph

39 Commits (2f9db25969f4af2f2961d45d981f57174ee638c0)

Author SHA1 Message Date
NiLuJe 2f9db25969
Unify LuaSocket usage (#7405)
* Add a new socketutil module with a few helper functions that allow us to:
  * Always use a sane User-Agent (previously, only Wikipedia did so)
  * Set timeouts in an almost sane manner. Doing it explicitly prevents an interaction with KOSync that does crazy stuff I don't even want to try to understand.
* Unified said timeouts based on the request's intended usage (except for Wikipedia, which already had meaningful timeout values).
* Stopped using LuaSec directly, LuaSocket defers to LuaSec sanely on its own. Everything now transparently supports HTTPS without code duplication.
3 years ago
NiLuJe dffe86dfe9
Cleanup eye-gouging madness around io.read calls (#7149)
* Don't reinvent the wheel when reading a one-line int or string from sysfs

* Simplify a whole other bunch of read calls
3 years ago
NiLuJe 1f994f8ede
Floor dimension computations (mul/div). (#6264)
* floor most every dimension computations involving MUL or DIV
Should avoid passing nonsensical floating point coordinates/dimensions
to the UI code.

* Update base

* https://github.com/koreader/koreader-base/pull/1113
* https://github.com/koreader/koreader-base/pull/1114
* https://github.com/koreader/koreader-base/pull/1115

* Bump android-luajit-launcher

https://github.com/koreader/android-luajit-launcher/pull/230
https://github.com/koreader/android-luajit-launcher/pull/231
4 years ago
poire-z 03140f505c Wikipedia EPUBs: keep links in bold text bold 4 years ago
poire-z 8ffb9aff64 Wikipedia EPUBs: keep original float left/right in web mode
Previous cleanup resurrected multiple class names, so
we know now the original alignment of a float.
Use them in 'web' mode, as it allows floats to be nearer
the section they are refering to, and it may limit
floats truncation in page splitting.
But keep floats aligned on a single side in 'book' mode,
as it might allow easier reading.
4 years ago
poire-z 6d2cada96e Wikipedia Save as EPUB: better gallery rendering
Switch Wikipedia galleries from floats to inline-block.
Also remove some crengine bugs workaround code as these
bugs have been fixed for a long time.
4 years ago
poire-z d6d49a64a7 [RTL UI] use auto or LTR text direction in some specific cases
Allow TextBoxWidget new text direction/lang parameters to be
set on upper widgets, and propagate them all the way to it
(ScrollTextWidget, InputText, InputDialog, TextViewer).

Use specific non-default ones in some specific cases:
- Force LTR text direction when showing HTML and CSS, and
  configuration files (in some plugins).
- Use Wikipedia server language and text direction when
  showing an article.
- Use auto with Dictionary results, as we don't know the
  dictionary language, and they may contain mixed content.
- Force LTR when showing some paths (still needs more of them)

TextEditor plugin: add 2 new options "Auto paragraph direction"
and "Force paragraph direction LTR".

Footnotes popup: grab HTML direction, and forward it
to MuPDF for proper display.
4 years ago
poire-z 4462380048
Wikipedia lookup results: fix page turning when image loading (#5560)
Tapping to turn page while some image is loading was
interrupting the image loading, but not turning the page,
since a82d7832 where using trap_widget=false is to be
used to not resend the event (while =nil does resend it).
5 years ago
poire-z 3e3b00429f
EPUB: more support for RTL documents (#5436)
bump crengine: enhanced RTL block rendering.
Includes:
- Re-enable: Use the same FT load flags in HB as in FT
- Avoid redundant calls to getStyle()
- CSS: parse and store "direction:"
- Enhanced block rendering: handle RTL direction
- Enhanced block rendering: handle RTL tables
- Pagesplitting: account for lines' text direction
- CSS: add support for more pseudo-classes
- epub.css: a few updates for RTL documents
- Fix LVDocView::getBookmark() which could be slow or wrong

Add a few style tweaks useful to RTL readers.

Wikipedia Save as EPUB: build proper RTL documents from
persian, arabic, hebrew (and others) Wikipedia articles.
5 years ago
Frans de Jonge a2dcfe9aec
[doc] Tag @todo, @fixme and @warning (#5244)
This commit standardizes the various todos around the code a bit in a manner recognized by LDoc.

Besides drawing more attention by being displayed in the developer docs, they're also extractable with LDoc on the command line:

```sh
ldoc --tags todo,fixme *.lua
```

However, whether that particular usage offers any advantage over other search tools is questionable at best.

* and some random beautification
5 years ago
poire-z 8749a3c5b6 Wikipedia download: increase timeout 5 years ago
poire-z 642aed240c Update Wikipedia EPUB stylesheet to allow floating thumbnails
Main thumbnails and galleries items will float in "book" and
"web" modes.
Also use a honest User-Agent when requesting Wikipedia to
comply with their policy and avoid rate limitation (and
broken images).
5 years ago
poire-z f8d8863712 Style tweaks: split in-page footnote tweaks
Split the In-page footnotes tweak into 3 distinct ones,
mainly because I want the 3rd one with classic class names
to be disabled'able, while keeping the others, in case
these classic class names are not used for footnotes.

Also fix footnotes list-style-type in Wikipedia EPUBs,
which may have been wrong (but it was less noticable when
following page links because of the little black marker,
or showing them in popup footnotes where the number/letter
is not shown).
5 years ago
poire-z ea946d52d6 bump crengine: tables rendering improvements and others
bump crengine, which includes:
- Adds support for symbol fonts (local or embedded)
- Fix some issues when rendering text in constrained width
- Page splitting: fix possible missing blocks
- CSS: adds support for 'auto', ignore % for borders
- Fix right border drawing position
- Fix: adds missing properties in copystyle()
- Adds comments, erm_killed rendering method
- Adds getRenderedWidths(): get node min/max node content width
- Tables rendering: fixes and improvements
- getRenderedWidths: enable min_width to be a single CJK char
- Fix wrong text wrap avoid in some case
- epub.css: add style for 'blockquote'
- Fix rendering issue when line ends with an image

Adds a few style tweaks related to tables.

Enforce table width: 100% in Wikipedia EPUBs to keep
previous look, which feels better with the various kinds
of tables in Wikipedia pages.

Fix unit tests as juliet.epub (full of blockquotes), grew quite
a few pages with the epub.css update.
5 years ago
poire-z c3a938aad6
bump crengine: alternative TOC, no page break on borders (#4011)
Includes:
- Avoid page break between a node and its borders
- Allow building an alternative TOC from document headings

On CRE documents, allows toggling between original TOC and an
alternative TOC with long-press on the "Table of content" menu
item.

Also update the Wikipedia stylesheet to further avoid
page-breaks between images and their caption, so a full
bordered wikipedia thumbnail is always full on a single page.
6 years ago
poire-z bdbaa7dfdd
bump crengine: HTML and rendering fixes (#3992)
- Fix getting xpointer to current page
- epub.css cleanup
- fb2def.h update
- Fix a few edge-case rendering issues
- Fix border being drawn in spite of 'border-width: 0'

Also update Wikipedia epub.css stylesheets regarding
recent HTML fixes and enhancements.
Remove "Remove all borders" workaround tweaks, as it's
now fixed.
(Unit tests failure to be fixed in upcoming commit)
6 years ago
poire-z b498d872be
bump crengine: LI and CITE fixes are now the defaults (#3976)
Books previously opened (that have a metadata.lua, whether with
highlights or not, but because they all have a last_xpointer that
points to the current page, that can be broken too by the changes)
will continue to have the old wrong behaviour, so they won't be
impacted by the breaking changes.
Update cre_dom_version code to use the new functions from cre.cpp.
Remove these Workarounds from Style tweaks.
6 years ago
poire-z 4bb3999cbc RenderImage: factorize all image rendering and scaling code
New module RenderImage (alongside existing RenderText) to provides
image rendering and scaling facilities.
Uses MuPDF, but tries first giflib on GIF.
Allows for getting all the frames from an animated GIF.
6 years ago
poire-z 58f6352d60 Wiki saved as EPUB: stylesheet fix (#3894)
Removed width:80% as it was never supported by crengine (the effect
was achieved thanks to margins and paddings).
Wikipedia saved articles from now on won't be effected by a double
effect if we later add full support for width: into crengine.
6 years ago
poire-z 305e75c5ea Wikipedia Save as EPUB: various encoding fixes (#3851)
* Wiki Save as EPUB: various encoding fixes

Fix display of & in article titles
Fix display of &, <, > in TOC entries and in targeted anchor (the mismatch
with the target id made these TOC entries invalid and simply not displayed).
Remove percent-encoded URLs tweaks for crengine now that crengine
correctly supports them (each percent encode handled as an UTF8 byte).
Bump crengine for that.
Don't include <meta name="cover"> when no cover present.

* bump base/crengine
6 years ago
poire-z 5cfe9992ad Wiki Save as EPUB: better handling of math formulas (#3639)
Also fix some bad filename and extension in epub's OEBPS/content.opf,
Store image files (jpg, png, gif) uncompressed in the .epub as they
don't need compression.
6 years ago
poire-z 1e9457c9b4 Wikipedia full & epub: swap symbols for H3 and H4 (#3627) 6 years ago
poire-z 775b7a364f Wikipedia: show images and allow interrupting queries
Reword some english messages
6 years ago
poire-z 69ec6c07c5 Wikipedia Save as EPUB: fix some wiki links and speedup download (#3551)
- Fix links to wikipedia pages containing '?oldid=123', that
  wouldn't work when used back thru the API.
- Make external links to other wikipedias with a different langage
  work (they didn't work when non-ascii page titles)
- Speedup download of images by using a newly added 'fast_refresh'
  option to Trapper:info() to bypass UIManager.
6 years ago
poire-z 8886e16baa Small fix to wikipedia epub stylesheet (#3534) 7 years ago
poire-z de54ef5ae6 Added Trapper module, for simple interaction with UI
This module provides methods for simple interaction with UI, without
the need for explicit callbacks, for use by linear jobs between
their steps.
Uses coroutines, but their usage is hidden by a simple API.
Factored out of Wikipedia:createEpubWithUI().
7 years ago
poire-z 80d8e44bde Fix Wiki save as epub crash on certain pages (#3231)
* Fix Wiki save as epub crash on certain pages

When first images don't have a height or width attribute
7 years ago
poire-z 79dca8e245 [UX] Wikipedia save as EPUB: allow for aborting download (#3224) 7 years ago
poire-z 0d38547990 Wikipedia save as epub: fix some image download failures 7 years ago
Qingping Hou fc12ee6537 decouple reader footer from dictquicklookup widget & translation fix (#2664)
* chore: fix strings for translations

* dictionary(chore): decouple reader footer from dictquicklookup widget
7 years ago
Frans de Jonge 6257bae77f Language: mostly Wikipedia-related changes 7 years ago
poire-z 2ded2bce5e Wikipedia: save full page as epub (html, with optional images)
Also for the current text-only wikipedia full page: replace
the ==s in section titles with some unicode symbols for a better
visual feeling of hierarchy. These same symbols are also used
in the .epub.
Both can be disabled by adding ["wikipedia_prettify"] = false
to settings.reader.lua

readerhighlight: close ButtonTable (like other buttons do) when looking
up wikipedia, otherwise if we save as epub, and swtich to new document,
this ButtonTable will never be closed and stays in UI.
7 years ago
Qingping Hou f95ad00b9e feat: add logger module & rewrite kobo suspend script in lua 7 years ago
poire-z 1708fd5e1c Dictionary and wikipedia enhancements (#2393)
Stardict:
- remove duplicate results
- better cleaning of selection
- append results from a 2nd query of a 2nd set of dictionaries
  in data/dict_ext/

Wikipedia:
- use the search API for better results
- allow viewing the full page content of a result in a bigger window
- allow queries for multiple languages
- available languages can be set in settings.reader.lua :
    ["wikipedia_languages"] = {"en", "fr", "it"}
- "Wikipedia lookup" added to Tools menu

For both:
- allow selection of multiple words for a new lookup (so one can
  actually browse wikipedia)
- allow continuous reading with Tap
- display "current result / total number of results"

Details in #2393
8 years ago
Qingping Hou 3c647ff244 minor: various luacheck fixes 8 years ago
Frans de Jonge ba994f41ab Fix Wikipedia (HTTP is now HTTPS) and some failsafes
Rudimentary JSON validity check by seeing if the first character is {. The JSON decode function will crash in spite of pcall if it's not.
9 years ago
chrox 82393f0ed3 fix loading frontend/JSON.lua for json.lua on Kindle
The VFAT file system of `/mnt/us` is case insensitive so that
require("json") from Spore which intends to load luajson module in
rock directory actually will load `frontend/JSON.lua`, the two JSON
parser libraries have slightly different APIs.

This patch remove the pure Lua JSON library in favor of `luajson` which
uses LPeg pattern marching backend for better performance.
9 years ago
chrox 7d22318641 don't require ssl.https since it cannot yet be built for win32 10 years ago
chrox 7b10d66e1b enable Wikipedia support
Since wikipedia server is language specific we should first detect
language of the text by querying Google Translate. Make sure you have
access to both Google Translate and Wikipedia service to use this
function.
10 years ago