Ejemplo n.º 1
0
class YuiWidget(twc.Widget):
    resources = [
        twc.DirLink(modname=__name__, filename="static/" + yui_version + "/"),
        twc.CSSLink(modname=__name__,
                    filename="static/" + yui_version + "/fonts/fonts-min.css"),
        twc.JSLink(modname=__name__,
                   filename="static/" + yui_version +
                   "/yahoo-dom-event/yahoo-dom-event.js"),
    ]
    options = twc.Param(
        'Configuration options for the widget. See the YUI docs for available options.',
        default={})

    def prepare(self):
        super(YuiWidget, self).prepare()
        self.options = twc.encoder.encode(self.options)
Ejemplo n.º 2
0
class WbPage(twc.Page):
    _no_autoid = True
    resources = [
        twc.CSSLink(modname=__name__, filename='static/css/reset.css'),
        twc.CSSLink(modname=__name__, filename='static/css/core.css'),
        twc.CSSLink(modname=__name__, filename='static/css/grid.css'),
        twc.CSSLink(modname=__name__, filename='static/css/pygments.css'),
        twc.DirLink(modname=__name__, filename='static/')
    ]

    template = "genshi:tw2.devtools.templates.wb_page"

    def prepare(self):
        super(WbPage, self).prepare()
        self.modules = sorted(ep.module_name
                              for ep in pr.iter_entry_points('tw2.widgets')
                              if not ep.module_name.endswith('.samples'))
        self.pypi = xmlrpclib.ServerProxy('http://pypi.python.org/pypi')

    @memoize.memoize
    def _pypi_versions(self, module):
        versions = self.pypi.package_releases(module, True)
        return versions

    @memoize.memoize
    def pypi_version(self, module):
        versions = self.pypi.package_releases(module)
        if len(versions):
            return versions[0]
        return '----'

    @memoize.memoize
    def pypi_downloads(self, module):
        return sum([
            sum([
                d['downloads']
                for d in self.pypi.release_urls(module, version)
            ]) for version in self._pypi_versions(module)
        ])
Ejemplo n.º 3
0
import tw2.core as twc

from moksha.wsgi.widgets.api.socket import AbstractMokshaSocket
from kitchen.iterutils import iterate

orbited_host = twc.Required
orbited_port = twc.Required
orbited_scheme = twc.Required

jsio_js = twc.JSLink(
    filename='static/jsio/jsio.js',
    modname=__name__)

amqp_resources = twc.DirLink(
    filename='static/',
    modname=__name__)


def amqp_subscribe(topic):
    """ Return a javascript callback that subscribes to a given topic,
        or a list of topics.
    """
    sub = """
        moksha.debug("Subscribing to the '%(topic)s' topic");
        var receiver = moksha_amqp_session.receiver('amq.topic/%(topic)s')
        receiver.onReady = raw_msg_callback;
        receiver.capacity(0xFFFFFFFF);
    """
    return ''.join([sub % {'topic': t} for t in iterate(topic)])
Ejemplo n.º 4
0
from moksha.lib.helpers import when_ready

modname = __name__

jquery_mbmenu_js = twc.JSLink(modname=modname, filename='static/mbMenu.js')
jquery_mbmenu_min_js = twc.JSLink(modname=modname,
                                  filename='static/mbMenu.min.js')

mbmenu_css_1 = twc.CSSLink(modname=modname,
                           filename='static/css/menu1.css',
                           media='screen')
mbmenu_css = twc.CSSLink(modname=modname,
                         filename='static/css/menu.css',
                         media='screen')
mbmenu_resources = twc.DirLink(modname=modname,
                               filename='static/images',
                               media='screen')


# TODO -- this should be broken out into tw2.jqplugins.mbmenu
class MokshaMenuBase(twc.Widget):
    template = "mako:moksha.apps.menus.templates.mbmenu"
    resources = [
        jquery_js,
        jquery_mbmenu_min_js,
        mbmenu_css_1,
        mbmenu_resources,
    ]

    rootMenuSelector = 'rootVoices'
    menuSelector = 'menuContainer'
Ejemplo n.º 5
0
import re
import os

import tw2.core as twc
from pkg_resources import ResourceManager

rm = ResourceManager()

tinymce_dir = twc.DirLink(modname=__name__, filename="static/tiny_mce")
#tinymce_js = twc.JSLink(modname=__name__, filename='static/tinymce.js')
#tinymce_css = twc.CSSLink(modname=__name__, filename='static/tinymce.css')
tinymce_js = twc.JSLink(modname=__name__,
                        filename='static/tiny_mce/tiny_mce_src.js',
                        init=twc.js_function('tinyMCE.init'))


def _get_available_languages():
    filename_re = re.compile(r'(\w+)\.js')
    langs = []
    locale_dir = rm.resource_filename(__name__, "static/tiny_mce/langs")
    for filename in os.listdir(locale_dir):
        match = filename_re.match(filename)
        if match:
            langs.append(match.groups(0)[0])
    return langs


from formencode.validators import UnicodeString, Validator
from genshi.core import Markup, stripentities

Ejemplo n.º 6
0
from tw2.jquery import jquery_js

from moksha.api.widgets.orbited import orbited_js

irc2_js = twc.JSLink(filename='static/irc2.js',
                 modname=__name__)

willowchat_js = twc.JSLink(filename='static/willowchat.js',
                       modname=__name__)

gui_js = twc.JSLink(filename='static/gui.js',
                modname=__name__)

willowchat_css = twc.CSSLink(filename='static/style.css', modname=__name__)

static_dir = twc.DirLink(filename='static', modname=__name__)


class LiveChatWidget(twc.Widget):
    name = 'Chat'
    template = 'mako:moksha.apps.chat.templates.chatwidget'
    bootstrap = twc.Param(default=twc.JSLink(link='/apps/chat/bootstrap'))
    visible = False
    resources = [static_dir]


class LiveChatFrameWidget(twc.Widget):
    template = 'mako:moksha.apps.chat.templates.chat'
    resources= [jquery_js, orbited_js, willowchat_js, irc2_js, gui_js,
                willowchat_css, static_dir]
Ejemplo n.º 7
0
import uuid
import tw2.core as twc
from tw2.core.resources import encoder
from tw2.jquery import jquery_js
from tw2.jquery.base import jQuery
from tw2.jqplugins.ui.base import jquery_ui_js

from moksha.api.widgets.live import LiveWidget
from moksha.api.widgets.live import subscribe_topics, unsubscribe_topics

container_js = twc.JSLink(filename='static/js/mbContainer.min.js',
                          modname=__name__)
container_css = twc.CSSLink(filename='static/css/mbContainer.css',
                            modname=__name__)
container_resources = twc.DirLink(filename='static/css/elements',
                                  modname=__name__)


# TODO -- this should extend from an as yet unwritten tw2 container (nb?)
# TODO -- should this extend from moksha/api/widgets/containers ?  duplication?
class MokshaContainer(twc.Widget):
    template = 'mako:moksha.widgets.container.templates.container'
    resources = [
        jquery_js,
        jquery_ui_js,
        container_js,
        container_css,
        container_resources,
    ]
    options = ['draggable', 'resizable']
    button_options = ['iconize', 'minimize', 'close']
Ejemplo n.º 8
0
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
:mod:`moksha.api.widgets.buttons` - Fancy Button CSS
====================================================

This module contains a ToscaWidget for the mbButtons
project::

    http://www.open-lab.com/mb.ideas/index.html#mbButtons

.. moduleauthor:: Luke Macken <*****@*****.**>
"""

import tw2.core as twc

buttons_css = twc.CSSLink(filename='static/buttons.css',
                          media='all',
                          modname=__name__)
buttons_dir = twc.DirLink(filename='static/images', modname=__name__)
static_images = twc.Link(filename='static/images/ventitre.gif',
                         modname=__name__)
Ejemplo n.º 9
0
import tw2.core as twc
import tw2.jquery as twj

import simplejson

jquery_gritter_js = twc.JSLink(
    modname='tw2.jqplugins.gritter',
    filename='static/jquery/gritter/js/jquery.gritter.min.js',
    resources=[twj.jquery_js],
)
jquery_gritter_css = twc.CSSLink(
    modname='tw2.jqplugins.gritter',
    filename='static/jquery/gritter/css/jquery.gritter.css'
)
jquery_gritter_dir = twc.DirLink(
    modname='tw2.jqplugins.gritter',
    filename='static/jquery/gritter/images'
)

gritter_resources = [
    jquery_gritter_js,
    jquery_gritter_css,
    jquery_gritter_dir,
]

def gritter_callback(**kw):
    """ Return js_callbacks that create gritter popups.

    >>> gritter_callback(title="Some Title", text="A message...")

    """
    json = simplejson.dumps(kw)
Ejemplo n.º 10
0
import uuid
import tw2.core as twc
import tw2.jquery

from moksha.wsgi.widgets.api.live import LiveWidget, LiveWidgetMeta
from moksha.wsgi.widgets.api.live import subscribe_topics, unsubscribe_topics

container_js = twc.JSLink(filename='static/js/mbContainer.min.js',
                          resources=[
                              tw2.jquery.jquery_js,
                              tw2.jqplugins.ui.jquery_ui_js,
                          ],
                          modname=__name__)
container_css = twc.CSSLink(
    filename='static/css/mbContainer.css',
    resources=[twc.DirLink(filename='static/css/elements', modname=__name__)],
    modname=__name__)


class MokshaContainer(twc.Widget):
    template = 'mako:moksha.wsgi.widgets.container.templates.container'
    resources = [container_js, container_css]
    options = ['draggable', 'resizable']
    button_options = ['iconize', 'minimize', 'close']
    params = [
        'buttons', 'skin', 'height', 'width', 'left', 'top', 'id', 'title',
        'icon', 'content', 'widget_name', 'view_source', 'dock', 'onResize',
        'onClose', 'onCollapse', 'onIconize', 'onDrag', 'onRestore'
    ] + options[:]
    draggable = droppable = True
    resizable = False
Ejemplo n.º 11
0
import tw2.core as twc
import tw2.forms as twf

editarea_js = twc.JSLink(modname=__name__,
                         filename='static/edit_area_full.js',
                         init=twc.js_function('editAreaLoader.init'))

editarea_langs = twc.DirLink(
    modname=__name__,
    filename='static/langs',
)
editarea_reg_syntaxes = twc.DirLink(
    modname=__name__,
    filename='static/reg_syntax',
)
editarea_images = twc.DirLink(
    modname=__name__,
    filename='static/images',
)


class EditAreaWidget(twf.TextArea):

    # declare static resources here
    # you can remove either or both of these, if not needed
    resources = [editarea_js]

    syntax = twc.Param('Which language syntax to highlight', default='')

    @classmethod
    def post_define(cls):
Ejemplo n.º 12
0
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
:mod:`moksha.wsgi.widgets.api.buttons` - Fancy Button CSS
====================================================

This module contains a ToscaWidget for the mbButtons
project::

    http://www.open-lab.com/mb.ideas/index.html#mbButtons

.. moduleauthor:: Luke Macken <*****@*****.**>
"""

import tw2.core as twc

static_images = twc.DirLink(filename='static/images/', modname=__name__)

buttons_css = twc.CSSLink(filename='static/buttons.css',
                          resources=[static_images],
                          media='all',
                          modname=__name__)