Back from holiday and trying to catchup on forum posts I thought of some usability improvements.
If you think these improvements make sense I could try to make a PR :-)
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...
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.
Or a solution based on marking teasers in posts (manually) like in Hakyll?
import qualified Data.Text as T
teaserMarker :: Text
teaserMarker = "<!-- more -->"
getTeaser :: Text -> Text
getTeaser text = do
let (tsr, _) = T.breakOn teaserMarker text
tsr
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
).
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 <> "…"
"This has been fixed by now :)"
Sorry didn't notice; I'm an IHP (and Haskell) newbie...
Agree with all of them :) We should also add email notifications asap :)