New IHP Case Study: How AirPV is making the process of going solar easier and better value with IHP

Usability suggestions


Back from holiday and trying to catchup on forum posts I thought of some usability improvements.

  1. In the homepage overview we should probably limit the size of the post previews
  2. In the homepage overview reverse the ordering of posts to have latest at the top
  3. Ability to change the topic when editing a thread

If you think these improvements make sense I could try to make a PR :-)

marc PRO

Agree with all of them :) We should also add email notifications asap :)

marc PRO

Just applied some improvements :) But there's IMO a lot more todo :)


Great, these are huge improvements!

Tonight I attempted to limit the length of the posts on the homepage. However, that was a bit more complicated than I thought. First I tried simply get #body thread |> take 200 |> renderMarkdown, however that gives me Text type errors (I really don't understand the Text/Char/String mess in Haskell). Then I thought of the problems of simply trimming Markdown would give, potentially incorrect Markdown? But starting to look into limiting the amount of text in HTML is a whole different rabbit hole...

marc PRO

Yeah, just limiting the html is not so easy. Also limiting the markdown string might have a few edge cases. E.g. the shorted markdown string could result in invalid markdown. Then the generated html would be an error message. In that case we'd need some kind of loop that keeps removing one more character and then looks whether the html can be successfully be generated from the markdown.

Mari Donkers

Or a solution based on marking teasers in posts (manually) like in Hakyll?

Using teasers in Hakyll

import qualified Data.Text as T

teaserMarker :: Text
teaserMarker = "<!-- more -->"

getTeaser :: Text -> Text
getTeaser text = do
  let (tsr, _) = T.breakOn teaserMarker text
stripTeaser :: Text -> Text
stripTeaser text = do
  let len = T.length teaserMarker
      (tsr, rst) = T.breakOn teaserMarker text
  T.concat [tsr,  T.drop len rst]

Just put it in before an e.g. |> renderMarkdown, as follows: ... |> getTeaser |> renderMarkdown ... (same with stripTeaser).

marc PRO

This has been fixed by now :)

The solution was to use stripTags after rendering the markdown to html. This way we just get the plain text output.

previewText post = post
        |> get #body
        |> renderMarkdown
        |> Blaze.renderHtml
        |> cs
        |> stripTags
        |> Text.take 240
        |> \text -> text <> "…"
Mari Donkers

"This has been fixed by now :)"

Sorry didn't notice; I'm an IHP (and Haskell) newbie...