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

wallabako integration #2621

Closed
houqp opened this issue Mar 8, 2017 · 39 comments
Closed

wallabako integration #2621

houqp opened this issue Mar 8, 2017 · 39 comments

Comments

@houqp
Copy link
Member

houqp commented Mar 8, 2017

ref: #1580

This is the master ticket wallabako integration discussion.

@houqp
Copy link
Member Author

houqp commented Mar 8, 2017

From @anarcat's comment:

I've tested wallabako with KSM/KoReader and it somewhat works. For some reason, the logfile (a simple .txt file!) doesn't render in Koreader, but otherwise koreader sees the downloaded files correctly.

CREngine has it's own heuristic on parsing out document hierarchy structures for txt file, which is wrong most of the time :P So yeah, don't use txt, you can just rename the ext to html and it will be rendered literally as what's in file.

Let me know if you run into another blockers. I would love to use it on my kobo too :)

@anarcat
Copy link
Contributor

anarcat commented Mar 11, 2017

the problem is i need to settle on one file extension - i haven't tested the .html extension in Nickel, but the .txt worked fine so I used that. i will test the .html extension, but it seems to me plain text should be rendered in Koreader without any heuristics - other than line endings (\r?\n) and character sets (assume UTF-8), obviously.

i have seen Koreader completely crash on wallabako log files. it's pretty disturbing, because then it crashes again when you try to restart it ;) the only workaround is to delete the logfile...

note that KSM can read those logfiles correctly through its native file browser...

my blockers are documented on the gitlab issue here. basically, the biggest issue right now is #2620: because Koreader doesn't read file metadata, the only thing you see is the Wallabag article ID, which says nothing about the content. i understand why the file manager is built that way, but it's a serious user interface regression compared to nickel. i have tried implementing a way to set article titles on the filename, but then you are still missing authorship, a title page and other metadata that could be useful. i am considering dropping this approach completely and just wait for koreader to have a better epub browser.

next in line is read status synchronization, but this should be fairly easy to implement... if a bit annoying because of the feature duplication, but there's nothing you can do about this, really.

@Frenzie
Copy link
Member

Frenzie commented Apr 2, 2017

Things might be a little bit better with #2702.

@anarcat
Copy link
Contributor

anarcat commented Apr 2, 2017

to clarify, #2702 will help Koreader show the wallabako logfile.

the most urgent issue, on top of #2614 (which will take more time) is to have some way of firing wallabako from the Koreader menus somehow. is there an easy way I could hook into koreader that way? right now i'm relying on udev firing the script when the wifi comes up, but since we control the UI now, the best would be to have a "sync" button that would start the script and show the output...

ideally, it would also auto-configure wallabako: ie. it would prompt for a username and password if missing and so on. i could do that within wallabako itself, but that would basically mean requesting a username/password on the commandline, and i'm not sure how that would interoperate with koreader.

thanks!

@Frenzie
Copy link
Member

Frenzie commented Apr 2, 2017

GUI-wise there's probably a lot of overlap with https://github.com/koreader/koreader/blob/c73a1c1fcf2c83bf44edfad3d06d48199f61f1ff/plugins/goodreads.koplugin/main.lua

There's also a JSON parser.

local JSON = require("json")

Then I guess there'd be an enabled_func for the menu entry that checks for the existence of /usr/local/bin/wallabako (or is that in $PATH?).

Showing terminal output… @Hzj-jie is #2646 (re)usable for that?

@anarcat
Copy link
Contributor

anarcat commented Apr 2, 2017

in other words, what I want to do is write a Lua plugin for koreader. :)

as for the terminal output - i could probably just show the output of a file somehow...

@houqp
Copy link
Member Author

houqp commented Apr 3, 2017

Yeah, it should be pretty straight forward to write a plugin that calls a shell command. The timesync plugin can be a good example.

We can also provide support for deeper integration like automatically spin up wallabako when network is connected etc.

@anarcat
Copy link
Contributor

anarcat commented Apr 5, 2017

it would be great if someone made some scaffolding i could just test instead of having to learn all this stuff myself. ;)

thanks for the pointers!

@Frenzie
Copy link
Member

Frenzie commented Apr 6, 2017

I just realized you wrote that series on password managers I read a few weeks ago. That was very interesting. :-)

Do you have the emulator set up? That's really the key to making this a simple and not a harrowing experience.

For basic scaffolding I think it should be enough to just copy what happens here?
https://github.com/koreader/koreader/blob/1461574894b9ac38960e41c45e54ede07ce463ca/plugins/timesync.koplugin/main.lua

One step at a time is how I take it, anyway. ;-)

@houqp
Copy link
Member Author

houqp commented Apr 7, 2017

timesync plugin is a good start if you just want to shell out to spin up wallabako. Quick example:

local Device = require("device")
-- only enable in kobo
if not Device:isKobo() then return { disabled = true, } end

local InfoMessage = require("ui/widget/infomessage")
local UIManager = require("ui/uimanager")
local WidgetContainer = require("ui/widget/container/widgetcontainer")
local _ = require("gettext")

local Wallabako = WidgetContainer:new{
    name = "wallabako",
}

function Wallabako:init()
    self.ui.menu:registerToMainMenu(self)
end

function Wallabako(menu_items)
    menu_items.wallabako = {
        text = _("Enable wallabako"),
        callback = function()
            os.execute("./wallabako&")
            UIManager:show(InfoMessage:new{
                text = _("Wallabako started.")
            })
        end
    }
end

return Wallabako

@anarcat
Copy link
Contributor

anarcat commented Apr 7, 2017 via email

@Frenzie
Copy link
Member

Frenzie commented Apr 7, 2017

GitLab is currently erroring out, but that's where the GoodReads plugin I mentioned comes in. It contains a GUI that I assume is quite similar to what you want: https://github.com/koreader/koreader/blob/master/plugins/goodreads.koplugin/main.lua#L74-L144

The config is in JSON iirc? (Like I said, GitLab isn't working for me atm.) There's already a JSON parser which you can call with

local JSON = require("json")
local ok, json_data = pcall(JSON.decode, lang_data_file:read("*all"))

I assume there's also a JSON.encode and such, but I've never actually used it.

@anarcat
Copy link
Contributor

anarcat commented Apr 8, 2017

the config is indeed JSON. Gitlab should be back online as well, it was a small blip...

thanks for the references!

@simonvanderveldt
Copy link

@anarcat Have you been able to make any progress with the integration?

@anarcat
Copy link
Contributor

anarcat commented Jan 10, 2018 via email

@anarcat
Copy link
Contributor

anarcat commented Mar 14, 2018

so, for what it's worth, i'm looking into this again, after abysmal failures at getting access to Kobo's firmware internals directly. BTW, if some were worried about using sqlite in koreader, i can tell you there is much, much worse in the depths of Nickel: their use of sqlite made my life just miserable...

so anyways... @Frenzie by emulator, i assume you mean https://github.com/koreader/koreader#building-prerequisites and so on?

i'm must admit i'm a little lost as to where to go from here... there's been some changes to the file browser if i remember correctly, is there anything i should take into account there? or i just need to get off my ass and write that plugin already? :)

i should probably start with the sample plugin above and see if that works. then i can try to hook the output in, and maybe have a configuration dialog and so on. this would be great!

@anarcat
Copy link
Contributor

anarcat commented Mar 14, 2018

so i've tried to build the "emulator" and boy that thing is huge! it builds its own copy of libpng, openssl, mupdf... all stuff that's already in debian! but anyways... i'm stuck now at the run step:

~/dist/koreader/koreader-emulator-x86_64-linux-gnu-debug/koreader ~/dist/koreader
---------------------------------------------
                launching...
  _  _____  ____                _
 | |/ / _ \|  _ \ ___  __ _  __| | ___ _ __
 | ' / | | | |_) / _ \/ _` |/ _` |/ _ \ '__|
 | . \ |_| |  _ <  __/ (_| | (_| |  __/ |
 |_|\_\___/|_| \_\___|\__,_|\__,_|\___|_|

 It's a scroll... It's a codex... It's KOReader!

 [*] Current time: 03/13/18-21:37:47
 [*] Version: v2015.11-1564-gbfd55c76_2018-03-13

03/13/18-21:37:47 ERROR cannot open translation file: l10n/fr_CA/koreader.po
./luajit: frontend/device.lua:35: did not find a hardware abstraction for this platform
stack traceback:
	[C]: in function 'error'
	frontend/device.lua:35: in function 'probeDevice'
	frontend/device.lua:38: in main chunk
	[C]: in function 'require'
	frontend/ui/widget/container/widgetcontainer.lua:19: in main chunk
	[C]: in function 'require'
	frontend/ui/widget/container/centercontainer.lua:5: in main chunk
	[C]: in function 'require'
	frontend/ui/widget/button.lua:19: in main chunk
	[C]: in function 'require'
	frontend/ui/widget/buttontable.lua:2: in main chunk
	[C]: in function 'require'
	frontend/ui/widget/confirmbox.lua:21: in main chunk
	[C]: in function 'require'
	./reader.lua:96: in main chunk
	[C]: at 0x56033ae570b0
~/dist/koreader

i figured this was a problem with translations, so i went into the l10n folder and ran make, and that warned me that it couldn't find transifex. so i installed transifex-client, and then it warned me I didn't have credentials. ... so then i registered on transifex.com, waited for the confirmation email, and then ran tx init to do a basic config, and then ran make (make po in top level, in fact) again. then I got:

$ LANG=C.UTF-8 make po
make -i -C l10n bootstrap
make[1]: Entering directory '/home/anarcat/dist/koreader/l10n'
tx set --auto-local -r koreader.koreader "<lang>/koreader.po" \
	--source-language=en \
	--source-file "templates/koreader.pot" --execute
Updating source for resource koreader.koreader ( en -> templates/koreader.pot ).
Exception: tx: File ( /home/anarcat/dist/koreader/l10n/templates/koreader.pot ) does not exist.
Makefile:4: recipe for target 'bootstrap' failed
make[1]: [bootstrap] Error 1 (ignored)
make[1]: Leaving directory '/home/anarcat/dist/koreader/l10n'
make -C l10n pull
make[1]: Entering directory '/home/anarcat/dist/koreader/l10n'
tx pull -a -f
New translations found for the following languages:el, zh, fi_FI, vi, ca, it_IT, ug, vi_VN, cs, nl_NL, eu, gl, es, ru, tr, pt_PT, pl, bg_BG, fr, zh_TW, pt_BR, bn, ar_AA, hu, fa, ko_KR, cs_CZ, ja, zh_CN, kk, sv, de, zh_TW.Big5, uk, pl_PL, nb_NO
Pulling new translations for resource koreader.koreader (source: templates/koreader.pot)
 -> el: el/koreader.po
HttpNotAuthorized: Forbidden
Makefile:9: recipe for target 'pull' failed
make[1]: *** [pull] Error 1
make[1]: Leaving directory '/home/anarcat/dist/koreader/l10n'
Makefile:371: recipe for target 'po' failed
make: *** [po] Error 2

clearly, there's something wrong if we can't build koreader without registering on a proprietary service. i understand transifex may be an attractive solution, but if you can't pull translations without begging for mercy, I think there's a problem. there are also free software alternatives to transifex, in particular weblate which directly write po files into git repositories, which I would recommend.

anyways, is there something i did wrong?

@Frenzie
Copy link
Member

Frenzie commented Mar 14, 2018

so i've tried to build the "emulator" and boy that thing is huge! it builds its own copy of libpng, openssl, mupdf... all stuff that's already in debian!

While the environment is different regardless, for better or for worse that's part of what makes it an "emulator" likely to exhibit the same behavior as the version on a real device and not just a regular program. libpng probably shouldn't matter, OpenSSL might be okay but could be different in some cases (see here), and MuPDF has some patches for our needs.

i figured this was a problem with translations

Translations are never a problem in that sense. You'll just get English instead. The error worth noting here is did not find a hardware abstraction for this platform. On PC, that would mean you're missing SDL.

in particular weblate

I'd love to, but as an initial reaction I'm a bit frightened of losing the concordance/history and some of the community.

The Transifex pulling/pushing thing only works when you have sufficient access rights, annoyingly. (Okay, makes sense for pushing, but pulling seems pretty basic… and that illustrates the general problem, I suppose.)

Anyway, you make it sound as if it were a recent decision. ;-) It probably dates back some six, maybe even seven years.

Do you have any experience in switching over?

@anarcat
Copy link
Contributor

anarcat commented Mar 14, 2018

While the environment is different regardless, for better or for worse that's part of what makes it an "emulator" likely to exhibit the same behavior as the version on a real device and not just a regular program. libpng probably shouldn't matter, OpenSSL might be okay but could be different in some cases (see here), and MuPDF has some patches for our needs.

Well, I guess I don't need the full emulator here: just a similar enough running copy would be enough to develop my plugin. So recompiling the universe seems way overkill...

It would be nice if there was a way to link against existing libraries: we already link against stuff like SDL for example... :) I assume the MuPDF patches were sent back upstream?

Translations are never a problem in that sense. You'll just get English instead. The error worth noting here is did not find a hardware abstraction for this platform. On PC, that would mean you're missing SDL.

Gah. Well, I guess that could have been made a little more obvious. ;) To be honest, the README had so many different steps that I got lost and didn't install everything... So I guess I got what I deserve...

I'd love to, but as an initial reaction I'm a bit frightened of losing the concordance/history and some of the community.

makes sense, i guess...

The Transifex pulling/pushing thing only works when you have sufficient access rights, annoyingly. (Okay, makes sense for pushing, but pulling seems pretty basic… and that illustrates the general problem, I suppose.)

yeah, that's a huge problem... surely there's a way to pull without an account... right??

Anyway, you make it sound as if it were a recent decision. ;-) It probably dates back some six, maybe even seven years.

oh, i didn't mean to imply anything. :)

Do you have any experience in switching over?

I do not, but weblate is my goto solution for free software projects, so I never had to switch. :)

ElementaryOS switched and it seemed pretty straightforward... Nextcloud stayed on Transifex without much explanation even though Weblate was prefered by translators...

For what it's worth, Transifex used to be partially free software, but they closed it all down in 2013...

In your place, I would be worried about such a silo and import at least the .po files in the git repo so that the public can operate on those without a transifex account. This kind of workflow is, by the way, perfectly easy (because git) in Weblate: you don't need a weblate account to contribute translations and people can work on their own machines directly without using the web interface...

@Frenzie
Copy link
Member

Frenzie commented Mar 14, 2018

I assume the MuPDF patches were sent back upstream?

You'll have to ask the patch author, mostly @TnS-hun in this case. But note that MuPDF has changed various functions between versions too, so you definitely can't just mix & match versions. Anyway, PRs are of course the best way to get something implemented. ;-) No one's against it (afaik).

Gah. Well, I guess that could have been made a little more obvious. ;)

Blame LuaJIT I guess? :-P We could consider changing the severity of the language stuff from error to warning.

if not po then
logger.err("cannot open translation file:", file)
return false
end

The real error could include some debugging advice about SDL if you're on PC.

yeah, that's a huge problem... surely there's a way to pull without an account... right??

I wanted to do some unit tests with the translation last year and there didn't seem to be a way.

In your place, I would be worried about such a silo

Setting that aside, I don't care for it much regardless. To me it's not really the GitHub/GitLab of translation and I prefer Poedit or even just going in with a text editor.

Do you have any examples of the Weblate to git workflow in practice?

anarcat added a commit to anarcat/koreader that referenced this issue Mar 14, 2018
This is not fatal and can be mistaken by new users for the cause of all their problems, like I did in koreader#2621.
anarcat added a commit to anarcat/koreader that referenced this issue Mar 14, 2018
"hardware abstraction" didn't mean anything for me when I tried the emulator at first on Debian. In koreader#2621, it was proposed to suggest installing SDL: do so here, although we do it for all platforms...
@anarcat
Copy link
Contributor

anarcat commented Mar 14, 2018

Blame LuaJIT I guess? :-P We could consider changing the severity of the language stuff from error to warning.

Done in #3752.

The real error could include some debugging advice about SDL if you're on PC.

Done in #3753.

I wanted to do some unit tests with the translation last year and there didn't seem to be a way.

See, that's a big concern to me.

Do you have any examples of the Weblate to git workflow in practice?

Should I do this here or in another issue? :)

Frenzie pushed a commit that referenced this issue Mar 14, 2018
This is not fatal and can be mistaken by new users for the cause of all their problems, like I did in #2621.
Frenzie pushed a commit that referenced this issue Mar 14, 2018
"hardware abstraction" didn't mean anything for me when I tried the emulator at first on Debian. In #2621, it was proposed to suggest installing SDL.
@TnS-hun
Copy link
Contributor

TnS-hun commented Mar 14, 2018

It would be nice if there was a way to link against existing libraries: we already link against stuff like SDL for example... :) I assume the MuPDF patches were sent back upstream?

The encrypted zip and a better version of the external font support patches could be upstreamed, but for example the patch that changes the ICC profile error to warning is KOReader specific, so you won't be able to use MuPDF provided by the system.

@anarcat
Copy link
Contributor

anarcat commented Mar 15, 2018

sure, but that's all stuff that's unnecessary for the reader... i guess i should just open a different issue for that wishlist, right? :)

@Frenzie
Copy link
Member

Frenzie commented Mar 15, 2018

I'd say that wishlist item already exists in #1417 and #3108 (unless you're talking about something else). At least my mental model of "desktop app" includes "bundle less stuff".

@anarcat
Copy link
Contributor

anarcat commented Mar 15, 2018

i guess that debian support (#3108) implies cleaning up those depends, but i made that explicit there. i wonder if we shouldn't explicitly add a todo for merging the patches upstream though...

@Frenzie
Copy link
Member

Frenzie commented Mar 15, 2018

Would you mind looking into that, @TnS-hun? The less patches the better. :-)

@anarcat
Copy link
Contributor

anarcat commented Mar 19, 2018

i filed #3777 to followup on upstream patch merging.

@anarcat
Copy link
Contributor

anarcat commented Mar 19, 2018

just to go back on track with the original wallabako support here... i've identified the following todo list on my side:

About the latter three four items:

  1. where's the read status metadata now? @houqp explained that it was in .lua files before and suggested parsing that directly, which is far from trivial. is this still the case after the UI refactoring? this is one of my biggest blockers...

  2. i need to know if i need to do anything to tell koreader )or the user) that new books have arrived. do we just rely on koreader's automatic detection of changes in the filesystem? then we'd need to tell the user "wallabako just ran and found 3 new books" or something... otherwise, what body part of koreader do i need to kick to make it notice the new books?

  3. see 2.

  4. should we limit ourselves to "manual" wallabako runs? ie. i'm not sure i want to have users click through the menu system to start wallabako by hand every time. maybe i'd get used to it, but it seems like a lot of tappety-taps. on Nickel now, wallabako starts automatically when wifi is turned on, through udev hooks. would that still work in Koreader?

Thanks so much for the hand holding. There's progress, and i'm confident we can see this throught! :)

@Frenzie
Copy link
Member

Frenzie commented Mar 19, 2018

Pinging @poire-z as to what's stored by CoverBrowser.

@houqp explained that it was in .lua files before and suggested parsing that directly, which is far from trivial.

Incidentally, I notice some hating on Lua there. Quoting from the old (but free) edition of PIL:

https://www.lua.org/pil/12.html

Lua not only runs fast, but it also compiles fast. For instance, the above program for listing authors runs in less than one second for 2 MB of data. Again, this is not by chance. Data description has been one of the main applications of Lua since its creation and we took great care to make its compiler fast for large chunks.

what body part of koreader do i need to kick to make it notice the new books?

Notice in what sense?

wallabako starts automatically when wifi is turned on, through udev hooks. would that still work in Koreader?

I don't see why it wouldn't since that's just a kernel thing? :-) Alternatively you should also be able to use Module:onNetworkConnected() from within KOReader.

@anarcat
Copy link
Contributor

anarcat commented Mar 19, 2018

Incidentally, I notice some hating on Lua there. Quoting from the old (but free) edition of PIL:

Not sure this was Lua "hating" as much as questioning the use of Lua as a data storage format. :p I understand the reasoning, but I disagree: I believe that language-neutral, non-executable data formats are better for storage. But if that's all there is, I'll deal with it the best I can.

Notice in what sense?

To make sure the new books show up in the (new) UI.

I don't see why it wouldn't since that's just a kernel thing? :-) Alternatively you should also be able to use Module:onNetworkConnected() from within KOReader.

Thanks!

@anarcat
Copy link
Contributor

anarcat commented Mar 19, 2018

I mean it looks all fine and easy in PIL:

    Entry{"Donald E. Knuth",
          "Literate Programming",
          "CSLI",
          1992}

But actually, it's more like:

    Entry{
      author = "Donald E. Knuth",
      title = "Literate Programming",
      publisher = "CSLI",
      year = 1992
    }

but really, what's actually going on in that .lua file is:

return {
    -- a bunch more stuff here.
    ["percent_finished"] = 1,
    ["summary"] = {
        ["status"] = "complete",
        ["modified"] = "2017-03-04"
    },
    -- and here too
}

notice how different those syntaxes are? to be safe, i would need to support all of those, which means I basically need to implement a CFG (context-free grammar) in Golang... @houqp was nice enough to actually do that and write a fairly complete one with peg.js, which apparently has go bindings:

config = comment "return " v:table { return v; }
table = "{" ws? v:key_value* ws? "}" { return v; }
key_value = k:key ws? '=' ws? v:value ','? ws? { return {"key": k, "value": v}; }
key = '[' ws? v:(str/number) ws? ']' { return v; }
value =  str / number / table / boolean
comment = "--" $[^'\n']* '\n'
ws = [ \n\r\t]*
str = '"' v:$[^'"']* '"' { return v; }
number = v:$([0-9]+('.'[0-9]+)?) { return Number(v); }
boolean = v:('true' / 'false') { return v == "true"; }

... but really, i just want to get this one field, so I'll probably go with a regex and deal when the breakage when/if it happens. :)

a more complete discussion of file formats can be seen in @houqp's response here: https://gitlab.com/anarcat/wallabako/issues/15#note_25908362

@Frenzie
Copy link
Member

Frenzie commented Mar 19, 2018

to be safe, i would need to support all of those

Yes, we might change our serialization any second. Muhahahahahaha! xD

a more complete discussion of file formats can be seen in @houqp's response here: https://gitlab.com/anarcat/wallabako/issues/15#note_25908362

@poire-z and Roberto Ierusalimschy convinced me to disagree with @houqp See discussion in #2789 (comment) and following.

@poire-z
Copy link
Contributor

poire-z commented Mar 19, 2018

I'm not sure I understand what wallabag/wallabako are :) From what I get, you select some articles elsewhere, and there's wallabako that downloads them automatically and make them appears as epub on your device?

The new UI if you're talking about the covers/metadata display is just some hacks to the FileManager, to make it display the files (in a directory) with a new dress. Details on what it does and how in #2940.

So, koreader has not evolved much: it's just a file manager. The metadata and cover images are extracted as you browse your directories, and stored in a sqlite database (it's just a cache database, like those Thumbs.db you see on windows when you select Mosaic/Minitatures display), so next time you revisit these directories, you don't need to reparse them. This db is defined in:

local BOOKINFO_DB_SCHEMA = [[
-- For caching book cover and metadata
CREATE TABLE IF NOT EXISTS bookinfo (
-- Internal book cache id
-- (not to be used to identify a book, it may change for a same book)

but I don't see how that would help with this topic.

To make sure the new books show up in the (new) UI.

The point is that in koreader, you don't notify when new books are available: the user sees them as he browses his directories.
Anyway, you don't need, as in nickel, to notify anything when you put books in directories.
(May be you could hack the history file (lua again :) to put them at top, so they are displayed in History.)

If I got that right (my first sentence above), and if you want it in a plugin, and if you have another process that is doing the syncing, your plugin would only need to:

  • notice when we are online, and watch (reschedule a function every 10 seconds, while we are online) some log file about the new books that are downloaded
  • and just pop up an InfoMessage or a TextViewer with what's available, with may be a button to close the current book and open filemanager in the target directory where the new files were saved.
    You wouldn't need to extract yourself metadata: the coverbrowser plugin would do that when your user goes to that directory (and with the way it works, displaying Filename... during the few seconds it need to extract metadata, your user would get some visual feedback about what's new).

@anarcat
Copy link
Contributor

anarcat commented Mar 20, 2018 via email

@poire-z
Copy link
Contributor

poire-z commented Mar 20, 2018

I guess that someone browsing to the "wallabako" folder could sort entries by modification date?

The sort option is global. There's been some wish for per-directory sort option (#3428), not implemented, so it went with naming files with date. But may be that could be added (like if there's a .sdr/diroptions.lua, have filemanager read some options from it and use them. You would then just need to create it when creating the folder. Or cleaner: just have plugins notify FileManager that this or that directory has to be sorted in this non-standard way.

The stats I am looking for are basically: * is the article present * is the article read or unread * what percentage of the book is read (not currently supported in wallabako) * annotations (not supported either)

Well, if you're writting a plugin in lua, and all your wallabag articles sit in a single Wallabag/ directory, your plugin can just list that directory content and use our existing functions to get these infos, like:

if DocSettings:hasSidecarFile(self.filepath) then
self.been_opened = true
if self.menu.cover_info_cache[self.filepath] then
pages, percent_finished, status = unpack(self.menu.cover_info_cache[self.filepath])
else
local docinfo = DocSettings:open(self.filepath)
-- We can get nb of page in the new 'doc_pages' setting, or from the old 'stats.page'
if docinfo.data.doc_pages then
pages = docinfo.data.doc_pages
elseif docinfo.data.stats and docinfo.data.stats.pages then
if docinfo.data.stats.pages ~= 0 then -- crengine with statistics disabled stores 0
pages = docinfo.data.stats.pages
end
end
if docinfo.data.summary and docinfo.data.summary.status then
status = docinfo.data.summary.status
end
percent_finished = docinfo.data.percent_finished
self.menu.cover_info_cache[self.filepath] = {pages, percent_finished, status}
end
end
if status == "complete" or status == "abandoned" then
-- Display these instead of the read %
if pages then
if status == "complete" then

Instead of having koreader do a busy loop

We don't busy loop :) Most of the stuff does as described in #2500 (comment)

I don't think we have an easy way to have koreader be notified from the outside (except via /dev/ events, fakevents, which are too device specific).
But your plugin could (if configured and enabled) just listen for different kind of other reader events (page turn, menu opening...), and decide that if checks haven't been done in the last 10 minutes, let's do one:

  • read wallabako logs, decide what's new, notify the user with one of our widget: InfoMessage, ConfirmBox (Some new articles arrived, do you want to switch to Filemanager Wallabag directory? Later|See new articles)
  • list Wallabag/ directory, find out book status and disappearances, write back a json file with current books in Wallabag/ status (or diffs of these) to be consumed by Wallabako so it can report it back?

That shouldn't be too expensive, neither in battery power nor in your lua hacking time :)

@anarcat
Copy link
Contributor

anarcat commented Mar 20, 2018 via email

@NiLuJe
Copy link
Member

NiLuJe commented Jul 7, 2018

On a slightly related note, with Mozilla's acquisition of Pocket, there are apparently plans in motion to make it OSS.

@anarcat
Copy link
Contributor

anarcat commented Jul 8, 2018 via email

@NiLuJe
Copy link
Member

NiLuJe commented Jul 8, 2018

Hence my use of "apparently" ^^. Last I checked, I think there's a few things somewhere on GH, and a tracking BZ issue, but that's the extent of the public-facing side of this ;).

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

No branches or pull requests

8 participants