Ejemplo n.º 1
0
 def from_list(cls, medias, **kw):
     to_add = dict((n, v) for n, v in pyk.iteritems(kw) if v)
     if len(medias) == 1 and not to_add:
         result = medias[0]
     else:
         result = \
             CHJ.Media (children = medias) if (medias or to_add) else None
     for n, v in pyk.iteritems(to_add):
         getattr(result, n).add(*v)
     return result
Ejemplo n.º 2
0
 def _get_media (self, head = None) :
     medias   = []
     parent   = self.parent
     template = getattr (self, "template")
     if head is not None :
         medias.append (head)
     if self._Media is not _TOP_Base_._Media :
         medias.append (self._Media)
     if getattr (template, "Media", None) :
         medias.append (template.Media)
     if parent and parent.Media is not _TOP_Base_._Media :
         medias.append (parent.Media)
     if medias :
         return CHJ.Media (children = medias)
     return self._Media
Ejemplo n.º 3
0
class _TOP_Mixin_ (_Ancestor) :
    """Mixin class for TOP classes."""

    _real_name                 = "_Mixin_"

    session_ttl_name           = "user_session_ttl"
    short_title                = ""
    title                      = ""

    _exclude_robots            = False
    _index                     = None
    _Media                     = CHJ.Media ()

    class _TOP_Base_GET_ (HTTP_Method_Mixin, _Ancestor.GET) :

        _real_name             = "GET"

    GET = _TOP_Base_GET_ # end class

    @property
    @getattr_safe
    def a_attr_dict (self) :
        result = self.__super.a_attr_dict
        title  = self.title
        if title :
            result.update (title = title)
        return result
    # end def a_attr_dict

    @property
    @getattr_safe
    def has_children (self) :
        return bool (getattr (self, "entries", []))
    # end def has_children

    def is_current_dir (self, page) :
        return False
    # end def is_current_dir

    def is_current_page (self, page) :
        return \
            (  (self.permalink    == page.permalink)
            or (self.href_dynamic == page.href_dynamic)
            )
Ejemplo n.º 4
0
Archivo: Media.py Proyecto: Tapyr/tapyr
       If neither `jsmin`_ nor `rjsmin`_ is installed, `code` is returned
       unchanged.

       .. _`jsmin`: https://bitbucket.org/dcs/jsmin/
       .. _`rjsmin`: http://opensource.perlig.de/rjsmin/
    """
    jsmin  = None
    result = code
    try :
        from rjsmin import jsmin
    except ImportError :
        try :
            ### https://packages.debian.org/sid/python/python-jsmin
            from jsmin import jsmin
        except ImportError :
            logging.warning ("Couldn't import either rjsmin nor jsmin")
    if jsmin is not None :
        try :
            result = jsmin (code)
        except Exception as exc :
            logging.error ("Exception during minified_js\n    %s" % (exc, ))
    return pyk.encoded \
        ( _clean_minified_js (pyk.decoded (result, "utf-8", "latin-1"))
        , "utf-8"
        )
# end def minified_js

if __name__ != "__main__":
    CHJ._Export ("*")
### __END__ CHJ.Media
Ejemplo n.º 5
0
        , requires  = (CHJ.Script._.jQuery, )
        )
else :
    CHJ.Script \
        ( src       = "/media/GTW/js/jquery.min.js"
        , rank      = -101  ## should be loaded first
        , name      = "jQuery"
        )
    CHJ.Script \
        ( src       = "/media/GTW/js/jquery-ui.min.js"
        , name      = "jQuery_UI"
        , rank      = -100  ## should be loaded first
        , requires  = (CHJ.Script._.jQuery, )
        )

CHJ.CSS_Link ("/media/GTW/css/jquery-ui.css", name = "jQuery_UI")

CHJ.Script \
    ( src      = "/media/GTW/js/leaflet.min.js"
    , name     = "leaflet"
    , rank     = -90
    )

CHJ.Script \
    ( src      = "/media/GTW/js/GTW.js"
    , name     = "GTW"
    , rank     = -50
    )

CHJ.Script \
    ( src      = "/media/GTW/js/GTW/inspect.js"
Ejemplo n.º 6
0
       .. _`jsmin`: https://bitbucket.org/dcs/jsmin/
       .. _`rjsmin`: http://opensource.perlig.de/rjsmin/
    """
    jsmin = None
    result = code
    try:
        from rjsmin import jsmin
    except ImportError:
        try:
            ### https://packages.debian.org/sid/python/python-jsmin
            from jsmin import jsmin
        except ImportError:
            logging.warning("Couldn't import either rjsmin nor jsmin")
    if jsmin is not None:
        try:
            result = jsmin(code)
        except Exception as exc:
            logging.error("Exception during minified_js\n    %s" % (exc, ))
    return pyk.encoded \
        ( _clean_minified_js (pyk.decoded (result, "utf-8", "latin-1"))
        , "utf-8"
        )


# end def minified_js

if __name__ != "__main__":
    CHJ._Export("*")
### __END__ CHJ.Media
Ejemplo n.º 7
0
# Glasauergasse 32, A--1130 Wien, Austria. [email protected]
# ****************************************************************************
# This package is part of the package CHJ.
#
# This module is licensed under the terms of the BSD 3-Clause License
# <http://www.c-tanzer.at/license/bsd_3c.html>.
# ****************************************************************************
#
#++
# Name
#    CHJ.CSS.__init__
#
# Purpose
#    Model cascading style sheets
#
# Revision Dates
#    29-Dec-2010 (CT) Creation
#    11-Oct-2016 (CT) Move from `GTW` to `CHJ`
#    ««revision-date»»···
#--

from   _TFL.Package_Namespace import Package_Namespace
from   _CHJ                   import CHJ

CSS = Package_Namespace ()
CHJ._Export ("CSS")

del Package_Namespace

### __END__ CHJ.CSS.__init__
Ejemplo n.º 8
0
      ; padding        : 0
      ; vertical-align : baseline
      }
    <BLANKLINE>
    /* --> rules from a existing CSS file `/
    a.hide
    {
        display:          none
    }
    /* <-- */

    >>> print (as_string (scope.script_files))
    /* a test javascript file directly included */

    >>> print (as_string (scope.js_on_ready))
    /* this is a JS on ready code with some non-Ascii äöü« chars */;

    >>> list (scope.css_links)
    [all: /media/GTW/css/jquery.gritter.css]

    >>> list (scope.rel_links)
    [href="/media/GTW/css/jquery.gritter.rel.css"]

    """
    , test_s = _test_scripts
    )

if __name__ != "__main__":
    CHJ._Export_Module()
### __END__ CHJ.Parameters
Ejemplo n.º 9
0
# Glasauergasse 32, A--1130 Wien, Austria. [email protected]
# ****************************************************************************
# This package is part of the package CHJ.
#
# This module is licensed under the terms of the BSD 3-Clause License
# <http://www.c-tanzer.at/license/bsd_3c.html>.
# ****************************************************************************
#
#++
# Name
#    CHJ.CSS.__init__
#
# Purpose
#    Model cascading style sheets
#
# Revision Dates
#    29-Dec-2010 (CT) Creation
#    11-Oct-2016 (CT) Move from `GTW` to `CHJ`
#    ««revision-date»»···
#--

from _TFL.Package_Namespace import Package_Namespace
from _CHJ import CHJ

CSS = Package_Namespace()
CHJ._Export("CSS")

del Package_Namespace

### __END__ CHJ.CSS.__init__
Ejemplo n.º 10
0
      ; padding        : 0
      ; vertical-align : baseline
      }
    <BLANKLINE>
    /* --> rules from a existing CSS file `/
    a.hide
    {
        display:          none
    }
    /* <-- */
    >>> print (as_string (scope.script_files))
    /* a test javascript file directly included */

    >>> list (scope.scripts)
    [/media/GTW/js/jquery.js: text/javascript, /media/GTW/js/jquery-ui.js: text/javascript, /media/GTW/js/V5a/V5a.js: text/javascript, /media/GTW/js/GTW.js: text/javascript, /media/GTW/js/GTW/jQ/button_pure.js: text/javascript, /media/GTW/js/V5a/history_test.js: text/javascript, /media/GTW/js/V5a/history_push.js: text/javascript, /media/GTW/js/GTW/util.js: text/javascript, /media/GTW/js/GTW/jQ/util.js: text/javascript, /media/GTW/js/GTW/jQ/autocomplete.js: text/javascript, /media/GTW/js/V5a/form_field.js: text/javascript, /media/GTW/js/GTW/jQ/e_type_selector.js: text/javascript, /media/GTW/js/GTW/L.js: text/javascript, /media/GTW/js/GTW/jQ/mf3.js: text/javascript]

    >>> list (scope.css_links)
    [all: /media/GTW/css/jquery.gritter.css]

    >>> list (scope.rel_links)
    [href="/media/GTW/css/jquery.gritter.rel.css"]

    >>> print (as_string (scope.js_on_ready))
    /* this is a JS on ready code */;

"""

if __name__ != "__main__" :
    CHJ._Export_Module ()
### __END__ CHJ.Parameters