Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Tadeusz Sośnierz committed Jun 22, 2012
0 parents commit 4cacb2c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
Binary file added blog.db
Binary file not shown.
22 changes: 22 additions & 0 deletions views/index.tt
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>
27 changes: 27 additions & 0 deletions źblog.pl
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;

0 comments on commit 4cacb2c

Please sign in to comment.