|
|
@ -70,7 +70,31 @@ sub register { |
|
|
|
}); |
|
|
|
}); |
|
|
|
$app->helper(comments_by_pid => sub { |
|
|
|
$app->helper(comments_by_pid => sub { |
|
|
|
my ($c, $pid) = @_; |
|
|
|
my ($c, $pid) = @_; |
|
|
|
return $self->app->db->select('comments', '*', {pid => $sid}, 'seq')->hashes; |
|
|
|
return $self->app->db->select('comments', '*', {pid => $pid}, 'seq')->hashes; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
$app->helper(add_page => sub { |
|
|
|
|
|
|
|
my ($c, $sid, $page) = @_; |
|
|
|
|
|
|
|
$self->app->db->insert('pages', { |
|
|
|
|
|
|
|
sid => $sid, |
|
|
|
|
|
|
|
hash => $page->{hash}, |
|
|
|
|
|
|
|
path => $page->{path}, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
$app->helper(add_comment => sub { |
|
|
|
|
|
|
|
my ($c, $pid, $cm) = @_; |
|
|
|
|
|
|
|
my $table = 'comments'; |
|
|
|
|
|
|
|
$self->app->db->begin; |
|
|
|
|
|
|
|
my $seq = $self->app->db->select($table, 'max(seq)', {pid => $pid})->list; |
|
|
|
|
|
|
|
$self->app->db->insert($table, { |
|
|
|
|
|
|
|
pid => $pid, |
|
|
|
|
|
|
|
seq => $seq, |
|
|
|
|
|
|
|
date => time(), |
|
|
|
|
|
|
|
name => $cm->{name}, |
|
|
|
|
|
|
|
reply => $cm->{reply}, |
|
|
|
|
|
|
|
email => $cm->{mail} || '', |
|
|
|
|
|
|
|
text => b64_encode($cm->{text}), |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
$self->app->db->commit; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|