Hi everyone,
I took the Yancy app example from the Mojolicious Advent calendar and made
some minor modifications to use an SQLite backend instead of Postgres.
Thing is, the page won't render at all , but there is no error message.
>From my understanding of the purpose of this plugin, it should render blank
at least ? (no posts, for instance)
Any idea what I'm doing wrong ? Below is the full code.
Best regards,
use Mojolicious::Lite;
use Mojo::SQLite;
my $sql = Mojo::SQLite->new('sqlite:config.db');
# Use migrations to create a table
$sql->migrations->name('my_config_app')->from_string(<<EOF)->migrate;
-- 1 up
create table hosts (id integer primary key autoincrement,title varchar not
null,created datetime default current_timestamp,markdown text not null,html
text not null);
-- 1 down
drop table hosts;
EOF
$sql->migrations->migrate(0)->migrate;
plugin Yancy => {
backend => 'sqlite:config.db',
collections => {
hosts => {
required => [ 'title', 'markdown', 'html' ],
properties => {
id => {
type => 'integer',
readOnly => 1,
},
title => {
type => 'string',
},
markdown => {
type => 'string',
format => 'markdown',
'x-html-field' => 'html',
},
html => {
type => 'string',
},
},
},
},
};
get '/' => sub {
my ( $c ) = @_;
return $c->render(
'index',
posts => [ $c->yancy->list(
'hosts',
) ],
);
};
app->start;
__DATA__
@@ index.html.ep
<!doctype html>
<html lang="en">
<head>
<title>Hello, world!</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1,
shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css"
integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb"
crossorigin="anonymous">
</head>
<body>
<main role="main" class="container">
% for my $post ( @{ stash 'posts' } ) {
<%== $post->{html} %>
% }
</main>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js"
integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh"
crossorigin="anonymous"></script>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"
integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ"
crossorigin="anonymous"></script>
</body>
</html>
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.