Example #1
0
def js_nominify(request):
    """View to render not minified/not combined Javascript
    
    Params:
        - ``request``: a ``django.http.HttpRequest`` object
    
    Returns:
        - response: a ``django.http.HttpResponse`` with not combined
          and not minified Javascript as its content 
    """
    js = ''
    if 'url' in request.GET:
        return utils.minify_js_from_url(request, request.GET['url'], nominify=True)
    if 'file' in request.GET:
        filename = request.GET['file']
        js = utils.check_and_read_from_file(request, filename)
    response = http.HttpResponse(js, mimetype='text/javascript')
    return response 
Example #2
0
def js_minify(request):
    """View to render minified/combined Javascript
    
    Params:
        - ``request``: a ``django.http.HttpRequest`` object
    
    Returns:
        - ``respons``e: a ``django.http.HttpResponse`` with combined
          and minified Javascript as its content 
    """
    res = ''    
    files = []
    url = request.GET.get('url')
    if url:
        minified_js = utils.minify_js_from_url(request, url)
        if minified_js:
            res = '%s\n%s' % (res, minified_js)
    if request.GET.get('files'):
        files = request.GET['files'].split(',')
        res = '%s\n%s' % (res, utils.minify_js_from_files(request, files))
    response = http.HttpResponse(res, mimetype='text/javascript')
    return response