1
0
Fork 0
mirror of https://github.com/perlbot/perlbuut-pastebin synced 2025-06-07 14:17:26 -04:00

Better multilanguage support on frontend, and fix backend bugs

This commit is contained in:
Ryan Voots 2017-07-28 01:41:01 -04:00
parent 2cc7c6ab75
commit fae3e21403
4 changed files with 20 additions and 5 deletions

View file

@ -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",
};

View file

@ -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;

View file

@ -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"));
}
});
});

View file

@ -69,12 +69,14 @@
<pre id="editor"></pre>
</div>
</div>
[% FOR lang IN eval.keys %]
<div class="row">
<div id="eval" class="col-md-12">
<h3>Program Output:</h3>
<pre>[% eval | html %]</pre>
<h3>Program Output as [% lang %]:</h3>
<pre>[% eval.$lang | html %]</pre>
</div>
</div>
[% END %]
<div class="panel-footer">
<input value="Fork and Edit" type="submit" id="submit" />
</div>