<commit_before><div class='organization'>

  <h2<% if @preview %> data-bind="text: name"<% end %>><%= organization.name %></h2>

  <div class='organization-logo pull-right' 
       style='background-image: url(<%= organization.logo %>)'
       <% if @preview %> data-bind='style: {backgroundImage: imageSrc}'<% end %> >
  </div>

  <i class='icon icon-home'></i> <a<% if @preview %> data-bind="text: url, attr: {href: url}"<% end %> href='<%= organization.url %>'><%= organization.url%></a>

  <div class='organization-description'>
    <% if @preview %>
      <p data-bind="text: description"></p>
    <% else %>
      <%= simple_format(organization.description) %>
    <% end %>
  </div>

  <% if @preview %>
    <script type="text/javascript">
        function OrganisationViewModel() {
            this.name        = ko.observable("<%= organization.name %>");
            this.description = ko.observable("<%= organization.description.try(:squish) %>");
            this.url         = ko.observable("<%= organization.url %>");
            this.imageSrc    = ko.observable("url(<%= organization.logo %>)");
            this.updateImage = function() {
              input = $('#member_organization_attributes_logo')[0]
              if (input.files[0] && window.FileReader) {
                reader = new FileReader();
                reader.onloadend = function( ){
                    window.organisationPreview.imageSrc("url("+this.result+")");
                }
                reader.readAsDataURL(input.files[0]);
              }
            };
        };
        window.organisationPreview = new OrganisationViewModel()
        ko.applyBindings(window.organisationPreview);
    </script>
  <% end %>
  
</div>





<commit_msg>Auto-format description in preview<commit_after><div class='organization'>

  <h2<% if @preview %> data-bind="text: name"<% end %>><%= organization.name %></h2>

  <div class='organization-logo pull-right' 
       style='background-image: url(<%= organization.logo %>)'
       <% if @preview %> data-bind='style: {backgroundImage: imageSrc}'<% end %> >
  </div>

  <i class='icon icon-home'></i> <a<% if @preview %> data-bind="text: url, attr: {href: url}"<% end %> href='<%= organization.url %>'><%= organization.url%></a>

  <div class='organization-description'>
    <% if @preview %>
      <div data-bind="html: formattedDescription"></div>
    <% else %>
      <%= simple_format(organization.description) %>
    <% end %>
  </div>

  <% if @preview %>
    <script type="text/javascript">
        function OrganisationViewModel() {
            this.name        = ko.observable("<%= organization.name %>");
            this.description = ko.observable("<%= escape_javascript(organization.description) %>");
            this.url         = ko.observable("<%= organization.url %>");
            this.imageSrc    = ko.observable("url(<%= organization.logo %>)");
            this.formattedDescription = ko.computed(function() {
              str = this.description().replace(/\r\n?/, "\n");
              str = $.trim(str);
              if (str.length > 0) {
                str = str.replace(/\n\n+/g, '</p><p>');
                str = str.replace(/\n/g, '<br />');
                str = '<p>' + str + '</p>';
              }
              return str;
            }, this);
            this.updateImage = function() {
              input = $('#member_organization_attributes_logo')[0]
              if (input.files[0] && window.FileReader) {
                reader = new FileReader();
                reader.onloadend = function( ){
                    window.organisationPreview.imageSrc("url("+this.result+")");
                }
                reader.readAsDataURL(input.files[0]);
              }
            };
        };
        window.organisationPreview = new OrganisationViewModel()
        ko.applyBindings(window.organisationPreview);
    </script>
  <% end %>
  
</div>






{'fraction_non_alphanumeric': 0.1821656050955414, 'fraction_numerical': 0.002802547770700637, 'mean_word_length': 2.2339373970345964, 'pattern_counts': {'":': 0, '<': 80, '<?xml version=': 0, '>': 81, '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': '1879049', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1076, 'n_words': 202}