mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
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.
This commit is contained in:
@@ -101,7 +101,7 @@ function ReaderWikipedia:initLanguages(word)
|
||||
end
|
||||
end
|
||||
|
||||
function ReaderWikipedia:onLookupWikipedia(word, box, get_fullpage)
|
||||
function ReaderWikipedia:onLookupWikipedia(word, box, get_fullpage, forced_lang)
|
||||
if not NetworkMgr:isOnline() then
|
||||
NetworkMgr:promptWifiOn()
|
||||
return
|
||||
@@ -109,8 +109,14 @@ function ReaderWikipedia:onLookupWikipedia(word, box, get_fullpage)
|
||||
-- word is the text to query. If get_fullpage is true, it is the
|
||||
-- exact wikipedia page title we want the full page of.
|
||||
self:initLanguages(word)
|
||||
-- use first lang from self.wiki_languages, which may have been rotated by DictQuickLookup
|
||||
local lang = self.wiki_languages[1]
|
||||
local lang
|
||||
if forced_lang then
|
||||
-- use provided lang (from readerlink when noticing that an external link is a wikipedia url)
|
||||
lang = forced_lang
|
||||
else
|
||||
-- use first lang from self.wiki_languages, which may have been rotated by DictQuickLookup
|
||||
lang = self.wiki_languages[1]
|
||||
end
|
||||
logger.dbg("lookup word:", word, box, get_fullpage)
|
||||
-- no need to clean word if get_fullpage, as it is the exact wikipetia page title
|
||||
if word and not get_fullpage then
|
||||
@@ -166,6 +172,7 @@ function ReaderWikipedia:onLookupWikipedia(word, box, get_fullpage)
|
||||
word = page.title,
|
||||
definition = definition,
|
||||
is_fullpage = get_fullpage,
|
||||
lang = lang,
|
||||
}
|
||||
table.insert(results, result)
|
||||
end
|
||||
@@ -179,6 +186,7 @@ function ReaderWikipedia:onLookupWikipedia(word, box, get_fullpage)
|
||||
word = word,
|
||||
definition = self.no_page,
|
||||
is_fullpage = get_fullpage,
|
||||
lang = lang,
|
||||
}
|
||||
}
|
||||
logger.dbg("dummy result table:", word, results)
|
||||
|
||||
Reference in New Issue
Block a user