Compare commits

...

10 Commits

Author SHA1 Message Date
ed5fb3d346 Some clean-up 2024-06-26 01:11:53 -04:00
bbc12f2b4a Add JS license information 2024-06-26 01:08:31 -04:00
b1cbaceaa5 New background for Feb 2024-06-25 20:17:41 -04:00
43e9ccd887 Mod only stuff finally plus a list mod view 2024-06-25 19:23:34 -04:00
04ff49c932 Narrow the scoping, so to speak (??) 2024-06-25 17:37:57 -04:00
f5f15d7d11 Remove this TODO 2024-06-25 17:26:43 -04:00
8c4d2dfb03 Automate the background 2024-06-25 17:23:54 -04:00
b9769de240 These are officially gone 2024-06-25 13:30:58 -04:00
5163c1fee8 See if I can get rid of this... 2024-06-25 13:19:56 -04:00
e3155fad7b Try this again... 2024-06-25 13:08:13 -04:00
19 changed files with 142 additions and 51 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

@ -60,22 +60,10 @@ 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. 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
### (Lord knows there's TODOs I could be working on...)
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
@ -150,6 +147,8 @@ sub startup($self) {
$r->get('/feeds')->to('page#feeds')->name('feeds_page');
$r->get('/javascript')->to('page#javascript')->name('javascript_page');
# Not-so-static but I mean they're all 'pages' c'mon
$human->get('/search')->to('page#search')->name('search_page');
@ -234,6 +233,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

@ -10,6 +10,8 @@ sub rules($self) { $self->render }
sub feeds($self) { $self->render }
sub javascript($self) { $self->render }
sub captcha($self) {
my $v;

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;

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

28
public/js/background.js Normal file
View File

@ -0,0 +1,28 @@
(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 1:
setImage('/images/outofthedarknessbkgtile.gif');
break;
case 2:
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

@ -10,4 +10,7 @@ $t->get_ok('/rules')->status_is(200)->text_like(h2 => qr/The Rules/);
$t->get_ok('/feeds')->status_is(200)->text_like(h2 => qr/Feeds/);
$t->get_ok('/javascript')->status_is(200)
->text_like(h2 => qr/JavaScript License Information/);
done_testing;

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>
<% } =%>
@ -89,6 +93,9 @@
<%= content =%>
<footer class="site-footer">
<p>In UTF-8 we trust. 🫡</p>
<p><%= link_to javascript_page =>
('data-jslicense', 1),
begin %>JavaScript License Information<% end %></p>
</footer>
</body>
</html>

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>

View File

@ -0,0 +1,28 @@
% layout 'default';
% title 'JavaScript License Information';
% content_for open_graph => begin
<meta property="og:type" content="website">
<meta property="og:title" content="<%= title %>">
<meta
property="og:description"
content="Post::Text is a textboard a bit like 2channel. You can post whatever you want anonymously just please mind the rules."
>
% end
% content_for twitter_card => begin
<meta name="twitter:title" content="<%= title %>">
<meta
name="twitter:description"
content="Post::Text is a textboard a bit like 2channel. You can post whatever you want anonymously just please mind the rules."
>
% end
<h2 class="page-title"><%= title %></h2>
<main class="page-body">
<table id="jslicense-labels1">
<tr>
<td><%= link_to 'background.js', '/js/background.js' %></td>
<td><%= link_to 'http://www.gnu.org/licenses/gpl-3.0.html',
begin%>GNU General Public License 3.0 or later<% end %></td>
<td><%= link_to 'background.js', '/js/background.js' %></td>
</tr>
</table>
</main>