Add view for hidden posts

This commit is contained in:
swagg boi 2022-12-08 18:50:21 -06:00
parent babd302ba2
commit a62a4c495e
6 changed files with 50 additions and 10 deletions

View file

@ -32,7 +32,6 @@ Run the tests locally (against development environment):
## TODOs
1. View for hidden posts
1. Actions for creating moderators and resetting passwords
1. CSS
@ -40,8 +39,8 @@ Run the tests locally (against development environment):
### (Lord knows there's TODOs I could be working on...)
1. Support at least some Markdown, specifically the code blocks
1. RSS feed!!
1. Support at least some Markdown, specifically the code blocks
1. Implement tripcodes (moving this down in priority due to complexity...)
1. Return a text response instead of HTML if a `.txt` extension [is
requested](https://docs.mojolicious.org/Mojolicious/Plugin/DefaultHelpers#respond_to)

View file

@ -152,6 +152,10 @@ sub startup($self) {
->to('moderator#flagged')
->name('flagged_list');
$moderator->get('/hidden')
->to('moderator#hidden')
->name('hidden_list');
my $mod_thread = $moderator->under('/thread');
$mod_thread->get('/unflag/:thread_id', [thread_id => qr/\d+/])

View file

@ -15,6 +15,19 @@ sub flagged($self) {
$self->render;
}
sub hidden($self) {
my $hidden_posts = $self->moderator->hidden;
my @post_links = map {
$self->url_for(
'single_' . $_->{'type'}, $_->{'type'} . '_id' => $_->{'id'}
)
} @{$hidden_posts};
$self->stash(post_links => \@post_links);
$self->render;
}
sub login($self) {
my $v;

View file

@ -99,4 +99,18 @@ sub flagged($self) {
END_SQL
}
sub hidden($self) {
$self->pg->db->query(<<~'END_SQL')->hashes
SELECT 'thread' AS type,
thread_id AS id
FROM threads
WHERE hidden_status
UNION
SELECT 'remark',
remark_id
FROM remarks
WHERE hidden_status;
END_SQL
}
1;

View file

@ -82,11 +82,11 @@ subtest Login => sub {
->text_like(h2 => qr/Flagged Posts/)
};
#subtest Hidden => sub {
# $t->get_ok('/moderator/hidden')
# ->status_is(200)
# ->text_like(h2 => qr/Hidden Posts/)
#};
subtest Hidden => sub {
$t->get_ok('/moderator/hidden')
->status_is(200)
->text_like(h2 => qr/Hidden Posts/)
};
# Mod session ends
$t->get_ok('/logout')
@ -110,9 +110,9 @@ subtest Login => sub {
->status_is(302)
->header_like(Location => qr/login/);
#$t->get_ok('/moderator/hidden')
# ->status_is(302)
# ->header_like(Location => qr/login/);
$t->get_ok('/moderator/hidden')
->status_is(302)
->header_like(Location => qr/login/);
};
};

View file

@ -0,0 +1,10 @@
% layout 'default';
% title 'Hidden Posts';
<h2><%= title %></h2>
<% if ($post_links->[0]) { =%>
<ul>
<% for my $link (@{$post_links}) { =%>
<li><%= link_to $link, $link %></li>
<% } =%>
</ul>
<% } =%>