Skip to content

Commit

Permalink
move opds to plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
pazos committed Feb 4, 2021
1 parent a43da51 commit 6ef71c1
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 4 deletions.
6 changes: 6 additions & 0 deletions plugins/opds.koplugin/_meta.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
local _ = require("gettext")
return {
name = "opds",
fullname = _("OPDS"),
description = _([[OPDS allows you to download books from online catalogs.]]),
}
47 changes: 47 additions & 0 deletions plugins/opds.koplugin/main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
local Dispatcher = require("dispatcher")
local UIManager = require("ui/uimanager")
local WidgetContainer = require("ui/widget/container/widgetcontainer")
local _ = require("gettext")

local OPDS = WidgetContainer:new{
name = "opds",
is_doc_only = false,
}

function OPDS:onDispatcherRegisterActions()
Dispatcher:registerAction("opds_show_catalog",
{category="none", event="ShowOPDSCatalog", title=_("OPDS Catalog"), filemanager=true,}
)
end

function OPDS:init()
self:onDispatcherRegisterActions()
self.ui.menu:registerToMainMenu(self)
end

function OPDS:showCatalog()
local OPDSCatalog = require("opdscatalog")
local filemanagerRefresh = function() self.ui:onRefresh() end
function OPDSCatalog:onClose()
filemanagerRefresh()
UIManager:close(self)
end
OPDSCatalog:showCatalog()
end

function OPDS:onShowOPDSCatalog()
self:showCatalog()
return true
end

function OPDS:addToMainMenu(menu_items)
if not self.ui.view then
menu_items.opds = {
text = _("OPDS catalog"),
sorting_hint = "search",
callback = function() self:showCatalog() end
}
end
end

return OPDS
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ local Menu = require("ui/widget/menu")
local MultiInputDialog = require("ui/widget/multiinputdialog")
local InputDialog = require("ui/widget/inputdialog")
local NetworkMgr = require("ui/network/manager")
local OPDSParser = require("ui/opdsparser")
local OPDSParser = require("opdsparser")
local Screen = require("device").screen
local UIManager = require("ui/uimanager")
local http = require('socket.http')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local Blitbuffer = require("ffi/blitbuffer")
local ConfirmBox = require("ui/widget/confirmbox")
local FrameContainer = require("ui/widget/container/framecontainer")
local InputContainer = require("ui/widget/container/inputcontainer")
local OPDSBrowser = require("ui/widget/opdsbrowser")
local OPDSBrowser = require("opdsbrowser")
local ReaderUI = require("apps/reader/readerui")
local UIManager = require("ui/uimanager")
local logger = require("logger")
Expand Down
File renamed without changes.
11 changes: 9 additions & 2 deletions spec/unit/opds_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,18 @@ local facet_sample = [[

describe("OPDS module #nocov", function()
local OPDSParser, OPDSBrowser
local orig_path

setup(function()
orig_path = package.path
package.path = "plugins/opds.koplugin/?.lua;" .. package.path
require("commonrequire")
OPDSParser = require("ui/opdsparser")
OPDSBrowser = require("ui/widget/opdsbrowser")
OPDSParser = require("opdsparser")
OPDSBrowser = require("opdsbrowser")
end)

teardown(function()
package.path = orig_path
end)

describe("OPDS parser module", function()
Expand Down

0 comments on commit 6ef71c1

Please sign in to comment.