X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/dd92616a516d41f9a84d080891f18d5a58754060..e26741ab236cbfaa89aa82d121c224137801a63b:/writer.plp?ds=inline
diff --git a/writer.plp b/writer.plp
index a97bbfa..b5f5032 100644
--- a/writer.plp
+++ b/writer.plp
@@ -5,117 +5,21 @@ Html({
version => '1.0',
nocache => 1,
raw => <<'EOT',
-
-
+
EOT
});
use List::Util qw( pairs pairkeys );
+use Shiar_Sheet::FormRow;
my $db = eval {
- my @dbinfo = (
- 'DBI:Pg:dbname=sheet;host=localhost', 'sheetadmin', 'fairuse',
- ) or die "database not configured\n";
- require DBIx::Simple;
- DBIx::Simple->new(@dbinfo[0..2], {
- RaiseError => 1,
- pg_enable_utf8 => 1,
- });
+ require Shiar_Sheet::DB;
+ Shiar_Sheet::DB->connect;
} or Abort('Database error', 501, $@);
-$db->abstract->{array_datatypes}++;
my $user = eval {
+ my $rootpath = ($ENV{REQUEST_URI} // '/writer') =~ s{(?new(
-name => 'login',
-value => '',
- -path => '/writer',
+ -path => $rootpath,
-expires => 'now',
)->as_string)) {
delete $cookie{login};
@@ -144,7 +48,7 @@ my $user = eval {
my $httpcookie = CGI::Cookie->new(
-name => 'login',
-value => join(':', @{$found}{qw( username pass )}),
- -path => '/writer',
+ -path => $rootpath,
) or die "prepared object is empty\n";
AddCookie($httpcookie->as_string);
} or Abort(["Unable to create login cookie", $@], 403);
@@ -169,6 +73,8 @@ my %lang = (
en => ["\N{REGIONAL INDICATOR SYMBOL LETTER G}\N{REGIONAL INDICATOR SYMBOL LETTER B}", 'english'],
eo => ['â ', 'esperanto'],
ru => ["\N{REGIONAL INDICATOR SYMBOL LETTER R}\N{REGIONAL INDICATOR SYMBOL LETTER U}", 'ÑÑÑÑкий'],
+ zh => ["\N{REGIONAL INDICATOR SYMBOL LETTER C}\N{REGIONAL INDICATOR SYMBOL LETTER N}", 'ä¸æ'],
+ la => ["\N{PUSHPIN}", 'latin'],
);
my @wordcols = pairkeys
my %wordcol = (
@@ -193,11 +99,28 @@ my %wordcol = (
form => {-label => 'Title'},
alt => {-label => 'Synonyms', -multiple => 1},
wptitle => {-label => 'Wikipedia'},
- source => {-label => 'Image'},
- thumb => {-label => 'Convert options', -multiple => 1},
+ source => {-label => 'Image', -src => sub {
+ return "data/word/org/$_[0]->{id}.jpg";
+ }},
+ thumb => {-label => 'Convert options', -multiple => 1, -src => sub {
+ return "data/word/en/$_[0]->{id}.jpg";
+ }},
+ story => {-label => 'Story', type => 'textarea'},
);
-my ($find) = map {{id => $_}} $fields{id} || $Request || ();
+if (my $search = $fields{q}) {
+ my %filter = (form => {ilike => '%'.$search.'%'});
+ my $results = $db->select(word => '*', \%filter);
+ say '
Search
';
+ printf("
%s %s %s
\n",
+ $_->{id}, showlink($_->{form}, "/writer/$_->{id}"),
+ sprintf('', $wordcol{thumb}->{-src}->($_)) x defined $_->{thumb}
+ ) for $results->hashes;
+ say "