Commit Graph

973 Commits

Author SHA1 Message Date
Gyrfalcon05
9f148b77fe Fix topic log link length overruns 2021-03-31 18:54:51 -05:00
Deimos
6f7618d1a1 Adjust zero-width joiner check to fix IndexError
There was the potential for an IndexError here, with a string that
started with a zero-width joiner and had at least one more character
afterwards.
2021-03-14 18:41:09 -06:00
Flashynuff
70e570b77f Handle zero width joiner unicode chars for emoji
Some emoji variants require a zero-width joiner, and they were being
broken by the current code that stripped them out.
2021-03-14 18:39:17 -06:00
Deimos
348c930133 Fix blank lines at start of Atom/RSS feeds 2021-02-28 14:51:10 -07:00
Deimos
5093fca18e Update feeds to have absolute permalinks 2021-02-27 14:15:16 -07:00
Andrew Shu
a021b96bc7 Add RSS and Atom feeds for topic listings 2021-02-27 14:14:56 -07:00
Andrew Shu
0404d0dfa2 Process tags to left of comma only
If user types "tag1 tag2" then adds a comma between,
it should respect the comma to give "tag1" and "tag2".

We use keydown and setTimeout because keyup
works on a keyboard but not reliably on mobile.

Nonzero timeout is needed or else the comma is sometimes
inserted too late and not seen by addChip(),
tested on desktop Firefox.
2021-02-21 15:25:32 -07:00
Carlos E. Garcia
d00a59ffa4 Fix link re-directing to development page 2021-01-24 22:49:50 +00:00
Deimos
071f1e04f6 Add some margin above a group's sidebar text 2020-12-15 19:38:59 -07:00
Deimos
e685639e84 Apply global rate-limit to Stripe donate endpoint
People are still continuing to try to abuse the donate page to check
stolen credit card numbers, and last night there was a massive burst of
attempts coming from many IPs, so the current rate-limiting wasn't able
to block most of it. Luckily Stripe blocked all of the charges this
time, but I can't keep risking another incident where Tildes is the
source of a bunch of fraudulent charges.

This adds a global rate-limit to the donate page that should never get
hit during normal usage. Hopefully this will be enough to keep the abuse
away from the page when it stops working for them relatively quickly.
2020-12-12 15:48:38 -07:00
Deimos
06764e9bc5 Add support for globally rate-limiting actions
Previously, rate limits had to apply to a particular user or a
particular IP address, or both. This adds support for global
rate-limits, where the limit will apply to everyone trying to perform
the action. This probably won't be used much overall, but might be
necessary for certain cases where something abusive is happening and it
can't be easily blocked by user or IP.

This is a bit ugly and would probably be better implemented by having a
separate class that inherits from RateLimitedAction or something
similar, but it will do the job.
2020-12-12 15:44:09 -07:00
Cassidy Dingenskirchen
91c408c6d8 Drop ic-current-url param in Intercooler requests 2020-12-06 13:07:37 -07:00
Deimos
88944bed17 Run app-related services under the app user 2020-11-30 20:31:14 -07:00
Deimos
5fbc72c44c Add ability to process posts with Lua scripts
This adds the backend pieces (no interface yet) to configure Lua scripts
that will be applied to topics and comments due to different events.
Initially, it only supports running a script when a new topic or comment
is posted. For example, here is a Lua script that would prepend a new
topic's title with "[Text] " or "[Link] " depending on its type, as well
as replace its tags with either "text" or "link":

function on_topic_post (topic)
    if (topic.is_text_type) then
        topic.title = "[Text] " .. topic.title
        topic.tags = {"text"}
    elseif (topic.is_link_type) then
        topic.title = "[Link] " .. topic.title
        topic.tags = {"link"}
    end
end

There can be a global script as well as group-specific scripts, and the
scripts are sandboxed, with limited access to data as well as being
restricted to a subset of Lua's built-in functions. The Lua sandboxing
code comes from Splash (https://github.com/scrapinghub/splash). It will
need to be modified, but this commit keeps it unmodified so that future
changes can be more easily tracked by comparing to the original state of
the file.

The sandboxing also includes some restrictions on number of instructions
and memory usage, but this might be more effectively managed on the OS
level. More research will still need to be done on security and resource
restrictions before this feature can be safely opened to users.
2020-11-30 17:05:00 -07:00
Deimos
8144a8b789 Use postponed evaluation of type annotations
The __future__ import will be able to be removed as of Python 3.10.
2020-11-18 15:33:31 -07:00
Deimos
b6d20340c9 Add action-settings to topic-with-excerpt grid
Whoops, only added it to the ones without excerpts, which causes a minor
layout issue for the with-excerpt ones.
2020-11-16 15:03:13 -07:00
Deimos
dac8ec3a01 Add ability to edit topic title from listing pages
This adds an "Edit title" choice in the actions dropdown for topics on
listing pages, instead of needing to go to the comments page.

Some pieces of this feel a little hack-ish (like needing to reduce the
bottom padding because of the usually-empty div that the title-editing
input gets put into), so I'll probably want to try and find a better
overall approach to this eventually, but it should do the job for now.
2020-11-15 15:49:06 -07:00
Deimos
8c913d595c Alphabetize invoke task functions
Just rearranges the module so the functions are in alphabetical order
(except web_server_reload, which has to be earlier so it can be called
as a post-task).
2020-11-03 18:20:05 -07:00
Deimos
79072f76d8 Rename invoke tasks to standardize format
I think this is going to be a better way to name invoke tasks. The
previous naming where a verb was often first made it much harder for
anyone to figure out the name of a task that affects a certain thing
without always looking through the entire list.

For example, if someone is looking for a task that affects the web
server, it's much easier to find web-server-reload than
reload-web-server.

The changes were:

- check-code-style -> code-style-check
- reload-web-server -> web-server-reload
- renew-tls-certificate -> tls-certificate-renew
- type-checking -> type-check
- update-pip-requirements -> pip-requirements-update
2020-11-03 18:09:36 -07:00
Deimos
9d5e2bf5e3 Add gemini:// to allowed link protocols 2020-11-02 14:56:21 -07:00
Deimos
2d70ef8da8 Update pypi package versions (requirements.txt) 2020-11-02 14:53:00 -07:00
Deimos
70949ff0e2 Add invoke task to renew TLS certificate 2020-10-21 16:01:48 -06:00
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