mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
quickstart fix (#2804)
* translation text fix * quickstart(fix): go back to home dir after document close * quickstart(fix): purge old quick start files * spec: fix quickstart tests
This commit is contained in:
committed by
Frans de Jonge
parent
6f037cec30
commit
72ae80870c
@@ -14,7 +14,7 @@ for shellscript in "${shellscript_locations[@]}"; do
|
||||
shellcheck "${shellscript}" || SHELLSCRIPT_ERROR=1
|
||||
echo -e "${ANSI_GREEN}Running shfmt on ${shellscript}"
|
||||
if [ "$(cat "${shellscript}")" != "$(shfmt -i 4 "${shellscript}")" ]; then
|
||||
echo -e "${ANSI_RED}Warning: ${shellscript} does not abide by coding style"
|
||||
echo -e "${ANSI_RED}Warning: ${shellscript} does not abide by coding style, diff for expected style:"
|
||||
shfmt -i 4 "${shellscript}" | diff "${shellscript}" - || SHELLSCRIPT_ERROR=1
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -26,6 +26,8 @@ cache:
|
||||
before_cache:
|
||||
# don't quote like you normally would or it won't expand
|
||||
- rm -frv ${TRAVIS_BUILD_DIR}/base/build/*/cache/*
|
||||
# don't cache unit tests
|
||||
- rm -frv ${TRAVIS_BUILD_DIR}/base/build/*/spec
|
||||
|
||||
addons:
|
||||
apt:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
local ConfirmBox = require("ui/widget/confirmbox")
|
||||
local FtpApi = require("frontend/apps/cloudstorage/ftpapi")
|
||||
local FtpApi = require("apps/cloudstorage/ftpapi")
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local MultiInputDialog = require("ui/widget/multiinputdialog")
|
||||
local ReaderUI = require("apps/reader/readerui")
|
||||
|
||||
@@ -38,7 +38,7 @@ local FileConverter = {
|
||||
---- @string title an optional title for the HTML document
|
||||
---- @treturn string an HTML document
|
||||
function FileConverter:mdToHtml(markdown, title)
|
||||
local MD = require("frontend/apps/filemanager/lib/md")
|
||||
local MD = require("apps/filemanager/lib/md")
|
||||
local md_options = {
|
||||
prependHead = "<!DOCTYPE html>\n<html>\n<head>\n",
|
||||
insertHead = string.format("<title>%s</title>\n</head>\n<body>\n", title),
|
||||
|
||||
@@ -3,11 +3,12 @@ local Device = require("device")
|
||||
local Event = require("ui/event")
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local Screensaver = require("ui/screensaver")
|
||||
local QuickStart = require("ui/quickstart")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local logger = require("logger")
|
||||
local dbg = require("dbg")
|
||||
local _ = require("gettext")
|
||||
local Screen = Device.screen
|
||||
local _ = require("gettext")
|
||||
|
||||
local ReaderMenu = InputContainer:new{
|
||||
tab_item_table = nil,
|
||||
@@ -42,12 +43,13 @@ function ReaderMenu:init()
|
||||
callback = function()
|
||||
self:onTapCloseMenu()
|
||||
self.ui:onClose()
|
||||
local FileManager = require("apps/filemanager/filemanager")
|
||||
local lastdir = nil
|
||||
local lastdir
|
||||
local last_file = G_reader_settings:readSetting("lastfile")
|
||||
if last_file then
|
||||
-- ignore quickstart guide as last_file so we can go back to home dir
|
||||
if last_file and last_file ~= QuickStart.quickstart_filename then
|
||||
lastdir = last_file:match("(.*)/")
|
||||
end
|
||||
local FileManager = require("apps/filemanager/filemanager")
|
||||
if FileManager.instance then
|
||||
FileManager.instance:reinit(lastdir)
|
||||
else
|
||||
|
||||
@@ -26,7 +26,7 @@ common_info.help = {
|
||||
common_info.quickstart_guide = {
|
||||
text = _("Quickstart guide"),
|
||||
callback = function()
|
||||
local QuickStart = require("frontend/ui/quickstart")
|
||||
local QuickStart = require("ui/quickstart")
|
||||
local ReaderUI = require("apps/reader/readerui")
|
||||
ReaderUI:showReader(QuickStart:getQuickStart())
|
||||
end
|
||||
|
||||
@@ -2,16 +2,17 @@
|
||||
]]
|
||||
local DataStorage = require("datastorage")
|
||||
local FileConverter = require("apps/filemanager/filemanagerconverter")
|
||||
local DocSettings = require("docsettings")
|
||||
local Version = require("version")
|
||||
local _ = require("gettext")
|
||||
local FFIUtil = require("ffi/util")
|
||||
local T = FFIUtil.template
|
||||
local lfs = require("libs/libkoreader-lfs")
|
||||
local T = require("ffi/util").template
|
||||
local _ = require("gettext")
|
||||
|
||||
local QuickStart = {
|
||||
quickstart_force_show_version = 201511982,
|
||||
}
|
||||
|
||||
local quickstart_shown_version = G_reader_settings:readSetting("quickstart_shown_version") or nil
|
||||
local language = G_reader_settings:readSetting("language") or "en"
|
||||
local version = Version:getNormalizedCurrentVersion()
|
||||
local rev = Version:getCurrentRevision()
|
||||
@@ -27,10 +28,10 @@ Turning pages can be done either by swiping left and right or by single taps on
|
||||
|
||||
### Contents
|
||||
|
||||
* [menu](#menu)
|
||||
* [main menu](#main-menu)
|
||||
* [settings](#settings)
|
||||
* [file browser](#file-browser)
|
||||
* [Menu](#menu)
|
||||
* [Main menu](#main-menu)
|
||||
* [Settings](#settings)
|
||||
* [File browser](#file-browser)
|
||||
|
||||
|
||||
## Menu <a id="menu"></a>
|
||||
@@ -63,11 +64,11 @@ shown yet or if display is forced through a higher version number than when
|
||||
it was first shown.
|
||||
]]
|
||||
function QuickStart:isShown()
|
||||
if quickstart_shown_version == nil then return false end
|
||||
return (quickstart_shown_version >= self.quickstart_force_show_version)
|
||||
local shown_version = G_reader_settings:readSetting("quickstart_shown_version")
|
||||
return shown_version ~= nil and (shown_version >= self.quickstart_force_show_version)
|
||||
end
|
||||
|
||||
--[[--Generates the quickstart guide in the user's language and returns its location.
|
||||
--[[-- Generates the quickstart guide in the user's language and returns its location.
|
||||
|
||||
The fileformat is `quickstart-en-v2015.11-985-g88308992.html`, `en` being the
|
||||
language of the generated file and `v2015.11-985-g88308992` the KOReader version
|
||||
@@ -77,16 +78,29 @@ used to generate the file.
|
||||
]]
|
||||
function QuickStart:getQuickStart()
|
||||
local quickstart_dir = ("%s/help"):format(DataStorage:getDataDir())
|
||||
local quickstart_filename = ("%s/quickstart-%s-%s.html"):format(quickstart_dir, language, rev)
|
||||
if lfs.attributes(quickstart_dir, "mode") ~= "dir" then
|
||||
lfs.mkdir(quickstart_dir)
|
||||
end
|
||||
|
||||
local quickstart_filename = ("%s/quickstart-%s-%s.html"):format(quickstart_dir, language, rev)
|
||||
if lfs.attributes(quickstart_filename, "mode") ~= "file" then
|
||||
-- purge old quickstart guides
|
||||
local iter, dir_obj = lfs.dir(quickstart_dir)
|
||||
for f in iter, dir_obj do
|
||||
if f:match("quickstart-.*%.html") then
|
||||
local file_abs_path = FFIUtil.realpath(("%s/%s"):format(quickstart_dir, f))
|
||||
os.remove(file_abs_path)
|
||||
DocSettings:open(file_abs_path):purge()
|
||||
end
|
||||
end
|
||||
|
||||
local quickstart_html = FileConverter:mdToHtml(quickstart_guide, _("KOReader Quickstart Guide"))
|
||||
if quickstart_html then
|
||||
FileConverter:writeStringToFile(quickstart_html, quickstart_filename)
|
||||
end
|
||||
end
|
||||
-- remember filemaname for file manager
|
||||
self.quickstart_filename = quickstart_filename
|
||||
G_reader_settings:saveSetting("quickstart_shown_version", version)
|
||||
return quickstart_filename
|
||||
end
|
||||
|
||||
@@ -81,7 +81,7 @@ end
|
||||
|
||||
function CalibreCompanion:addToMainMenu(menu_items)
|
||||
menu_items.calibre_wireless_connection = {
|
||||
text = _("Calibre wireless connection"),
|
||||
text = _("calibre wireless connection"),
|
||||
sub_item_table = {
|
||||
{
|
||||
text_func = function()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
describe("QuickStart module", function()
|
||||
setup(function()
|
||||
require("commonrequire")
|
||||
require("commonrequire")
|
||||
end)
|
||||
it("should return false shown_version lower than force_show_version", function()
|
||||
G_reader_settings:saveSetting("quickstart_shown_version", 1)
|
||||
|
||||
Reference in New Issue
Block a user