diff --git a/lib/App/Controller/Apiv1.pm b/lib/App/Controller/Apiv1.pm index 4017263..978e16a 100644 --- a/lib/App/Controller/Apiv1.pm +++ b/lib/App/Controller/Apiv1.pm @@ -43,7 +43,7 @@ sub api_get_paste { username => $row->{who}, description => $row->{desc}, language => $output_lang, - output => $output + output => $output, warning => "If this was multi-language paste, you just got a random language", }; diff --git a/lib/App/Model/Eval.pm b/lib/App/Model/Eval.pm index 8b7cde8..2b57fa7 100644 --- a/lib/App/Model/Eval.pm +++ b/lib/App/Model/Eval.pm @@ -21,7 +21,7 @@ sub get_eval { my ($self, $paste_id, $code, $langs, $callback) = @_; if ($paste_id && (my $cached = $memd->get($paste_id))) { # TODO make this use sereal to store objects - return $cached; + $callback->($cached); } else { # connect to server my %futures; diff --git a/templates/editor.html b/templates/editor.html index 048b064..7ca4edb 100755 --- a/templates/editor.html +++ b/templates/editor.html @@ -268,7 +268,20 @@ data: {code: code, language: language}, dataType: "json", success: function(data, status) { - $('#eval').text(data.evalout); + console.log("data out", data); + var keys = Object.keys(data.evalout); + var outputarr = []; + + if (keys.length > 1) { + outputarr = $.map(data.evalout, function(output, lang) { + return "[[ "+lang+" ]]\n"+output+"\n\n"; + }); + } else { + outputarr = [data.evalout[keys[0]]]; + } + console.log("outputarr", outputarr); + + $('#eval').text(Array.join(outputarr, "\n")); } }); }); diff --git a/templates/viewer.html b/templates/viewer.html index 88f78de..79e45f4 100755 --- a/templates/viewer.html +++ b/templates/viewer.html @@ -69,12 +69,14 @@

           
         
+	[% FOR lang IN eval.keys %]
         
-

Program Output:

-
[% eval | html %]
+

Program Output as [% lang %]:

+
[% eval.$lang | html %]
+ [% END %]