Page MenuHomePhabricator

Improve partner description HTML handling
Closed, ResolvedPublic

Description

Preferably, use Wiki markup instead. Would prefer not to need to write full HTML for adding links, paragraphing, etc.

Event Timeline

I've done research on this and have found the following:

There are two full and correct implementations of wikitext markup parsing

  • mediawiki, the wiki hosting software you all know and love
  • parsoid, a bidirectional wikitext <-> html parser that operates as its own service

Integrating either of these into twlight (or vice versa) would be non-trivial. Although using parsoid is probably the Right Thing to Do(TM), I think it would blow our timeline.

I was imagining simply running input text through a python wikitext parser library, and there is a seemingly good, but imperfect one available:

We would just need to try it and see if we were happy with it. Bugs or missing features in this library could lead to some problems with getting translations done, though.

If those options aren't appealing, markdown should be extremely straightforward to implement.

That looks like a great solution. I assume that any bugs or missing features wouldn't be a big deal - we wouldn't be doing anything more complicated than adding hyperlinks, paragraphing, or doing bullet points, which I hope would work!

So, I've been noodling around with this. mwparserfromhell didn't end up being as good of a choice for this as I'd hoped; though the parsing is excellent, it doesn't have a convenient html renderer baked in. I went with pandoc instead.
This works pretty well and is mostly done. Since I'm firing up a pandoc process to render the output, I need to enable per-langauge fragment caching on the descriptions so that the site won't fall over under moderate load.

See it in action on the staging system and let me know if you're happy with it.

Would like to, but I don't seem to be able to change any partner descriptions there. Altering the Description field, then saving, doesn't seem to actually save my changes.

Ah, editing the [en] description works, and that automatically updates the general Description box, but editing the general one doesn't save. Seems like an unrelated bug/fix.

Hm, ok. It's not working in a different way. I update the [en] description, it shows as updated in the /admin/partners interface, but looking at it on the platform it hasn't updated.

Oh I see the issue. On twlight-staging, on a partner page in the /admin interface, if you click 'View on site', it takes you back to twl-test instead of staging.

Did some testing on ASHA (https://twlight-staging.wmflabs.org/partners/11/) and it seems to work well, at least for adding links and paragraphing, which is 99% of what we need.

Hmm, I think that issue you're seeing is actually related to the 500 error we were getting before. Does it make sense to have 2 input boxes if the content should always be the same? Are there times when the first general input box needs to differ from en?

the fix for T161620 should resolve the view on site issue in staging.

Yeah not certain why there's a general description box; just one for each language would make sense.

Thinking to the future having a description box for every language on this page might not be optimal, but we can worry about that another day.

fragment caching looking good in development branch. I've verified that we're properly scoping the cache and that invalidation on partner update is working correctly.

I was planning on pushing this to production this weekend, but I realized that I wasn't handling the "stream" objects which are a lot like partners. I'm currently working on applying the changes there and testing the results locally.

For reference, Streams are called collections on the admin interface

Found and fixed a issue with the way preformatted wikicode was being rendered. I'm now forcing line wraps there, even on non-breaking characters. See attachment.

wikicode-preformatted.png (940×1 px, 152 KB)

Testing on caching stream html output looks good. Pushing to staging

So, let's do another round acceptance checks on staging, and then we'll get this thing pushed to prod.

From some quick testing of the syntax we're likely to use, it seems to work generally fine!

One strange issue: After I updated the T&F Collection description once, it doesn't seem to want to update again. Despite the db being saved with an update, the front facing description hasnt changed since my first update.

@jsn.sherman Do you think this will go live before tomorrow? It would be great to be able to discuss the new/finalised descriptions (which I'm pre-formatting in Wikitext!) then. No pressure if something is holding this up.

Sure, I think we're not quite done with the way preformatted text is handled, but we don't have to wait for perfection on that. I'll merge the code and push to production tonight.

@Samwalton9 I see what you're describing with T&F. To update the description on the front page, you have to edit the T&F partner description. The collection descriptions only show in the detail page.

@Samwalton9 updated code pushed to production. You should now have wikicode input.

Awesome, thanks! Looks to be working great :)

Shall I leave this task open for the preformatted text issues?

One URL, with the formatting [https://www.ebscohost.com/academic/book-review-digest-plus-h.w.-wilson/ Book Review Digest Plus], didn't format correctly. The output is that exactly, with "https://www.ebscohost.com/academic/book-review-digest-plus-h.w." hyperlinked.

Samwalton9-WMF lowered the priority of this task from Medium to Low.

Last bug probably not fixable by us, hardcoded as HTML instead.