示例#1
0
文件: __init__.py 项目: mmspide/Prism
    def delete_site(self, site_uuid):
        """ Removes configs from nginx and jack, folders
        created for the site, and the menu item """
        del prism.flask_app().extensions['menu']._child_entries[self._jack_plugin._endpoint]._child_entries[site_uuid]
        site_config = self.configs[site_uuid]

        site_folder = os.path.join(self._jack_plugin.site_files_location, site_uuid)

        # Remove the jack configuration file
        os.remove(os.path.join(self.config_location, site_uuid + '.conf'))

        # Remove the site folder
        if os.path.exists(site_folder):
            shutil.rmtree(site_folder)

        # Gets the default configuration the site used
        # and runs its delete method for cleanup
        default_config = JackPlugin.get().get_default_config(site_config['type'])
        default_config.delete(site_config)

        site_config.delete()
        del self.configs[site_uuid]

        # Regen nginx configuration files
        self.rebuild_sites()
示例#2
0
文件: __init__.py 项目: mmspide/Prism
    def init(self, prism_state):
        self._available_widgets = {}
        self._widgets = self.config('widgets', {})

        # Search the plugins for Widget classes
        for plugin_id, plugin, name, obj in prism_state.plugin_manager.find_classes(
                Widget):
            widget = obj()
            widget.plugin_id = plugin.plugin_id
            widget.widget_id = plugin.plugin_id + '.' + widget.widget_id
            self._available_widgets[widget.widget_id] = widget

            if widget.widget_id not in self._widgets:
                self._widgets[widget.widget_id] = {
                    'shown': True,
                    'order': len(self._available_widgets)
                }

        logging.output('Registered %s widgets' % len(self._available_widgets))
        prism.flask_app(
        ).jinja_env.globals["render_widget"] = self.render_widget
示例#3
0
文件: helpers.py 项目: alenz33/Prism
import math
import os
import time
from datetime import datetime

from docutils.core import publish_string
from docutils.writers.html4css1 import Writer, HTMLTranslator
import flask
import jinja2

import prism
import prism.settings

flask_app = prism.flask_app()


def next_color(i):
    """ Provides a way to loop through a list of colors in templates """
    colors = [
        '#337AB7', '#00A65A', '#F39C12', '#DD4B39', '#4682B4', '#20B2AA',
        '#FFD700', '#00FA9A', '#7B68EE', '#FF00FF', '#20B2AA', '#BC8F8F',
        '#8B008B', '#008000', '#000080'
    ]
    return colors[i % len(colors)]


flask_app.jinja_env.globals["next_color"] = next_color

flask_app.jinja_env.globals[
    "generate_random_string"] = prism.generate_random_string