Paste server written in Haskell. Fork of Hpaste, fully freedom and privacy respecting and generally improved. At the time of writing there's an instance at <http://paste.rel4tion.org>.

[[ 🗃 ^aoqmo toothpaste ]] :: [📥 Inbox] [📤 Outbox] [🐤 Followers] [🤝 Collaborators] [🛠 Commits]

Clone

HTTPS: git clone https://vervis.peers.community/repos/aoqmo

SSH: git clone USERNAME@vervis.peers.community:aoqmo

Branches

Tags

hpaste :: src / Hpaste / Controller /

Raw.hs

{-# OPTIONS -Wall -fno-warn-name-shadowing #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}

-- | Raw controller.

module Hpaste.Controller.Raw
  (handle)
  where

import Hpaste.Model.Paste   (getRevisions)
import Hpaste.Types

import Control.Applicative
import Data.ByteString.UTF8 (toString)
import Data.Maybe
import Data.Text.Lazy       (fromStrict)
import Prelude              hiding ((++))
import Safe
import Snap.App

-- | Handle the paste page.
handle :: HPCtrl ()
handle = do
  pid <- (>>= readMay) . fmap (toString) <$> getParam "id"
  case pid of
    Nothing -> goHome
    Just (pid :: Integer) -> do
      modifyResponse $ setContentType "text/plain; charset=UTF-8"
      paste <- fmap listToMaybe $ model $ getRevisions (PasteId pid)
      maybe goHome (outputText . fromStrict . pastePaste) paste
[See repo JSON]