Skip to content

Commit c8012c3

Browse files
committed
Template wrapup
1 parent 16f5871 commit c8012c3

File tree

7 files changed

+228
-4
lines changed

7 files changed

+228
-4
lines changed

DB/lib/BlogDB/DB/Result/Person.pm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ sub setting {
295295

296296
return $value;
297297
} else {
298-
my $result = $self->find_related('person_settings', { name => $setting });
298+
return undef unless $setting;
299+
my $result = $self->find_related('person_settings', { 'name' => $setting });
299300
return undef unless $result;
300301
return $self->_get_setting_value($result);
301302
}

Web/lib/BlogDB/Web.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ sub startup ($self) {
5656
if ( $person && $person->is_enabled ) {
5757
$c->stash->{person} = $person;
5858
$c->stash->{person_permissions} = {
59-
can_manage_tags => $person->setting('can_manage_tags'),
60-
can_manage_blogss => $person->setting('can_manage_blogs'),
59+
can_manage_tags => $person->setting('can_manage_tags'),
60+
can_manage_blogs => $person->setting('can_manage_blogs'),
6161
};
6262
$c->stash->{person_permissions}->{can_manage_tags} &&= 1;
6363
$c->stash->{person_permissions}->{can_manage_tags} ||= 0;

Web/lib/BlogDB/Web/Controller/Blog.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ sub post_new_blog ($c) {
199199
}
200200

201201
sub get_edit_new_blog ($c) {
202-
$c->set_template( 'blog/new/item' );
202+
$c->set_template( 'blog/new/edit' );
203203

204204
my $blog_id = $c->stash->{blog_id} = $c->param('id');
205205
my $blog = $c->stash->{blog} = $c->db->resultset('PendingBlog')->find( $blog_id );

Web/templates/simple/_/layout.tx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@
8787

8888
%% block blog_homepage_section -> {}
8989

90+
%% block sidebar_card -> {}
91+
92+
9093
<!-- Search widget-->
9194
<div class="card mb-4">
9295
<div class="card-header">Suggest a blog to be added</div>
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
2+
%% cascade simple::_::layout { title => 'Edit ' ~ $blog_url,
3+
%%
4+
%% }
5+
6+
%% override blog_homepage_section -> {
7+
<div class="card mb-4">
8+
<div class="card-header">Screenshot</div>
9+
<div class="card-body">
10+
<a target="_blank" title="Visit [% $blog.title %]" href="[% $blog.url %]">
11+
<figure class="mb-4"><img class="img-fluid rounded" src="[% $blog.img_url %]" alt="..." /></figure>
12+
</a>
13+
</div>
14+
</div>
15+
%% }
16+
17+
%% override panel -> {
18+
<h3>[% $blog.title %]</h3>
19+
20+
<div class="row">
21+
<!-- Error Handling On LHS -->
22+
<div class="col">
23+
%% if ( $errors.size() ) {
24+
<div style="margin-top: 2em" class="alert alert-danger" role="alert">
25+
There were errors with your request that could not be resolved:
26+
<ul>
27+
%% for $errors -> $error {
28+
<li>[% $error %]</li>
29+
%% }
30+
</ul>
31+
</div>
32+
%% }
33+
</div>
34+
</div>
35+
36+
<div class="row">
37+
<div class="col">
38+
<form method="post" action="[% $c.url_for( 'do_edit_blog', slug => $blog.slug ) %]">
39+
40+
%% include 'simple/_/form/input.tx' { type => 'text', name => 'title',
41+
%% title => 'Title',
42+
%% help => 'The title of the blog',
43+
%% value => $form_title,
44+
%% };
45+
46+
%% include 'simple/_/form/input.tx' { type => 'text', name => 'tagline',
47+
%% title => 'Tagline',
48+
%% help => 'The tagline of the blog.',
49+
%% value => $form_tagline,
50+
%% };
51+
52+
<textarea name="about" rows="4">[% $form_about %]</textarea>
53+
54+
55+
<br />
56+
57+
<div class="form-check form-switch">
58+
59+
<input class="form-check-input" type="checkbox" value="1" name="is_adult" id="is_adult" [% $form_adult ? " checked " : "" %]>
60+
<label class="form-check-label" for="is_adult">Adult Content</label>
61+
</div>
62+
63+
%% for $tags -> $tag {
64+
<div class="form-check">
65+
<input class="form-check-input" type="checkbox" value="[% $tag.id %]" name="tags" id="tag_[% $tag.id %]" [% $tag.checked ? " checked " : "" %]>
66+
<label class="form-check-label" for="tag_[% $tag.id %]">[% $tag.name %]</label>
67+
</div>
68+
%% }
69+
<br />
70+
%% include 'simple/_/form/input.tx' { type => 'text', name => 'url',
71+
%% title => 'Homepage URL',
72+
%% help => 'The url of the blog',
73+
%% value => $form_url,
74+
%% };
75+
76+
%% include 'simple/_/form/input.tx' { type => 'text', name => 'rss_url',
77+
%% title => 'RSS URL',
78+
%% help => 'A URL to an RSS feed for the blog.',
79+
%% value => $form_rss_url,
80+
%% };
81+
82+
<button type="submit" class="btn btn-primary float-end">Update Blog</button>
83+
84+
</form>
85+
</div>
86+
</div>
87+
<div class="row">
88+
<h2>Recent Posts</h2>
89+
%% for $blog.posts -> $post {
90+
<a href="[% $post.url %]" target="_blank" alt="[% $post.date %]">[% $post.title %]</a>
91+
%% }
92+
</div>
93+
94+
%% }

Web/templates/simple/blog/item.html.tx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@
1010
</div>
1111
%% }
1212

13+
%% override sidebar_card -> {
14+
%% if ( $person_permissions.can_manage_blogs ) {
15+
<div class="card mb-4">
16+
<div class="card-header">Actions</div>
17+
<div class="card-body">
18+
<a href="[% $c.url_for( 'edit_blog' => 'slug', $blog.slug ) %]" class="btn btn-primary float-end">Edit Blog</a>
19+
</div>
20+
</div>
21+
%% }
22+
%% }
23+
24+
1325
%% override panel -> {
1426
<article>
1527
<header class="mb-4">
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
%% cascade simple::_::layout { title => 'Edit ' ~ $blog.url,
2+
%% hide_welcome_screen => 1,
3+
%% }
4+
5+
%% override sidebar_card -> {
6+
%% if ( $person_permissions.can_manage_blogs ) {
7+
<div class="card mb-4">
8+
<div class="card-header">Actions</div>
9+
<div class="card-body">
10+
<form method="post" action="[% $c.url_for( 'do_publish_new_blog', id => $blog.id ) %]">
11+
<button type="submit" class="btn btn-primary float-end">Publish Blog</button>
12+
</form>
13+
</div>
14+
</div>
15+
%% }
16+
%% }
17+
18+
%% override blog_homepage_section -> {
19+
<div class="card mb-4">
20+
<div class="card-header">Screenshot</div>
21+
<div class="card-body">
22+
<a target="_blank" title="Visit [% $blog.title %]" href="[% $blog.url %]">
23+
<figure class="mb-4"><img class="img-fluid rounded" src="[% $blog.img_url %]" alt="..." /></figure>
24+
</a>
25+
</div>
26+
</div>
27+
%% }
28+
29+
%% override panel -> {
30+
<h3>[% $blog.title %]</h3>
31+
32+
33+
<div class="row" style="margin: 2em">
34+
<div class="col">
35+
</div>
36+
<div class="col">
37+
</div>
38+
</div>
39+
40+
<div class="row">
41+
<!-- Error Handling On LHS -->
42+
<div class="col">
43+
%% if ( $errors.size() ) {
44+
<div style="margin-top: 2em" class="alert alert-danger" role="alert">
45+
There were errors with your request that could not be resolved:
46+
<ul>
47+
%% for $errors -> $error {
48+
<li>[% $error %]</li>
49+
%% }
50+
</ul>
51+
</div>
52+
%% }
53+
</div>
54+
</div>
55+
56+
<div class="row">
57+
<div class="col">
58+
<form method="post" action="[% $c.url_for( 'do_edit_new_blog', slug => $blog.slug ) %]">
59+
60+
%% include 'simple/_/form/input.tx' { type => 'text', name => 'title',
61+
%% title => 'Title',
62+
%% help => 'The title of the blog',
63+
%% value => $form_title,
64+
%% };
65+
66+
%% include 'simple/_/form/input.tx' { type => 'text', name => 'tagline',
67+
%% title => 'Tagline',
68+
%% help => 'The tagline of the blog.',
69+
%% value => $form_tagline,
70+
%% };
71+
72+
<textarea name="about" rows="4">[% $form_about %]</textarea>
73+
74+
75+
<br />
76+
77+
<div class="form-check form-switch">
78+
79+
<input class="form-check-input" type="checkbox" value="1" name="is_adult" id="is_adult" [% $form_adult ? " checked " : "" %]>
80+
<label class="form-check-label" for="is_adult">Adult Content</label>
81+
</div>
82+
83+
%% for $tags -> $tag {
84+
<div class="form-check">
85+
<input class="form-check-input" type="checkbox" value="[% $tag.id %]" name="tags" id="tag_[% $tag.id %]" [% $tag.checked ? " checked " : "" %]>
86+
<label class="form-check-label" for="tag_[% $tag.id %]">[% $tag.name %]</label>
87+
</div>
88+
%% }
89+
<br />
90+
%% include 'simple/_/form/input.tx' { type => 'text', name => 'url',
91+
%% title => 'Homepage URL',
92+
%% help => 'The url of the blog',
93+
%% value => $form_url,
94+
%% };
95+
96+
%% include 'simple/_/form/input.tx' { type => 'text', name => 'rss_url',
97+
%% title => 'RSS URL',
98+
%% help => 'A URL to an RSS feed for the blog.',
99+
%% value => $form_rss_url,
100+
%% };
101+
102+
<button type="submit" class="btn btn-primary float-end">Update Blog Data</button>
103+
104+
</form>
105+
</div>
106+
</div>
107+
<div class="row">
108+
<h2>Recent Posts</h2>
109+
%% for $blog.posts -> $post {
110+
<a href="[% $post.url %]" target="_blank" alt="[% $post.date %]">[% $post.title %]</a>
111+
%% }
112+
</div>
113+
114+
%% }

0 commit comments

Comments
 (0)