Ejemplo n.º 1
0
def init_g():
    # argumentos de busqueda por defecto
    g.args = {}
    g.active_types = {}
    g.active_srcs = {}

    # caracteristicas del cliente
    g.full_browser=is_full_browser()
    g.search_bot=is_search_bot()

    # peticiones en modo preproduccion
    g.beta_request = request.url_root[request.url_root.index("//")+2:].startswith("beta.")

    # prefijo para los contenidos estáticos
    if g.beta_request:
        app_static_prefix = current_app.static_url_path
    else:
        app_static_prefix = current_app.config["STATIC_PREFIX"] or current_app.static_url_path
    g.static_prefix = app_static_prefix
    current_app.assets.url = app_static_prefix + "/"

    g.autocomplete_disabled = "false" if current_app.config["SERVICE_TAMING_ACTIVE"] else "true"

    # dominio de la web
    g.domain = "foofind.is" if request.url_root.rstrip("/").endswith(".is") else "foofind.com"

    # informacion de la página por defecto
    g.title = g.domain
    g.keywords = set()
    g.page_description = g.title

    g.full_lang = current_app.config["ALL_LANGS_COMPLETE"][g.lang]
Ejemplo n.º 2
0
def init_g():
    g.accept_cookies = None

    # argumentos de busqueda por defecto
    g.args = {}
    g.active_types = {}
    g.active_srcs = {}

    # caracteristicas del cliente
    g.full_browser=is_full_browser()
    g.search_bot=is_search_bot()

    # peticiones en modo preproduccion
    g.beta_request = request.url_root[request.url_root.index("//")+2:].startswith("beta.")

    # prefijo para los contenidos estáticos
    if g.beta_request:
        app_static_prefix = current_app.static_url_path
    else:
        app_static_prefix = current_app.config["STATIC_PREFIX"] or current_app.static_url_path
    g.static_prefix = app_static_prefix
    current_app.assets.url = app_static_prefix + "/"

    g.autocomplete_disabled = "false" if current_app.config["SERVICE_TAMING_ACTIVE"] else "true"

    # dominio de la web
    g.domain = "foofind.is" if request.url_root.rstrip("/").endswith(".is") else "foofind.com"

    # informacion de la página por defecto
    g.title = g.domain
    g.keywords = set()
    g.page_description = g.title

    g.full_lang = current_app.config["ALL_LANGS_COMPLETE"][g.lang]

    # downloader links
    g.downloader = current_app.config["DOWNLOADER"]
    g.downloader_properties = local_cache["downloader_properties"]

    g.user_build = current_app.config["DOWNLOADER_DEFAULT_BUILD"]

    # Find the best active build for the user
    for build, info in g.downloader_properties.iteritems():
        try:
            if build != "common" and info["active"] and info["length"] and info.get("check_user_agent", lambda x:False)(request.user_agent):
                g.user_build = build
        except BaseException as e:
            logging.exception(e)


    accept_cookies = request.cookies.get("ck", "0")
    if accept_cookies=="0":
        if not (any(lang_code in request.accept_languages.values() for lang_code in current_app.config["SPANISH_LANG_CODES"]) or request.remote_addr in spanish_ips):
            accept_cookies = "2"
    g.accept_cookies = accept_cookies
Ejemplo n.º 3
0
Archivo: web.py Proyecto: Desala/appweb
def init_g(app):
    g.license_name = "torrents"

    g.tos_link = "http://torrents.com/legal#tos"
    g.privacy_link = "http://torrents.com/legal#privacy"

    g.analytics_code = """<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-38333996-2']);  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>"""

    # caracteristicas del cliente
    g.search_bot = is_search_bot()

    # peticiones en modo preproduccion
    g.beta_request = request.url_root[request.url_root.index("//")+2:].startswith("beta.")

    # endpoint de entrada (usado en la página de error)
    if app.config["APPWEB_MODE"] == "search":
        g.home_route = "files.home"
    elif app.config["APPWEB_MODE"] == "extras":
        g.home_route = "extras.home"
    else:
        logging.error(u"APPWEB_MODE no especificado en la configuración")
        g.home_route = "files.home"

    # prefijo para los contenidos estáticos
    if g.beta_request:
        app_static_prefix = app.static_url_path
    else:
        app_static_prefix = app.config["STATIC_PREFIX"] or app.static_url_path
    g.static_prefix = app.assets.url = app_static_prefix

    g.keywords = set()
    g.args = {}

    g.page_description=g.title=""

    g.categories = (('movies', {"q": "movie"}),
                     ('games', {"q": "game"}),
                     ('tv', {"q": "series"}),
                     ('music', {"q": "audio"}),
                     ('anime', {"q": "anime"}),
                     ('books', {"q": "ebook"}),
                     ('adult', {"q": "p**n"}),
                     ('software', {"q": "software"}),
                     ('mobile', {"q": "mobile"}),
                     ('pictures', {"q": "image"})
                     )
Ejemplo n.º 4
0
def init_g(app):
    if not g.lang in current_app.config["APPWEB_AVAILABLE_LANGS"]:
        g.lang = "en"

    g.design = bool(request.form.get("wklk", False))
    g.license_name = license_name = "foofind" if "foofind" in request.url_root else "blubster"

    g.version_code = request.form.get("version",None)
    g.analytics_code = current_app.config["ANALYTICS_CODE"][license_name] % {"client_version":g.version_code or ""}

    # caracteristicas del cliente
    g.search_bot = is_search_bot()

    # peticiones en modo preproduccion
    g.beta_request = request.url_root[request.url_root.index("//")+2:].startswith("beta.")

    # endpoint de entrada (usado en la página de error)
    if current_app.config["APPWEB_MODE"] == "search":
        g.home_route = "files.home"
    elif current_app.config["APPWEB_MODE"] == "extras":
        g.home_route = "extras.home"
    else:
        logging.error(u"APPWEB_MODE no especificado en la configuración")
        g.home_route = "files.home"

    # prefijo para los contenidos estáticos
    if g.beta_request:
        app_static_prefix = current_app.static_url_path
    else:
        app_static_prefix = current_app.config["STATIC_PREFIX"] or current_app.static_url_path
    g.static_prefix = current_app.assets.url = app_static_prefix

    g.keywords = set()
    g.args = {}

    g.page_description=g.title=""

    g.tos_link = current_app.config["TOS_LINK"][license_name]
    g.privacy_link = current_app.config["PRIVACY_LINK"][license_name]

    g.categories = (('video',{"q":["video"]}),
                     ('audio',{"q":["audio"]}),
                     ('document',{"q":["document"]}),
                     ('image',{"q":["image"]}),
                     ('software',{"q":["software"]})
                     )

    g.downloader_properties = local_cache["downloader_properties"]
Ejemplo n.º 5
0
def init_g(app):

    g.wakalaka = bool(request.form.get("wklk", False))
    g.license_name = "foofind" if "foofind" in request.url_root else "blubster"

    # caracteristicas del cliente
    g.search_bot = is_search_bot()

    # peticiones en modo preproduccion
    g.beta_request = request.url_root[request.url_root.index("//") +
                                      2:].startswith("beta.")

    # endpoint de entrada (usado en la página de error)
    if app.config["APPWEB_MODE"] == "search":
        g.home_route = "files.home"
    elif app.config["APPWEB_MODE"] == "extras":
        g.home_route = "extras.home"
    else:
        logging.error(u"APPWEB_MODE no especificado en la configuración")
        g.home_route = "files.home"

    # prefijo para los contenidos estáticos
    if g.beta_request:
        app_static_prefix = app.static_url_path
    else:
        app_static_prefix = app.config["STATIC_PREFIX"] or app.static_url_path
    g.static_prefix = app.assets.url = app_static_prefix

    g.keywords = set()
    g.args = {}

    g.page_description = g.title = ""

    g.categories = (('video', {
        "t": "video"
    }), ('audio', {
        "t": "audio"
    }), ('document', {
        "t": "document"
    }), ('image', {
        "t": "image"
    }), ('software', {
        "t": "software"
    }))
Ejemplo n.º 6
0
def init_g(app):

    g.design = bool(request.form.get("wklk", False))
    g.license_name = "foofind" if "foofind" in request.url_root else "blubster"

    # caracteristicas del cliente
    g.search_bot = is_search_bot()

    # peticiones en modo preproduccion
    g.beta_request = request.url_root[request.url_root.index("//")+2:].startswith("beta.")

    # endpoint de entrada (usado en la página de error)
    if app.config["APPWEB_MODE"] == "search":
        g.home_route = "files.home"
    elif app.config["APPWEB_MODE"] == "extras":
        g.home_route = "extras.home"
    else:
        logging.error(u"APPWEB_MODE no especificado en la configuración")
        g.home_route = "files.home"

    # prefijo para los contenidos estáticos
    if g.beta_request:
        app_static_prefix = app.static_url_path
    else:
        app_static_prefix = app.config["STATIC_PREFIX"] or app.static_url_path
    g.static_prefix = app.assets.url = app_static_prefix

    g.keywords = set()
    g.args = {}

    g.page_description=g.title=""

    g.tos_link = app.config["TOS_LINK"]
    g.privacy_link = app.config["PRIVACY_LINK"]

    g.categories = (('video',{"t":"video"}),
                     ('audio',{"t":"audio"}),
                     ('document',{"t":"document"}),
                     ('image',{"t":"image"}),
                     ('software',{"t":"software"})
                     )
Ejemplo n.º 7
0
Archivo: web.py Proyecto: Desala/www
def init_g(app):

    # cache por defecto
    g.must_cache = 7200

    # caracteristicas del cliente
    g.full_browser=is_full_browser()
    g.search_bot=is_search_bot()

    # idioma ingles
    g.lang = "en"

    # peticiones en modo preproduccion
    g.beta_request = request.url_root[request.url_root.index("//")+2:].startswith("beta.")

    # prefijo para los contenidos estáticos
    if g.beta_request:
        app_static_prefix = app.static_url_path
    else:
        app_static_prefix = app.config["STATIC_PREFIX"] or app.static_url_path
    g.static_prefix = app.assets.url = app_static_prefix

    # permite sobreescribir practicamente todo el <head> si es necesario
    g.override_header = False

    # alerts system
    g.alert = {}

    g.keywords = {'torrents', 'download', 'files', 'search', 'audio', 'video', 'image', 'document', 'software'}

    g.show_blacklisted_content = app.config["SHOW_BLACKLISTED_CONTENT"]

    # informacion de categorias
    g.categories = categories_cache.categories
    g.categories_by_url = categories_cache.categories_by_url
    g.categories_results = None

    g.featured = []

    # pagina actual
    g.page_type = None

    # busqueda actual
    g.track = False
    g.query = g.clean_query = None
    g.category = None

    # cookie control
    g.must_accept_cookies = app.config["MUST_ACCEPT_COOKIES"]

    # images server
    g.images_server = app.config["IMAGES_SERVER"]

    g.is_adult_content = False

    # permite ofrecer el downloader en enlaces de descarga
    g.offer_downloader = False

    # dominio de la web
    g.domain = None
    g.domains_family = app.config["ALLOWED_DOMAINS"]

    for domain in g.domains_family:
        if domain in request.url_root:
            g.domain = domain
            break
    else:
        return

    g.domain_cookies = [url_for('index.cookies', _domain=domain) for domain in g.domains_family if domain!=g.domain]

    g.section = "torrents" if g.domain=="torrents.fm" else "downloader" if g.domain=="torrents.ms" else "news"
    g.domain_capitalized = g.domain.capitalize()

    # RUM
    if "RUM_CODES" in app.config:
        rum_codes = app.config["RUM_CODES"]
        g.RUM_code = rum_codes[g.domain] if g.domain in rum_codes else rum_codes["torrents.com"]
    else:
        g.RUM_code = None

    # título de la página por defecto
    g.title = [g.domain_capitalized]

    # Patrón de URL de busqueda, para evitar demasiadas llamadas a url_for
    g.url_search_base = url_for("files.search", query="___")
    g.url_adult_search_base = url_for("files.category", category="p**n", query="___")

    # downloader links
    g.downloader_properties = local_cache["downloader_properties"]
Ejemplo n.º 8
0
Archivo: web.py Proyecto: Weej1/www
def init_g(app):
    # secure?
    g.secure_request = request.headers.get("X-SSL-Active", "No")=="Yes"
    request.environ['wsgi.url_scheme'] = "https" if g.secure_request else "http"

    # cache por defecto
    g.must_cache = 7200

    # caracteristicas del cliente
    g.full_browser=is_full_browser()
    g.search_bot=is_search_bot()

    # peticiones en modo preproduccion
    g.beta_request = request.url_root[request.url_root.index("//")+2:].startswith("beta.")

    # prefijo para los contenidos estáticos
    if g.beta_request:
        app_static_prefix = app.static_url_path
    else:
        app_static_prefix = app.config["STATIC_PREFIX"] or app.static_url_path
    g.static_prefix = app.assets.url = app_static_prefix

    # permite sobreescribir practicamente todo el <head> si es necesario
    g.override_header = False

    # alerts system
    g.alert = {}

    g.keywords = {'torrents', 'download', 'files', 'search', 'audio', 'video', 'image', 'document', 'software'}

    g.show_blacklisted_content = app.config["SHOW_BLACKLISTED_CONTENT"]

    # informacion de categorias
    g.categories = categories_cache.categories
    g.categories_by_url = categories_cache.categories_by_url
    g.categories_results = None

    g.featured = []

    # pagina actual
    g.page_type = None

    # busqueda actual
    g.track = False
    g.query = g.clean_query = None
    g.category = None

    # cookie control
    g.must_accept_cookies = app.config["MUST_ACCEPT_COOKIES"]

    # images server
    g.images_server = app.config["IMAGES_SERVER"]

    g.is_adult_content = False

    # dominio de la web
    g.domain = None
    g.domains_family = app.config["ALLOWED_DOMAINS"]

    for domain in g.domains_family:
        if domain in request.url_root:
            g.domain = domain
            break
    else:
        return

    g.section = "torrents" if g.domain=="torrents.fm" else "downloader" if g.domain=="torrents.ms" else "news"
    g.domain_capitalized = g.domain.capitalize()

    # language selector
    g.langs = langs = app.config["LANGS"]
    g.translate_domains = app.config["TRANSLATE_DOMAINS"]

    g.lang = "".join(lang for lang in langs[1:] if lang+"."+g.domain in request.url_root) or langs[0]
    g.langs_switch = app.config["LANGS_SWITCH"]

    # IMPORTANT: DON'T USE URL_FOR BEFORE THIS POINT IN THIS FUNCTION!

    # RUM
    if "RUM_CODES" in app.config:
        rum_codes = app.config["RUM_CODES"]
        g.RUM_code = rum_codes[g.domain] if g.domain in rum_codes else rum_codes["torrents.com"]
    else:
        g.RUM_code = None

    # título de la página por defecto
    g.title = [g.domain_capitalized]

    # cookies
    g.domain_cookies = [url_for('index.cookies', _domain=domain) for domain in g.domains_family if domain!=g.domain]

    # Patrón de URL de busqueda, para evitar demasiadas llamadas a url_for
    g.url_search_base = url_for("files.search", query="___")
    g.url_adult_search_base = url_for("files.category", category="p**n", query="___")

    # permite ofrecer el downloader en enlaces de descarga
    g.offer_downloader = True

    # downloader links
    g.downloader_properties = local_cache["downloader_properties"]

    g.user_build = current_app.config["DOWNLOADER_DEFAULT_BUILD"]
    # Find the best active build for the user
    for build, info in g.downloader_properties.iteritems():
        try:
            if build != "common" and info["active"] and info["length"] and info.get("check_user_agent", lambda x:False)(request.user_agent):
                g.user_build = build
        except BaseException as e:
            logging.exception(e)

    # banners
    g.banners = app.config["BANNERS"]