| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
Yesod.Media.Simple
Description
Easily serve different media types to the user.
- serve :: RenderContent a => a -> IO ()
- serveHandler :: RenderContent a => LiteHandler a -> IO ()
- class RenderContent a where
- renderContent :: a -> HandlerT site IO TypedContent
- serveDiagram :: Diagram Cairo -> IO ()
- data SizedDiagram = SizedDiagram (SizeSpec V2 Double) (Diagram Cairo)
- data PixelList = PixelList Int Int [[(Word8, Word8, Word8)]]
- data Jpeg = Jpeg Word8 (Image PixelYCbCr8)
- imageToDiagramEmb :: (Renderable (DImage (N b) Embedded) b, V b ~ V2, TypeableFloat (N b)) => DynamicImage -> Diagram b
- imageToDiagramExt :: (Renderable (DImage (N b) External) b, V b ~ V2, TypeableFloat (N b)) => DynamicImage -> IO (Diagram b)
- diagramToImage :: Diagram Cairo -> Double -> Double -> IO (Either String DynamicImage)
Documentation
serve :: RenderContent a => a -> IO () Source
Starts a web server which serves the given data to the client. It
listens on the port specified by the PORT environment variable.
If there is no PORT variable, it defaults to port 3000. This
means that the results will be visible at http://localhost:3000.
The server responds to any GET request with the results - the
route is ignored.
serveHandler :: RenderContent a => LiteHandler a -> IO () Source
Like serve, but the media to render results from a LiteHandler
action. This allows the data to render to be computed within the
LiteHandler monad, allowing it to respond particularly to the
user's request.
class RenderContent a where Source
This class defines how to serve different media types to the user.
Methods
renderContent :: a -> HandlerT site IO TypedContent Source
Given some data, computes the TypedContent which should be
sent to the client in order to view it.
Instances
Diagrams
Cairo is used to render diagrams to pngs.
serveDiagram :: Diagram Cairo -> IO () Source
data SizedDiagram Source
SizedDiagram can be used to specify the output size of the
diagram when rendering it with Cairo.
Instances
Images
The various types of Image from JuicyPixels (Codec.Picture) are servable
as pngs, unless the Jpeg wrapper type is used.
This type wraps RGB8 image data stored in nested lists, so that you don't need to use Codec.Picture. The inner list is one row of the image, and the tuple elements are the red green blue values, respectively.
Instances
This type wraps image data that is appropriate for JPEG export, along with the requested quality (from 0 to 100).
Constructors
| Jpeg Word8 (Image PixelYCbCr8) |
Instances
Utilities
imageToDiagramEmb :: (Renderable (DImage (N b) Embedded) b, V b ~ V2, TypeableFloat (N b)) => DynamicImage -> Diagram b Source
imageToDiagramExt :: (Renderable (DImage (N b) External) b, V b ~ V2, TypeableFloat (N b)) => DynamicImage -> IO (Diagram b) Source