Added AnsiLove for rendering messages with ANSI sequences
This commit is contained in:
parent
0e5a04596a
commit
01107cd3dc
@ -4,6 +4,7 @@ namespace App\Casts;
|
||||
|
||||
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class CompressedString implements CastsAttributes
|
||||
{
|
||||
@ -20,6 +21,11 @@ class CompressedString implements CastsAttributes
|
||||
*/
|
||||
public function get($model,string $key,mixed $value,array $attributes): string
|
||||
{
|
||||
static $converted = [];
|
||||
|
||||
if (Arr::get($converted,$key))
|
||||
return $value;
|
||||
|
||||
// For stream resources, we to fseek in case we've already read it.
|
||||
if (is_resource($value))
|
||||
fseek($value,0);
|
||||
@ -28,6 +34,8 @@ class CompressedString implements CastsAttributes
|
||||
? stream_get_contents($value)
|
||||
: $value;
|
||||
|
||||
$converted[$key] = TRUE;
|
||||
|
||||
return $value ? zstd_uncompress(base64_decode($value)) : '';
|
||||
}
|
||||
|
||||
|
2555
public/ansilove/ansilove.js
vendored
Normal file
2555
public/ansilove/ansilove.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -112,6 +112,7 @@
|
||||
<li>PHP/Laravel - the coding framework used to create this UI, and to enable the transfer of mail between systems</li>
|
||||
<li>jQuery - to help with the web UI</li>
|
||||
<li>Highcharts - to render the graphs</li>
|
||||
<li>AnsiLove - to render the messages, for when they have ANSI code sequences</li>
|
||||
</ul>
|
||||
|
||||
<p>If you'd like to support enhancing Clearing Houz, <a href="https://buymeacoffee.com/dege">Buy me a coffee!</a></p>
|
||||
|
@ -33,8 +33,8 @@ use App\Classes\FTN\Message;
|
||||
|
||||
<div class="row pb-2">
|
||||
<div class="col-8">
|
||||
<div class="pad pb-0">
|
||||
<pre class="highlight">{!! Message::tr($msg->msg).($msg->origin ? sprintf("\r * Origin: %s",$msg->origin) : '') !!}</pre>
|
||||
<div class="p-2">
|
||||
<div id="canvas"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -83,3 +83,24 @@ use App\Classes\FTN\Message;
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@section('page-scripts')
|
||||
<script type="text/javascript" src="{{ asset('ansilove/ansilove.js') }}"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
var msg = new Uint8Array({!! json_encode(array_values(unpack('C*',str_replace("\r","\n",$msg->msg)))) !!});
|
||||
retina = window.devicePixelRatio > 1;
|
||||
|
||||
AnsiLove.renderBytes(
|
||||
msg,
|
||||
function (canvas, sauce) {
|
||||
console.log(canvas);
|
||||
document.getElementById("canvas").appendChild(canvas);
|
||||
},
|
||||
{'font': '80x25', 'bits': 8, 'icecolors': 0, 'columns': 80}
|
||||
);
|
||||
});
|
||||
</script>
|
||||
|
||||
@append
|
Loading…
Reference in New Issue
Block a user