Compare commits

...

8 commits

15 changed files with 102 additions and 47 deletions

View file

@ -2,7 +2,6 @@ FROM docker.io/perl:5.36
# Move it
WORKDIR /opt
COPY assets/ ./assets/
COPY lib/ ./lib/
COPY migrations/ ./migrations/
COPY public/ ./public/
@ -15,9 +14,6 @@ COPY post_text.conf .
# Dependency time
RUN apt-get update
RUN apt-get -y upgrade
# Work around for test failing due to headers being lowercase now that
# cpan.org is on HTTP/2
RUN cpanm --notest Net::HTTP
RUN cpanm --installdeps .
# Finish setting up the environment

View file

@ -19,8 +19,7 @@ should be YAML or XML or something better suited.
Run it in development mode:
morbo -w assets/css/ -w public/ -w lib/ -w templates/ \
-w script/ script/post_text
morbo -w public/ -w lib/ -w templates/ -w script/ script/post_text
Now try requesting http://localhost:3000
@ -61,15 +60,8 @@ tests locally:
## TODOs
1. Re-visit this TODO list because it doesn't seem like I'm gunna
bother with all new posts flagged mode lmao. There's a CAPTCHA now
so it's not as painfully open...
1. Deprecate/remove AssetPack dependency
1. Automate the holiday backgrounds with JS
1. Test JS with LibreJS or something like that (I don't like RMS I
just want free JS!!)
1. "All new posts flagged" mode (require approval for new posts)
1. Tests for mod-only user?
## Crazy future ideas
@ -78,6 +70,7 @@ tests locally:
1. Is `remark_tally` counting hidden remarks? Tried to add a `WHERE
NOT hidden_status` but that returns null, probably need a different
`JOIN` which may not be worth the trouble/processing
1. Nah it needs a subquery instead of just `COUNT(*)` (dude trust me)
1. Implement tripcodes (moving this down in priority due to complexity...)
1. Post thread via SMS (twil.io??)

View file

@ -1,12 +0,0 @@
[css-min:css/PostText.css]
checksum=3698d7bf52
format=css
minified=1
[css-min:https://unpkg.com/98.css]
checksum=4f089bc53f
format=css
minified=1
[sass:sass/post_text.scss]
checksum=ecda188939
format=css
minified=0

View file

@ -1,5 +0,0 @@
! app.css
< https://unpkg.com/normalize.css@8.0.1/normalize.css
< css/elements.css
< css/simple.css
< css/nested.css

View file

@ -1,12 +1,9 @@
requires 'Mojolicious';
requires 'Mojo::Pg';
requires 'Mojolicious::Plugin::TagHelpers::Pagination';
requires 'Mojolicious::Plugin::AssetPack';
requires 'Crypt::Passphrase::Argon2';
requires 'Date::Format';
requires 'XML::RSS';
requires 'CSS::Minifier::XS';
requires 'Text::Markdown';
requires 'HTML::Restrict';
requires 'IO::Socket::SSL';
requires 'Roman::Unicode';

View file

@ -18,7 +18,6 @@ use PostText::Model::Page;
sub startup($self) {
$self->plugin('Config');
$self->plugin('TagHelpers::Pagination');
$self->plugin(AssetPack => {pipes => [qw{Css Combine}]});
# Helpers
$self->helper(pg => sub ($c) {
@ -108,8 +107,6 @@ sub startup($self) {
$self->thread->max_pages($max_thread_pages)
}
$self->asset->process;
push @{$self->commands->namespaces}, 'PostText::Command';
# Begin routing
@ -234,6 +231,10 @@ sub startup($self) {
->to('moderator#mod_reset')
->name('mod_reset');
$moderator->get('/list')
->to('moderator#list')
->name('mod_list');
my $mod_thread = $moderator->any('/thread');
$mod_thread->get('/unflag/:thread_id', [thread_id => qr/\d+/])

View file

@ -344,4 +344,12 @@ sub remark_by_id($self) {
$self->render;
}
sub list($self) {
my $moderators = $self->moderator->list;
$self->stash(moderators => $moderators);
$self->render;
}
1;

View file

@ -259,4 +259,19 @@ sub remark_by_id($self, $remark_id) {
END_SQL
}
sub list($self) {
my $date_format = $self->date_format;
$self->pg->db->query(<<~'END_SQL', $date_format)->hashes;
SELECT moderator_id AS id,
moderator_name AS name,
email_addr,
TO_CHAR(creation_date, $1) AS creation_date,
TO_CHAR(last_login_date, $1) AS last_login_date,
lock_status,
admin_status
FROM moderators;
END_SQL
}
1;

View file

@ -28,14 +28,6 @@
body {
background-image: url('/images/background_stars_anm.gif');
/* Was feelin this for September idk */
/* background-image: url('/images/topwwbackground.gif'); */
/* Spooky time! */
/* background-image: url('/images/halloween_background_1.gif'); */
/* Winter/snow */
/* background-image: url('/images/jwsfp1.gif'); */
/* Christmas */
/* background-image: url('/images/christmas.gif'); */
width: 95vmin;
margin: 0 auto;
font-family: 'w95fa', sans-serif;

25
public/js/background.js Normal file
View file

@ -0,0 +1,25 @@
(function () {
const bodyStyle = document.body.style;
function setImage(url) {
bodyStyle.backgroundImage = "url('" + url + "')";
}
switch (new Date().getMonth()) {
case 0:
setImage('/images/jwsfp1.gif');
break;
case 3:
setImage('/images/background2.gif');
break;
case 9:
setImage('/images/halloween_background_1.gif');
break;
case 10:
setImage('/images/topwwbackground.gif');
break;
case 11:
setImage('/images/christmas.gif');
break;
}
})();

View file

@ -5,8 +5,8 @@ use Test::Mojo;
my $t = Test::Mojo->new('PostText');
my %valid_login = (
email => 'swaggboi@slackware.uk',
password => 'i like to party'
email => 'swaggboi@gangstalking.agency',
password => 'i also like to party'
);
my %invalid_login = (
@ -114,6 +114,12 @@ subtest Login => sub {
->element_exists('form input[name="password"]')
};
subtest List => sub {
$t->get_ok('/moderator/list')
->status_is(200)
->text_like(h2 => qr/Moderator List/)
};
# Mod session ends
$t->get_ok('/logout')
->status_is(302)
@ -127,6 +133,7 @@ subtest Login => sub {
->element_exists_not('a[href*="/unflag/1"]' )
->element_exists_not('a[href*="/moderator/flagged"]')
->element_exists_not('a[href*="/moderator/hidden"]' )
->element_exists_not('a[href*="/moderator/list"]' )
->element_exists_not('a[href*="/logout"]' );
$t->get_ok('/remark/single/1')
@ -136,6 +143,7 @@ subtest Login => sub {
->element_exists_not('a[href*="/unflag/1"]' )
->element_exists_not('a[href*="/moderator/flagged"]')
->element_exists_not('a[href*="/moderator/hidden"]' )
->element_exists_not('a[href*="/moderator/list"]' )
->element_exists_not('a[href*="/logout"]' );
$t->get_ok('/moderator/flagged')
@ -145,6 +153,10 @@ subtest Login => sub {
$t->get_ok('/moderator/hidden')
->status_is(302)
->header_like(Location => qr/login/);
$t->get_ok('/moderator/list')
->status_is(302)
->header_like(Location => qr/login/);
};
};

View file

@ -29,7 +29,10 @@
content="<%= url_for('/images/logo.png')->to_abs %>">
<meta name="twitter:image:alt"
content="Post::Text logo; a small nerdy anime girl giving a V sign">
<%= asset 'app.css' %>
<%= stylesheet '/css/elements.css' %>
<%= stylesheet '/css/simple.css' %>
<%= stylesheet '/css/nested.css' %>
<%= javascript '/js/background.js', defer => undef %>
</head>
<body>
<header class="header">
@ -48,6 +51,7 @@
<%= link_to Flagged => flagged_list => (class => 'click') %>
<%= link_to Hidden => hidden_list => (class => 'click') %>
<%= link_to Reset => mod_reset => (class => 'click') %>
<%= link_to List => mod_list => (class => 'click') %>
<%= link_to Logout => mod_logout => (class => 'click') %>
</nav>
<% } =%>

View file

@ -0,0 +1,29 @@
% layout 'default';
% title 'Moderator List';
<h2 class="page-title"><%= title %></h2>
<main class="page-body">
<% if (scalar @{$moderators}) { =%>
<table>
<tr>
<th>Moderator ID</th>
<th>Moderator Name</th>
<th>Email Address</th>
<th>Creation Date</th>
<th>Last Login Date</th>
<th>Locked?</th>
<th>Admin?</th>
</tr>
<% for my $moderator (@{$moderators}) { %>
<tr>
<td><%= $moderator->{'id' } %></td>
<td><%= $moderator->{'name' } %></td>
<td><%= $moderator->{'email_addr' } %></td>
<td><%= $moderator->{'creation_date' } %></td>
<td><%= $moderator->{'last_login_date'} %></td>
<td><%= $moderator->{'lock_status' } %></td>
<td><%= $moderator->{'admin_status' } %></td>
</tr>
<% } %>
</table>
<% } =%>
</main>