<commit_before># -*- coding: utf-8 -*-
"""
    app.static
    ~~~~~~~~~~

    Manage the static assets for the Kibera School Project.

    This module injects the right css and javascript for templates.

"""

import os
try:
    from urllib.parse import urlencode
except ImportError:  # python2
    from urllib import urlencode
import requests
from hashlib import sha1
from cssmin import cssmin as cssmin_func
from flask import Markup
from . import app


def static_config():
    return {
        'tag_templates': {
            'css': '<link rel="stylesheet" href="{}" />',
            'js':'<script src="{}"></script>',
        },
        'build_filters': {
            'css': (concatenate, cssmin),
            'js': (concatenate, closure),
        }
    }


def concatenate(sources):
    combined = '\n'.join(sources)
    return [combined]


def cssmin(sources):
    return map(cssmin_func, sources)


def closure_func(source):
    """Compile javascript with google's closure compiler.

    This function uses the google closure http api to do the work, so you need
    an active internet connection to use it. If that app cannot be accessed for
    whatever reason, this filter can be disabled by removing it from
    `build_filters` in `static_config()`, above.
    """
    closure_api_url = 'https://closure-compiler.appspot.com/compile'
    params = urlencode([
        ('js_code', source),
        ('compilation_level', 'ADVANCED_OPTIMIZATIONS'),
        ('output_format', 'json'),
        ('output_info', 'compiled_code'),
    ])<commit_msg>Use simple optimizations only from closure compiler<commit_after># -*- coding: utf-8 -*-
"""
    app.static
    ~~~~~~~~~~

    Manage the static assets for the Kibera School Project.

    This module injects the right css and javascript for templates.

"""

import os
try:
    from urllib.parse import urlencode
except ImportError:  # python2
    from urllib import urlencode
import requests
from hashlib import sha1
from cssmin import cssmin as cssmin_func
from flask import Markup
from . import app


def static_config():
    return {
        'tag_templates': {
            'css': '<link rel="stylesheet" href="{}" />',
            'js':'<script src="{}"></script>',
        },
        'build_filters': {
            'css': (concatenate, cssmin),
            'js': (concatenate, closure),
        }
    }


def concatenate(sources):
    combined = '\n'.join(sources)
    return [combined]


def cssmin(sources):
    return map(cssmin_func, sources)


def closure_func(source):
    """Compile javascript with google's closure compiler.

    This function uses the google closure http api to do the work, so you need
    an active internet connection to use it. If that app cannot be accessed for
    whatever reason, this filter can be disabled by removing it from
    `build_filters` in `static_config()`, above.
    """
    closure_api_url = 'https://closure-compiler.appspot.com/compile'
    params = urlencode([
        ('js_code', source),
        ('compilation_level', 'SIMPLE_OPTIMIZATIONS'),
        ('output_format', 'json'),
        ('output_info', 'compiled_code'),
    ])
{'fraction_non_alphanumeric': 0.11742182514358647, 'fraction_numerical': 0.0019144862795149968, 'mean_word_length': 2.933500627352572, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '3772170', 'n_tokens_mistral': 916, 'n_tokens_neox': 877, 'n_words': 304}