Skip to content

Instantly share code, notes, and snippets.

import qualified App.Models.Bases.CommentsType as Comment -- We import the type of the comment, this file is generated by the ORM.
import App.Models.Posts -- This is the Post model We find here some basic function generated by the ORM, and We can add more.
-- In App/Models/Bases/PostFunctions.hs We can find the generated functions.
import Data.Maybe
import Data.Time
import qualified Database.HDBC as HDBC
import qualified App.Models.Bases.CommentsType as Comment -- We import the type of the comment, this file is generated by the ORM.
import App.Models.Posts -- This is the Post model We find here some basic function generated by the ORM, and We can add more.
-- In App/Models/Bases/PostFunctions.hs We can find the generated functions.
import Data.Maybe
import Data.Time
import qualified Database.HDBC as HDBC
markup = <html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>A poor-man's blog</title>
<meta name="keywords" content="turbinado, haskell, mvc " > </meta>
<meta name="description" content="This is a small Blog application written in Turbinado." > </meta>
<% styleSheet "default" "screen"%>
</head>
<div id="page">
import qualified App.Models.Bases.CommentsType as Comment -- We import the type of the comment, this file is generated by the ORM.
import App.Models.Posts -- This is the Post model We find here some basic function generated by the ORM, and We can add more.
-- In App/Models/Bases/PostFunctions.hs We can find the generated functions.
import Data.Maybe
import Data.Time
import qualified Database.HDBC as HDBC
-- getViewDataValue_u return the data which was stored in the controller with the name of "save-url" --
-- in this case we saved the url of the action which create a new post.
markup = <div>
<h1>New Post </h1>
<form action=(getViewDataValue_u "save-url" :: View String) method="post">
Title :
<input type="text" id="title" name="title"></input><br /><br />
<textarea name="content" id="content" cols="40" rows="5">
</textarea>
<br />
-- All the values which are called by getViewDataValue_u were specified in the action show in the controller Posts
markup = <div class="post">
<h1 class="title"><% getViewDataValue_u "post-title":: View String %></h1>
<p class="entry">
<% getViewDataValue_u "post-content":: View String %>
</p>
<p>
<small>
Created at: <% getViewDataValue_u "post-createdAt":: View String %>
</small>
markup = <div>
<% do l <- getViewDataValue_u "posts-list" ::View [(String,String,String,String)]
mapM indexItem l
%>
</div>
indexItem (i,t,b,d) = return $ cdata $ unlines $
["<div class=\"post\">"
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 18 Mar 2009 21:34:40 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: close
Last-Modified: Wed, 18 Mar 2009 21:34:36 +0000
Cache-Control: max-age=26, must-revalidate
Vary: Cookie
X-hacker: If you're reading this, you should visit automattic.com/jobs and apply to join the fun, mention this header.
{-
-- If the task doesn't exist in the "db" it leaves AppState with the old state
setTaskStatus ::Int -> Bool -> Update AppState Bool
setTaskStatus tid ns =do
(AppState old) <- get
case (adjustTask tid (set_taskStatus ns) old) of
[] -> return False
xs -> do
put (AppState xs)
return True
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <iostream>
#include <curl/curl.h>