diff options
-rw-r--r-- | static/website/css/main.css | 16 | ||||
-rw-r--r-- | static/website/js/cloud.js | 22 | ||||
-rw-r--r-- | static/website/templates/ajax-contributor.html | 21 | ||||
-rw-r--r-- | static/website/templates/index.html | 10 | ||||
-rw-r--r-- | website/ajax.py | 15 | ||||
-rw-r--r-- | website/helpers.py | 4 |
6 files changed, 77 insertions, 11 deletions
diff --git a/static/website/css/main.css b/static/website/css/main.css index d4938fe..7c545a9 100644 --- a/static/website/css/main.css +++ b/static/website/css/main.css @@ -133,14 +133,19 @@ body, html { font-size: .6em; display: block; } -#lightbox-me-wrapper { +#plotbox-wrapper, +#databox-wrapper { padding: 35px; background: #ffffff; - box-shadow: 0 0 10px #ffffff; + -webkit-box-shadow: 0 0 10px #ffffff; + -moz-box-shadow: 0 0 10px #ffffff; + -o-box-shadow: 0 0 10px #ffffff; + box-shadow: 0 0 10px #ffffff; } a.extra-link { float: right; color: #aaaaaa; + display: none; } .ajax-loader { position: relative; @@ -152,3 +157,10 @@ a.extra-link { background: url("../images/ajax-loader.gif"); background-size: cover; } +table { + border: 1px solid #cccccc; +} +table td { + padding: 5px 10px; + border: 1px solid #cccccc; +} diff --git a/static/website/js/cloud.js b/static/website/js/cloud.js index 50b9a07..162da73 100644 --- a/static/website/js/cloud.js +++ b/static/website/js/cloud.js @@ -71,6 +71,7 @@ $(document).ready(function() { $("#books-wrapper").html(""); $("#chapters-wrapper").html(""); $("#examples-wrapper").html(""); + $("#contributor").hide(); ajax_loader(this); Dajaxice.website.books(function(data) { Dajax.process(data); @@ -81,6 +82,8 @@ $(document).ready(function() { $(document).on("change", "#books", function() { $("#chapters-wrapper").html(""); $("#examples-wrapper").html(""); + $("#contributor").show(); + $("#download-book").show(); ajax_loader(this); Dajaxice.website.chapters(function(data) { Dajax.process(data); @@ -90,6 +93,7 @@ $(document).ready(function() { $(document).on("change", "#chapters", function() { $("#examples-wrapper").html(""); + $("#download-chapter").show(); ajax_loader(this); Dajaxice.website.examples(function(data) { Dajax.process(data); @@ -99,6 +103,7 @@ $(document).ready(function() { $(document).on("change", "#examples", function() { ajax_loader(this); + $("#download-example").show(); Dajaxice.website.code(function(data) { editor.setValue(data.code); ajax_loader("clear"); @@ -106,8 +111,8 @@ $(document).ready(function() { }); /* Execute the code */ - $lightbox_wrapper = $("#lightbox-me-wrapper"); - $lightbox = $("#lightbox-me"); + $plotbox_wrapper = $("#plotbox-wrapper"); + $plotbox = $("#plotbox"); $(document).on("click", "#execute", function() { $("#execute-inner").html("Executing..."); Dajaxice.website.execute(function(data) { @@ -119,8 +124,8 @@ $(document).ready(function() { src: data.plot_path, width: 400 }); - $lightbox.html($plot); - $lightbox_wrapper.lightbox_me({centered: true}); + $plotbox.html($plot); + $plotbox_wrapper.lightbox_me({centered: true}); } }, { token: $("[name='csrfmiddlewaretoken']").val(), @@ -155,4 +160,13 @@ $(document).ready(function() { $(key).after("<span class='ajax-loader'></span>"); } } + + /* Contributor details */ + $(document).on("click", "#contributor", function(e) { + Dajaxice.website.contributor(function(data) { + Dajax.process(data); + $("#databox-wrapper").lightbox_me({centered: true}); + }, {book_id: $("#books").val()}); + e.preventDefault(); + }); }); diff --git a/static/website/templates/ajax-contributor.html b/static/website/templates/ajax-contributor.html new file mode 100644 index 0000000..a3ab2dc --- /dev/null +++ b/static/website/templates/ajax-contributor.html @@ -0,0 +1,21 @@ +<h6><u>Contributor details</u></h6> +<table> + <tbody> + <tr> + <td>Contributor name</td> + <td>{{ proposal.full_name }}</td> + </tr> + <tr> + <td>Mentor</td> + <td>{{ proposal.faculty }}</td> + </tr> + <tr> + <td>Book Reviewer</td> + <td>{{ proposal.reviewer }}</td> + </tr> + <tr> + <td>College</td> + <td>{{ proposal.university }}</td> + </tr> + </tbody> +</table> diff --git a/static/website/templates/index.html b/static/website/templates/index.html index 31d028c..ee58a95 100644 --- a/static/website/templates/index.html +++ b/static/website/templates/index.html @@ -105,9 +105,13 @@ </div> <!-- /#content-inner --> </div> <!-- /#content-wrapper --> - <div id="lightbox-me-wrapper"> - <div id="lightbox-me"></div> - </div> <!-- /#lightbox-me-wrapper --> + <div id="plotbox-wrapper"> + <div id="plotbox"></div> + </div> <!-- /#plotbox-wrapper --> + + <div id="databox-wrapper"> + <div id="databox"></div> + </div> <!-- /#databox-wrapper --> <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script> <script src="{% static '/static/dajax/jquery.dajax.core.js' %}"></script> diff --git a/website/ajax.py b/website/ajax.py index a7a1c3c..6b6f998 100644 --- a/website/ajax.py +++ b/website/ajax.py @@ -80,3 +80,18 @@ def execute(request, token, code, book_id, chapter_id, example_id): .filter(example_id=example_id).exists() data = scilab_run(code, token, book_id, dependency_exists) return simplejson.dumps(data) + +@dajaxice_register +def contributor(request, book_id): + dajax = Dajax() + preference = TextbookCompanionPreference.objects.using('scilab')\ + .get(id=book_id) + proposal = TextbookCompanionProposal.objects.using('scilab')\ + .get(id=preference.proposal_id) + context = { + "preference": preference, + "proposal": proposal, + } + contributor = render_to_string('website/templates/ajax-contributor.html', context) + dajax.assign('#databox', 'innerHTML', contributor) + return dajax.json() diff --git a/website/helpers.py b/website/helpers.py index 20ef288..e11cfb3 100644 --- a/website/helpers.py +++ b/website/helpers.py @@ -17,7 +17,7 @@ def scilab_run(code, token, book_id, dependency_exists): plot_exists = False #Finding the plot and appending xs2jpg function - p = re.compile(r'.*plot.*\(.*,.*,*\).*\n|bode\(.*,.*\)') + p = re.compile(r'.*plot.*\(.*\).*\n|bode\(.*\)') plot_path = '' if p.search(code): @@ -49,7 +49,7 @@ def scilab_run(code, token, book_id, dependency_exists): cmd = 'printf "exec(\'{0}\',2);\nquit();"'.format(file_path) cmd += ' | /home/cheese/scilab-5.4.1/bin/scilab-adv-cli -nw' - task = TimerTask(cmd, timeout=10) + task = TimerTask(cmd, timeout=15) output = task.run().communicate()[0] e = task.wait() |