default plugin icon added
plugins moved to /icons/plugins/PLUGINNAME
This commit is contained in:
parent
662be231b9
commit
5ca5164a50
5 changed files with 36 additions and 3 deletions
|
@ -4,6 +4,7 @@
|
|||
#
|
||||
|
||||
import os
|
||||
import cherrypy
|
||||
|
||||
|
||||
class CryptoBoxPlugin:
|
||||
|
@ -22,7 +23,7 @@ class CryptoBoxPlugin:
|
|||
|
||||
|
||||
## default icon of this plugin (relative path)
|
||||
iconFile = "plugin_icon.png"
|
||||
defaultIconFileName = "plugin_icon.png"
|
||||
|
||||
|
||||
def __init__(self, cbox, pluginDir):
|
||||
|
@ -47,10 +48,14 @@ class CryptoBoxPlugin:
|
|||
return self.__module__
|
||||
|
||||
|
||||
@cherrypy.expose
|
||||
def getIcon(self):
|
||||
"""return the image data of the icon of the plugin"""
|
||||
import cherrypy
|
||||
return cherrypy.lib.cptools.serveFile(os.path.join(self.pluginDir, self.iconFile))
|
||||
plugin_icon_file = os.path.join(self.pluginDir, self.defaultIconFileName)
|
||||
if not os.access(plugin_icon_file, os.R_OK):
|
||||
plugin_icon_file = os.path.join(self.cbox.prefs["Locations"]["PluginDir"], "plugin_icon_unknown.png")
|
||||
return cherrypy.lib.cptools.serveFile(plugin_icon_file)
|
||||
|
||||
|
||||
def getTemplateFileName(self, template_name):
|
||||
|
|
|
@ -20,6 +20,29 @@ class WebInterfacePlugins:
|
|||
#setattr(getattr(self, plname), "stream_respones", True)
|
||||
|
||||
|
||||
class IconHandler:
|
||||
|
||||
def __init__(self, plugins):
|
||||
self.plugins = PluginIconHandler(plugins)
|
||||
self.plugins.exposed = True
|
||||
|
||||
|
||||
class PluginIconHandler:
|
||||
|
||||
def __init__(self, plugins):
|
||||
for plugin in plugins.getPlugins():
|
||||
if not plugin: continue
|
||||
plname = plugin.getName()
|
||||
## this should be the "easiest" way to expose all plugins as URLs
|
||||
x = lambda: plugin.getIcon()
|
||||
print x
|
||||
print plugin.getIcon
|
||||
def getIcon(p):
|
||||
return p.getIcon()
|
||||
setattr(self, plname, plugin.getIcon)
|
||||
## the function is exposed in the CryptoBoxPlugin class - it did not work here
|
||||
|
||||
|
||||
|
||||
class WebInterfaceSites:
|
||||
'''
|
||||
|
@ -46,6 +69,8 @@ class WebInterfaceSites:
|
|||
## publish the url "/system" as an alias for "/plugins"
|
||||
self.plugins.index = self.system
|
||||
self.dataset = WebInterfaceDataset.WebInterfaceDataset(self.cbox, self.prefs, self.pluginList.getPlugins())
|
||||
## publish plugin icons
|
||||
self.icons = IconHandler(self.pluginList)
|
||||
|
||||
|
||||
def __check_config(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue