Commit Graph

66 Commits

Author SHA1 Message Date
Deimos 134848b9bd Add margin-bottom to <table>
Adding a table to a post wouldn't have any margin below it, so the next
paragraph would be right up against the bottom.
2018-08-13 17:16:07 -06:00
Deimos 1a2b5a8593 Add Black format check to git hooks 2018-08-13 14:33:31 -06:00
Deimos 4d8998d8f9 Re-wrap comments with new max line-length
Black won't re-wrap comments because it has no way to determine when
that's a "safe" thing to do (that might break deliberate line-breaks).
So this is a quick pass through to re-wrap most multi-line comments and
docstrings to the new max line-length of 88.
2018-08-13 14:33:31 -06:00
Deimos 09cf3c47f4 Apply Black code formatter
This commit contains only changes that were made automatically by Black
(except for some minor fixes to string un-wrapping and two
format-disabling blocks in the user and group schemas). Some manual
cleanup/adjustments will probably need to be made in a follow-up commit,
but this one contains the result of running Black on the codebase
without significant further manual tweaking.
2018-08-13 00:24:12 -06:00
Deimos 7961a51b87 Update pylama config for Black style changes
Just a couple minor tweaks needed so that pylama won't edit on some of
the style changes that Black is going to make.
2018-08-12 23:59:26 -06:00
Deimos 320e45d8cf Install Black code-formatter for Python 2018-08-12 18:12:33 -06:00
Deimos 8c6a537665 Move Boussole to its own venv
Boussole (which watches the SCSS files for changes and compiles them)
has just been running in the same venv as the main app until now, but
it's holding back the version of the click package. There's no real
reason that it needs to be in the app venv, so this moves it to its own
one, which also eliminates quite a few other packages that were only
being installed because of Boussole.
2018-08-12 18:00:38 -06:00
Deimos eb712f25f2 Update pypi package versions (requirements.txt) 2018-08-12 14:28:02 -06:00
James Southern 73b73c2591 Prepend REST verbs to all view methods
Example: `def vote_comment` becomes `def put_vote_comment`
2018-08-12 14:13:05 -06:00
Deimos 9746203b55 Add redis.sessions.cookie_max_age to dev INI file
I don't think there was any particular reason this wasn't included, and
makes the behavior closer to what it is in production.
2018-08-10 16:14:49 -06:00
Deimos e3842e88c4 Enable cmark-gfm extensions (table, strikethrough)
An example was recently added to the github cmark repo to show how to
set up the extensions from Python, so this is heavily based on that
code:
https://github.com/github/cmark/blob/master/wrappers/wrapper_ext.py

This should also fix a memory leak, since I wasn't manually freeing the
returned buffer (as the library recommends that you do).
2018-08-10 01:01:58 -06:00
Deimos a5664b8589 Sort previous notifications when marking all read
Because of the way the topic_visits update works (only updating visits
that were before the comment was posted), this will only behave
correctly when the previous notifications are processed in the order
their comments were posted.

This process needs to be replaced soon anyway, but this should make it
work correctly for now.
2018-08-09 23:04:48 -06:00
James Southern 45b2de0a44 Add mark all read button to unread notifications
This will only mark notifications up to the timestamp of the most recent
one shown on the unread notifications page where it was clicked.
2018-08-09 23:04:45 -06:00
Deimos 83298c36e6 Refactor Group and User ACLs
These ones are very simple, just a small update to make them match the
style of the others as well.
2018-08-09 15:41:21 -06:00
Deimos be77f323d3 Refactor Topic ACL, update tests 2018-08-09 15:27:58 -06:00
Deimos 99f1912d94 Add more comment permissions tests
Just a couple more tests for comment permissions that are more essential
to be working correctly - replying in locked threads, and viewing
removed comments. Also changes the "deleted comments lose all
permissions" test slightly to actually check all permissions instead of
a hard-coded (and obsolete) set of them.
2018-08-09 07:30:02 -06:00
Deimos 2ffddb2fbd comment_by_id36 resource: include removed comments
Not including removed comments here was preventing authors from being
able to edit/delete their comments once they had been removed.
2018-08-09 07:30:02 -06:00
Deimos 4667d0ecce Refactor Comment ACL
The previous approach to writing ACLs made them difficult to follow,
which resulted in making it easy to make mistakes (like allowing users
to reply to themselves in locked threads). This approach should work
much better.
2018-08-09 07:30:01 -06:00
Deimos 0481a9ea01 Add some more tests for comments triggers
Unfortunately some of the triggers aren't currently testable due to
the fact that postgresql's NOW() and similar functions will always
return the same value during the entire test transaction, but this at
least tests a couple more of the behaviors.
2018-08-09 07:30:01 -06:00
Deimos eb1e4c6eca Tests: move common fixtures into a module
This moves some of the commonly-used fixtures (creating a topic, etc.)
into a separate module, which gets included into conftest.py (so the
fixtures are available everywhere) by treating it as a "plugin".
2018-08-08 23:27:00 -06:00
Deimos 06333a8417 Update comments triggers to handle removals
Well, this alembic migration was a gigantic pain in the ass. Might be
worth writing a tool to be able to deal with things like this.
2018-08-08 19:37:14 -06:00
Deimos 3fed4783f7 Prevent replying to self in locked topics
I think it's time to refactor the ACL methods.
2018-08-08 13:57:44 -06:00
Deimos 08ec214e4d CSS: Set <table> width to auto 2018-08-08 12:23:41 -06:00
Deimos f388b86306 Skip deleted/removed comments in mentions consumer 2018-08-08 02:04:28 -06:00
Deimos 5968fcd139 Add handling for "curly" apostrophes
There was some special handling of apostrophes in two string-related
functions: the one for generating url slugs, as well as the one for
doing a word count. Both of these weren't handling "curly" apostrophes
(unicode char 0x2019) properly before, so they've both been updated now.
2018-08-07 19:04:26 -06:00
Deimos e0549be5fd Prevent OverflowErrors from long time periods
A couple of different locations in the code were causing crashes if the
user specified ridiculously long time periods (via topic listings).

This should prevent it, or at least give a better error when it happens.
2018-08-07 16:30:54 -06:00
Deimos e1b35cdb1a Fix intercooler targeting for .comment-itself
The functions that target a comment's .comment-itself div (editing,
voting, deleting) were nesting an additional .comment-itself inside it,
instead of replacing the existing one.
2018-08-07 13:40:14 -06:00
Deimos df2177db70 Replace spaces in topic tag CSS classes 2018-08-07 12:51:32 -06:00
Deimos 4f0075966d Comment: Fix parent_comment relationship 2018-08-06 16:44:14 -06:00
Deimos b729bf1d98 Change "new replies" to "new comments"
With username mentions implemented, calling comment notifications
"replies" isn't very accurate any more.
2018-08-06 13:35:02 -06:00
Celeo 420ea5a15b Add notifications for users being mentioned
This detects mentions of users in comments using the same pattern as the
markdown parsing uses to generate user links. Mentioned users are sent a
notification, and mentions are added/deleted if needed on comment edits.

As part of this, setup was done to generate rabbitmq messages for
comment creation and edits, and the mentions are handled by an async
consumer of these messages.
2018-08-05 23:25:54 -06:00
Deimos 34a933e6d3 Refactor text topic excerpt display into a macro 2018-08-05 15:30:21 -06:00
Ivan Fonseca 35ea0f43b4 Hide topic text excerpt for spoilers 2018-08-05 15:04:01 -06:00
Ivan Fonseca dba7ace0d4 Highlight special topic tags (nsfw, spoiler) 2018-08-05 15:03:59 -06:00
Deimos b6c5be0593 Fix excessive margin on <ol> at end of block
The bottom margin on <ol> was causing some weird spacing when it's the
last element inside a block. This is most noticeable on a blockquote
where the background color extends further down than it should.
2018-08-03 17:06:01 -06:00
Deimos 2de03d719e PaginatedResults: use id36s for before/after
This was previously using regular integer IDs, but it should have been
ID36s.
2018-08-03 14:06:34 -06:00
Deimos 7276b15e39 Add paginated topics/comments pages to own profile
This needs some more work still to clean up a few things, but it should
be good enough for now. This allows users to see (only on their own user
page), separate "tabs" for Topics and Comments, and those separate
listings are paginated.
2018-08-03 13:58:32 -06:00
Deimos f95a504ca4 PaginatedQuery: set a default for _sort_column
Previously, _sort_column wasn't set by default and needed to be set by
the query, but some of the other methods would fail if it hadn't been
set. This just defaults it to use the created_time column as the default
sort, which should always be present on models being queried by this
class (for now, at least).
2018-08-03 00:05:10 -06:00
Deimos 03f5450414 PaginatedResults: add props for before/after IDs
This adds two new properties to PaginatedResults - .next_page_after_id
and .prev_page_before_id. These can be used when creating the links to
the before/after pages, instead of needing to access the right
element/property "manually".

This will be most useful in listings that contain items of multiple
types (such as comments and topics), since we won't necessarily know
which type the first/last elements are.
2018-08-02 23:58:30 -06:00
Josh Holland 147c22d071 Consistently refer to Markdown with a capital 2018-08-01 18:12:12 -06:00
Deimos 268d98e3de Increase edit "grace period" to 5 minutes 2018-08-01 16:59:51 -06:00
Deimos f3cd4f805e User profile: fix ordering of "initial comments"
When you're posting a new topic and you fill out both the link and text
fields, it posts as a link topic with the text posted as the first
comment. Because this is done in the same database transaction, the link
and comment get exactly the same `created_time` value. Previously, the
comment was being sorted "before" the topic, which was a bit confusing
when viewing a user's profile - it would show the comment as being
posted before the topic it was posted on.

This just reverses the order that the two lists are joined in to fix
this slight oddity.
2018-07-30 23:40:06 -06:00
Ivan Fonseca 3d4b963096 Open in new tabs: Add support for links in text
Adds a new sub-option to the "Open links in new tabs" setting which uses
javascript to find external links in the text of topics, comments, and
messages and sets them to open in new tabs.
2018-07-30 17:18:24 -06:00
Deimos 52db30cdad Remove handling of None in some query methods
The previous setup was a bit unusual and confusing - various functions
that restricted the query somehow were accepting None as an argument and
simply doing nothing if it was passed. This made calling them a little
simpler, but overall didn't make a lot of sense - if you don't want to
apply the restriction, you shouldn't call the function in the first
place.
2018-07-25 19:02:08 -06:00
Deimos de9c86bc1b Set default period to "all time" inside groups
Currently, the default sort+period combination is "by activity, last 3
days". This works fairly well on the home page, but isn't working well
inside individual groups because there usually aren't many posts made
yet in a specific group in the last 3 days. Because of this, going into
an individual group looks quite empty by default.

This commit changes the default *only* when inside a group to be "by
activity, all time". This will still be overridden if the user has set
up custom defaults.
2018-07-25 16:53:44 -06:00
Deimos 68e2e0ea33 Tests: don't load Redis ReBloom module
This module is only being used by the breached-passwords Redis server,
which is separate. It's not relevant to any of the tests, so there's no
reason to load it.
2018-07-25 16:03:14 -06:00
Deimos d1fccfd153 Data cleanup script: exclude previously-cleaned
The cleanup of old deleted comments and topics was repeatedly hitting
the same items even though they had already been cleaned up on previous
runs. This just explicitly excludes all the ones that have already had
their user_id info removed, so it will only hit ones that actually need
it.
2018-07-25 13:31:35 -06:00
Shane Moore b0d2be5eeb Invite page: Move codes below button and sort
The codes weren't in any defined order previously, so this sorts them to
put the newest ones at the top, and also moves the button above.
2018-07-24 19:57:14 -06:00
Ivan Fonseca 6d8b3c2d3a Add user menu sidebar to all user pages
Previously, the user menu sidebar was only available on the "base" user
page, but disappeared if you went into any of the individual pages. This
adds it to all of the pages, including highlighting the current page in
the menu.

Behavior of the "invite count" was changed slightly to save needing to
do an extra query on every page - it now only includes the number of
"un-generated" invite codes, not the number that have already been
generated but are sitting unused.
2018-07-23 18:27:54 -06:00
Deimos 4772891522 CONTRIBUTING.md: Clarify inbound=outbound license 2018-07-22 17:20:40 -06:00