Skip to content

Commit

Permalink
Try at a new template
Browse files Browse the repository at this point in the history
  • Loading branch information
symkat committed Nov 29, 2021
1 parent fb35c3e commit fdb76cf
Show file tree
Hide file tree
Showing 9 changed files with 11,540 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Web/lib/BlogDB/Web.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@ sub startup ($self) {
$c->stash->{template} = sprintf( "%s/%s", $c->config->{template_dir}, $name );
});

# Make _public/ in the template dir be on the static path resolution.
push @{$self->static->paths}, 'templates/' . $self->config->{template_dir} . "/_public";

$self->plugin( 'BlogDB::Web::Plugin::MinionTasks');

# Add the templates/$name/_public/ directory to the static paths,
# if the directory exists.

# Get the router.
my $router = $self->routes;

Expand Down
2 changes: 1 addition & 1 deletion Web/lib/BlogDB/Web/Controller/Blog.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ sub _slug_to_id ($self, $slug) {
}

sub get_view_blog ($c) {
$c->set_template( 'blog/index' );
$c->set_template( 'blog/item' );

my $blog = $c->stash->{blog} = $c->db->resultset('Blog')->find(
$c->_slug_to_id($c->param('slug'))
Expand Down
2 changes: 2 additions & 0 deletions Web/lib/BlogDB/Web/Controller/Root.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ sub get_homepage ($c) {
$c->set_template( 'index' );

push @{$c->stash->{blogs}}, $c->db->resultset('Blog')->all;
push @{$c->stash->{tags_a}}, grep { $_->id % 2 == 1 } $c->db->resultset('Tag')->all;
push @{$c->stash->{tags_b}}, grep { $_->id % 2 == 0 } $c->db->resultset('Tag')->all;

}

Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions Web/templates/simple/_/_blog_card.tx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- _/_blog_card.tx start -->
<div class="card mb-4">
<a href="[% $c.url_for( 'view_blog', 'slug' => $blog.slug ) %]"><img class="card-img-top" src="[% $blog.img_url %]" alt="..." /></a>
<div class="card-body">
<div class="small text-muted">Last Updated: January 1, 2021</div>
<h2 class="card-title h4">[% $blog.title %]</h2>
<p class="card-text">[% $blog.tagline %]</p>
<a class="btn btn-primary" href="[% $c.url_for( 'view_blog', 'slug',$blog.slug ) %]">View Entry →</a>
</div>
</div>
<!-- _/_blog_card.tx end -->
129 changes: 129 additions & 0 deletions Web/templates/simple/_/layout.tx
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description" content="" />
<meta name="author" content="" />
<title>[% $title ? "BlogDB - " ~ $title : "BlogDB" %]</title>
<!-- Favicon-->
<link rel="icon" type="image/x-icon" href="assets/favicon.ico" />
<!-- Core theme CSS (includes Bootstrap)-->
<link href="/css/styles.css" rel="stylesheet" />
</head>
<body>
<!-- Responsive navbar-->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="[% $c.url_for( 'homepage' ) %]">BlogDB</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
<li class="nav-item"><a class="nav-link" href="#">Home</a></li>
<li class="nav-item"><a class="nav-link" href="#!">About</a></li>
<li class="nav-item"><a class="nav-link" href="#!">Contact</a></li>
<li class="nav-item"><a class="nav-link active" aria-current="page" href="#">Blog</a></li>
</ul>
</div>
</div>
</nav>

%% if ( $hide_welcome_screen ) {
<!-- Minimal Page header for padding-->
<header class="py-5 bg-light border-bottom mb-4"></header>
%% } else {
<!-- Page header with logo and tagline-->
<header class="py-5 bg-light border-bottom mb-4">
<div class="container">
<div class="text-center my-5">
<h1 class="fw-bolder">Welcome to BlogDB!</h1>
<p class="lead mb-0">We showcase a collection of blogs from around the internet.</p>
</div>
</div>
</header>
%% }

<!-- Page content-->
<div class="container">
<div class="row">
<!-- Blog entries-->
<div class="col-lg-8">

<!-- Panel Block Begin-->
%% block panel -> {

%% }
<!-- Panel Block End-->

<!-- Pagination-->
<nav aria-label="Pagination">
<hr class="my-0" />
<ul class="pagination justify-content-center my-4">
<li class="page-item disabled"><a class="page-link" href="#" tabindex="-1" aria-disabled="true">Newer</a></li>
<li class="page-item active" aria-current="page"><a class="page-link" href="#!">1</a></li>
<li class="page-item"><a class="page-link" href="#!">2</a></li>
<li class="page-item"><a class="page-link" href="#!">3</a></li>
<li class="page-item disabled"><a class="page-link" href="#!">...</a></li>
<li class="page-item"><a class="page-link" href="#!">15</a></li>
<li class="page-item"><a class="page-link" href="#!">Older</a></li>
</ul>
</nav>
</div>
<!-- Side widgets-->
<div class="col-lg-4">

%% block blog_homepage_section -> {}


<!-- Search widget-->
<div class="card mb-4">
<div class="card-header">Suggest a blog to be added</div>
<div class="card-body">
<form method="post" action="[% $c.url_for( 'do_new_blog' ) %]">
<div class="input-group">
<input class="form-control" type="text" placeholder="https://..." aria-label="Enter url" aria-describedby="button-add" />
<button class="btn btn-primary" id="button-add" type="submit">Suggest Blog</button>
</div>
</form>
</div>
</div>
<!-- Categories widget-->
<div class="card mb-4">
<div class="card-header">Tags</div>
<div class="card-body">
<div class="row">
<div class="col-sm-6">
<ul class="list-unstyled mb-0">
%% for $tags_a -> $tag {
<li><a href="#!">#[% $tag.name %]</a></li>
%% }
</ul>
</div>
<div class="col-sm-6">
<ul class="list-unstyled mb-0">
%% for $tags_a -> $tag {
<li><a href="#!">#[% $tag.name %]</a></li>
%% }
</ul>
</div>
</div>
</div>
</div>
<!-- Side widget-->
<div class="card mb-4">
<div class="card-header">Side Widget</div>
<div class="card-body">You can put anything you want inside of these side widgets. They are easy to use, and feature the Bootstrap 5 card component!</div>
</div>
</div>
</div>
</div>
<!-- Footer-->
<footer class="py-5 bg-dark">
<div class="container"><p class="m-0 text-center text-white">Copyright &copy; Your Website 2021</p></div>
</footer>
<!-- Bootstrap core JS-->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
<!-- Core theme JS-->
<script src="js/scripts.js"></script>
</body>
</html>
Loading

0 comments on commit fdb76cf

Please sign in to comment.