-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tadeusz Sośnierz
committed
Jun 22, 2012
0 parents
commit 4cacb2c
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE HTML> | ||
<html lang="en-US"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>źblog</title> | ||
</head> | ||
<body> | ||
% my %args = @_[0]; | ||
% for %args<articles>.list -> $art { | ||
<h2> <%= $art<title> %> </h2> | ||
<i><small> Published: <%= $art<pubdate> %> </small></i> | ||
<p> <%= $art<text> %> </p> | ||
<hr /> | ||
% } | ||
<form method='POST' action='/post'> | ||
Title: <input name='title' type='text'></input><br/> | ||
Text:<br/> | ||
<textarea name='text' cols='72' rows='20'></textarea><br/> | ||
<input type='submit'></input> | ||
</form> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use Bailador; Bailador::import; | ||
use DBIish; | ||
|
||
my $db = DBIish.connect('SQLite', database => 'blog.db'); | ||
|
||
sub get-articles { | ||
my $sth = $db.prepare: 'SELECT * FROM articles'; | ||
$sth.execute; | ||
return $sth.fetchall_arrayref.map: { | ||
{ title => $_[0], | ||
pubdate => $_[1], | ||
text => $_[2] } | ||
}; | ||
} | ||
|
||
get '/' => sub { | ||
template 'index.tt', { articles => get-articles }; | ||
} | ||
|
||
post '/post' => sub { | ||
my $p = request.params; | ||
my $sth = $db.prepare: 'INSERT INTO articles VALUES (?, datetime(?), ?)'; | ||
$sth.execute($p<title>, DateTime.now.posix, $p<text>); | ||
"ok, done"; | ||
} | ||
|
||
baile; |