#!/bin/sh
echo 'use utf8;'
psql sheet -XAt -c "
- SELECT json_object_agg(coalesce(form, ''), forms) FROM _cat_words
+ SELECT json_object_agg(coalesce(id::text, ''), forms) FROM _cat_words
" | sed 's/ : / => /g'
CREATE OR REPLACE FUNCTION exportform(word) RETURNS text AS $$
SELECT concat(
- $1.prio || CASE WHEN $1.cover THEN 'c' ELSE '' END || ':',
+ $1.id, ':',
+ $1.prio, CASE WHEN $1.cover THEN 'c' ELSE '' END, ':',
array_to_string($1.form || $1.alt, '/')
);
$$ LANGUAGE SQL IMMUTABLE;
sub printimgs {
say '<ul>';
for my $row (@_) {
- my ($level, $mark, $title) = split /([a-z]*):/, $row, 2;
+ my ($id, $level, $title) = split /:/, $row, 3;
my @type;
- push @type, 'parent' if defined $table->{$row};
- push @type, 'large' if $mark;
+ push @type, 'parent' if defined $table->{$id};
+ push @type, 'large' if $level =~ s/c$//;
push @type, 'level'.($level || 0);
printf '<li%s>', @type ? sprintf ' class="%s"', join ' ', @type : '';
print showimg($title) if $level <= $limit;
- printimgs(@{$_}) for $table->{$row} // ();
+ printimgs(@{$_}) for $table->{$id} // ();
print '</li>';
}
say '</ul>';
}
say '<section class="gallery">';
-printimgs(@{$table->{''}});
+printimgs($table->{''}->[0]);
say '</section>';