<commit_before><!DOCTYPE html>
<html lang="en">
    <head>
        <title>URL Shortener - QiWeb Sample App</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
        <link href="/client/lib/webjars/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" media="screen">
        <link href="/client/lib/webjars/bootstrap/3.0.0/css/bootstrap-theme.min.css" rel="stylesheet" media="screen">
        <style>
            #api-output p,
            #api-output pre {
                font-size: 0.8em;
            }
        </style>
    </head>
    <body>
        <nav class="navbar navbar-default">
            <div class="navbar-header">
                <span class="navbar-brand">URL Shortener</span>
            </div>
            <p class="navbar-text pull-right">Sample application built with <a href="http://qiweb.org/" target="_blank">QiWeb</a></p>
        </nav>
        <div class="container">
            <form class="form-inline" id="form-shorten">
                <div class="form-group">
                    <div class="input-group">
                        <input type="url" class="form-control input-sm" id="input-shorten" placeholder="Long URL" required/>
                        <span class="input-group-btn">
                            <button type="submit" class="btn btn-default btn-sm" id="btn-shorten">
                                <span class="glyphicon glyphicon-resize-small"></span>
                                Shorten
                            </button>
                        </span>
                    </div>
                </div>
            </form>
            <hr/>
            <div class="row">
                <div class="col-md-8">
                    <div id="list-output"></div>
                </div>
                <div class="col-md-4">
                    <div id="api-output"></div>
                </div>
            </div>
        </div>
        <script src="/client/lib/webjars/jquery/2.0.3/jquery.min.js"></script>
        <script src="/client/lib/webjars/bootstrap/3.0.0/js/bootstrap.js"></script>
        <script type="text/javascript">
            function data_to_pre_json(title, data)
            {
                return "<p><strong>" + title + "</strong></p><pre>" + JSON.stringify(data) + "</pre>";
            }
            var shorten, expand, lookup, redirect;
            $(document).ready(function() {
                var $list_out = $("#list-output");
                var $api_out = $("#api-output");
                var $input_shorten = $("#input-shorten");
                function refresh_list()
                {
                    var url = "/api/list"
                    $.getJSON(url, function(data) {
                        $api_out.prepend(data_to_pre_json("GET " + url, data));
                        var list = "";
                        if (data.length > 0) {
                            for (var idx = 0; idx < data.length; idx++) {
                                var link = data[idx];
                                list += " <div class='panel panel-default'>\
                                            <div class='panel-heading'>\
                                                <span class='glyphicon glyphicon-new-window'></span> \
                                                <a href=\"javascript:redirect('" + link.hash + "');\">" + window.location + link.hash + "</a>\
                                                <div class='pull-right'><a href=\"javascript:expand('" + link.hash + "');\" class='btn btn-xs btn-default'><span class='glyphicon glyphicon-resize-full'></span> Expand</a></div>\
                                            </div>\
                                            <div class='panel-body'>\
                                              " + link.clicks + " click" + (link.clicks > 1 ? "s" : "") + "\
                                              <span class='glyphicon glyphicon-arrow-right'></span> " + link.long_url + "\
                                              <div class='pull-right'><a href=\"javascript:lookup('" + link.long_url + "');\" class='btn btn-xs btn-default'><span class='glyphicon glyphicon-search'></span> Lookup</a></div>\
                                            </div>\
                                          </div>";
                            }
                        } else {
                            list += "<p>No shortened URL.</p>";
                        }
                        $list_out.html(list);
                    });
                }
                shorten = function(longUrl) {
                    var url = "/api/shorten?long_url=" + encodeURIComponent(longUrl);
                    $.getJSON(url, function(data) {
                        $api_out.prepend(data_to_pre_json("GET " + url, data));
                        refresh_list();
                    });
                    $input_shorten.focus();
                };
                expand = function(hash) {
                    var url = "/api/expand?hash=" + hash;
                    $.getJSON(url, function(data) {
                        $api_out.prepend(data_to_pre_json("GET " + url, data));
                    });
                    $input_shorten.focus();
                };
                lookup = function(longUrl)
                {
                    var url = "/api/lookup?long_url=" + encodeURIComponent(longUrl);
                    $.getJSON(url, function(data) {
                        $api_out.prepend(data_to_pre_json("GET " + url, data));
                    });
                    $input_shorten.focus();
                };
                redirect = function(hash) {
                    var url = "/" + hash;
                    window.open(url);
                    setTimeout(function() {
                        $api_out.prepend(data_to_pre_json("GET " + url, "303 See Other"));
                        refresh_list();
                    }, "500");
                    $input_shorten.focus();
                };
                $("#form-shorten").submit(function(e) {
                    e.preventDefault();
                    shorten($input_shorten.val());
                });
                $input_shorten.focus();
                refresh_list();
            });
        </script>
    </body>
</html><commit_msg>URL Shortener Sample: clear shorten form field on submit<commit_after><!DOCTYPE html>
<html lang="en">
    <head>
        <title>URL Shortener - QiWeb Sample App</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
        <link href="/client/lib/webjars/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" media="screen">
        <link href="/client/lib/webjars/bootstrap/3.0.0/css/bootstrap-theme.min.css" rel="stylesheet" media="screen">
        <style>
            #api-output p,
            #api-output pre {
                font-size: 0.8em;
            }
        </style>
    </head>
    <body>
        <nav class="navbar navbar-default">
            <div class="navbar-header">
                <span class="navbar-brand">URL Shortener</span>
            </div>
            <p class="navbar-text pull-right">Sample application built with <a href="http://qiweb.org/" target="_blank">QiWeb</a></p>
        </nav>
        <div class="container">
            <form class="form-inline" id="form-shorten">
                <div class="form-group">
                    <div class="input-group">
                        <input type="url" class="form-control input-sm" id="input-shorten" placeholder="Long URL" required/>
                        <span class="input-group-btn">
                            <button type="submit" class="btn btn-default btn-sm" id="btn-shorten">
                                <span class="glyphicon glyphicon-resize-small"></span>
                                Shorten
                            </button>
                        </span>
                    </div>
                </div>
            </form>
            <hr/>
            <div class="row">
                <div class="col-md-8">
                    <div id="list-output"></div>
                </div>
                <div class="col-md-4">
                    <div id="api-output"></div>
                </div>
            </div>
        </div>
        <script src="/client/lib/webjars/jquery/2.0.3/jquery.min.js"></script>
        <script src="/client/lib/webjars/bootstrap/3.0.0/js/bootstrap.js"></script>
        <script type="text/javascript">
            function data_to_pre_json(title, data)
            {
                return "<p><strong>" + title + "</strong></p><pre>" + JSON.stringify(data) + "</pre>";
            }
            var shorten, expand, lookup, redirect;
            $(document).ready(function() {
                var $list_out = $("#list-output");
                var $api_out = $("#api-output");
                var $input_shorten = $("#input-shorten");
                function refresh_list()
                {
                    var url = "/api/list"
                    $.getJSON(url, function(data) {
                        $api_out.prepend(data_to_pre_json("GET " + url, data));
                        var list = "";
                        if (data.length > 0) {
                            for (var idx = 0; idx < data.length; idx++) {
                                var link = data[idx];
                                list += " <div class='panel panel-default'>\
                                            <div class='panel-heading'>\
                                                <span class='glyphicon glyphicon-new-window'></span> \
                                                <a href=\"javascript:redirect('" + link.hash + "');\">" + window.location + link.hash + "</a>\
                                                <div class='pull-right'><a href=\"javascript:expand('" + link.hash + "');\" class='btn btn-xs btn-default'><span class='glyphicon glyphicon-resize-full'></span> Expand</a></div>\
                                            </div>\
                                            <div class='panel-body'>\
                                              " + link.clicks + " click" + (link.clicks > 1 ? "s" : "") + "\
                                              <span class='glyphicon glyphicon-arrow-right'></span> " + link.long_url + "\
                                              <div class='pull-right'><a href=\"javascript:lookup('" + link.long_url + "');\" class='btn btn-xs btn-default'><span class='glyphicon glyphicon-search'></span> Lookup</a></div>\
                                            </div>\
                                          </div>";
                            }
                        } else {
                            list += "<p>No shortened URL.</p>";
                        }
                        $list_out.html(list);
                    });
                }
                shorten = function(longUrl) {
                    var url = "/api/shorten?long_url=" + encodeURIComponent(longUrl);
                    $.getJSON(url, function(data) {
                        $api_out.prepend(data_to_pre_json("GET " + url, data));
                        refresh_list();
                    });
                    $input_shorten.focus();
                };
                expand = function(hash) {
                    var url = "/api/expand?hash=" + hash;
                    $.getJSON(url, function(data) {
                        $api_out.prepend(data_to_pre_json("GET " + url, data));
                    });
                    $input_shorten.focus();
                };
                lookup = function(longUrl)
                {
                    var url = "/api/lookup?long_url=" + encodeURIComponent(longUrl);
                    $.getJSON(url, function(data) {
                        $api_out.prepend(data_to_pre_json("GET " + url, data));
                    });
                    $input_shorten.focus();
                };
                redirect = function(hash) {
                    var url = "/" + hash;
                    window.open(url);
                    setTimeout(function() {
                        $api_out.prepend(data_to_pre_json("GET " + url, "303 See Other"));
                        refresh_list();
                    }, "500");
                    $input_shorten.focus();
                };
                $("#form-shorten").submit(function(e) {
                    e.preventDefault();
                    shorten($input_shorten.val());
                    $input_shorten.val("");
                });
                $input_shorten.focus();
                refresh_list();
            });
        </script>
    </body>
</html>
{'fraction_non_alphanumeric': 0.14422851791149613, 'fraction_numerical': 0.004526652618434403, 'mean_word_length': 1.1197684036393714, 'pattern_counts': {'":': 0, '<': 181, '<?xml version=': 0, '>': 183, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 50, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '986787', 'n_tokens_mistral': 3330, 'n_tokens_neox': 3138, 'n_words': 552}