<commit_before>from __future__ import unicode_literals

from functools import wraps
from flask.ext.sitemap import Sitemap, sitemap_page_needed

from udata.app import cache


sitemap = Sitemap()


@sitemap_page_needed.connect
def create_page(app, page, urlset):
    cache.set(page, sitemap.render_page(urlset=urlset))


def load_page(fn):
    @wraps(fn)
    def loader(*args, **kwargs):
        page = kwargs.get('page')
        return cache.get(page) or fn(*args, **kwargs)
    return loader


def init_app(app):
    app.config['SITEMAP_VIEW_DECORATORS'] = [load_page]
    app.config['SITEMAP_URL_METHOD'] = 'https'
    sitemap.init_app(app)<commit_msg>Only use https URLs when USE_SSL is True<commit_after>from __future__ import unicode_literals

from functools import wraps
from flask.ext.sitemap import Sitemap, sitemap_page_needed

from udata.app import cache


sitemap = Sitemap()


@sitemap_page_needed.connect
def create_page(app, page, urlset):
    cache.set(page, sitemap.render_page(urlset=urlset))


def load_page(fn):
    @wraps(fn)
    def loader(*args, **kwargs):
        page = kwargs.get('page')
        return cache.get(page) or fn(*args, **kwargs)
    return loader


def init_app(app):
    app.config['SITEMAP_VIEW_DECORATORS'] = [load_page]
    app.config['SITEMAP_URL_METHOD'] = 'https' if app.config['USE_SSL'] else 'http'
    sitemap.init_app(app)
{'fraction_non_alphanumeric': 0.1145985401459854, 'fraction_numerical': 0.0, 'mean_word_length': 4.595918367346939, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5957102', 'n_tokens_mistral': 506, 'n_tokens_neox': 489, 'n_words': 106}