Implement the rest of the stuff for bumps; then some clean up along the way
This commit is contained in:
parent
451e751aae
commit
7e05af4c4b
|
@ -32,7 +32,6 @@ Run the tests locally (against development environment):
|
||||||
|
|
||||||
## TODOs
|
## TODOs
|
||||||
|
|
||||||
1. Bump button/counter (need the migration and model next)
|
|
||||||
1. Implement
|
1. Implement
|
||||||
[bcrypt](https://metacpan.org/pod/Mojolicious::Plugin::BcryptSecure)
|
[bcrypt](https://metacpan.org/pod/Mojolicious::Plugin::BcryptSecure)
|
||||||
1. Some sort of admin/moderator login and view
|
1. Some sort of admin/moderator login and view
|
||||||
|
@ -48,6 +47,4 @@ Run the tests locally (against development environment):
|
||||||
requested](https://docs.mojolicious.org/Mojolicious/Plugin/DefaultHelpers#respond_to)
|
requested](https://docs.mojolicious.org/Mojolicious/Plugin/DefaultHelpers#respond_to)
|
||||||
(JSON?)
|
(JSON?)
|
||||||
1. Post thread via SMS (twil.io??)
|
1. Post thread via SMS (twil.io??)
|
||||||
1. CAPTCHA with
|
1. Option to remark without bumping?
|
||||||
[Lingua::EN::Inflexion](https://metacpan.org/pod/Lingua::EN::Inflexion#cardinal()-and-cardinal($threshold))
|
|
||||||
(This may not even be necessary with proper admin/moderation stuff)
|
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
|
.field-with-info {
|
||||||
|
border-style: solid;
|
||||||
|
border-color: green;
|
||||||
|
}
|
||||||
|
|
||||||
.field-with-error {
|
.field-with-error {
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
border-color: red;
|
border-color: red;
|
||||||
}
|
}
|
||||||
|
|
||||||
.thread, .remark, .field-with-error {
|
.thread, .remark, .field-with-error, .field-with-info {
|
||||||
border-style: dotted;
|
border-style: dotted;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,19 +28,6 @@ sub create($self, $author, $title, $body, $hidden = 0, $flagged = 0) {
|
||||||
END_SQL
|
END_SQL
|
||||||
}
|
}
|
||||||
|
|
||||||
sub dump_all($self) {
|
|
||||||
$self->pg->db->query(<<~'END_SQL', $self->{'date_format'})->hashes
|
|
||||||
SELECT thread_id AS id,
|
|
||||||
TO_CHAR(thread_date, ?) AS date,
|
|
||||||
thread_author AS author,
|
|
||||||
thread_title AS title,
|
|
||||||
thread_body AS body
|
|
||||||
FROM threads
|
|
||||||
WHERE NOT hidden_status
|
|
||||||
ORDER BY bump_date DESC;
|
|
||||||
END_SQL
|
|
||||||
}
|
|
||||||
|
|
||||||
sub by_page($self, $this_page = 1) {
|
sub by_page($self, $this_page = 1) {
|
||||||
my $date_format = $self->{'date_format'};
|
my $date_format = $self->{'date_format'};
|
||||||
my $row_count = $self->{'threads_per_page'};
|
my $row_count = $self->{'threads_per_page'};
|
||||||
|
@ -53,7 +40,8 @@ sub by_page($self, $this_page = 1) {
|
||||||
t.thread_author AS author,
|
t.thread_author AS author,
|
||||||
t.thread_title AS title,
|
t.thread_title AS title,
|
||||||
t.thread_body AS body,
|
t.thread_body AS body,
|
||||||
COUNT(r.*) AS remark_count
|
COUNT(r.*) AS remark_count,
|
||||||
|
t.bump_count AS bump_count
|
||||||
FROM threads t
|
FROM threads t
|
||||||
LEFT JOIN remarks r
|
LEFT JOIN remarks r
|
||||||
ON t.thread_id = r.thread_id
|
ON t.thread_id = r.thread_id
|
||||||
|
@ -103,7 +91,8 @@ sub by_id($self, $thread_id) {
|
||||||
sub bump($self, $thread_id) {
|
sub bump($self, $thread_id) {
|
||||||
$self->pg->db->query(<<~'END_SQL', $thread_id)
|
$self->pg->db->query(<<~'END_SQL', $thread_id)
|
||||||
UPDATE threads
|
UPDATE threads
|
||||||
SET bump_date = NOW()
|
SET bump_date = NOW(),
|
||||||
|
bump_count = bump_count + 1
|
||||||
WHERE thread_id = ?;
|
WHERE thread_id = ?;
|
||||||
END_SQL
|
END_SQL
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,9 @@ subtest 'View single remark', sub {
|
||||||
$t->get_ok('/remark/1')->status_is(200)->text_like(h2 => qr/Remark #1/);
|
$t->get_ok('/remark/1')->status_is(200)->text_like(h2 => qr/Remark #1/);
|
||||||
};
|
};
|
||||||
|
|
||||||
subtest 'Post new remark', sub {
|
$t->ua->max_redirects(1);
|
||||||
$t->ua->max_redirects(1);
|
|
||||||
|
|
||||||
|
subtest 'Post new remark', sub {
|
||||||
# GET
|
# GET
|
||||||
$t->get_ok('/post/1')->status_is(200)
|
$t->get_ok('/post/1')->status_is(200)
|
||||||
->element_exists('form input[name="author"]' )
|
->element_exists('form input[name="author"]' )
|
||||||
|
|
21
t/thread.t
21
t/thread.t
|
@ -30,18 +30,9 @@ subtest 'View single thread', sub {
|
||||||
$t->get_ok('/thread/1/1')->status_is(200)->text_like(h2 => qr/Thread #1/);
|
$t->get_ok('/thread/1/1')->status_is(200)->text_like(h2 => qr/Thread #1/);
|
||||||
};
|
};
|
||||||
|
|
||||||
subtest 'Bumping thread', sub {
|
$t->ua->max_redirects(1);
|
||||||
$t->get_ok('/list')->status_is(200)
|
|
||||||
->element_exists('a[href~="bump"]')
|
|
||||||
->text_like(h2 => qr/Threads List/);
|
|
||||||
|
|
||||||
$t->get_ok('/bump/1')->status_is(302)
|
|
||||||
->header_like(Location => qr/list/);
|
|
||||||
};
|
|
||||||
|
|
||||||
subtest 'Post new thread', sub {
|
subtest 'Post new thread', sub {
|
||||||
$t->ua->max_redirects(1);
|
|
||||||
|
|
||||||
# GET
|
# GET
|
||||||
$t->get_ok('/post')->status_is(200)
|
$t->get_ok('/post')->status_is(200)
|
||||||
->element_exists('form input[name="author"]' )
|
->element_exists('form input[name="author"]' )
|
||||||
|
@ -66,4 +57,14 @@ subtest 'Post new thread', sub {
|
||||||
->text_like(h2 => qr/Thread #[0-9]+/);
|
->text_like(h2 => qr/Thread #[0-9]+/);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
subtest 'Bumping thread', sub {
|
||||||
|
$t->get_ok('/list')->status_is(200)
|
||||||
|
->element_exists('a[href*="bump"]')
|
||||||
|
->text_like(h2 => qr/Threads List/);
|
||||||
|
|
||||||
|
$t->get_ok('/bump/1')->status_is(200)
|
||||||
|
->element_exists('p[class="field-with-info"]')
|
||||||
|
->text_like(p => qr/Thread #[0-9]+ has been bumped/);
|
||||||
|
};
|
||||||
|
|
||||||
done_testing();
|
done_testing();
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
<%= asset 'main.css' %>
|
<%= asset 'main.css' %>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<% if (flash 'info') { =%>
|
||||||
|
<p class="field-with-info"><%= flash 'info' %></p>
|
||||||
|
<% } =%>
|
||||||
<h1>Post::Text</h1>
|
<h1>Post::Text</h1>
|
||||||
<nav>
|
<nav>
|
||||||
<%= link_to List => 'threads_list' %>
|
<%= link_to List => 'threads_list' %>
|
||||||
|
|
|
@ -18,6 +18,11 @@
|
||||||
(<%= $thread->{'remark_count'} %> remarks)
|
(<%= $thread->{'remark_count'} %> remarks)
|
||||||
<% end %>
|
<% end %>
|
||||||
</nav>
|
</nav>
|
||||||
|
<nav class="bumps">
|
||||||
|
<%= link_to bump_thread => {thread_id => $thread->{'id'}}, begin %>
|
||||||
|
Bump (<%= $thread->{'bump_count'} %> bumps)
|
||||||
|
<% end %>
|
||||||
|
</nav>
|
||||||
</article>
|
</article>
|
||||||
<% } =%>
|
<% } =%>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue