Commit Graph

12 Commits

Author SHA1 Message Date
evazion
1d2bac7b95 Remove CurrentUser.ip_addr.
Remove the `CurrentUser.ip_addr` global variable and replace it with
`request.remote_ip`. Before we had to track the current user's IP in a
global variable so that when we edited a post for example, we could pass
down the user's IP to the model and save it in the post_versions table.
Now that we now longer save IPs in version tables, we don't need a global
variable to get access to the current user's IP outside of controllers.
2022-09-18 05:02:10 -05:00
evazion
21f0c2acc3 BURs: add processing and failed states.
When a BUR is approved, put it in a `processing` state. After it
successfully finishes processing, put it in the `approved` state. If it
fails processing, put it in the `failed` state.

If approving the BUR fails with a validation error, for example because
the alias already exists or an implication lacks a wiki, then leave the
BUR in the `pending` state. The `failed` state is only for unexpected
errors during processing.
2021-09-20 01:12:14 -05:00
evazion
6320db2541 BURs: fix rewriting wiki links with qualifiers.
When renaming a tag and the new tag has a qualifier, use the pipe trick
to hide the qualifier in wiki links. For example, renaming Fallout to
Fallout_(series) should change wiki links from [[Fallout]] to [[Fallout
(series)|]].
2020-08-28 13:57:18 -05:00
evazion
bbf2b53d83 aliases: fix broken wiki links when aliasing tags.
When aliasing A to B, update any wikis linking to [[A]] to link to [[B]]
instead.

This is a best-effort process based on rough heuristics. There are a few
known problems:

* We don't always know how to capitalize the new tag. We try to mimic
  the capitalization of the old tag, such that if the old tag was
  capitalized (because it was at the beginning of a sentence), or if
  every word in the old link was capitalized (because it's a proper
  noun), then the new link will be capitalized in the same way. This can
  handle simple general tags and character tags, but will fail for
  copyright tags with mixed capitalization. For example, we don't know
  that [[jojo_no_kimyou_na_bouken]] should be capitalized as [[JoJo no
  Kimyou na Bouken]]. If we don't know how to capitalize the new tag, we
  leave the old tag as-is so it can manually be fixed.

* Some aliases might require changing how a tag is pluralized. If we
  changed [[rat]] to [[mouse]], then we should change `[[rat]]s` to
  [[mice]]. We don't try to deal with this.

* In general, some changes might require entire sentences to be
  rewritten to keep the grammar correct. Changing something like
  [[skirt lift]] to [[lifting skirt]] could break the grammar of the
  sentence. We don't try to deal with this.
2020-08-26 19:02:19 -05:00
evazion
206ac7dd9a dtext#from_html: convert basic links to <url> syntax.
Convert

    <a href="https://www.example.com">https://www.example.com</a>

to

    <https://www.example.com>

instead of

    "https://www.example.com":[https://www.example.com]
2020-05-29 15:36:21 -05:00
evazion
3656063a6b tests: fix unit tests.
* Move old post archive tests to post version tests.

* Fix pool tests that assumed that multiple edits by the same user
  weren't merged.

* Fix references to `is_active` and `notes` on artist model.
2020-03-21 21:07:35 -05:00
evazion
e72c10bc23 dtext: don't link non-artist tags to artist entries.
* Don't link non-artist tags to artist pages, even when the tag has an
  artist entry. These artist entries are usually old deleted entries
  that happen to have the same name as a gentag, or leftover entries
  that need to be deleted.

* URL escape the artist name in /artists/show_or_new?name={name}
2020-01-08 12:33:55 -06:00
evazion
06d0ceb016 dmails: fix bug with parsing wiki links in email notifications.
Bug: sending a dmail containing a wiki link (ex: [[tagme]]) failed when
the recipient had email notifications turned on.

Cause: wiki links inside email notifications use absolute urls, which
the dtext postprocessor didn't parse correctly.
2019-11-05 19:10:41 -06:00
evazion
4bb1bdbe10 dtext: handle [bur:<id>] tags in main parser.
Move the parsing for the [bur:<id>], [ta:<id>], [ti:<id>] pseudo tags to
the main parser in `DText.format_text`. This fixes a bug where wiki
links inside bulk update requests on the forum weren't properly
colorized because the text of the BUR was embedded after we scanned for
wiki links, not before.

This also ensures that tags inside bulk update requests will be recorded
in the dtext_links table, meaning that forum posts can be properly
searched by tags.

This incidentally means that these request pseudo tags can now be used
outside the forum.
2019-10-28 16:40:38 -05:00
evazion
9f0ecf7247 dtext links: add table for tracking links between wikis.
Add a dtext_links table for tracking links between wiki pages. This is
to allow for broken link detection and "what links here" searches, among
other uses.
2019-10-23 21:36:48 -05:00
evazion
33f2725ae7 Fix #4112: Colorize tags in DText.
DText is processed in three phases: a preprocessing phase, the regular
parsing phases, and a postprocessing phase.

In the preprocessing phase we extract all the wiki links from all the
dtext messages on the page (more precisely, we do this in forum threads
and on comment pages, because these are the main places with lots of
dtext). This is so we can lookup all the tags and wiki pages in one
query, which is necessary because in the worst case (in certain forum
threads and in certain list_of_* wiki pages) there can be hundreds of
tags per page.

In the postprocessing phase we fixup the html generated by the ragel
parser to add CSS classes to wiki links. We do this in a postprocessing
step because it's easier than doing it in the ragel parser itself.
2019-10-11 18:45:55 -05:00
evazion
08b1c76533 dtext: refactor stripping markup from dtext.
There are a handful of places where we need to strip markup from a piece
of dtext, primarily in <meta> description tags in the wiki. Currently
the dtext parser handles this by having a special mode where it parses
the text but doesn't output html tags. Here we refactor to instead parse
the text normally then strip out the html tags after the fact.

This is more flexible and allows us to simplify a lot of things in the
dtext parser. This also produces more readable output than before in
certain cases.
2019-10-09 16:36:01 -05:00