<commit_before>angular.module('gratefulplaceApp').directive 'post', ->
  restrict: "E"
  scope:
    post: '='
  controller: ['$scope', 'Authorize', 'Post', ($scope, Authorize, Post)->
    $scope.formatCreatedAt = (date)->
      moment(date).format("MMM D, YYYY h:mma")

    $scope.showEdit = ->
      Authorize.canModifyContent($scope.post)

    $scope.toggleEdit = ($event)->
      $scope.post.editing = !$scope.post.editing
      $event && $event.preventDefault()

    $scope.updatePost = ->
      post = new Post($scope.post)
      post.$save((p)->
        $scope.post = p
        $scope.toggleEdit()
      , (res)->
        $scope.errors = res.data.errors
      )
  ]
  template: '
    <div class="post" ng-class="{editing: post.editing}">
      <div class="error" error-messages="errors.authorization"></div>
      <i class="edit icon-pencil"
         ng-show="showEdit()"
         ng-click="toggleEdit()"></i>
      <div class="content"
           ng-bind-html-unsafe="post.content"
           ng-show="!post.editing">
      </div>
      <div class="error" error-messages="errors.content"></div>
      <div class="content-edit" ng-show="post.editing">
        <form ng-submit="updatePost()">
          <textarea ng-model="post.content"></textarea>
          <input type="submit" value="Save" />
          <a href="#"
             ng-click="toggleEdit($event)"
             class="cancel">Cancel</a>
        </form>
      </div>
      <footer>
        <div class="author">
          <a href="" ng-click="peekAt(post.author)">
            {{post.author.username}}
          </a>
        </div>
        <div class="date">{{formatCreatedAt(post["created-at"])}}</div>
        <i class="like icon-thumbs-up"></i>
      </footer>
    </div>'
  replace: true<commit_msg>further permission for editing post<commit_after>angular.module('gratefulplaceApp').directive 'post', ->
  restrict: "E"
  scope:
    post: '='
  controller: ['$scope', 'Authorize', 'Post', ($scope, Authorize, Post)->
    $scope.formatCreatedAt = (date)->
      moment(date).format("MMM D, YYYY h:mma")

    $scope.showEdit = ->
      Authorize.canModifyContent($scope.post)

    $scope.toggleEdit = ($event)->
      if Authorize.canModifyContent($scope.post)
        $scope.post.editing = !$scope.post.editing
      $event && $event.preventDefault()

    $scope.updatePost = ->
      post = new Post($scope.post)
      post.$save((p)->
        $scope.post = p
        $scope.toggleEdit()
      , (res)->
        $scope.errors = res.data.errors
      )
  ]
  template: '
    <div class="post" ng-class="{editing: post.editing}">
      <div class="error" error-messages="errors.authorization"></div>
      <i class="edit icon-pencil"
         ng-show="showEdit()"
         ng-click="toggleEdit()"></i>
      <div class="content"
           ng-bind-html-unsafe="post.content"
           ng-show="!post.editing">
      </div>
      <div class="error" error-messages="errors.content"></div>
      <div class="content-edit" ng-show="post.editing">
        <form ng-submit="updatePost()">
          <textarea ng-model="post.content"></textarea>
          <input type="submit" value="Save" />
          <a href="#"
             ng-click="toggleEdit($event)"
             class="cancel">Cancel</a>
        </form>
      </div>
      <footer>
        <div class="author">
          <a href="" ng-click="peekAt(post.author)">
            {{post.author.username}}
          </a>
        </div>
        <div class="date">{{formatCreatedAt(post["created-at"])}}</div>
        <i class="like icon-thumbs-up"></i>
      </footer>
    </div>'
  replace: true
{'fraction_non_alphanumeric': 0.1896981445582941, 'fraction_numerical': 0.0, 'mean_word_length': 2.366262814538677, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 77, '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': '2483269', 'n_tokens_mistral': 1157, 'n_tokens_neox': 1139, 'n_words': 191}