Skip to content

wallabag: Add option to archive locally, instead of deleting + rewording of menu options#12949

Merged
Frenzie merged 32 commits into
koreader:masterfrom
harmtemolder:master
Jan 12, 2025
Merged

wallabag: Add option to archive locally, instead of deleting + rewording of menu options#12949
Frenzie merged 32 commits into
koreader:masterfrom
harmtemolder:master

Conversation

@harmtemolder

@harmtemolder harmtemolder commented Dec 27, 2024

Copy link
Copy Markdown
Contributor

This PR started as a fix for #12712, but encountering minor bugs and unclear menu options along the way, I decided to improve the entire wallabag plugin. So now this also fixes #11687 and #9151. Also, something was off with the behavior described in #6119, but now it works as expected: a maximum of the set number of articles is kept in KOReader deleting/archiving older articles when downloading newer ones. It includes logic to migrate from old settings to new ones, so there won't be any surprises for existing users.

I've set this PR to draft, because I'd like to test this on my KOReader device for a couple of days before submitting. It would be great if other users of the wallabag plugin could help test this as well:

  1. Rename plugins/wallabag.koplugin/main.lua in your KOReader folder to main.lua.bak
  2. Download this main.lua to plugins/wallabag.koplugin/
  3. Go through the new settings in Tools > Wallabag and set them as you like
  4. Let me know your thoughts and any bugs you may encounter

Fix #12712, fix #11687, fix #9151.


This change is Reviewable

@harmtemolder harmtemolder left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way of prepending all logs within this function with the function name gives a build warning 431 (see https://luacheck.readthedocs.io/en/stable/warnings.html). How much of a problem is that warning?

Comment thread plugins/wallabag.koplugin/main.lua Outdated
Comment thread plugins/wallabag.koplugin/main.lua Outdated
Comment thread plugins/wallabag.koplugin/main.lua Outdated
Comment thread plugins/wallabag.koplugin/main.lua Outdated
Comment thread plugins/wallabag.koplugin/main.lua Outdated
Comment thread plugins/wallabag.koplugin/main.lua Outdated
Comment thread plugins/wallabag.koplugin/main.lua Outdated
Comment thread plugins/wallabag.koplugin/main.lua Outdated
Comment thread plugins/wallabag.koplugin/main.lua Outdated
Comment thread plugins/wallabag.koplugin/main.lua Outdated
@Frenzie Frenzie added the Plugin label Dec 27, 2024
Comment thread plugins/wallabag.koplugin/main.lua Outdated
Comment thread plugins/wallabag.koplugin/main.lua Outdated
@harmtemolder harmtemolder changed the title Add option to archive locally, instead of deleting + rewording of menu options wallabag: Add option to archive locally, instead of deleting + rewording of menu options Dec 28, 2024
Comment thread plugins/wallabag.koplugin/main.lua Outdated
@poire-z

poire-z commented Dec 29, 2024

Copy link
Copy Markdown
Contributor

Is there a way to update an existing dialog instead of closing and showing a new one?

Depends on what you mean with "update".
If it's inner little widgets like buttons or a title bar or a textbox, we usually have these update themselves, and notify the parent (usually the ancestor/container standalong widget, passed all along as self.dialog) via setDirty to repaint itself - and so all the inner widgets, that will update repaint themselves to their current state.
If it's some bigger update, closing and recreating a new one is something possible and that we do. Sometimes there is a shortcut in that upper widget where we :reinit() or :update() and rebuild/relayout the whole inner content without actually closing and creating a new one.

@Frenzie

Frenzie commented Dec 31, 2024

Copy link
Copy Markdown
Member

plugins/wallabag.koplugin/main.lua line 1079 at r9 (raw file):

                        else
                            logger.warn("Wallabag:uploadStatuses: - could not archive/delete on remote")
                            skip = true -- Skip local archiving/deleting

useless comment

@Frenzie Frenzie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 2 files at r8.
Reviewable status: 1 of 2 files reviewed, 34 unresolved discussions (waiting on @harmtemolder and @poire-z)


plugins/wallabag.koplugin/main.lua line 600 at r9 (raw file):

            if #article_list == self.articles_per_sync then
                logger.dbg("Wallabag:getArticleList: #article_list == self.articles_per_sync ==", self.articles_per_sync)
                break -- exit for loop

useless comment


plugins/wallabag.koplugin/main.lua line 612 at r9 (raw file):

--- Remove all the articles from the list containing one of the ignored tags.
-- @tparam tab article_list Array containing a JSON formatted list of articles
-- @treturn tab Same array, but without any articles that contain an ignored tag.

We write table in full in such scenarios.


plugins/wallabag.koplugin/main.lua line 781 at r9 (raw file):

                    logger.dbg("Wallabag:callAPI: JSON downloaded")
                    -- Only enable this log when needed, the output can be large
                    -- logger.dbg("result =", result)

Undesirable change


plugins/wallabag.koplugin/main.lua line 870 at r9 (raw file):

        UIManager:forceRePaint()

        for i, article in ipairs(articles) do -- Do not use `_`

Useless comment


plugins/wallabag.koplugin/main.lua line 964 at r9 (raw file):

    if self.upload_queue and next(self.upload_queue) ~= nil then
        local msg = T(_("Uploading %1 articles from queue…"), #self.upload_queue)

The old string Adding articles from queue… is better. No articles are being uploaded, only some URLs are added ("uploaded" in some technical sense) to Wallabag.


plugins/wallabag.koplugin/main.lua line 981 at r9 (raw file):

    if not quiet then
        local msg = T(_("Uploaded %1 articles from the queue to wallabag"), count)

Also uploaded.

Plurals need to be double wrapped for localization. http://koreader.rocks/doc/modules/gettext.html#ngettext


plugins/wallabag.koplugin/main.lua line 1016 at r9 (raw file):

                    logger.dbg("Wallabag:processRemoteDeletes: deleting", local_id, "at", entry_path)
                    count = count + self:deleteLocalArticle(entry_path)
                end -- if self.use_local_archive

Useless comment


plugins/wallabag.koplugin/main.lua line 1020 at r9 (raw file):

                logger.dbg("Wallabag:processRemoteDeletes: local_id", local_id, "found in remote_ids; not archiving/deleting")
            end -- if not remote_article_ids[ id ]
        end -- if entry ~= . and entry ~= ..

Useless comment


plugins/wallabag.koplugin/main.lua line 1045 at r9 (raw file):

    if self.archive_finished or self.archive_read or self.archive_abandoned then
        local info = InfoMessage:new{ text = _("Uploading local article statuses…") }

uploading

should be submitting or syncing


plugins/wallabag.koplugin/main.lua line 1240 at r9 (raw file):

        util.makePath(self.archive_directory)
        UIManager:show(InfoMessage:new{
            text = T(_("Created the archive directory at %1."), self.archive_directory),

Useless info message.


plugins/wallabag.koplugin/main.lua line 1416 at r9 (raw file):

function Wallabag:setArticlesPerSync(touchmenu_instance)
    self.articles_dialog = InputDialog:new{
        title = _("Number of articles to download"),

Something like "to store/keep locally" seems clearer.


plugins/wallabag.koplugin/main.lua line 1515 at r9 (raw file):

function Wallabag:onAddWallabagArticle(article_url)
    if not NetworkMgr:isOnline() then
        self:addToUploadQueue(article_url)

Definitely not a fan of changing the function name either. It's a queue to download. The fact that it does so by uploading a few bytes is an implementation detail.


plugins/wallabag.koplugin/main.lua line 1517 at r9 (raw file):

        self:addToUploadQueue(article_url)
        UIManager:show(InfoMessage:new{
            text = T(_("Article added to upload queue:\n%1"), BD.url(article_url)),

Definitely should not be upload queue in anything user facing.


plugins/wallabag.koplugin/main.lua line 1572 at r9 (raw file):

    NetworkMgr:runWhenOnline(connect_callback)

    -- stop propagation

useless comment


plugins/wallabag.koplugin/main.lua line 1590 at r9 (raw file):

    end

    -- stop propagation

useless comment

Comment thread plugins/wallabag.koplugin/main.lua Outdated

@harmtemolder harmtemolder left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 2 files reviewed, 30 unresolved discussions (waiting on @Frenzie and @poire-z)


plugins/wallabag.koplugin/main.lua line 600 at r9 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

useless comment

Done.


plugins/wallabag.koplugin/main.lua line 612 at r9 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

We write table in full in such scenarios.

Done.


plugins/wallabag.koplugin/main.lua line 781 at r9 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

Undesirable change

Done.


plugins/wallabag.koplugin/main.lua line 870 at r9 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

Useless comment

Done.


plugins/wallabag.koplugin/main.lua line 964 at r9 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

The old string Adding articles from queue… is better. No articles are being uploaded, only some URLs are added ("uploaded" in some technical sense) to Wallabag.

Done.


plugins/wallabag.koplugin/main.lua line 981 at r9 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

Also uploaded.

Plurals need to be double wrapped for localization. http://koreader.rocks/doc/modules/gettext.html#ngettext

Done.


plugins/wallabag.koplugin/main.lua line 1016 at r9 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

Useless comment

I added these when I was counting ends and read https://github.com/koreader/koreader-base/wiki/Coding-style#end-terminator, but I'm happy to remove them if you think they are useless


plugins/wallabag.koplugin/main.lua line 1045 at r9 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

uploading

should be submitting or syncing

Done.


plugins/wallabag.koplugin/main.lua line 1079 at r9 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

useless comment

Done.


plugins/wallabag.koplugin/main.lua line 1240 at r9 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

Useless info message.

Done.


plugins/wallabag.koplugin/main.lua line 1416 at r9 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

Something like "to store/keep locally" seems clearer.

Done.


plugins/wallabag.koplugin/main.lua line 1517 at r9 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

Definitely should not be upload queue in anything user facing.

Done.


plugins/wallabag.koplugin/main.lua line 1572 at r9 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

useless comment

Done.


plugins/wallabag.koplugin/main.lua line 1590 at r9 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

useless comment

Done.

@harmtemolder harmtemolder left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 2 files reviewed, 30 unresolved discussions (waiting on @Frenzie and @poire-z)


plugins/wallabag.koplugin/main.lua line 1515 at r9 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

Definitely not a fan of changing the function name either. It's a queue to download. The fact that it does so by uploading a few bytes is an implementation detail.

I agree to not calling it "upload" for anything user facing, so I've changed that.

But regarding the variable and function names: trying to understand the internal functionality of this plugin and the flow through it, it was very confusing for me that something called "download_queue" was not used to download anything:

  • If there is a network connection, the article is added to the remote wallabag directly, but not downloaded to KOReader yet until the next manual download
  • If there is no network connection, the article is added to the queue, to be added to the remote wallabag on the next manual upload or complete sync

Only after adding the articles to the remote wallabag will they be downloaded, like any other new article added from anywhere else. The "download_queue" variable is not part of that process.

@harmtemolder

Copy link
Copy Markdown
Contributor Author

Is there a way to update an existing dialog instead of closing and showing a new one?

Depends on what you mean with "update". If it's inner little widgets like buttons or a title bar or a textbox, we usually have these update themselves, and notify the parent (usually the ancestor/container standalong widget, passed all along as self.dialog) via setDirty to repaint itself - and so all the inner widgets, that will update repaint themselves to their current state. If it's some bigger update, closing and recreating a new one is something possible and that we do. Sometimes there is a shortcut in that upper widget where we :reinit() or :update() and rebuild/relayout the whole inner content without actually closing and creating a new one.

Thanks! I'll dive into these. The reason I asked is for updating a counter in a status message while running a sync, which, depending on the number of articles, could take a long time

@harmtemolder harmtemolder left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 2 files reviewed, 30 unresolved discussions (waiting on @Frenzie and @poire-z)

Comment thread plugins/wallabag.koplugin/main.lua Outdated
@poire-z

poire-z commented Jan 1, 2025

Copy link
Copy Markdown
Contributor

The reason I asked is for updating a counter in a status message while running a sync, which, depending on the number of articles, could take a long time

Oh, if I get it right that you want to update some kind of InfoMessage with a text + counter while some download is happening (like in the background, but not really with KOReader: there is no background :)), you may want to look at the other stuff that does similar things, ie. Wikipedia EPUB images download.
It's a bit different as you need to use the Trapper module, but it allows the sequence of downloads to be interrupted.

-- Create an epub file (with possibly images)
function Wikipedia:createEpub(epub_path, page, lang, with_images)
-- Use Trapper to display progress and ask questions through the UI.
-- We need to have been Trapper.wrap()'ed for UI to be used, otherwise
-- Trapper:info() and Trapper:confirm() will just use logger.
local UI = require("ui/trapper")

-- OEBPS/images/*
if include_images then
local nb_images = #images
for inum, img in ipairs(images) do
-- Process can be interrupted at this point between each image download
-- by tapping while the InfoMessage is displayed
-- We use the fast_refresh option from image #2 for a quicker download
local go_on = UI:info(T(_("Retrieving image %1 / %2 …"), inum, nb_images), inum >= 2)
if not go_on then
cancelled = true
break
end
local src = img.src
if use_img_2x and img.src2x then
src = img.src2x
end
logger.dbg("Getting img ", src)
local success, content = getUrlContent(src)
-- success, content = getUrlContent(src..".unexistant") -- to simulate failure
if success then
logger.dbg("success, size:", #content)
else
logger.info("failed fetching:", src)
end
if success then
-- Images do not need to be compressed, so spare some cpu cycles
local no_compression = true
if img.mimetype == "image/svg+xml" then -- except for SVG images (which are XML text)
no_compression = false
end
epub:add("OEBPS/"..img.imgpath, content, no_compression)
else
go_on = UI:confirm(T(_("Downloading image %1 failed. Continue anyway?"), inum), _("Stop"), _("Continue"))
if not go_on then
cancelled = true
break
end
end
end
end

@Frenzie Frenzie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 2 files at r10.
Reviewable status: 1 of 2 files reviewed, 19 unresolved discussions (waiting on @harmtemolder and @poire-z)


plugins/wallabag.koplugin/main.lua line 964 at r9 (raw file):

Previously, harmtemolder (hrm) wrote…

Done.

Adding 1 article from queue…


plugins/wallabag.koplugin/main.lua line 981 at r9 (raw file):

Previously, harmtemolder (hrm) wrote…

Done.

from queue


plugins/wallabag.koplugin/main.lua line 1016 at r9 (raw file):

Previously, harmtemolder (hrm) wrote…

I added these when I was counting ends and read https://github.com/koreader/koreader-base/wiki/Coding-style#end-terminator, but I'm happy to remove them if you think they are useless

I'm not saying each and every one is necessarily useless (that being said, I'm not sure if this file even contains anything that resembles a "large block") but if self.use_local_archive for example is a mere 4 lines up. That makes it a double whammy maintenance nightmare: extremely distracting and guaranteed to be outdated soon.

In short, since they were added indiscriminately I'd also remove them indiscriminately, yes.


plugins/wallabag.koplugin/main.lua line 1515 at r9 (raw file):

Previously, harmtemolder (hrm) wrote…

I agree to not calling it "upload" for anything user facing, so I've changed that.

But regarding the variable and function names: trying to understand the internal functionality of this plugin and the flow through it, it was very confusing for me that something called "download_queue" was not used to download anything:

  • If there is a network connection, the article is added to the remote wallabag directly, but not downloaded to KOReader yet until the next manual download
  • If there is no network connection, the article is added to the queue, to be added to the remote wallabag on the next manual upload or complete sync

Only after adding the articles to the remote wallabag will they be downloaded, like any other new article added from anywhere else. The "download_queue" variable is not part of that process.

I think I understand your point about download, although I don't agree with it and that's how I feel about the word upload. What about something like pending queue or sync queue?


plugins/wallabag.koplugin/main.lua line 208 at r10 (raw file):

                                        path = filemanagerutil.abbreviate(self.directory)
                                    end
                                    return T(_("Download directory: %1"), BD.dirpath(path))

Download folder


plugins/wallabag.koplugin/main.lua line 329 at r10 (raw file):

                            },
                            {
                                text = _("Move to archive directory instead of deleting"),

archive folder


plugins/wallabag.koplugin/main.lua line 461 at r10 (raw file):

-- Do not request a new token if the saved one is valid for more than 5 minutes.
function Wallabag:getBearerToken()
    local function is_empty(s)

isEmpty


plugins/wallabag.koplugin/main.lua line 582 at r10 (raw file):

            -- No error occurred, but no JSON was returned either
            logger.warn("Wallabag:getArticleList: requesting page", page, "did not return anything")
            UIManager:show(InfoMessage:new{ text = _("Requesting article list did not return anything.") })

Is that an accurate change? nil and a JSON that is "empty" are two very different things.


plugins/wallabag.koplugin/main.lua line 866 at r10 (raw file):

                #articles
            ),
            timeout = 5

timeout = 3


plugins/wallabag.koplugin/main.lua line 886 at r10 (raw file):

                        #articles
                    ),
                    timeout = 5

timeout = 3


plugins/wallabag.koplugin/main.lua line 912 at r10 (raw file):

        logger.info("Wallabag:downloadArticles: - queue_count =", queue_count)
        if queue_count > 0 then
            msg = msg..T(_("\n- added from queue: %1"), queue_count)

concatenate the \n, don't bother translators with it

Though the part about not being too clever also goes. For localization it's generally preferable to write it out in full.

As a user I don't care about skipped at all tbh, that's almost always >0, and as a user I'm definitely not convinced that dynamically changing the message so everything is always somewhere else is desirable.

I'd just skip all the cleverness as a single message which clearly says 0 to serve users better, and it's better for translators as an added bonus.


plugins/wallabag.koplugin/main.lua line 931 at r10 (raw file):

        if del_count_local > 0 then
            if self.use_local_archive then
                msg = msg..T(_("\n- archived in KOReader: %1"), del_count_local)

cleverness works for these, but note the \n concat


plugins/wallabag.koplugin/main.lua line 1113 at r10 (raw file):

        if self.delete_instead then
            msg = msg..T(_("\n- deleted from Wallabag: %1"), count_remote)

\n concat


request.method = method
if filepath ~= "" then
if filepath ~= nil then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's okay.

Comment thread plugins/wallabag.koplugin/main.lua Outdated

@harmtemolder harmtemolder left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 of 2 files reviewed, 19 unresolved discussions (waiting on @Frenzie and @poire-z)


plugins/wallabag.koplugin/main.lua line 964 at r9 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

Adding 1 article from queue…

Done.


plugins/wallabag.koplugin/main.lua line 981 at r9 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

from queue

Done.


plugins/wallabag.koplugin/main.lua line 1016 at r9 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

I'm not saying each and every one is necessarily useless (that being said, I'm not sure if this file even contains anything that resembles a "large block") but if self.use_local_archive for example is a mere 4 lines up. That makes it a double whammy maintenance nightmare: extremely distracting and guaranteed to be outdated soon.

In short, since they were added indiscriminately I'd also remove them indiscriminately, yes.

Done.


plugins/wallabag.koplugin/main.lua line 1020 at r9 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

Useless comment

Done.


plugins/wallabag.koplugin/main.lua line 1515 at r9 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

I think I understand your point about download, although I don't agree with it and that's how I feel about the word upload. What about something like pending queue or sync queue?

How do you feel about "offline_queue", because it's only used when adding articles when offline?


plugins/wallabag.koplugin/main.lua line 208 at r10 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

Download folder

So for my understanding: I should use "folder" in anything user facing and "directory" in variable names?


plugins/wallabag.koplugin/main.lua line 461 at r10 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

isEmpty

Done.


plugins/wallabag.koplugin/main.lua line 582 at r10 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

Is that an accurate change? nil and a JSON that is "empty" are two very different things.

Unfortunately, https://app.wallabag.it/api/doc/ does not explain if an empty JSON will ever be returned from the /api/entries endpoint, but you're right, my wording here might not be correct.

I kept this check for nil because it was there before, but seeing that I've adapted callAPI to always give true/false as its first return value, it will never trigger: true is only ever returned when a valid JSON was returned by the wallabag API (or a filepath was provided, which is not the case here). So this check can be removed entirely.


plugins/wallabag.koplugin/main.lua line 866 at r10 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

timeout = 3

Done.


plugins/wallabag.koplugin/main.lua line 886 at r10 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

timeout = 3

Done.


plugins/wallabag.koplugin/main.lua line 912 at r10 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

concatenate the \n, don't bother translators with it

Though the part about not being too clever also goes. For localization it's generally preferable to write it out in full.

As a user I don't care about skipped at all tbh, that's almost always >0, and as a user I'm definitely not convinced that dynamically changing the message so everything is always somewhere else is desirable.

I'd just skip all the cleverness as a single message which clearly says 0 to serve users better, and it's better for translators as an added bonus.

Done.


plugins/wallabag.koplugin/main.lua line 931 at r10 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

cleverness works for these, but note the \n concat

Done.


plugins/wallabag.koplugin/main.lua line 1113 at r10 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

\n concat

Done.

Comment thread plugins/wallabag.koplugin/main.lua Outdated

request.method = method
if filepath ~= "" then
if filepath ~= nil then

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean it's okay if I include these checks? Or it's okay to leave it as is?

@Frenzie Frenzie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 of 2 files reviewed, 8 unresolved discussions (waiting on @harmtemolder and @poire-z)


plugins/wallabag.koplugin/main.lua line 1515 at r9 (raw file):

Previously, harmtemolder (hrm) wrote…

How do you feel about "offline_queue", because it's only used when adding articles when offline?

Yes, indeed, excellent. It's an offline (message/article) queue. 👍


plugins/wallabag.koplugin/main.lua line 208 at r10 (raw file):

Previously, harmtemolder (hrm) wrote…

So for my understanding: I should use "folder" in anything user facing and "directory" in variable names?

Close enough. It's indeed folder for user-facing. For the code it matters less but underlying C and callers/wrappers tend to use dir. What's clearer can be contextual, which also includes whatever it's currently named. (In the sense of don't randomly change things for weak reasons, at least mixed in with other changes.)


plugins/wallabag.koplugin/main.lua line 582 at r10 (raw file):

Previously, harmtemolder (hrm) wrote…

Unfortunately, https://app.wallabag.it/api/doc/ does not explain if an empty JSON will ever be returned from the /api/entries endpoint, but you're right, my wording here might not be correct.

I kept this check for nil because it was there before, but seeing that I've adapted callAPI to always give true/false as its first return value, it will never trigger: true is only ever returned when a valid JSON was returned by the wallabag API (or a filepath was provided, which is not the case here). So this check can be removed entirely.

Depending on the actual behavior it should then either be moved one up as not ok and result == nil or stay here as something along the general lines of #result == 0.


plugins/wallabag.koplugin/main.lua line 344 at r11 (raw file):

                                        path = filemanagerutil.abbreviate(self.archive_directory)
                                    end
                                    return T(_("Archive directory: %1"), BD.dirpath(path))

Archive folder


plugins/wallabag.koplugin/main.lua line 415 at r11 (raw file):

                    {
                        text = _("Send review as tags"),
                        help_text = _("This allows you to write tags in the review field, separated by commas, which will be uploaded to the article on Wallabag."),

added to or applied to the article


request.method = method
if filepath ~= "" then
if filepath ~= nil then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay to leave it as.

@Frenzie Frenzie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r12, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @harmtemolder)


plugins/wallabag.koplugin/main.lua line 876 at r12 (raw file):

        info = InfoMessage:new{
            text = T(
                _("Got a list of %1 articles…"),

Received


plugins/wallabag.koplugin/main.lua line 1597 at r12 (raw file):

end

function Wallabag:addToUploadQueue(article_url)

addToOfflineQueue


plugins/wallabag.koplugin/main.lua line 1069 at r12 (raw file):

            {
                text = self.server_url,
                --description = T(_("Server URL:")),

Don't randomly remove these.

@harmtemolder harmtemolder left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @Frenzie)


plugins/wallabag.koplugin/main.lua line 1515 at r9 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

Yes, indeed, excellent. It's an offline (message/article) queue. 👍

Done.


plugins/wallabag.koplugin/main.lua line 208 at r10 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

Close enough. It's indeed folder for user-facing. For the code it matters less but underlying C and callers/wrappers tend to use dir. What's clearer can be contextual, which also includes whatever it's currently named. (In the sense of don't randomly change things for weak reasons, at least mixed in with other changes.)

Done.


plugins/wallabag.koplugin/main.lua line 329 at r10 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

archive folder

Done.


plugins/wallabag.koplugin/main.lua line 582 at r10 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

Depending on the actual behavior it should then either be moved one up as not ok and result == nil or stay here as something along the general lines of #result == 0.

I have tried different calls to the wallabag API using Insomnium to see what is returned:

  • There is a pages parameter that we can use to stop us from having to rely on a 404 error to determine the last page (see below).
  • I do propose to leave the check for 404 in, just in case. But split in two:
    • If no articles were returned from previous pages, alert the user of the 404 error, because something else might be wrong
    • If articles were returned from previous pages, return those without alerting, because for whatever reason we might have blown past the last page
  • I did find a case where 0 items were returned: when a non-existing tag was used to filter. I was thinking of changing the last message to something like "Requesting article list did not return anything. Are your tag filters correctly set up?", but there might be other edge cases. What do you think?

plugins/wallabag.koplugin/main.lua line 344 at r11 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

Archive folder

Done.


plugins/wallabag.koplugin/main.lua line 415 at r11 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

added to or applied to the article

Done.


plugins/wallabag.koplugin/main.lua line 876 at r12 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

Received

Done.


plugins/wallabag.koplugin/main.lua line 1069 at r12 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

Don't randomly remove these.

Done.


plugins/wallabag.koplugin/main.lua line 1597 at r12 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

addToOfflineQueue

Done.


request.method = method
if filepath ~= "" then
if filepath ~= nil then

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@Frenzie Frenzie added this to the 2025.01 milestone Jan 6, 2025

@Frenzie Frenzie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r13, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @harmtemolder)


plugins/wallabag.koplugin/main.lua line 582 at r10 (raw file):

Previously, harmtemolder (hrm) wrote…

I have tried different calls to the wallabag API using Insomnium to see what is returned:

  • There is a pages parameter that we can use to stop us from having to rely on a 404 error to determine the last page (see below).
  • I do propose to leave the check for 404 in, just in case. But split in two:
    • If no articles were returned from previous pages, alert the user of the 404 error, because something else might be wrong
    • If articles were returned from previous pages, return those without alerting, because for whatever reason we might have blown past the last page
  • I did find a case where 0 items were returned: when a non-existing tag was used to filter. I was thinking of changing the last message to something like "Requesting article list did not return anything. Are your tag filters correctly set up?", but there might be other edge cases. What do you think?

If Wallabag doesn't distinguish between a tag with no articles associated and a non-existent tag I wouldn't editorialize it.

@harmtemolder harmtemolder left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @harmtemolder)


plugins/wallabag.koplugin/main.lua line 582 at r10 (raw file):

Previously, Frenzie (Frans de Jonge) wrote…

If Wallabag doesn't distinguish between a tag with no articles associated and a non-existent tag I wouldn't editorialize it.

Good point. I'll leave it as is

@Frenzie Frenzie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @harmtemolder)

@harmtemolder harmtemolder marked this pull request as ready for review January 9, 2025 12:15
@harmtemolder

Copy link
Copy Markdown
Contributor Author

I've been using the last revision on my Kobo for a couple of days now, and everything seems to be working as expected. Is there any process for testing this types of functionality before release?

And @poire-z thanks for pointing me to Trapper. That looks interesting, but I'll leave it out of this PR because it has already grown beyond what I initially set out to do.

Both of you (and especially @Frenzie) thanks for all your time and effort in getting my work up to the standards and conventions of KOReader.

@Frenzie

Frenzie commented Jan 9, 2025

Copy link
Copy Markdown
Member

Is there any process for testing this types of functionality before release?

If you feel confident we hand it to nightly testers so that it's not limited to you and me.

@Frenzie Frenzie merged commit 6a0aa95 into koreader:master Jan 12, 2025
0xstillb pushed a commit to 0xstillb/koreader-thai that referenced this pull request May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

3 participants