Exemple #1
0
def getStorageToInputTranslator():
    """Looks for a storage-to-input translator first in the session and then
    in the globals.  If no translator is found, return the identity function.
    
    """
    if session['user_storageToInputTranslator']:
        return lambda x: h.literal(session['user_storageToInputTranslator'].
                                   translate(x))
    elif app_globals.storageToInputTranslator:
        return lambda x: h.literal(
            app_globals.storageToInputTranslator.translate(x))
    else:
        return lambda x: x
Exemple #2
0
def getStorageToInputTranslator():
    """Looks for a storage-to-input translator first in the session and then
    in the globals.  If no translator is found, return the identity function.
    
    """
    if session['user_storageToInputTranslator']:
        return lambda x: h.literal(session[
            'user_storageToInputTranslator'].translate(x))
    elif app_globals.storageToInputTranslator:
        return lambda x: h.literal(
            app_globals.storageToInputTranslator.translate(x))
    else:
        return lambda x: x
Exemple #3
0
def getKeyboardTable(fieldId, appSettings=None):
    """Create the keyboardTable to be displayed under the input field with id =
    fieldId.  The graphs of keyboard are those of the input orthography.

    """

    if not appSettings:
        appSettings = getApplicationSettings()

    if fieldId == 'transcription':
        graphemeList = getOrthographyAsList(appSettings, 'user input')
    elif fieldId == 'morphemeBreak':
        if app_globals.morphemeBreakIsObjectLanguageString == u'yes':
            graphemeList = getOrthographyAsList(appSettings, 'user input')
        else:
            graphemeList = app_globals.morphBreakInvObj.getInputList()
    elif fieldId == 'phoneticTranscription':
        graphemeList = app_globals.broadPhonInvObj.getInputList()
    elif fieldId == 'narrowPhoneticTranscription':
        graphemeList = app_globals.narrPhonInvObj.getInputList()
    else:
        graphemeList = []

    keys = ['<a class="key" title="Click this key to insert \'%s\' into the %s field" \
            onclick="graphToInput(\'%s\', \'%s\');">%s</a>' \
            % (x.replace("'", "\\'"), fieldId, x.replace("'", "\\'"), fieldId, \
            x) for x in graphemeList]
    return h.literal(h.tablify(keys, 10, 'keyboardTable'))
Exemple #4
0
def getKeyboardTable(fieldId, appSettings=None):
    """Create the keyboardTable to be displayed under the input field with id =
    fieldId.  The graphs of keyboard are those of the input orthography.

    """

    if not appSettings:
        appSettings = getApplicationSettings()

    if fieldId == 'transcription':
        graphemeList = getOrthographyAsList(appSettings, 'user input')
    elif fieldId == 'morphemeBreak':
        if app_globals.morphemeBreakIsObjectLanguageString == u'yes':
            graphemeList = getOrthographyAsList(appSettings, 'user input')
        else:
            graphemeList = app_globals.morphBreakInvObj.getInputList()
    elif fieldId == 'phoneticTranscription':
        graphemeList = app_globals.broadPhonInvObj.getInputList()
    elif fieldId == 'narrowPhoneticTranscription':
        graphemeList = app_globals.narrPhonInvObj.getInputList()
    else:
        graphemeList = []

    keys = ['<a class="key" title="Click this key to insert \'%s\' into the %s field" \
            onclick="graphToInput(\'%s\', \'%s\');">%s</a>' \
            % (x.replace("'", "\\'"), fieldId, x.replace("'", "\\'"), fieldId, \
            x) for x in graphemeList]
    return h.literal(h.tablify(keys, 10, 'keyboardTable'))
Exemple #5
0
def flickr():
    flickr_feed = feedparser.parse('http://api.flickr.com/services/feeds/photos_public.gne?id=%s@N00&lang=en-us&format=atom' % config['flickr.id'])
    if len(flickr_feed.entries):
        items = []
        template = """
        <div id="wurdig-flickr-feed">
            <h4>Public Flickr Stream</h4>
            <ul>
                %s
            </ul>
        </div>
        """
        for entry in flickr_feed.entries[:12]:
            image = entry['enclosures'][0]['href']
            image = image.replace('m.jpg', 's.jpg')
            i = '<li>%s</li>' % h.link_to(
                                        h.literal('<img src="%s" title="%s" alt="%s">' % (image, entry['title'], entry['title'])),
                                        entry['link']
                                        )
            items.append(i)
        return template % '\n'.join(items)
    else:
        return ''