<commit_before>form.ui.form(action="/posts", method="post")
  input(type="hidden", name="_author", value="#{user._id}")
  input(type="hidden", name="hashcash")
  .field
    label Link
    input(type="text", name="link", placeholder="http://...")
  .field.required
    label Title
    input(type="text", name="name", placeholder="e.g., \"TEST POST PLEASE IGNORE\"", required)
  .field
    label Content
    textarea(name="description", placeholder="Your thoughtful contribution.")
  .right.floated
    button.ui.submit.button.primary
      i.edit.icon
      | Create Post &raquo;

block append scripts
  script.
    String.prototype.hexEncode = function(){
      var hex, i;
      var result = '';
      for (i=0; i<this.length; i++) {
        hex = this.charCodeAt(i).toString(16);
        result += ('000'+hex).slice(-4);
      }
      return result;
    }

    $('form[action="/posts"][method=post]').submit(function(e) {
      e.preventDefault();
      
      $('form[action="/posts"][method=post]').addClass('loading');
      $('form[action="/posts"][method=post] .submit').html('working...');
      
      var data = $(self).form('get values');
      var cash = $('form[action="/posts"][method=post] input[name=hashcash]');
      var name = $('form[action="/posts"][method=post] input[name=name]');
      var input = name.val().hexEncode();

      var worker = new Worker('/js/worker.js');
      worker.onmessage = function(e) {
        console.log('work result:', e.data);
        var hash = e.data;
        cash.val(hash);
        
        data.hashcash = hash;
        data._author     = $('form[action="/posts"][method=post] input[name=_author]').val();
        data.link        = $('form[action="/posts"][method=post] input[name=link]').val();
        data.name        = $('form[action="/posts"][method=post] input[name=name]').val();
        data.description = $('form[action="/posts"][method=post] textarea[name=description]').val();
        
        $.post('/posts', data, function(post, status, xhr) {
          document.location.href = '/posts/' + post._id;
        }, 'json');
      }

      var difficulty = 3;
      worker.postMessage([ input , difficulty ]);

      return false;
    });<commit_msg>Lower difficulty to 2 for demo.<commit_after>form.ui.form(action="/posts", method="post")
  input(type="hidden", name="_author", value="#{user._id}")
  input(type="hidden", name="hashcash")
  .field
    label Link
    input(type="text", name="link", placeholder="http://...")
  .field.required
    label Title
    input(type="text", name="name", placeholder="e.g., \"TEST POST PLEASE IGNORE\"", required)
  .field
    label Content
    textarea(name="description", placeholder="Your thoughtful contribution.")
  .right.floated
    button.ui.submit.button.primary
      i.edit.icon
      | Create Post &raquo;

block append scripts
  script.
    String.prototype.hexEncode = function(){
      var hex, i;
      var result = '';
      for (i=0; i<this.length; i++) {
        hex = this.charCodeAt(i).toString(16);
        result += ('000'+hex).slice(-4);
      }
      return result;
    }

    $('form[action="/posts"][method=post]').submit(function(e) {
      e.preventDefault();
      
      $('form[action="/posts"][method=post]').addClass('loading');
      $('form[action="/posts"][method=post] .submit').html('working...');
      
      var data = $(self).form('get values');
      var cash = $('form[action="/posts"][method=post] input[name=hashcash]');
      var name = $('form[action="/posts"][method=post] input[name=name]');
      var input = name.val().hexEncode();

      var worker = new Worker('/js/worker.js');
      worker.onmessage = function(e) {
        console.log('work result:', e.data);
        var hash = e.data;
        cash.val(hash);
        
        data.hashcash = hash;
        data._author     = $('form[action="/posts"][method=post] input[name=_author]').val();
        data.link        = $('form[action="/posts"][method=post] input[name=link]').val();
        data.name        = $('form[action="/posts"][method=post] input[name=name]').val();
        data.description = $('form[action="/posts"][method=post] textarea[name=description]').val();
        
        $.post('/posts', data, function(post, status, xhr) {
          document.location.href = '/posts/' + post._id;
        }, 'json');
      }

      var difficulty = 2;
      worker.postMessage([ input , difficulty ]);

      return false;
    });
{'fraction_non_alphanumeric': 0.19914683430624158, 'fraction_numerical': 0.003816793893129771, 'mean_word_length': 2.877284595300261, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '5687336', 'n_tokens_mistral': 1393, 'n_tokens_neox': 1351, 'n_words': 249}