#! /usr/bin/perl
+###
+### Setup program for Odin services
+###
+### (c) 2015 Mark Wooding
+###
+
+###----- Licensing notice ---------------------------------------------------
+###
+### This file is part of the `odin.gg' service, `odin-cgi'.
+###
+### `odin-cgi' is free software; you can redistribute it and/or modify
+### it under the terms of the GNU Affero General Public License as
+### published by the Free Software Foundation; either version 3 of the
+### License, or (at your option) any later version.
+###
+### `odin-cgi' is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+### GNU Affero General Public License for more details.
+###
+### You should have received a copy of the GNU Affero General Public
+### License along with `odin-cgi'; if not, see
+### <http://www.gnu.org/licenses/>.
use lib "lib";
use Odin;
open my $fh, "-|", "highlight", "-p" or die "highlight: $!";
while (<$fh>) {
my ($descr, $lang) = /^(.*\S)\s*:\s*(\S+)(?:\s.*|)$/;
- next unless defined $lang;
- $newlang{$lang} = $descr;
+ next if !defined $lang or $lang eq "txt";
+ $newlang{"hl:$lang"} = $descr;
}
close $fh or die "close highlight: $! $?";
-$newlang{"txt"} //= "Plain text";
+$newlang{"txt"} = "Plain text";
+$newlang{"md"} = "Markdown";
Odin::xact {
my $h = $db->selectall_hashref
for my $lang (keys %newlang) {
if (!exists $oldlang{$lang}) {
print ";; insert new language `$lang' (`$newlang{$lang}')\n";
- $db->do("INSERT INTO odin_pastebin_lang (lang) VALUES (?)",
- undef, $lang);
+ $db->do("INSERT INTO odin_pastebin_lang (lang, descr) VALUES (?, ?)",
+ undef, $lang, $newlang{$lang});
} elsif ($oldlang{$lang} ne $newlang{$lang}) {
print ";; change description for `$lang' ",
"(`$oldlang{$lang}' -> `$newlang{$lang}')\n";