diff --git a/README.md b/README.md index 72033a7..1f73953 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/lib/PostText.pm b/lib/PostText.pm index 141982f..8bc45ca 100644 --- a/lib/PostText.pm +++ b/lib/PostText.pm @@ -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+/]) diff --git a/lib/PostText/Controller/Moderator.pm b/lib/PostText/Controller/Moderator.pm index 581c4c1..67d894e 100644 --- a/lib/PostText/Controller/Moderator.pm +++ b/lib/PostText/Controller/Moderator.pm @@ -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; diff --git a/lib/PostText/Model/Moderator.pm b/lib/PostText/Model/Moderator.pm index 3455af1..77222f2 100644 --- a/lib/PostText/Model/Moderator.pm +++ b/lib/PostText/Model/Moderator.pm @@ -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; diff --git a/t/moderator.t b/t/moderator.t index d344d09..8ae7f02 100644 --- a/t/moderator.t +++ b/t/moderator.t @@ -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/); }; }; diff --git a/templates/moderator/hidden.html.ep b/templates/moderator/hidden.html.ep new file mode 100644 index 0000000..0f21808 --- /dev/null +++ b/templates/moderator/hidden.html.ep @@ -0,0 +1,10 @@ +% layout 'default'; +% title 'Hidden Posts'; +