Exemple #1
0
    def render(self):
        # FIXME: move theme management to a plugin !
        if env.request.user:
            theme = env.request.user.get_property(
                "theme", default=env.config.general.default_theme)
            lang = env.request.user.get_property(
                "language", default=env.config.general.default_locale)
        else:
            theme = env.config.general.default_theme
            lang = env.config.general.default_locale

        _HEAD = copy.copy(_CSS_FILES)
        _HEAD[resource.CSSLink("prewikka/css/themes/%s.css" % theme)] = True
        _HEAD.update(_JS_FILES)

        # The jqgrid locale files use only two characters for identifying the language (e.g. pt_BR -> pt)
        _HEAD[resource.JSLink("prewikka/js/locales/grid.locale-%s.min.js" %
                              lang[:2])] = True

        for contents in filter(None,
                               hookmanager.trigger("HOOK_LOAD_HEAD_CONTENT")):
            _HEAD.update((i, True) for i in contents)

        _BODY = utils.OrderedDict()
        for contents in filter(None,
                               hookmanager.trigger("HOOK_LOAD_BODY_CONTENT")):
            _BODY.update((i, True) for i in contents)

        env.request.dataset["document"].head_content = _HEAD
        env.request.dataset["document"].body_content = _BODY
        env.request.dataset["toplayout_extra_content"] = filter(
            None, hookmanager.trigger("HOOK_TOPLAYOUT_EXTRA_CONTENT"))
Exemple #2
0
    def __init__(self):
        self._data = local()
        self._catalogs = {}
        self._catalogs_lock = Lock()

        self._domains_lock = Lock()
        self._domains = utils.OrderedDict([
            ("prewikka", pkg_resources.resource_filename(__name__, "locale"))
        ])
Exemple #3
0
    def __init__(self, path):
        PrewikkaResponse.__init__(self)

        self.fd = open(path, "rb")
        stat = os.fstat(self.fd.fileno())

        content_type = mimetypes.guess_type(env.request.web.path)[0] or "application/octet-stream"

        self.headers = utils.OrderedDict((('Content-Type', content_type),
                                          ('Content-Length', str(stat[6])),
                                          ('Last-Modified', time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(stat[8])))
                                        ))
Exemple #4
0
    def __init__(self, data=None, headers=_sentinel, code=None, status_text=None):
        self.data = data
        self.code = code or 200
        self.status_text = status_text
        self.ext_content = {}

        if headers is not _sentinel:
            self.headers = headers
        else:
            self.headers = utils.OrderedDict((("Content-Type", "text/html"),
                                              ("Last-Modified", time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime())),
                                              ("Expires", "Fri, 01 Jan 1999 00:00:00 GMT"),
                                              ("Cache-control", "no-store, no-cache, must-revalidate"),
                                              ("Cache-control", "post-check=0, pre-check=0"),
                                              ("Pragma", "no-cache")))
Exemple #5
0
 def __init__(self, name):
     object.__setattr__(self, "_instance_name", name)
     object.__setattr__(self, "_od", utils.OrderedDict())
Exemple #6
0
 def __init__(self):
     self._sections = utils.OrderedDict()
Exemple #7
0
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

from __future__ import absolute_import, division, print_function, unicode_literals

import copy

from prewikka import hookmanager, resource, template, utils, view

_CSS_FILES = utils.OrderedDict(
    (resource.CSSLink(link), True)
    for link in ("prewikka/css/jquery-ui.min.css",
                 "prewikka/css/bootstrap.min.css",
                 "prewikka/css/jquery-ui-timepicker-addon.min.css",
                 "prewikka/css/font-awesome.min.css",
                 "prewikka/css/ui.jqgrid.min.css",
                 "prewikka/css/ui.multiselect.min.css",
                 "prewikka/css/loader.css"))

_JS_FILES = utils.OrderedDict(
    (resource.JSLink(link), True)
    for link in ("prewikka/js/jquery.js", "prewikka/js/jquery-ui.min.js",
                 "prewikka/js/bootstrap.min.js", "prewikka/js/functions.js",
                 "prewikka/js/ajax.js", "prewikka/js/underscore-min.js",
                 "prewikka/js/jquery-ui-timepicker-addon.min.js",
                 "prewikka/js/ui.multiselect.min.js",
                 "prewikka/js/jquery.jqgrid.min.js",
                 "prewikka/js/commonlisting.js"))
Exemple #8
0
 def __init__(self, location, code=302, status_text=None):
     PrewikkaResponse.__init__(self, code=code, status_text=status_text or "%d Redirect" % code)
     self.headers = utils.OrderedDict((('Location', location),))