summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/ansi2html20
-rwxr-xr-xscripts/install_helper.pl7
-rwxr-xr-xscripts/mimetype38
3 files changed, 65 insertions, 0 deletions
diff --git a/scripts/ansi2html b/scripts/ansi2html
new file mode 100755
index 000000000..e33e24630
--- /dev/null
+++ b/scripts/ansi2html
@@ -0,0 +1,20 @@
+#!/usr/bin/perl
+use strict;
+use HTML::FromANSI ();
+
+my $h = HTML::FromANSI->new(
+ fill_cols => 0,
+ font_face => "",
+ style => "",
+ tt => 0
+);
+
+open IN, "<", $ARGV[0] or die "cannot read $ARGV[0]: $!";
+
+$h->add_text(<IN>);
+my $html = $h->html;
+$html =~ s/background: black; //g;
+$html =~ s/color: white; /color: black /g;
+$html =~ s/<br>/\n/g;
+
+print $html;
diff --git a/scripts/install_helper.pl b/scripts/install_helper.pl
new file mode 100755
index 000000000..68ac709dd
--- /dev/null
+++ b/scripts/install_helper.pl
@@ -0,0 +1,7 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use File::MimeInfo::Magic;
+use HTML::FromANSI;
+
+print "works";
diff --git a/scripts/mimetype b/scripts/mimetype
new file mode 100755
index 000000000..3c0c17e9b
--- /dev/null
+++ b/scripts/mimetype
@@ -0,0 +1,38 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use File::MimeInfo::Magic qw(mimetype globs);
+
+exit 1 unless @ARGV == 2;
+
+my $filename = $ARGV[0];
+my $file = $ARGV[1];
+my $type = "";
+my $file_type = "";
+
+exit 1 unless -f $file;
+
+$type = globs($filename);
+
+# globbing takes priority over all other
+if (!$type) {
+ $type = mimetype($file);
+ if ($type eq "application/octet-stream") {
+ # application/octet-stream normally means the detection failed
+ # use the output of file in this case
+ $file_type = `file -b --mime-type $file`;
+ chomp $file_type;
+ $type = $file_type;
+ if ($type eq "text/plain") {
+ # detect ascii with color codes
+ $file_type = `file -b $file`;
+ chomp $file_type;
+ if ($file_type eq "ASCII text, with escape sequences") {
+ $type = "text/plain-ascii";
+ }
+ }
+ }
+}
+
+print "$type\n";
+