示例#1
0
def setup():
    delegate.fakeload()    
    from infogami.utils import types
    types.register_type('/i18n(/.*)?/strings.[^/]*', '/type/i18n')
    
    for site in db.get_all_sites():
        load_strings(site)
示例#2
0
def setup():
    delegate.fakeload()
    from infogami.utils import types
    types.register_type('/i18n(/.*)?/strings.[^/]*', '/type/i18n')

    for site in db.get_all_sites():
        load_strings(site)
示例#3
0
def setup():
    delegate.fakeload()
    
    load_all()
    
    from infogami.utils import types
    types.register_type('/templates/.*\.tmpl$', '/type/template')
    types.register_type('^/type/[^/]*$', '/type/type')
    types.register_type('/macros/.*$', '/type/macro')
示例#4
0
文件: code.py 项目: purhan/infogami
def setup():
    delegate.fakeload()

    load_all()

    from infogami.utils import types
    types.register_type(r'/templates/.*\.tmpl$', '/type/template')
    types.register_type('^/type/[^/]*$', '/type/type')
    types.register_type('/macros/.*$', '/type/macro')
示例#5
0
def register_types():
    """Register default types for various path patterns used in OL.
    """
    from infogami.utils import types

    types.register_type('^/authors/[^/]*$', '/type/author')
    types.register_type('^/books/[^/]*$', '/type/edition')
    types.register_type('^/works/[^/]*$', '/type/work')
    types.register_type('^/languages/[^/]*$', '/type/language')

    types.register_type('^/usergroup/[^/]*$', '/type/usergroup')
    types.register_type('^/permission/[^/]*$', '/type/permission')

    types.register_type('^/(css|js)/[^/]*$', '/type/rawtext')
示例#6
0
def register_types():
    """Register default types for various path patterns used in OL.
    """
    from infogami.utils import types

    types.register_type('^/authors/[^/]*$', '/type/author')
    types.register_type('^/books/[^/]*$', '/type/edition')
    types.register_type('^/works/[^/]*$', '/type/work')
    types.register_type('^/languages/[^/]*$', '/type/language')
    types.register_type('^/libraries/[^/]*$', '/type/library')

    types.register_type('^/usergroup/[^/]*$', '/type/usergroup')
    types.register_type('^/permission/[^/]*$', '/type/permission')

    types.register_type('^/(css|js)/[^/]*$', '/type/rawtext')
示例#7
0
def setup():
    """Setup for upstream plugin"""
    models.setup()
    utils.setup()
    addbook.setup()
    covers.setup()
    merge_authors.setup()
    
    import data
    data.setup()
    
    # Types for upstream paths
    types.register_type('^/authors/[^/]*$', '/type/author')
    types.register_type('^/books/[^/]*$', '/type/edition')
    types.register_type('^/languages/[^/]*$', '/type/language')

    types.register_type('^/subjects/places/[^/]*$', '/type/place')
    types.register_type('^/subjects/people/[^/]*$', '/type/person')
    types.register_type('^/subjects/[^/]*$', '/type/subject')

    # fix photo/cover url pattern
    ol_code.Author.photo_url_patten = "%s/photo"
    ol_code.Edition.cover_url_patten = "%s/cover"

    # setup template globals
    from openlibrary.i18n import ugettext, ungettext
            
    web.template.Template.globals.update({
        "gettext": ugettext,
        "ugettext": ugettext,
        "_": ugettext,
        "ungettext": ungettext,
        "random": random.Random(),
        "commify": web.commify,
        "group": web.group,
        "storage": web.storage,
        "all": all,
        "any": any,
        "locals": locals
    });
    
    import jsdef
    web.template.STATEMENT_NODES["jsdef"] = jsdef.JSDefNode
    
    setup_jquery_urls()
示例#8
0
文件: code.py 项目: ziwar/openlibrary
    ol_infobase.init_plugin()

try:
    from infogami.plugins.api import code as api
except:
    api = None

# http header extension for OL API
infogami.config.http_ext_header_uri = "http://openlibrary.org/dev/docs/api"

# setup special connection with caching support
import connection
client._connection_types['ol'] = connection.OLConnection
infogami.config.infobase_parameters = dict(type="ol")

types.register_type('^/a/[^/]*$', '/type/author')
types.register_type('^/b/[^/]*$', '/type/edition')
types.register_type('^/l/[^/]*$', '/type/language')

types.register_type('^/works/[^/]*$', '/type/work')
types.register_type('^/subjects/[^/]*$', '/type/subject')
types.register_type('^/publishers/[^/]*$', '/type/publisher')

types.register_type('^/usergroup/[^/]*$', '/type/usergroup')
types.register_type('^/permission/[^/]*$', '/type/permision')

types.register_type('^/(css|js)/[^/]*$', '/type/rawtext')

# set up infobase schema. required when running in standalone mode.
import schema
dbstore.default_schema = schema.get_schema()
示例#9
0
def setup():
    """Setup for upstream plugin"""
    models.setup()
    utils.setup()
    addbook.setup()
    covers.setup()
    
    # overwrite ReadableUrlProcessor patterns for upstream
    ReadableUrlProcessor.patterns = [
        (r'/books/OL\d+M', '/type/edition', 'title', 'untitled'),
        (r'/authors/OL\d+A', '/type/author', 'name', 'noname'),
        (r'/works/OL\d+W', '/type/work', 'title', 'untitled')
    ]

    # Types for upstream paths
    types.register_type('^/authors/[^/]*$', '/type/author')
    types.register_type('^/books/[^/]*$', '/type/edition')
    types.register_type('^/languages/[^/]*$', '/type/language')

    types.register_type('^/subjects/places/[^/]*$', '/type/place')
    types.register_type('^/subjects/people/[^/]*$', '/type/person')
    types.register_type('^/subjects/[^/]*$', '/type/subject')

    # fix photo/cover url pattern
    ol_code.Author.photo_url_patten = "%s/photo"
    ol_code.Edition.cover_url_patten = "%s/cover"

    # setup template globals
    from openlibrary.i18n import gettext as _
            
    web.template.Template.globals.update({
        "gettext": _,
        "_": _,
        "random": random.Random(),
        "commify": web.commify,
        "group": web.group,
        "storage": web.storage,
        "all": all,
        "any": any,
        "locals": locals
    });
    
    setup_jquery_urls()
示例#10
0
from infogami.infobase import client, dbstore

try:
    from infogami.plugins.api import code as api
except:
    api = None

# http header extension for OL API
infogami.config.http_ext_header_uri = "http://openlibrary.org/dev/docs/api"

# setup special connection with caching support
import connection
client._connection_types['ol'] = connection.OLConnection
infogami.config.infobase_parameters = dict(type="ol")

types.register_type('^/a/[^/]*$', '/type/author')
types.register_type('^/b/[^/]*$', '/type/edition')

# set up infobase schema. required when running in standalone mode.
import schema
dbstore.default_schema = schema.get_schema()

# this adds /show-marc/xxx page to infogami
import showmarc

# add zip and tuple to the list of public functions
public(zip)
public(tuple)
web.template.Template.globals['NEWLINE'] = "\n"

@infogami.action
示例#11
0
import infogami
from infogami.utils import delegate, types
from infogami.utils.storage import OrderedDict
from infogami.utils.template import render
from infogami.utils.view import public, thingview, thingrepr, require_login
from infogami.infobase import client
from infogami import config
from telugu_months import months as te_months
import datetime
import utils

import re
import os
import Image

types.register_type('^/[0-9][0-9][0-9][0-9]/[0-9][0-9]$',  '/type/issue')
types.register_type('^/[0-9][0-9][0-9][0-9]/[0-9][0-9]/.*$',  '/type/article')

class Article(client.Thing):    
    def get_issue(self):
        parent = self.key.rsplit('/', 1)[0]
        return web.ctx.site.get(parent)
    
class Issue(client.Thing):
    @property
    def banner_url(self):
        _, yyyy, mm = self.key.split("/")
        prefix = os.path.join("static", "images", yyyy, mm, "banner")
        extensions = [".jpg", ".JPG", ".gif", ".GIF", ".png", ".PNG"]
        for ext in extensions:
            if os.path.exists(prefix + ext):