Commit Graph

951 Commits

Author SHA1 Message Date
Deimos
f31052670a Remove "via" annotations from requirements files
I should have just done this all along, these have been way more trouble
than they're worth.

If the information is needed, it's always possible to just do a temp run
of pip-compile without --no-annotate or use a dedicated tool like
pipdeptree.
2020-10-09 22:00:08 -06:00
Deimos
9652dfb722 Add --full flag to invoke test
This is simpler than needing to know that --html-validation is the flag
to use to make sure that all tests are run, and can stay constant even
if we add other types of excluded-by-default tests in the future.
2020-10-09 19:16:04 -06:00
Deimos
9e7906c4a1 Add invoke task to start an IPython shell 2020-10-09 17:52:13 -06:00
Deimos
4e6d56574a CONTRIBUTING.md: Update links to development pages 2020-10-09 16:56:33 -06:00
Deimos
f4933be2dd Nginx: remove /development redirects on Docs site
These were set up to redirect the original locations of the development
pages to their new locations inside the instructions folder, but can't
be used any more now that we're creating a development folder.
2020-10-09 16:50:11 -06:00
Deimos
e4a187eb56 Stop stripping periods from multi-sentence titles
If a topic title has multiple sentences in it, it looks strange to strip
the trailing period off it, so we only want to do that automatically
when it's a single sentence.
2020-10-07 17:16:25 -06:00
Deimos
ee78cd7760 Update Black to version 20.8b1
Updates the Black code-formatter for Python to the latest version, and
applies it to some files that had formatting that the new version does
differently (splitting collections with trailing commas across lines).
2020-10-07 16:19:28 -06:00
Deimos
6231a5e6a2 Update pypi package versions (requirements.txt) 2020-10-07 16:14:43 -06:00
Deimos
21e016d481 Fix "-r" check in invoke update-pip-requirements
This needs to check for spaces around the "-r", otherwise it ends up
removing comments that include "pyramid-session-redis" and similar.
2020-10-07 16:13:49 -06:00
Deimos
dd00e2e79c Add invoke tab-completion script to dev .bashrc
This enables tab-completion for the new invoke tasks in the dev version.
So for example, you can type "invoke ty<Tab>" and it will complete to
"type-checking".
2020-10-07 15:39:14 -06:00
Deimos
ffde9f29a1 Use invoke tasks in git pre-push/pre-commit hooks 2020-10-07 15:25:04 -06:00
Deimos
ff07815985 Add invoke task to run code-style checks
The output of this has some issues and can definitely use some work, but
should do the job for now.
2020-10-07 15:21:55 -06:00
Deimos
037176524b Add invoke task to check type annotations 2020-10-06 18:31:24 -06:00
Deimos
c2bfe2e2c7 Add invoke task to run tests
This way, instead of needing to know that you run "pytest" and knowing
tricks like "pytest -m ''" to run webtests and HTML validation, you can
now just run "invoke test", with more intuitive flags. This also reduces
the output in quiet mode even more.

After adding invoke tasks for some of the other tools/checks, I'll be
able to switch the git hooks to use these instead.
2020-10-05 20:33:16 -06:00
Deimos
6a216aba52 Add invoke task to update pip package versions
First invoke task: uses pip-compile to update the versions of all the
pip packages in requirements.txt and requirements-dev.txt. It also
post-processes the output file and removes any comments that have a "-r"
reference in them, since those currently cause Salt to break (and are
kind of redundant anyway).

Unfortunately, as part of writing this I discovered that invoke can't
handle type annotations in the definitions of its task functions, so I
had to exclude tasks.py from being checked by mypy. That makes me a
little nervous about whether invoke is still being maintained. Relevant
issue (over 4 years old): https://github.com/pyinvoke/invoke/issues/357
2020-10-05 18:20:41 -06:00
Deimos
85bbe7feb5 Install invoke python package 2020-10-05 14:19:14 -06:00
Deimos
4efff58bac Add Amazonbot to list of bot user agents 2020-10-02 13:14:28 -06:00
Deimos
746568cb44 Fix .btn-primary hover colors reverting to Spectre 2020-10-01 17:59:04 -06:00
Bauke
3d6fcb5a70 Add the Love themes. 2020-10-01 17:35:14 -06:00
Deimos
be3403680d Fix border color for <fieldset> (new topic page) 2020-09-29 13:07:39 -06:00
Deimos
de1a64b3d0 CSS: fix some border color regressions 2020-09-28 17:21:26 -06:00
Deimos
082e3b51a1 CSS: replace some custom props with native values
This isn't perfectly equivalent in some cases, but it's a barely
noticeable difference, and it's nice to not have all of these extra
custom properties like "--button-darkened-8-color" for an extremely
niche usage.
2020-09-28 17:03:02 -06:00
Deimos
135a010aa4 CSS: Move all theme color rules into normal places
Now that we've switched to CSS custom properties, all the color rules
don't need to be repeated for each theme via a mixin, so the
_theme_base.scss could be split up with all its rules going into the
expected modules/locations along with all the other associated styles.
2020-09-28 15:34:17 -06:00
Deimos
f311e294dc Move syntax-highlighting CSS into a module
No need for this to be a mixin any more now that it only exists once and
isn't being called for each theme separately.
2020-09-24 17:44:23 -06:00
Deimos
0f4890dda5 CSS: add "-color" suffix to all custom properties
I think it's best to be specific that all of these are colors, otherwise
there could be some confusing usages (and potential collisions) with
ones like --border.

Sorry @Bauke (and probably some others), I know this will most likely
mess with any changes you've already made to override these properties,
but I wanted to do it eventually and it's only going to get worse the
longer I wait.
2020-09-24 16:52:00 -06:00
Deimos
0cbe17f763 Fix sidebar background color in fallback themes 2020-09-15 00:24:49 -06:00
Deimos
925278ed7c Add minimal theme support for old browsers
This should allow users with browsers that don't support CSS custom
properties to still have some minimal theme support. There will be
various issues with the themes (and that's fine), but it will at least
set the main colors for their chosen theme.
2020-09-14 20:28:41 -06:00
Deimos
cbf77c1def Fix transparent sidebar for very old browsers
With the switch to CSS custom properties for the themes, old browsers
with no support are ending up with a transparent background on the
sidebar. This makes the site especially difficult to use on mobile.

I'm going to do something more extensive to allow browsers with no
support for custom properties to still get basic theming, but it's
dependent on a @supports query. For browsers that don't support that
query either, we need this line to give the sidebar a background.
2020-09-14 20:22:21 -06:00
Deimos
7afbcb85d0 Revert "Temp: test @supports query for CSS custom props"
This reverts commit df64807384.
2020-09-14 17:38:37 -06:00
Deimos
df64807384 Temp: test @supports query for CSS custom props 2020-09-13 10:46:26 -06:00
Deimos
a13179044e Fix border colors on some more elements 2020-09-11 21:54:27 -06:00
Deimos
8ec4a86eb2 Remove donation goal from Financials page
This is probably just temporary, but I'm going to leave the donation
goal meter off the sidebar for now, so I don't want the confusing
section in the middle of the Financials page saying that the goal is $0
and so on.
2020-09-11 18:55:50 -06:00
Deimos
f8f7a96431 Show Exemplary badge on labeled comments
This starts showing the Exemplary badge to all users again (but only the
author can see the count still).

It also changes the "priority" of the .is-comment-exemplary and
.is-comment-new classes so that the stripe will show the new color when
a comment is both new and exemplary.
2020-09-11 13:39:41 -06:00
Deimos
3a18be64ad Fix border on hovered comment collapse button 2020-09-09 17:23:33 -06:00
Deimos
d3a84fe411 Fix issue if "most recent comment" not found
Not sure exactly how this can happen, but I've seen a few errors caused
by this.
2020-09-09 16:41:41 -06:00
Bauke
2d023cd659 Use CSS custom properties for theming 2020-09-08 19:27:35 -06:00
Deimos
68870119f4 Remove remnants of Redis breached-passwords check
We've been using pts_lbsearch on the text file for a few weeks now, and
it's working fine. Checks generally seem to take about 10 ms, and that's
totally fine for the relatively uncommon events of registrations and
password changes.

This removes everything related to the previous Redis-based method,
which means we no longer need the second Redis server or the ReBloom
module.
2020-09-06 18:32:10 -06:00
Deimos
624123929a Exclude removed comments from "last comment" link
The "last comment posted" link in the sidebar on a topic's comments page
was still considering removed comments, so if the last comment in a
topic was removed it would link to that one. That's not very useful for
anyone, so this excludes removed comments the same way that deleted ones
were already excluded.
2020-09-03 15:16:21 -06:00
Deimos
26b1d4dd9b Use pts_lbsearch to check for breached passwords
This replaces the current method of using a Bloom filter in Redis to
check for breached passwords with searching the text file directly using
pts_lbsearch (https://github.com/pts/pts-line-bisect/).

I'm not removing the Redis-based method yet because I want to test the
performance of this first, but this is *far* simpler and doesn't have
the possibility for false positives like the Bloom filter does.
2020-08-11 18:27:16 -06:00
Deimos
a70cc61499 Add metric to breached-password check 2020-08-10 13:16:04 -06:00
Deimos
d61b848816 Fix bug with trying to unnest non-webargs errors
When a ValidationError comes up for a reason unrelated to webargs (for
example, if a user tries to set a password that's in the breached list),
this crashes when trying to unnest it, since it doesn't have the extra
level that webargs adds.

This is a bit ugly, but checks to see whether the extra level is there
first.
2020-08-10 12:52:10 -06:00
Deimos
2e5a2d96bf Switch user permissions to use an enum
Previously, there wasn't any defined list of which permissions were
valid or not. You basically had to look through each model's __acl__
method to see what the possibilities were.

Using an enum will be less convenient when adding new permissions or
changing existing ones (since it will require a database migration), but
it makes it much easier to see what the valid options are, and will
prevent invalid permissions from being set up in the database.
2020-08-05 16:34:22 -06:00
Deimos
a46283436d Rename "post_topic" permission to "topic.post"
This permission was a strange exception, with every other permission
being of a format like "topic.lock", "comment.remove", and so on.
2020-08-04 18:29:17 -06:00
Deimos
036d46d589 Add marks to slower tests and don't run by default
This uses pytest's "markers" system to add markers to two special types
of tests:

* webtest - ones that use the WebTest library and are testing the actual
  HTTP app, instead of executing code/functions directly
* html_validation - ones that are generating HTML output (via webtest)
  and running it through the Nu HTML Checker to validate it.

The "webtest" marker is added automatically by checking whether a test
uses either of the webtest fixtures, and the html_validation one is
currently added manually to the only module that has those tests. In the
future, we could probably put HTML validation tests in their own folder
and mark them automatically based on the module's path or something
similar.

This also changes the default arguments for pytest to exclude these two
marked types of tests, and updates the git hooks so that webtests are
run pre-commit (but not HTML validation), and all tests are run
pre-push. Similar to the way we use prospector, this makes it so that
the very slow tests are only run before pushing.
2020-08-03 14:37:08 -06:00
Andrew Shu
87dce83f26 Install html5validator, validate HTML in tests
Installs the Nu Html Checker and starts using it to validate the home
page's HTML: https://validator.github.io/validator/

Also includes fixes to some lists that were nested in an invalid way.
2020-08-02 19:16:52 -06:00
Andrew Shu
9ff86bedb7 Fix HTML- and URL-encoding bugs on homepage 2020-08-02 14:42:56 -06:00
Deimos
3026d066d3 Set function scope for logged-out webtest fixture
I mistakenly assumed that not setting the cookiejar argument when
creating a webtest TestApp would mean that no cookies would be retained
between requests, but that's wrong. If you don't pass a cookiejar, it
just automatically creates one for you. Because of this, logged-out
webtests would end up being logged-in after any test logged in.

This reduces the webtest_loggedout fixture's scope to function-level so
that it will be re-initiated on every test instead. It also stops
passing a cookiejar for the logged-in webtest, since that's unnecessary.
2020-08-02 14:29:36 -06:00
Deimos
6f272fcd54 Revert "Build HTML Tidy, validate homepage HTML in tests"
This reverts commit cb7be83877.

HTML Tidy seems to have various gaps in its validation that we've found
already, including one that's pretty much a deal-breaker for Tildes's
HTML: it doesn't think that <menu> is a valid parent for <li>.

We're looking at alternative validators still.
2020-08-02 14:20:37 -06:00
Andrew Shu
cb7be83877 Build HTML Tidy, validate homepage HTML in tests
Adds the HTML Tidy library to the dev version, along with the pytidylib
wrapper for it, and a couple of tests that use it to validate the HTML
of the home page.

Includes a fix to the GitLab "Planned features" link that Tidy considers
invalid because it includes some un-encoded characters.
2020-08-01 14:20:57 -06:00
Deimos
f41bd1eabe Upgrade webargs to 6.1.0
This was not a fun upgrade. webargs made some major changes to its
approaches in 6.0, which are mostly covered here:
https://webargs.readthedocs.io/en/latest/upgrading.html

To keep using it on Tildes, this commit had to make the following
changes:

  - Write my own wrapper for use_kwargs that changes some of the default
    behavior. Specifically, we want the location that data is being
    loaded from to default to "query" (the query string) instead of
    webargs' default of "json". We also needed to set the "unknown"
    behavior on every schema to "exclude" so that the schemas would
    ignore any data fields they didn't need, since the default behavior
    is to throw an error, which happens almost everywhere because of
    Intercooler variables and/or multiple use_kwargs calls for different
    subsets of the data.

  - All @pre_load hooks in schemas needed to be rewritten so that they
    weren't modifying data in-place (copy to a new data dict first).
    Because webargs is now passing all data through all schemas,
    modifying in-place could result in an earlier schema modifying data
    that would then be passed in modified form to the later ones.
    Specifically, this caused an issue with tags on posting a new topic,
    where we just wanted to treat the tags as a string, but TopicSchema
    would convert it to a list in @pre_load.

  - use_kwargs on every endpoint using non-query data needed to be
    updated to support the new single-location approach, either replacing
    an existing locations= with location=, or adding location="form",
    since form data was no longer used by default.

  - The code that parsed the errors returned by webargs/Marshmallow
    ValidationErrors needed to update to handle the additional "level"
    in the dict of errors, where errors are now split out by location
    and then field, instead of only by field.

  - A few other minor updates, like always passing a schema object
    instead of a class, and never passing a callable (mostly just for
    simplicity in the wrapper).
2020-07-31 12:13:23 -06:00