<commit_before><!DOCTYPE html>
<html ng-app="url-shortener">
  <head>
    <title>URL shortener</title>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
    <script>
    var app = angular.module('url-shortener', []);

    function absoluteUrl(relative) {
      var a = document.createElement('a');
      a.href = relative;
      return a.href;
    }

    app.filter('contains', function() {
      return function(haystack, needle) {
        if (!haystack) {
          return false;
        }
        return !!haystack.filter(function(straw) {
          return straw == needle;
        }).length;
      };
    });

    app.controller('newURL', function($scope, $http, $location) {
      $scope.name = $location.search()['name'];
      $scope.error = $location.search()['error'];
      $scope.urls = [];

      // internalPagesPrefix is a prefix that is reserved (cannot be used as a
      // shortened URL name) for the pages and method of the shortener itself.
      var internalPagesPrefix = '_';

      $scope.save = function() {
        if (!$scope.url || !$scope.name) {
          return;
        }

        $http.post(internalPagesPrefix + '/save',
            {url: $scope.url, name: $scope.name})
            .success(function(data, status, headers, config) {
              $scope.error = null;
              if (data.url) {
                $scope.short_url = data.url + data.name;
              } else {
                $scope.short_url = absoluteUrl(data.name);
              }
            })
            .error(function(data, status, headers, config) {
              $scope.short_url = null;
              $scope.error = data.error;
            });
      }

      $scope.list = function() {
        $http.post(internalPagesPrefix + '/list')
            .success(function(data) {
              $scope.error = null;
              $scope.urls = data.urls;
              $scope.user = data.user;
              $scope.superUser = data.superUser;
            })
            .error(function(data) {
              $scope.urls = [];
              $scope.error = data.error;
            });
      }

      $scope.delete = function(name) {
        $http.delete(internalPagesPrefix + '/' + name)
            .success(function() {
              $scope.error = null;
              $scope.urls = $scope.urls.filter(function(url) {
                return url.name != name;
              });
            })
            .error(function(data) {
              $scope.error = data.error;
            });
      }
    });
  </script>
  </head>
  <body ng-controller="newURL">
    <section>
      URL <input ng-model="url">
      Name <input ng-model="name">
       <button type="button" ng-click="save()">Make URL shorter</button>
      <br/>
      {{ short_url }}
    </section>

    <section ng-show="error" ng-bind="error">
    </section>

    <section>
      <button type="button" ng-click="list()">List all</button>
      <table ng-show="urls.length" border="1">
        <thead><tr>
          <th>Name</th>
          <th>Long URL</th>
          <th>Owners</th>
        </tr></thead>
        <tbody>
          <tr ng-repeat="url in urls">
            <td ng-bind="url.name"></td>
            <td ng-bind="url.url"></td>
            <td>
              <button ng-show="url.owners | contains: user || superUser"
                      ng-click="delete(url.name)">Delete</button>
              <ul ng-show="url.owners.length">
                <li ng-repeat="owner in url.owners" ng-bind="owner"></li>
              </ul>
            </td>
          </tr>
        </tbody>
      </table>
    </section>
  </body>
</html><commit_msg>Fix operator priority to show button for super user.<commit_after><!DOCTYPE html>
<html ng-app="url-shortener">
  <head>
    <title>URL shortener</title>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
    <script>
    var app = angular.module('url-shortener', []);

    function absoluteUrl(relative) {
      var a = document.createElement('a');
      a.href = relative;
      return a.href;
    }

    app.filter('contains', function() {
      return function(haystack, needle) {
        if (!haystack) {
          return false;
        }
        return !!haystack.filter(function(straw) {
          return straw == needle;
        }).length;
      };
    });

    app.controller('newURL', function($scope, $http, $location) {
      $scope.name = $location.search()['name'];
      $scope.error = $location.search()['error'];
      $scope.urls = [];

      // internalPagesPrefix is a prefix that is reserved (cannot be used as a
      // shortened URL name) for the pages and method of the shortener itself.
      var internalPagesPrefix = '_';

      $scope.save = function() {
        if (!$scope.url || !$scope.name) {
          return;
        }

        $http.post(internalPagesPrefix + '/save',
            {url: $scope.url, name: $scope.name})
            .success(function(data, status, headers, config) {
              $scope.error = null;
              if (data.url) {
                $scope.short_url = data.url + data.name;
              } else {
                $scope.short_url = absoluteUrl(data.name);
              }
            })
            .error(function(data, status, headers, config) {
              $scope.short_url = null;
              $scope.error = data.error;
            });
      }

      $scope.list = function() {
        $http.post(internalPagesPrefix + '/list')
            .success(function(data) {
              $scope.error = null;
              $scope.urls = data.urls;
              $scope.user = data.user;
              $scope.superUser = data.superUser;
            })
            .error(function(data) {
              $scope.urls = [];
              $scope.error = data.error;
            });
      }

      $scope.delete = function(name) {
        $http.delete(internalPagesPrefix + '/' + name)
            .success(function() {
              $scope.error = null;
              $scope.urls = $scope.urls.filter(function(url) {
                return url.name != name;
              });
            })
            .error(function(data) {
              $scope.error = data.error;
            });
      }
    });
  </script>
  </head>
  <body ng-controller="newURL">
    <section>
      URL <input ng-model="url">
      Name <input ng-model="name">
       <button type="button" ng-click="save()">Make URL shorter</button>
      <br/>
      {{ short_url }}
    </section>

    <section ng-show="error" ng-bind="error">
    </section>

    <section>
      <button type="button" ng-click="list()">List all</button>
      <table ng-show="urls.length" border="1">
        <thead><tr>
          <th>Name</th>
          <th>Long URL</th>
          <th>Owners</th>
        </tr></thead>
        <tbody>
          <tr ng-repeat="url in urls">
            <td ng-bind="url.name"></td>
            <td ng-bind="url.url"></td>
            <td>
              <button ng-show="(url.owners | contains: user) || superUser"
                      ng-click="delete(url.name)">Delete</button>
              <ul ng-show="url.owners.length">
                <li ng-repeat="owner in url.owners" ng-bind="owner"></li>
              </ul>
            </td>
          </tr>
        </tbody>
      </table>
    </section>
  </body>
</html>
{'fraction_non_alphanumeric': 0.15940849274182609, 'fraction_numerical': 0.001085334418667752, 'mean_word_length': 1.642293906810036, 'pattern_counts': {'":': 0, '<': 111, '<?xml version=': 0, '>': 111, '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': '2594254', 'n_tokens_mistral': 2204, 'n_tokens_neox': 2161, 'n_words': 421}