Skip to content

Commit

Permalink
Add script documentation field to hold longer script docs.
Browse files Browse the repository at this point in the history
This adds support for longer documentation for scripts using a
`documentation` field. The Javascript ShowDown markdown converted
is used to render markdown on the client side to avoid dependencies
for the installation.
  • Loading branch information
mfitzp committed Aug 26, 2015
1 parent fbeea3a commit c0b7d30
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
19 changes: 19 additions & 0 deletions wooey/migrations/0007_script_documentation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

dependencies = [
('wooey', '0006_script_group_defaults'),
]

operations = [
migrations.AddField(
model_name='script',
name='documentation',
field=models.TextField(null=True, blank=True),
),
]
1 change: 1 addition & 0 deletions wooey/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Script(ModelDiffMixin, WooeyPy2Mixin, models.Model):
# or else we will fail form validation before we hit the model.
script_group = models.ForeignKey('ScriptGroup', null=True, blank=True)
script_description = models.TextField(blank=True, null=True)
documentation = models.TextField(blank=True, null=True)
script_order = models.PositiveSmallIntegerField(default=1)
is_active = models.BooleanField(default=True)
user_groups = models.ManyToManyField(Group, blank=True)
Expand Down
9 changes: 9 additions & 0 deletions wooey/templates/wooey/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@
<script type="text/javascript" src="//cdn.datatables.net/1.10.6/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="//cdn.datatables.net/responsive/1.0.5/js/dataTables.responsive.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/showdown/1.2.2/showdown.min.js"></script>
{% endblock js %}

{% block extra_js %}
Expand Down Expand Up @@ -707,6 +708,10 @@
return false;
}

var converter = new showdown.Converter({
'github_flavouring': true,
'tables': true
});

$(document).ready(function(){

Expand Down Expand Up @@ -775,6 +780,10 @@

}, 100);

$(".markdown").each(function( index ) {
$( this ).html( converter.makeHtml( $( this ).html() ) );
});



});
Expand Down
10 changes: 10 additions & 0 deletions wooey/templates/wooey/scripts/script_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ <h3 id="wooey-script-title">{{ script.script_name }}</h3>

<div class="container-fluid">

{% if script.documentation %}
<div class="panel panel-default">
<div class="panel-heading">Documentation <a class="icon icon-collapse" data-toggle="collapse" data-target="#collapse-metadata" href="#collapse-metadata"></a></div>
<div id="collapse-metadata" class="panel-collapse collapse in">
<div class="panel-body markdown">{{ script.documentation }}</div>
</div>
</div>
{% endif %}


<form id="wooey-job-form" method="POST" action="{{ form.action }}" enctype="multipart/form-data">
{% csrf_token %}

Expand Down

0 comments on commit c0b7d30

Please sign in to comment.