コード例 #1
0
class MovieForm(TableForm):

    template = "toscasample.widgets.templates.table_form"
    css = [CSSLink(link=url('/css/tooltips.css'))]

    genre_options = enumerate((
        'Action & Adventure', 'Animation', 'Comedy',
        'Documentary', 'Drama', 'Sci-Fi & Fantasy'))

    fields = [
        TextField('title', label_text='Movie Title',
            help_text='Please enter the full title of the movie.'),
        Spacer(),
        TextField('year', size=4,
            help_text='Please enter the year this movie was made.'),
        CalendarDatePicker('release_date', date_format='%y-%m-%d',
            help_text='Please pick the exact release date.'),
        SingleSelectField('genre', options=genre_options,
            help_text = 'Please choose the genre of the movie.'),
        Spacer(),
        TextArea('description', attrs=dict(rows=3, cols=25),
            help_text = 'Please provide a short description of the plot.'),
        Spacer()]

    submit_text = 'Save Movie'
コード例 #2
0
ファイル: widgets.py プロジェクト: deets/wirbelsturm
class SignupForm(TableForm):

    css = [CSSLink(modname=__name__,
                         filename="css/signup_form.css",
                         css=[super_chat_css])]

    class fields(WidgetsList):
        name = TextField("name", validator=NotRegistered())

    submit_text = "Join"
コード例 #3
0
class LiveGraphWidget(LiveWidget):
    """
    This is an example live graph widget based on Michael Carter's article
    "Scalable Real-Time Web Architecture, Part 2: A Live Graph with Orbited,
    MorbidQ, and js.io".

    http://cometdaily.com/2008/10/10/scalable-real-time-web-architecture-part-2-a-live-graph-with-orbited-morbidq-and-jsio
    """
    params = ['id', 'onconnectedframe', 'onmessageframe']
    topic = 'graph_demo'
    onmessage = 'modify_graph(bars, frame.body)'
    javascript = [JSLink(filename='static/livegraph.js', modname=__name__)]
    css = [CSSLink(filename='static/livegraph.css', modname=__name__)]
    template = '<div id="${id}" />'

    def update_params(self, d):
        super(LiveGraphWidget, self).update_params(d)
        self.add_call(js_function('init_graph')(self.id))
コード例 #4
0
ファイル: proyecto.py プロジェクト: Alberto2011/SAP
class ProyectoForm(TableForm):

    #template = "toscasample.widgets.templates.table_form"
    #template = "sap.templates.administrar.proyecto.new"
    css = [CSSLink(link=url('/css/tooltips.css'))]
    show_errors = True

    lider_options = []
    fields = [
        TextField('nombre', validator=NotEmpty, label_text='Nombre'),
        Spacer(),
        TextField('descripcion', label_text='Descripcion'),
        #TextArea('descripcion', attrs=dict(rows=3, cols=10)),
        Spacer(),
        SingleSelectField('liderProyecto', options=lider_options),
        #TextField('liderProyecto', label_text='Lider de Proyecto')
    ]

    submit_text = 'Crear Proyecto'
コード例 #5
0
ファイル: ptd.py プロジェクト: decause/moksha
class ProcessedTowerDefense(Widget):
    name = 'Processed Tower Defense'
    hidden = True
    template = 'mako:moksha.widgets.misc.ptd.templates.ptd'
    css = [
        CSSLink(filename='static/style.css', modname=modname),
    ]
    javascript = [
        processing_js,
        jsfprocessing_js,
        effects_core_js,
        effects_highlight_js,
        JSLink(filename='game/creep_waves.js', modname=modname),
        JSLink(filename='game/terrain.js', modname=modname),
        JSLink(filename='game/util.js', modname=modname),
        JSLink(filename='game/creeps.js', modname=modname),
        JSLink(filename='game/ui_modes.js', modname=modname),
        JSLink(filename='game/weapons.js', modname=modname),
        JSLink(filename='game/ptd.js', modname=modname),
    ]
コード例 #6
0
ファイル: movie_form_7.py プロジェクト: clsdaniel/tg2docs
class MovieForm(TableForm):

    template = "toscasample.widgets.templates.table_form"
    css = [CSSLink(link=url('/css/tooltips.css'))]
    show_errors = True
    genre_options = [
        x for x in enumerate(('Action & Adventure', 'Animation', 'Comedy',
                              'Documentary', 'Drama', 'Sci-Fi & Fantasy'))
    ]

    fields = [
        TextField('title',
                  validator=NotEmpty,
                  label_text='Movie Title',
                  help_text='Please enter the full title of the movie.'),
        Spacer(),
        TextField('year',
                  validator=Int(min=1900, max=2100),
                  size=4,
                  help_text='Please enter the year this movie was made.'),
        CalendarDatePicker('release_date',
                           validator=DateConverter(),
                           help_text='Please pick the exact release date.'),
        SingleSelectField('genre',
                          options=genre_options,
                          help_text='Please choose the genre of the movie.'),
        Spacer(),
        TextArea('description',
                 attrs=dict(rows=3, cols=25),
                 help_text='Please provide a short description of the plot.'),
        Spacer(),
        FileField('picture_filename',
                  help_text='Please provide a picture for this movie.'),
        Spacer()
    ]

    submit_text = 'Save Movie'
コード例 #7
0
from moksha.api.widgets.orbited import orbited_js

irc2_js = JSLink(filename='static/irc2.js',
                 javascript=[orbited_js],
                 modname=__name__)

willowchat_js = JSLink(filename='static/willowchat.js',
                       javascript=[jquery_js, irc2_js],
                       modname=__name__)

gui_js = JSLink(filename='static/gui.js',
                javascript=[willowchat_js],
                modname=__name__)

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


class LiveChatWidget(Widget):
    name = 'Chat'
    params = ['bootstrap']
    bootstrap = JSLink(link='/apps/chat/bootstrap')
    template = '<div id="willowchat" reposition="true">${bootstrap}</div>'
    visible = False


class LiveChatFrameWidget(Widget):
    template = 'mako:moksha.apps.chat.templates.chat'
    javascript = [orbited_js, willowchat_js, irc2_js, gui_js, jquery_js]
    css = [willowchat_css]
コード例 #8
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.
#
# Authors: Luke Macken <*****@*****.**>

""" ToscaWidget's for the Blueprint CSS Framework """

from tw.api import CSSLink, IECSSLink

modname = __name__

blueprint_screen_css = CSSLink(modname=modname,
                               filename='static/screen.css',
                               media='screen, projection')

blueprint_print_css = CSSLink(modname=modname,
                              filename='static/print.css',
                              media='print')

blueprint_ie_css = IECSSLink(modname=modname,
                             filename='static/ie.css',
                             media='screen, projection')

##
## Blueprint Plugins
##

# Gives you some great CSS-only buttons.
コード例 #9
0
from tw.api import Widget, JSLink, CSSLink, js_function
from moksha.widgetbrowser import util
import string

__all__ = ['WidgetBrowserTabs']

mod = __name__
#mod = 'widgetbrowser'
flora_all_css = CSSLink(modname=mod, filename="static/themes/flora/flora.all.css")
tabs_css = CSSLink(modname=mod, filename="static/ui.tabs.css")
wb_css = CSSLink(modname=mod, filename="static/widgetbrowser.css")
pygments_css = CSSLink(modname=mod, filename="static/pygments.css")
httprepl_css = CSSLink(modname=mod, filename="static/httprepl.css")
jquery_js = JSLink(modname=mod, filename="static/jquery.js")
# Do not pull jquery as an automatic dependency since Sphinx already includes
# it
ui_base_js = JSLink(modname=mod, filename="static/ui.base.js",
                    location="bodybottom")
ui_tabs_js = JSLink(modname=mod, filename="static/ui.tabs.js",
                    location="bodybottom",
                    javascript=[ui_base_js])
ui_dragabble_js = JSLink(modname=mod, filename="static/ui.draggable.js",
                         location="bodybottom")
ui_resizable_js = JSLink(modname=mod, filename="static/ui.resizable.js",
                         location="bodybottom")
ui_dialog_js = JSLink(modname=mod, filename="static/ui.dialog.js",
                      location="bodybottom",
                      javascript=[ui_base_js, ui_dragabble_js, ui_resizable_js])
widgetbrowser_js = JSLink(modname=mod, filename="static/widgetbrowser.js",
                          javascript=[ui_tabs_js],
                          css=[tabs_css, wb_css, pygments_css],
コード例 #10
0
import errno

import tw
from tw.api import CSSLink, JSLink, js_function
from tw.forms import FormField, validators

__all__ = [
    "CalendarDatePicker", "CalendarDateTimePicker", "calendar_js",
    "calendar_setup"
]

setup_calendar = js_function("Calendar.setup")

log = logging.getLogger(__name__)

calendar_css = CSSLink(modname='tw.forms',
                       filename='static/calendar/calendar-system.css')
calendar_js = JSLink(modname='tw.forms',
                     filename='static/calendar/calendar.js')
calendar_setup = JSLink(javascript=[calendar_js],
                        modname='tw.forms',
                        filename='static/calendar/calendar-setup.js')


class CalendarDatePicker(FormField):
    """
    Uses a javascript calendar system to allow picking of calendar dates.
    The date_format is in mm/dd/yyyy unless otherwise specified
    """
    css = [calendar_css]
    javascript = [calendar_js, calendar_setup]
    template = "tw.forms.templates.calendar"
コード例 #11
0
ファイル: widgets.py プロジェクト: ralphbean/moksha
from tw.jquery import jquery_js, jQuery

from moksha.lib.helpers import when_ready

modname = __name__

jquery_mbmenu_js = JSLink(modname=modname,
                          filename='static/mbMenu.js',
                          javascript=[jquery_js])

jquery_mbmenu_min_js = JSLink(modname=modname,
                              filename='static/mbMenu.min.js',
                              javascript=[jquery_js])

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


class MokshaMenuBase(Widget):
    template = "mako:moksha.apps.menus.templates.mbmenu"
    javascript = [jquery_mbmenu_min_js]
    css = [mbmenu_css_1]
    params = [
        'callback', 'rootMenuSelector', 'menuSelector', 'id', 'menus',
        'additionalData', 'iconPath', 'menuWidth', 'openOnRight', 'hasImages',
        'fadeTime', 'adjustLeft', 'adjustTop', 'opacity', 'shadow',
        'fadeInTime', 'fadeOutTime', 'overflow', 'effect', 'minZindex'
コード例 #12
0
#    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.

import moksha
import moksha.utils

from tw.api import Widget, JSLink, CSSLink
from tw.jquery import jquery_js

layout_js = JSLink(filename='static/layout.js', modname=__name__)
layout_css = CSSLink(filename='static/layout.css', modname=__name__)
ui_core_js = JSLink(filename='static/ui/ui.core.js', modname=__name__)
ui_draggable_js = JSLink(filename='static/ui/ui.draggable.js', modname=__name__)
ui_droppable_js = JSLink(filename='static/ui/ui.droppable.js', modname=__name__)
ui_sortable_js = JSLink(filename='static/ui/ui.sortable.js', modname=__name__)

class LayoutWidget(Widget):
    template = 'mako:moksha.api.widgets.layout.templates.layout'
    params = ['header', 'content', 'sidebar', 'footer', 'invisible']
    css = [layout_css]
    javascript = [jquery_js, layout_js, ui_core_js, ui_draggable_js,
                  ui_droppable_js, ui_sortable_js]

    header = content = sidebar = footer = invisible = []

    def update_params(self, d):
コード例 #13
0
ファイル: widgets.py プロジェクト: nlaurance/twepiclock
from tw.jquery import jquery_js

from datetime import datetime

__all__ = ["Epiclock"]

# declare your static resources here

dateformat_js = JSLink(modname=__name__,
                       filename='static/jquery.dateformat.min.js',
                       javascript=[jquery_js])
epiclock_js = JSLink(modname=__name__,
                     filename='static/jquery.epiclock.min.js',
                     javascript=[dateformat_js])

epiclock_css = CSSLink(modname=__name__, filename='static/jquery.epiclock.css')


class Epiclock(Widget):
    """ widget implementation
    """
    template = """<span id="${id}"></span>"""

    javascript = [epiclock_js]
    css = [epiclock_css]

    params = {
        # see included jquery.epiclock.js for more info
        "mode": "one of 'clock', 'explicit', 'countdown', 'countup', \
                    rollover', 'expire', 'loop', 'stopwatch', 'holdup', 'timer'",
        # see included jquery.dateformat.js for more info
コード例 #14
0
## Load our feed tree widgets.
feedtree_engine = config.get('moksha.feedtree.engine', 'live')
if feedtree_engine == 'live':   # Live widgets
    feed_tree = MokshaLiveFeedTree('feed_tree')
    feed_entries_tree = MokshaLiveFeedEntriesTree('feed_entries_tree')
elif feedtree_engine == 'ajax': # Ajax widgets
    feed_tree = MokshaAjaxFeedTree('feed_tree')
    feed_entries_tree = MokshaAjaxFeedEntriesTree('feed_entries_tree')

splitter_js = JSLink(filename='static/splitter.js',
                     javascript=[jquery_js],
                     modname=__name__)

splitter_css = CSSLink(filename='static/main.css',
                       media='all',
                       modname=__name__)


class MokshaFeedReaderWidget(LiveWidget):
    name = 'Moksha Feed Reader'
    params = ['topic']
    topic = 'moksha.feeds' # will get replaced by a unique uuid at render-time
    template = 'mako:moksha.widgets.feeds.templates.feedreader'
    children = [feed_tree, feed_entries_tree]
    javascript = [splitter_js]
    css = [splitter_css]
    container_options = {
            'top': 50,
            'left': 50,
            'height': 600,
コード例 #15
0
ファイル: widgets.py プロジェクト: deets/wirbelsturm
      }
    });
    """ % dict(opts=dumps(opts), start=start),
                    javascript = [centralstation_js]
                    )


my_central_station = central_station("/dispatch")






reset_css = CSSLink(modname=__name__,
                   filename="css/reset-min.css"
                   )


super_chat_css = CSSLink(modname=__name__,
                         filename="css/super_chat.css",
                         css=[reset_css]
)



class SignupForm(TableForm):

    css = [CSSLink(modname=__name__,
                         filename="css/signup_form.css",
                         css=[super_chat_css])]
コード例 #16
0
ファイル: areachart.py プロジェクト: ralphbean/moksha
A widget for the Javascript InfoVis Toolkit.

.. moduleauthor:: Ralph Bean <*****@*****.**> 
.. upstream:: http://thejit.org
.. upstream-license:: BSD
"""

from tw.api import Widget, JSLink, CSSLink
from tw.jquery import jquery_js
from tw.jquery.flot import excanvas_js

jit_yc_js = JSLink(filename='static/jit-yc.js',
                   javascript=[excanvas_js],
                   modname=__name__)
jit_base_css = CSSLink(filename='static/css/base.css', modname=__name__)
jit_areachart_css = CSSLink(filename='static/css/Areachart.css',
                            modname=__name__)


class AreaChart(Widget):
    params = {
        'query': 'URL to query for JSON data',
        'title': 'The title of this graph',
        'description': 'A description of this graph',
    }
    javascript = [jit_yc_js]
    css = [jquery_js, jit_base_css, jit_areachart_css]
    template = 'mako:moksha.widgets.mokshajit.templates.areachart'
    query = '/apps/mokshajit/query'
コード例 #17
0
A widget for the Javascript InfoVis Toolkit.

.. moduleauthor:: Luke Macken <*****@*****.**>
.. upstream:: http://thejit.org
.. upstream-license:: BSD
"""

from tw.api import Widget, JSLink, CSSLink
from tw.jquery import jquery_js
from tw.jquery.flot import excanvas_js

jit_js = JSLink(filename='static/jit.js',
                javascript=[excanvas_js],
                modname=__name__)
jit_base_css = CSSLink(filename='static/css/base.css', modname=__name__)
jit_hypertree_css = CSSLink(filename='static/css/Hypertree.css',
                            modname=__name__)


class HyperTree(Widget):
    params = {
        'query': 'URL to query for JSON data',
        'root': 'The id of the selected root node',
        'title': 'The title of this graph',
        'description': 'A description of this graph',
        'child_fields': 'JS callback to display child data',
    }
    javascript = [jit_js]
    css = [jquery_js, jit_base_css, jit_hypertree_css]
    template = 'mako:moksha.widgets.mokshajit.templates.hypertree'
コード例 #18
0
ファイル: notify.py プロジェクト: ralphbean/moksha
from tw.api import JSLink, CSSLink, Widget
from tw.jquery import jquery_js

jquery_jgrowl_js = JSLink('jquery_jgrowl_js',
                          filename='static/jquery.jgrowl.js',
                          javascript=[jquery_js],
                          modname=__name__)
jquery_jgrowl_css = CSSLink('jquery_jgrowl_css',
                            filename='static/jquery.jgrowl.css',
                            modname=__name__)


class MokshaNotificationWidget(Widget):
    javascript = [jquery_jgrowl_js]
    css = [jquery_jgrowl_css]


moksha_notify = MokshaNotificationWidget('moksha_notify')
コード例 #19
0
ファイル: datagrid.py プロジェクト: rudyvallejos/GestionItems
class DataGrid(Widget):
    """Generic widget to present and manipulate data in a grid (tabular) form.

    The columns to build the grid from are specified with fields constructor
    argument which is a list. An element can be a Column, an accessor
    (attribute name or function), a tuple (title, accessor) or a tuple
    (title, accessor, options).

    You can specify columns' data statically, via fields constructor parameter,
    or dynamically, via 'fields' key.

    """
    css_class = "grid"
    css = [CSSLink(modname='tw.forms', filename='static/grid.css')]
    template = "tw.forms.templates.datagrid"
    engine_name = "genshi"
    fields = []
    params = ["fields"]

    def get_column(self, name):
        """Return Column with specified name.

        Raises KeyError if no such column exists.

        """
        for col in self.columns:
            if col.name == name:
                return col
        raise KeyError(name)

    def __getitem__(self, name):
        """Shortcut to get_column."""
        return self.get_column(name)

    @staticmethod
    def get_field_getter(columns):
        """Return a function to access the fields of table by row, col."""
        idx = {}  # index columns by name
        for col in columns:
            idx[col.name] = col

        def _get_field(row, col):
            return idx[col].get_field(row)

        return _get_field

    def update_params(self, d):
        super(DataGrid, self).update_params(d)
        if d.get('fields'):
            fields = d.pop('fields')
            columns = self._parse(fields)
        else:
            columns = self.columns[:]
        d['columns'] = columns
        d['get_field'] = self.get_field_getter(columns)
        # this is for backward compatibility
        d['headers'] = [col.title for col in columns]
        d['collist'] = [col.name for col in columns]

    def _parse(self, fields):
        """Parse field specifications into a list of Columns.

        A specification can be a Column,
        an accessor (attribute name or function), a tuple (title, accessor)
        or a tuple (title, accessor, options).

        """
        columns = []
        names = {}  # keep track of names to ensure there are no dups
        for n, col in enumerate(fields):
            if not isinstance(col, Column):
                if isinstance(col, str) or callable(col):
                    name_or_f = col
                    title = options = None
                else:
                    title, name_or_f = col[:2]
                    try:
                        options = col[2]
                    except IndexError:
                        options = None
                # construct name using column index
                name = 'column-' + str(n)
                col = Column(name, name_or_f, title, options)
            if col.name in names:
                raise ValueError('Duplicate column name: %s' % col.name)
            columns.append(col)
            names[col.name] = 1
        return columns
コード例 #20
0
ファイル: spacetree.py プロジェクト: ralphbean/moksha
A widget for the Javascript InfoVis Toolkit.

.. moduleauthor:: Luke Macken <*****@*****.**>
.. upstream:: http://thejit.org
.. upstream-license:: BSD
"""

from tw.api import Widget, JSLink, CSSLink
from tw.jquery import jquery_js
from tw.jquery.flot import excanvas_js

jit_yc_js = JSLink(filename='static/jit-yc.js',
                   javascript=[excanvas_js],
                   modname=__name__)
jit_base_css = CSSLink(filename='static/css/base.css', modname=__name__)
jit_spacetree_css = CSSLink(filename='static/css/Spacetree.css',
                            modname=__name__)


class SpaceTree(Widget):
    params = {
        'query': 'URL to query for JSON data',
        'title': 'The title of this graph',
        'description': 'A description of this graph',
    }
    javascript = [jit_yc_js]
    css = [jquery_js, jit_base_css, jit_spacetree_css]
    template = 'mako:moksha.widgets.mokshajit.templates.spacetree'
    query = '/apps/mokshajit/query'
コード例 #21
0
ファイル: container.py プロジェクト: ralphbean/moksha
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Authors: Luke Macken <*****@*****.**>

import uuid
from tw.api import Widget, JSLink, CSSLink, js_callback
from tw.jquery import jquery_js, jQuery

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

container_js = JSLink(filename='static/js/mbContainer.min.js',
                      javascript=[jquery_js],
                      modname=__name__)
container_css = CSSLink(filename='static/css/mbContainer.css',
                        modname=__name__)


class MokshaContainer(Widget):
    template = 'mako:moksha.widgets.container.templates.container'
    javascript = [container_js]
    css = [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
コード例 #22
0
ファイル: buttons.py プロジェクト: ralphbean/moksha
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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 <*****@*****.**>
"""

from tw.api import CSSLink, Link

buttons_css = CSSLink(filename='static/buttons.css',
                      media='all', modname=__name__)
static_images = Link(filename='static/images/ventitre.gif', modname=__name__)