Commit Graph

110 Commits

Author SHA1 Message Date
4709f5567e Add home and rules pages
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-17 18:16:30 -07:00
b40b65bef6 Add restricted.css for future styles that are accessible by admin-only
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-17 17:49:12 -07:00
bd970943de Add user IP and token to posts in-line for staff
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-17 17:48:12 -07:00
0b0c0fe603 Update wipe to check user token as well as user IP
Wiping is done via a single user post. It will search for all posts by
that IP address *or* user token and delete them.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-17 17:02:51 -07:00
1856adaf3b Add user post wiping
If a user has spammed a lot of posts and made a mess of the board, this
will allow us to delete all posts by the offending user from the same
IP.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-17 16:59:23 -07:00
8ea95a927c Move modify.js + ban.js => restricted.js
Further in on restricted JS to simplify things. Rather than breaking out
all Javascript stuff into their own granular files, this just includes
all admin actions together in the same file.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-17 15:56:44 -07:00
1a2ac653d7 Fix /banned/ page redirect error
The URL routing for /banned/ was going to the board controller because it
would match /banned/ as a board URL rather than its verbatim value. This
is fixed by moving the board route match to the bottom of the URL
routing list.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-17 15:47:46 -07:00
794db714de Remove can_modify context variable, use is_staff instead
For both ban and modify actions, we trust staff users to not abuse
otherwise-secret scripts and links. We don't supply "can_modify" context
variable anymore and just use user.is_staff instead. The same goes for
ban links and scripts.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-17 15:32:10 -07:00
e686c3b235 Add ActionSuccessView
ActionSuccessView is a a generic view that indicates that something was
successful, e.g. deleting a post or banning a user. This hopefully
reduces the amount of boilerplate code used for creating success pages
since most of them can derive from this generic view.

The report and delete success views are updated to use this directly.

The ban and modify success views are updated to derive from this class,
with special permissions required.

The post success view is updated to derive from this class, using a
different template.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-17 15:08:33 -07:00
bfd3dedb09 Better positioning of ban window
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-14 00:08:56 -07:00
996e75dc2a Add news posts
You know. For basic information.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-13 23:01:51 -07:00
a4f00e6242 Add user post deletion
Users can delete their posts as long as they don't clear their cookies,
and as long as server-side user sessions are persistent.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-13 21:28:07 -07:00
96e8b7752f Yet more unnecessary field removal
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-13 15:44:52 -07:00
a1483007b7 Remove unnecessary fields from boardview
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-13 15:42:27 -07:00
708e232e49 Remove unnecessary fields from PostView
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-13 15:36:17 -07:00
83533b5fb4 Add post and image deletion
This one was kind of a doozy. This also adds a custom 403 error page and
fixes some permission denied behavior that I was having issues with for
a while.

This is also set up in a way that hopefully will allow me to easily
implement user post deletion.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-13 15:19:20 -07:00
6ff64a3299 Rename {post_create,post_modify,reply_create}_view.html
This drops the _view suffix of each of these, makes it more consistent
and less of a chore to type.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-13 13:16:57 -07:00
f54337a139 Add report cooldowns
This is to prevent report flooding/spamming.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-13 13:06:33 -07:00
f04604ce69 Users may only report a post once per IP address.
If a user *really* doesn't like a post, they may try to report it
multiple times. Users may now only report a single post once per IP
address.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-13 12:35:57 -07:00
f131c58d1b Add post hiding
This allows users to hide posts that they may find unsavory. On threads
themselves in the board view, this adds a minus/plus button that will
toggle back and forth if hidden. This also adds a post menu item that
will toggle a post being hidden.

This also changes the post snippet layout a little bit. This caused
minor issues with the other menu items, but it should be fixed in this
set of changes too.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-13 12:03:09 -07:00
089913c8fe Center some text on the board and post detail views
The board name and the "create new thread/reply" links are now centered.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-12 22:39:24 -07:00
925c17675f Add inline image expansion
Clicking an image will expand it.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-12 22:26:51 -07:00
0d6b6ca5b5 Add image hover
If a user hovers over an image with their mouse, it will load the image
and display it in the corner.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-12 22:02:51 -07:00
b646509f75 Update post information to come before the image info in a post
The post number, username, subject, etc all come before the an image (if
there is one) now, rather than sorta wedged afterwards. This seems to be
working.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-12 21:17:19 -07:00
c8fd8ffa89 Update Post.get_absolute_url() to always include the post ID
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-12 21:16:38 -07:00
3f1615f058 Add post count, image count, and unique posters to post detail
Just like 4chan has!!!!!!!

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-12 21:12:16 -07:00
5df21ccb95 Add poster name saving via cookie
When a user makes a new post with a name set, it will get saved via a
cookie to the user's client and it will automatically get set the next
time a user makes a post.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-12 20:28:21 -07:00
b096f70751 Add BoardMixin, update can_modify
* BoardMixin adds a cached property that gets the current viewed board -
  this assumes that there is a self.kwargs["url"] value available.
* can_modify now checks for some more permissions.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-12 19:28:20 -07:00
d3e1f5a978 Add board locking, update tests, and update clean() methods
* Boards can be locked from allowing posts - this is can be useful for
  things like archived boards or locking down in the event of an
  emergency
* Some validation checks for new posts are from the reply/thread form to
  the Post model's clean() method
* Add some new tests, I've really been falling behind on those

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-12 18:30:16 -07:00
250ebe2b84 Add COPYING file
In case it wasn't clear - this work belongs to me and me alone. keep
your paws off

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-12 16:59:45 -07:00
7941acc224 Add ALLOWED_HOSTS file to gitignore
In tandem with the last commit, ALLOWED_HOSTS file is no longer tracked
by git.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-12 16:54:03 -07:00
8fef30b9c0 Move ALLOWED_HOSTS -> ALLOWED_HOSTS.example with some examples too
ALLOWED_HOSTS file is used in production to determine which hosts this
server is allowed to respond from. This has been moved to
ALLOWED_HOSTS.example with some example usage included. This is mostly
used to prevent accidentally committing and overwriting allowed hosts
used in production.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-12 16:51:44 -07:00
a38162a8df Fix up create*Window functions to be more mobile-friendly
I was surprised to see that the site is already pretty mobile-friendly.
The main issue was the quick reply, new thread, and report
windows - they were all hard-coded to be 500px, 500px, and 360px wide
respectively. Now, those hard-coded widths are the default but if the
viewport is thinner than that, the new window will size itself down with
some padding.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-12 16:48:21 -07:00
1eb960cb23 Limit post max length to 2k instead of 10k
10k is a little too long for this style of social media.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-12 15:42:59 -07:00
0de62aa63d Add overflow-wrap: break-word; to post_body CSS
This will cause long, unbroken posts to wrap.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-12 15:40:14 -07:00
a3ebf75e83 Add thread locking and permissions
Mods can lock threads from replying now. Yay!

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-08 21:55:25 -07:00
e866cbae0f Update reply and post forms to display correct capcodes
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-07-01 18:41:40 -07:00
b791cf6a6b Update various windows that open to have their height automatically set
Some windows have a variable height based on the user's permissions
(e.g. having a capcode option). This sets the window height to the
minimum requiremed height based on the document loaded in.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-30 20:37:19 -07:00
76f641a935 Remove some more old winbox references
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-30 19:31:37 -07:00
376066e55f Remove old winbox reference
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-30 19:31:18 -07:00
bbe0765f38 Prevent bumping a thread when it's stickied
This prevents all stickied threads from having their own bump order. We
want stickies to all stay in the same order.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-30 18:58:43 -07:00
e56832ab1b Fix some context values for can_modify in context
can_modify needs to be present in order to load the modify.js script.
This wasn't present on the PostView and was on a couple of unnecessary
views.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-30 18:52:44 -07:00
61b9e2a277 Merge report_window.js into post.js
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-30 18:44:58 -07:00
638d8cd349 Add bumplock to post modify form, and add set_bump permission
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-30 18:42:16 -07:00
0ac383ce6c Update PostModifyForm to use permissions to create its fields
Fields are only displayed via the PostModifyForm if the user has
specific permissions to do things, like set stickies.

Also, add PostModifySuccessView that will close the modify window when
the process is complete.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-30 18:16:08 -07:00
6f99472f16 Add post modify view
This allows moderators to modify posts (add sticky, etc).

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-30 16:21:36 -07:00
2947ab6cf2 Add fontawesome
My kingdom for a sticky icon

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-30 15:46:54 -07:00
6c11d210e8 Add floating window for new threads
New threads get a floating window just like new replies have. This only
pops up on the board detail view.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-28 23:55:44 -07:00
6ad2a72b86 Remove old winbox JS include from base.html
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-28 22:48:58 -07:00
66f6093f9b Remove old reply form code
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-06-28 22:14:42 -07:00