<commit_before>{% extends "base.html" %}
{% load tz %}
{% load flatblock_tags %}

{%  block extra_head_js %}

{%  endblock extra_head_js %}
{% block content %}

{% if request.user == article.site_owner %}
<a class="btn btn-default" href="{% url 'compendia:update' article.id %}"><i class="fa fa-pencil"></i> Edit</a>
{% endif %}

<h2><a href="{{ article.article_url }}">{{ article.title }}</a></h2>

<p>{{ article.authors_text }}</p>

{% for contributor in article.contributors.all %}
  {% if contributor.public_name %}
    <a href="{% url 'users:detail' contributor.id  %}">{{ contributor.firstname }} {{ contributor.lastname }}</a>
    {% if not forloop.last %}, {% endif %}
  {% endif %}
{% endfor %}

<h2>Code and Data Abstract</h2>
<p>{{ article.code_data_abstract }}</p>

{% if article.code_archive_file %}
  <button class="btn btn-default" data-toggle="modal" data-target="#citecode">
  <i class="fa fa-code"></i> code
  </button>
  <div class="modal fade" id="citecode" tabindex="-1" role="dialog" aria-labelledby="citeCodeAndDownloadLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="citeCodeAndDownloadLabel">Download Code</h4>
            </div>
            <div class="modal-body">
                {%  flatblock "cite_reminder" %}
                {% include "compendia/citation.html" %}

                <a class="btn btn-primary" href="{{ article.code_archive_file.url }}"><i class="fa fa-code"></i> code</a>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
  </div>
{% endif %}


 {% if article.data_archive_file %}
  <button class="btn btn-default" data-toggle="modal" data-target="#citedata">
  <i class="fa fa-bar-chart-o"></i> data
  </button>
  <div class="modal fade" id="citedata" tabindex="-1" role="dialog" aria-labelledby="citeDataAndDownloadLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="citeDataAndDownloadLabel">Download Data</h4>
            </div>
            <div class="modal-body">
                {%  flatblock "cite_reminder" %}
                {% include "compendia/citation.html" %}

                <a class="btn btn-primary" href="{{ article.data_archive_file.url }}"><i class="fa fa-bar-chart-o"></i> data</a>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
  </div>
{% endif %}

{% if article.lecture_notes_archive_file %}
<a class="btn btn-default" href="{{ article.lecture_notes_archive_file.url }}"><i class="fa fa-file-o"></i> Lectures</a>
{% endif %}
{% if article.homework_archive_file %}
<a class="btn btn-default" href="{{ article.homework_archive_file.url }}"><i class="fa fa-file-o"></i> Assignments</a>
{% endif %}
{% if article.solution_archive_file %}
<a class="btn btn-default" href="{{ article.solution_archive_file.url }}"><i class="fa fa-file-o"></i> Solutions</a>
{% endif %}
{% if article.article_file %}
<a class="btn btn-default" href="{{ article.article_file.url }}"><i class="fa fa-file-o"></i> Article</a>
{% endif %}
{% if article.book_file %}
<a class="btn btn-default" href="{{ article.book_file.url }}"><i class="fa fa-file-o"></i> Book</a>
{% endif %}



{% if article.verification_archive_file %}
<button type="button" id="compendia_verification" onclick="verification(event);" data-loading-text="Verifying..."
    class="btn btn-default"><i class="fa fa-cog"></i> Verify</button>
<div id="compendia_verifications"></div>
{% endif %}

{% if article.paper_abstract %}
<h2>Paper Abstract</h2>
<p>{{ article.paper_abstract }}</p>
{% endif %}


<p>
{% include "compendia/citation.html" %}
</p>

<p>
{% if article.compendium_type %}
<b>Compendium Type</b>: {{ article.compendium_type}}</br>
{% endif %}
{% if article.content_license %}
<b>Content License</b>: {{ article.content_license }}</br>
{% endif %}
{% if article.code_license %}
<b>Code License</b>: {{ article.code_license }}</br>
{% endif %}
</p>

{% if article.admin_notes %}
<h3>Administrator Notes</h3>
<p>{{ article.admin_notes }}</p>
{% endif %}

{% include "compendia/verification.html" %}

<h2>Page Owner</h2>
{{ article.site_owner }}
{% localtime on %}
<p>created {{ article.created|date:"SHORT_DATE_FORMAT" }}</p>
<p>modified {{ article.modified|date:"SHORT_DATE_FORMAT" }}</p>
{% endlocaltime %}

{% load disqus_tags %}
{% disqus_show_comments %}

 <!--<div id="disqus_thread"></div>
    <script type="text/javascript">
        /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
        var disqus_shortname = 'researchcompendiaorg'; // required: replace example with your forum shortname

        /* * * DON'T EDIT BELOW THIS LINE * * */
        (function() {
            var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
            dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
        })();
    </script>
    <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
    -->
    
    <script type="text/javascript">
    /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
    var disqus_shortname = 'researchcompendiaorg'; // required: replace example with your forum shortname

    /* * * DON'T EDIT BELOW THIS LINE * * */
    (function () {
        var s = document.createElement('script'); s.async = true;
        s.type = 'text/javascript';
        s.src = '//' + disqus_shortname + '.disqus.com/count.js';
        (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
    }());
    </script>
    
<p>
{% if article.legacy_id %}
<a href="http://www.runshare.org/CompanionSite/site.do?siteId={{ article.legacy_id }}">rmc id</a>
{% endif %}
</p>
<!-- AddThis Smart Layers BEGIN -->
<!-- Go to http://www.addthis.com/get/smart-layers to customize -->
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5334d4381d265227"></script>
<script type="text/javascript">
  addthis.layers({
    'theme' : 'transparent',
    'share' : {
      'position' : 'right',
      'numPreferredServices' : 6
    }, 
    'follow' : {
      'services' : [
        {'service': 'twitter', 'id': 'researchcompend', "offset":"{'bottom':'10px'}"}
      ]
    }   
  });
</script>
<!-- AddThis Smart Layers END -->

{% endblock content %}

{% block extrajs %}
<script type="text/javascript">

function verification(event) {
  event.preventDefault();
  var btn = $(this);
  btn.button('loading');
  $("#compendia_verifications").html(
      "<div class='alert alert-info'>" +
      "Verification request submitted with default parameters.<i class=\"fa fa-cog fa-spin\"></i>" +
      "</div>");
  $.ajax({
      type: "POST",
      url: "{% url 'verification' article.id %}",
      data: {},
      timeout: 6000, // 6 second timeout
  })
  .done(function (msg) {
      var alert_message = msg.message ? msg.message : "Verification request complete.";
      $("#compendia_verifications").html("<div class='alert alert-info'>" + alert_message + "</div>");
      $("#compendia_verifications").append(
      /*
       * TODO cached results should get returned by the backend.
       * This is faking it for now.
       * eurg. and I apologize for this javascript mess.
       */
        {% if recent_verifications %}
        {% with v=recent_verifications.0 %}
          "<ul>" +
          "<li>Verification run {{ v.id }}</li>" +
          "<li><a href=\"{{ v.archive_file.url }}\">{{ v.archive_base_name }}</a></li>" +
          "<li>verification files: {{ v.archive_info }}</li>" +
          "<li>parameters: default parameters</li>" +
          "</ul>"
        {% endwith %} 
        {% endif %}
      );
  })
  .fail(function (msg) {
      console.log("failed");
      var error_message = msg.responseJSON.message ? msg.responseJSON.message : "A service exception occured and we could not finish verification results.";
      $("#compendia_verifications").html("<div class='alert alert-danger'>" + error_message + "</div>");
  })
  .always(function (msg) {
      console.log(msg);
      btn.button('reset');
  });
};
</script>
{% endblock extrajs %}
<commit_msg>very primitive demonstration of permissions<commit_after>{% extends "base.html" %}
{% load tz %}
{% load flatblock_tags %}

{%  block extra_head_js %}

{%  endblock extra_head_js %}
{% block content %}

{% if request.user == article.site_owner %}
<a class="btn btn-default" href="{% url 'compendia:update' article.id %}"><i class="fa fa-pencil"></i> Edit</a>
{% endif %}

<h2><a href="{{ article.article_url }}">{{ article.title }}</a></h2>

<p>{{ article.authors_text }}</p>

{% for contributor in article.contributors.all %}
  {% if contributor.public_name %}
    <a href="{% url 'users:detail' contributor.id  %}">{{ contributor.firstname }} {{ contributor.lastname }}</a>
    {% if not forloop.last %}, {% endif %}
  {% endif %}
{% endfor %}

<h2>Code and Data Abstract</h2>
<p>{{ article.code_data_abstract }}</p>

{% if article.code_archive_file %}
  <button class="btn btn-default" data-toggle="modal" data-target="#citecode">
  <i class="fa fa-code"></i> code
  </button>
  <div class="modal fade" id="citecode" tabindex="-1" role="dialog" aria-labelledby="citeCodeAndDownloadLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="citeCodeAndDownloadLabel">Download Code</h4>
            </div>
            <div class="modal-body">
                {%  flatblock "cite_reminder" %}
                {% include "compendia/citation.html" %}

                <a class="btn btn-primary" href="{{ article.code_archive_file.url }}"><i class="fa fa-code"></i> code</a>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
  </div>
{% endif %}


 {% if article.data_archive_file %}
  <button class="btn btn-default" data-toggle="modal" data-target="#citedata">
  <i class="fa fa-bar-chart-o"></i> data
  </button>
  <div class="modal fade" id="citedata" tabindex="-1" role="dialog" aria-labelledby="citeDataAndDownloadLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="citeDataAndDownloadLabel">Download Data</h4>
            </div>
            <div class="modal-body">
                {%  flatblock "cite_reminder" %}
                {% include "compendia/citation.html" %}

                <a class="btn btn-primary" href="{{ article.data_archive_file.url }}"><i class="fa fa-bar-chart-o"></i> data</a>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
  </div>
{% endif %}

{% if article.lecture_notes_archive_file %}
<a class="btn btn-default" href="{{ article.lecture_notes_archive_file.url }}"><i class="fa fa-file-o"></i> Lectures</a>
{% endif %}
{% if article.homework_archive_file %}
<a class="btn btn-default" href="{{ article.homework_archive_file.url }}"><i class="fa fa-file-o"></i> Assignments</a>
{% endif %}

{% if 'can_change_compendium' in perms %}
{% if article.solution_archive_file %}
<a class="btn btn-default" href="{{ article.solution_archive_file.url }}"><i class="fa fa-file-o"></i> Solutions</a>
{% endif %}
{% endif %}

{% if article.article_file %}
<a class="btn btn-default" href="{{ article.article_file.url }}"><i class="fa fa-file-o"></i> Article</a>
{% endif %}
{% if article.book_file %}
<a class="btn btn-default" href="{{ article.book_file.url }}"><i class="fa fa-file-o"></i> Book</a>
{% endif %}



{% if article.verification_archive_file %}
<button type="button" id="compendia_verification" onclick="verification(event);" data-loading-text="Verifying..."
    class="btn btn-default"><i class="fa fa-cog"></i> Verify</button>
<div id="compendia_verifications"></div>
{% endif %}

{% if article.paper_abstract %}
<h2>Paper Abstract</h2>
<p>{{ article.paper_abstract }}</p>
{% endif %}


<p>
{% include "compendia/citation.html" %}
</p>

<p>
{% if article.compendium_type %}
<b>Compendium Type</b>: {{ article.compendium_type}}</br>
{% endif %}
{% if article.content_license %}
<b>Content License</b>: {{ article.content_license }}</br>
{% endif %}
{% if article.code_license %}
<b>Code License</b>: {{ article.code_license }}</br>
{% endif %}
</p>

{% if article.admin_notes %}
<h3>Administrator Notes</h3>
<p>{{ article.admin_notes }}</p>
{% endif %}

{% include "compendia/verification.html" %}

<h2>Page Owner</h2>
{{ article.site_owner }}
{% localtime on %}
<p>created {{ article.created|date:"SHORT_DATE_FORMAT" }}</p>
<p>modified {{ article.modified|date:"SHORT_DATE_FORMAT" }}</p>
{% endlocaltime %}

{% load disqus_tags %}
{% disqus_show_comments %}

 <!--<div id="disqus_thread"></div>
    <script type="text/javascript">
        /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
        var disqus_shortname = 'researchcompendiaorg'; // required: replace example with your forum shortname

        /* * * DON'T EDIT BELOW THIS LINE * * */
        (function() {
            var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
            dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
        })();
    </script>
    <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
    -->
    
    <script type="text/javascript">
    /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
    var disqus_shortname = 'researchcompendiaorg'; // required: replace example with your forum shortname

    /* * * DON'T EDIT BELOW THIS LINE * * */
    (function () {
        var s = document.createElement('script'); s.async = true;
        s.type = 'text/javascript';
        s.src = '//' + disqus_shortname + '.disqus.com/count.js';
        (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
    }());
    </script>
    
<p>
{% if article.legacy_id %}
<a href="http://www.runshare.org/CompanionSite/site.do?siteId={{ article.legacy_id }}">rmc id</a>
{% endif %}
</p>
<!-- AddThis Smart Layers BEGIN -->
<!-- Go to http://www.addthis.com/get/smart-layers to customize -->
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5334d4381d265227"></script>
<script type="text/javascript">
  addthis.layers({
    'theme' : 'transparent',
    'share' : {
      'position' : 'right',
      'numPreferredServices' : 6
    }, 
    'follow' : {
      'services' : [
        {'service': 'twitter', 'id': 'researchcompend', "offset":"{'bottom':'10px'}"}
      ]
    }   
  });
</script>
<!-- AddThis Smart Layers END -->

{% endblock content %}

{% block extrajs %}
<script type="text/javascript">

function verification(event) {
  event.preventDefault();
  var btn = $(this);
  btn.button('loading');
  $("#compendia_verifications").html(
      "<div class='alert alert-info'>" +
      "Verification request submitted with default parameters.<i class=\"fa fa-cog fa-spin\"></i>" +
      "</div>");
  $.ajax({
      type: "POST",
      url: "{% url 'verification' article.id %}",
      data: {},
      timeout: 6000, // 6 second timeout
  })
  .done(function (msg) {
      var alert_message = msg.message ? msg.message : "Verification request complete.";
      $("#compendia_verifications").html("<div class='alert alert-info'>" + alert_message + "</div>");
      $("#compendia_verifications").append(
      /*
       * TODO cached results should get returned by the backend.
       * This is faking it for now.
       * eurg. and I apologize for this javascript mess.
       */
        {% if recent_verifications %}
        {% with v=recent_verifications.0 %}
          "<ul>" +
          "<li>Verification run {{ v.id }}</li>" +
          "<li><a href=\"{{ v.archive_file.url }}\">{{ v.archive_base_name }}</a></li>" +
          "<li>verification files: {{ v.archive_info }}</li>" +
          "<li>parameters: default parameters</li>" +
          "</ul>"
        {% endwith %} 
        {% endif %}
      );
  })
  .fail(function (msg) {
      console.log("failed");
      var error_message = msg.responseJSON.message ? msg.responseJSON.message : "A service exception occured and we could not finish verification results.";
      $("#compendia_verifications").html("<div class='alert alert-danger'>" + error_message + "</div>");
  })
  .always(function (msg) {
      console.log(msg);
      btn.button('reset');
  });
};
</script>
{% endblock extrajs %}

{'fraction_non_alphanumeric': 0.19316029854071515, 'fraction_numerical': 0.005235602094240838, 'mean_word_length': 3.258776091081594, 'pattern_counts': {'":': 2, '<': 333, '<?xml version=': 0, '>': 333, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5517948', 'n_tokens_mistral': 6149, 'n_tokens_neox': 5730, 'n_words': 1193}