mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
@@ -28,6 +28,9 @@ function ReaderMenu:init()
|
||||
typeset = {
|
||||
icon = "resources/icons/appbar.page.text.png",
|
||||
},
|
||||
plugins = {
|
||||
icon = "resources/icons/appbar.tools.png",
|
||||
},
|
||||
home = {
|
||||
icon = "resources/icons/appbar.home.png",
|
||||
callback = function()
|
||||
@@ -105,6 +108,7 @@ function ReaderMenu:onShowReaderMenu()
|
||||
self.tab_item_table.navi,
|
||||
self.tab_item_table.typeset,
|
||||
self.tab_item_table.main,
|
||||
self.tab_item_table.plugins,
|
||||
self.tab_item_table.home,
|
||||
},
|
||||
show_parent = menu_container,
|
||||
|
||||
44
frontend/apps/reader/pluginloader.lua
Normal file
44
frontend/apps/reader/pluginloader.lua
Normal file
@@ -0,0 +1,44 @@
|
||||
local DEBUG = require("dbg")
|
||||
-- lfs
|
||||
|
||||
local PluginLoader = {
|
||||
plugin_path = lfs.currentdir().."/plugins"
|
||||
}
|
||||
|
||||
function PluginLoader:loadPlugins()
|
||||
if self.plugins then return self.plugins end
|
||||
|
||||
self.plugins = {}
|
||||
for f in lfs.dir(self.plugin_path) do
|
||||
local path = self.plugin_path.."/"..f
|
||||
local mode = lfs.attributes(path, "mode")
|
||||
-- valid koreader plugin directory
|
||||
if mode == "directory" and f:find(".+%.koplugin$") then
|
||||
local mainfile = path.."/".."main.lua"
|
||||
local package_path = package.path
|
||||
local package_cpath = package.cpath
|
||||
package.path = path.."/?.lua;"..package.path
|
||||
package.cpath = path.."/lib/?.so;"..package.cpath
|
||||
local ok, module = pcall(require, "main")
|
||||
if not ok then
|
||||
DEBUG("Error when loading", mainfile, module)
|
||||
end
|
||||
package.path = package_path
|
||||
package.cpath = package_cpath
|
||||
if ok then
|
||||
module.path = path
|
||||
table.insert(self.plugins, module)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for _,plugin in ipairs(self.plugins) do
|
||||
package.path = package.path..";"..plugin.path.."/?.lua"
|
||||
package.cpath = package.cpath..";"..plugin.path.."/lib/?.so"
|
||||
end
|
||||
|
||||
return self.plugins
|
||||
end
|
||||
|
||||
return PluginLoader
|
||||
|
||||
@@ -31,6 +31,7 @@ local ReaderDictionary = require("apps/reader/modules/readerdictionary")
|
||||
local ReaderHyphenation = require("apps/reader/modules/readerhyphenation")
|
||||
local ReaderActivityIndicator = require("apps/reader/modules/readeractivityindicator")
|
||||
local ReaderLink = require("apps/reader/modules/readerlink")
|
||||
local PluginLoader = require("apps/reader/pluginloader")
|
||||
|
||||
--[[
|
||||
This is an abstraction for a reader interface
|
||||
@@ -261,6 +262,18 @@ function ReaderUI:init()
|
||||
document = self.document,
|
||||
})
|
||||
end
|
||||
|
||||
-- koreader plugins
|
||||
for _,module in ipairs(PluginLoader:loadPlugins()) do
|
||||
DEBUG("Loaded plugin", module.path)
|
||||
table.insert(self, module:new{
|
||||
dialog = self.dialog,
|
||||
view = self[1],
|
||||
ui = self,
|
||||
document = self.document,
|
||||
})
|
||||
end
|
||||
|
||||
--DEBUG(self.doc_settings)
|
||||
-- we only read settings after all the widgets are initialized
|
||||
self:handleEvent(Event:new("ReadSettings", self.doc_settings))
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!./koreader-base
|
||||
|
||||
require "defaults"
|
||||
package.path = "./frontend/?.lua;./?.lua"
|
||||
package.cpath = "?.so;/usr/lib/lua/?.so"
|
||||
package.path = "?.lua;common/?.lua;frontend/?.lua"
|
||||
package.cpath = "?.so;common/?.so;/usr/lib/lua/?.so"
|
||||
|
||||
local DocSettings = require("docsettings")
|
||||
local _ = require("gettext")
|
||||
|
||||
BIN
resources/icons/appbar.tools.png
Normal file
BIN
resources/icons/appbar.tools.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
Reference in New Issue
Block a user