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):
|
||||
|
|
BIN
pythonrewrite/plugins/plugin_icon_unknown.png
Normal file
BIN
pythonrewrite/plugins/plugin_icon_unknown.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
|
@ -88,6 +88,6 @@ def:print_form_header(form_name, action) ?><?cs #
|
|||
|
||||
def:show_plugin(plugin) ?><?cs
|
||||
# show the icon and the name of this plugin
|
||||
?><div<?cs each:x=Settings.PluginList[plugin].Types ?> class="plugin_<?cs var:html_escape(name(x)) ?><?cs /each ?>"><img src="<?cs call:link('plugins/' + plugin, 'icon','x','','') ?>" alt="<?cs var:html_escape('icon: ' + plugin) ?>" /><br/><?cs var:html_escape(Settings.PluginList[plugin].Link) ?></div><?cs
|
||||
?><a href="<?cs call:link('plugins/' + plugin,'','','','') ?>" title="<?cs var:html_escape(Settings.PluginList[plugin].Name) ?>"><div<?cs each:x=Settings.PluginList[plugin].Types ?> class="plugin_<?cs var:html_escape(name(x)) ?><?cs /each ?>"><img src="<?cs call:link('icons/plugins/' + plugin, '','','','') ?>" alt="<?cs var:html_escape('icon: ' + plugin) ?>" /><br/><?cs var:html_escape(Settings.PluginList[plugin].Link) ?></div></a><?cs
|
||||
/def ?>
|
||||
|
||||
|
|
|
@ -454,6 +454,9 @@ div.plugin_main, div.plugin_system, div.plugin_volume {
|
|||
margin: 5px;
|
||||
}
|
||||
|
||||
div.plugin_main img, div.plugin_system img, div.plugin_volume img {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
div.plugin_main {
|
||||
width: 80px;
|
||||
|
|
Loading…
Reference in a new issue