Skip to content

Move to archive plugin#6101

Merged
Frenzie merged 38 commits intokoreader:masterfrom
mwoz123:move-to-archive
May 2, 2020
Merged

Move to archive plugin#6101
Frenzie merged 38 commits intokoreader:masterfrom
mwoz123:move-to-archive

Conversation

@mwoz123
Copy link
Copy Markdown
Contributor

@mwoz123 mwoz123 commented Apr 28, 2020

Plugin to move/copy current reading book to archive folder

Zrzut ekranu z 2020-04-28 20-58-19


This change is Reviewable

@Frenzie Frenzie added this to the 2020.05 milestone Apr 29, 2020
@Frenzie Frenzie added the Plugin label Apr 29, 2020
Copy link
Copy Markdown
Member

@Frenzie Frenzie left a comment

Choose a reason for hiding this comment

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

Interesting concept!

"zsync",
"news_downloader",
"send2ebook",
"moveToArchive",
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.

This pushes more plugins to the next page, not necessarily the best move.

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.

ok will be last here.

@Robertmccalister747
Copy link
Copy Markdown

Robertmccalister747 commented Apr 29, 2020 via email

@mwoz123
Copy link
Copy Markdown
Contributor Author

mwoz123 commented Apr 29, 2020

@Robertmccalister747 I don't understand what you mean. Code is in this repo/PR.

@mwoz123
Copy link
Copy Markdown
Contributor Author

mwoz123 commented Apr 29, 2020

Interesting concept!

Thanks:)

@mwoz123
Copy link
Copy Markdown
Contributor Author

mwoz123 commented Apr 29, 2020

Changes done.

@mwoz123
Copy link
Copy Markdown
Contributor Author

mwoz123 commented Apr 29, 2020

Changes done.

Copy link
Copy Markdown
Member

@Frenzie Frenzie left a comment

Choose a reason for hiding this comment

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

A few minor string nitpicks

end

function MoveToArchive:copyToArchive()
local copy_done_text =_("Book copied. \nDo you want to open it from archive folder?")
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.

Suggested change
local copy_done_text =_("Book copied. \nDo you want to open it from archive folder?")
local copy_done_text =_("Book copied.\nDo you want to open it from the archive folder?")


function MoveToArchive:addToMainMenu(menu_items)
menu_items.move_to_archive = {
text = _("Move to Archive"),
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.

Suggested change
text = _("Move to Archive"),
text = _("Move to archive"),

"news_downloader",
"send2ebook",
"text_editor",
"move_to_archive",
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.

I'm inclined to think this would fit better near progress_sync if we insert it in this part of the menu. The more_plugins menu will be pushed down no matter where above it you insert an extra entry.

Pinging @NiLuJe @poire-z @pazos for some thoughts.

Copy link
Copy Markdown
Contributor

@poire-z poire-z Apr 29, 2020

Choose a reason for hiding this comment

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

I guess the more_plugins menu isn't really needed anymore, now that the user can disable the plugins he doesn't need.
If you put some in more_plugins, no matter the user cleaning, he would have to tap once more to reach that unfortunate plugin we put into more_plugins.
If we'd want to keep more_plugins, only non-user-action plugins (those with only settings or some permanent behaviour) should go in there.
So, I wouldn't mind an initial Plugins menu with 20 items :) as I can clean it up to the 5 that matters to me.

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.

Yes, I have only a few plugins activated, and definitely do not need More plugins menu.

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.

I agree that the more plugins menu in not necessary, and just annoying for the plugins that i use that are there. (I only use ~5 plugins)

@mwoz123
Copy link
Copy Markdown
Contributor Author

mwoz123 commented Apr 29, 2020

A few minor string nitpicks

Resolved

Copy link
Copy Markdown
Member

@Frenzie Frenzie left a comment

Choose a reason for hiding this comment

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

lgtm, letting it sit for another day or maybe two in case anybody else has any comments

@mwoz123
Copy link
Copy Markdown
Contributor Author

mwoz123 commented Apr 29, 2020

Btw off topic : do we still need "more plugins" as there's something like "next page" in menu if there're too many entries?

Imho it's misleading.

@Frenzie
Copy link
Copy Markdown
Member

Frenzie commented Apr 29, 2020

Like @poire-z said we should organize it differently.

@poire-z
Copy link
Copy Markdown
Contributor

poire-z commented Apr 29, 2020

Just unsure what's happening when moving:

  • you're currently reading a book
  • you move the book file (only the file, not the docsetting (book.sdr/metadata.lua ?)
  • you quit the book, the docsetting is saved and stays at the old place?

If that is what's really happening, you have:

  1. and old docsetting unused and dangling
  2. possibilities for undefined behaviours in other contexts as that's a case we don't expect until now: having the book opened but no underlying file anymore

In FileManager, when we move/rename a file (and we do that the book closed), there are a bit more stuff taken care of:

local function infoMoveFile()
-- if we move a file, also move its sidecar directory
if DocSettings:hasSidecarFile(orig) then
self:moveFile(DocSettings:getSidecarDir(orig), dest) -- dest is always a directory
end
if self:moveFile(orig, dest) then
-- Update history and collections.
local dest_file = string.format("%s/%s", dest, BaseUtil.basename(orig))
require("readhistory"):updateItemByPath(orig, dest_file)
ReadCollection:updateItemByPath(orig, dest_file)
-- Update last open file.
if G_reader_settings:readSetting("lastfile") == orig then
G_reader_settings:saveSetting("lastfile", dest_file)
end
UIManager:show(InfoMessage:new {
text = T(_("Moved to: %1"), BD.dirpath(dest)),
timeout = 2,
})
else
UIManager:show(InfoMessage:new {
text = T(_("An error occurred while trying to move %1"), BD.filepath(orig)),
timeout = 2,
})
end
end

@mwoz123
Copy link
Copy Markdown
Contributor Author

mwoz123 commented Apr 29, 2020

Ok, cool off topic extracted to : #6105

@mwoz123
Copy link
Copy Markdown
Contributor Author

mwoz123 commented Apr 29, 2020

@poire-z right sdr is currently not moved.

This was designed mainly for wallabag /nd/S2E so it shouldn't be a big issue.

But anyway I wanted to add this next PR.
Are you ok with that?

@poire-z
Copy link
Copy Markdown
Contributor

poire-z commented Apr 29, 2020

This was designed mainly for wallabag /nd/S2E so it shouldn't be a big issue.
But anyway I wanted to add this next PR.
Are you ok with that?

Files lying around is an issue for me :) People might test it tomorrow if merged, and that's rather not cool leaving mess on their device.
It's a plugin, so I wouldn't really mind it having bugs. But now that you know of them, it would be a bit unfortunate to not fix them before merging :)

But I reckon it's not easy fixing... Even if you move the docsettings, it will be saved at the old place when the book is closed. So, ideally, when moving, you would ask/tell the user that the file will be moved and re-opened, and if he says OK: close the book, move file + docsettings, re-open the book from the archived file (and if you propose and option to not re-open the book, what to do from there?).
And when you close the book, your plugin is gone... so... not easy (may be adding a after_close_callback in ReaderUI:switchDocument() like it's done for ReaderUI:reloadDocument(after_close_callback) )

Anyway, I let @Frenzie decide how critical that is :)
(I won't use this plugin, I don't really mind people testing it having mess on their devices, and it would probably take us quite a bit of time to help you getting it fully right :)

@Frenzie
Copy link
Copy Markdown
Member

Frenzie commented Apr 29, 2020

I didn't realize it didn't deal with SDRs properly; I'd definitely prefer to see that fixed first too.

@mwoz123
Copy link
Copy Markdown
Contributor Author

mwoz123 commented Apr 29, 2020

Ok will try.
Can you help me how to force close current book or force save unsaved book progress/changes in sdr?

@poire-z
Copy link
Copy Markdown
Contributor

poire-z commented Apr 29, 2020

Can you help me how to force close current book or force save unsaved book progress/changes in sdr?

$ rgrep ui:onClose frontend/
frontend/apps/reader/modules/readermenu.lua:                self.ui:onClose()
frontend/apps/reader/modules/readermenu.lua:        self.ui:onClose()
frontend/apps/reader/modules/readergesture.lua:        self.ui:onClose()
frontend/apps/reader/modules/readerstatus.lua:    self.ui:onClose()

But it mostly depends on what you want to do after (open another document, go to file browser, exit koreader).

It's a bit unclear to me what's your workflow with this plugin (and what it will be for other people):

  • do you really need/want to stay reading the book after you archived it? Isn't it something you do when you're done with it?
  • if that's something you invoke at end of book, it could just be a new item in "Gear > Document > End of document action" and in it's "ask with popup dialog" - in which case, one just have to "go to end of book" to invoke this action/popup.
  • does "copy to archive folder" has some use case?

mwoz123 and others added 8 commits May 2, 2020 18:24
Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>
Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>
Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>
Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>
Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>
Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>

local MoveToArchive = WidgetContainer:new{
name = "move2archive",
move_to_archive_settings = nil,
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.

I can't tell what you're referring to in EverNote, but PerceptionExpander surely does not:

local PerceptionExpander = Widget:extend{
is_enabled = nil,
name = "perceptionexpander",
page_counter = 0,
shift_each_pages = 100,
margin = 0.1,
line_thickness = 2,
line_color_intensity = 0.3,
margin_shift = 0.03,
settings = nil,
ALMOST_CENTER_OF_THE_SCREEN = 0.37,
last_screen_mode = nil
}

Note how it says settings, not perception_expander_settings.

NB Other plugins do it too is not a good argument.

mwoz123 and others added 5 commits May 2, 2020 19:47
Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>
Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>
@mwoz123
Copy link
Copy Markdown
Contributor Author

mwoz123 commented May 2, 2020

done

Copy link
Copy Markdown
Member

@Frenzie Frenzie left a comment

Choose a reason for hiding this comment

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

Should be okay, good by you @poire-z ?

@poire-z
Copy link
Copy Markdown
Contributor

poire-z commented May 2, 2020

Looks fine, no more comment.

@Frenzie Frenzie merged commit ce3bf47 into koreader:master May 2, 2020
@Frenzie
Copy link
Copy Markdown
Member

Frenzie commented May 2, 2020

Thanks @mwoz123 !

@mwoz123 mwoz123 deleted the move-to-archive branch May 3, 2020 05:06
@poire-z
Copy link
Copy Markdown
Contributor

poire-z commented May 3, 2020

Can't be disabled. I guess it needs the names to be coherent with the plugin directory name:

--- a/plugins/movetoarchive.koplugin/_meta.lua
+++ b/plugins/movetoarchive.koplugin/_meta.lua
@@ -1,6 +1,6 @@
 local _ = require("gettext")
 return {
-    name = "move_to_archive",
+    name = "movetoarchive",
     fullname = _("Move to archive"),
     description = _([[Moves/copies current book to archive folder]]),
 }
diff --git a/plugins/movetoarchive.koplugin/main.lua b/plugins/movetoarchive.koplugin/main.lua
index f575a849..08cba643 100644
--- a/plugins/movetoarchive.koplugin/main.lua
+++ b/plugins/movetoarchive.koplugin/main.lua
@@ -14,7 +14,7 @@ local BaseUtil = require("ffi/util")
 local _ = require("gettext")

 local MoveToArchive = WidgetContainer:new{
-    name = "move2archive",
+    name = "movetoarchive",
 }

 function MoveToArchive:init()

Frenzie pushed a commit that referenced this pull request May 3, 2020
Mismatches in these names prevent this plugin from being disabled'able. #6101 (comment)
@Robertmccalister747
Copy link
Copy Markdown

Robertmccalister747 commented May 5, 2020 via email

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants