-- | Example with BlazeHtml running behind the Snap Haskell web framework.
-- For more information on snap, you can refer to http://snapframework.com.
--
{-# LANGUAGE OverloadedStrings #-}
import Text.Blaze.Html5 hiding (main)
import qualified Text.Blaze.Html5 as H hiding (main)
import Text.Blaze.Html.Renderer.Utf8 (renderHtml)
import Text.Blaze.Html5.Attributes hiding (id)
import Text.Parsec
import Text.BibTeX.Parse
import Text.BibTeX.Entry
import Data.Maybe
import Control.Monad
import Data.Char
import Data.Text hiding (length, null, toUpper)
import Data.Either
import System.Environment
import System.Directory
-- | Title
--
pageTitle :: Html
pageTitle = do
H.head
$ H.title "Maksym Radziwill"
-- | address email-gif-file
--
address :: AttributeValue -> Html
address email = do
h2 "Maksym Radziwill"
br
"Department of Mathematics"
br
"McGill University"
br
"805 Sherbrooke Street West"
br
"Montreal, Quebec H3A 0G4"
br
br
img ! src email
largeBreak :: Html
largeBreak = do hr ! width "100"
teachingFall2016 :: Html
teachingFall2016 = do
h2 "Teaching"
-- p $ do
-- a ! href (textValue (pack "./analysis.html")) $ toHtml $ pack "Honours Analysis 3"
p $ do
a ! href (textValue (pack "./outline.pdf")) $ toHtml $ pack "Analytic number theory"
cv :: Html
cv = do
p $ do
a ! href (textValue (pack "./cv.pdf")) $ toHtml $ pack "CV"
bio :: Html
bio = do
p $ do
"Since August 2016 I'm an Assistant Professor at McGill University. "
br
"I am interested in analytic number theory and its interactions "
"with probability theory, spectral theory and harmonic analysis."
papersDisclaimer :: Html
papersDisclaimer = do
p $ do
"Please note that the published version of the papers below is always the "
"definitive one. The arxiv version is also always at least as up to date as the local copies below."
showAuthors :: [String] -> String
showAuthors s | length s == 1 = Prelude.head s
showAuthors (x:s) = x ++ " " ++ (showAuthors s)
bibTexParse :: String -> Either ParseError [T]
bibTexParse content = Text.Parsec.runParser Text.BibTeX.Parse.file () "" content
toUpperString :: String -> String
toUpperString xs = [ toUpper x | x <- xs, isAlpha x ]
toMaybeHtml :: (Html -> Html) -> Html -> Html -> Maybe String -> Html
toMaybeHtml _ _ _ Nothing = do return ()
toMaybeHtml c a b (Just s) = do
a
(c . toHtml) s
b
toMaybeText :: Maybe String -> Text
toMaybeText Nothing = ""
toMaybeText (Just s) = pack s
toMaybeLocalText :: Maybe String -> Text
toMaybeLocalText Nothing = ""
toMaybeLocalText (Just s) = pack ("http://www.math.mcgill.ca/radziwill/" ++ s)
toMaybeArxivText :: Maybe String -> Text
toMaybeArxivText Nothing = ""
toMaybeArxivText (Just s) = pack ("http://arxiv.org/abs/" ++ s)
paperParser :: T -> Html
paperParser bib =
let v = fmap (\(x,y) -> (toUpperString x, y)) $ fields bib
in
do
-- toMaybeHtml id "" "" $ lookup "TITLE" v
a ! href (textValue $ toMaybeLocalText $ lookup "LOCAL" v)
$ toMaybeHtml id "" "" $ lookup "TITLE" v
toMaybeHtml id " (with " ")" $ lookup "AUTHOR" v
toMaybeHtml i ", " "" $ lookup "BOOKTITLE" v
toMaybeHtml i ", " "" $ lookup "JOURNAL" v
toMaybeHtml b ", " "" $ lookup "VOLUME" v
if ((not . isNothing) (lookup "JOURNAL" v)) then (toMaybeHtml id ", (" ")" $ lookup "YEAR" v) else return ()
toMaybeHtml id ", " "" $ lookup "NUMBER" v
toMaybeHtml id ", pp. " "" $ lookup "PAGES" v
" "
a ! href (textValue $ toMaybeArxivText $ lookup "EPRINT" v)
$ toMaybeHtml id "" "" $ (Just "arXiv")
-- " "
-- a ! href (textValue $ toMaybeText $ lookup "LOCAL" v)
-- $ toMaybeHtml id "" "" $ if (not . isNothing) (lookup "LOCAL" v)
-- then (Just "Download")
-- else (Nothing)
papersList :: [T] -> Html
papersList paperlist = do
h2 "Papers"
papersDisclaimer
forM_ (Prelude.zip paperlist [1..((length paperlist) + 1)])
(\(x,y) -> do
p $ do
toHtml (show y :: String)
". "
paperParser x)
pubkey :: Html
pubkey = do
br
"("
a ! href (textValue (pack "./pub_key.txt")) $ toHtml $ pack "public key"
" and mirrors "
a ! href ((textValue . pack) "http://math.rutgers.edu/~mr789/pub_key.txt")
$ toHtml $ pack "1"
" "
a ! href ((textValue . pack) "http://math.stanford.edu/~maksymr/pub_key.txt")
$ toHtml $ pack "2"
" "
a ! href ((textValue . pack) "http://crm.umontreal.ca/~radziwil/pub_key.txt")
$ toHtml $ pack "3"
")"
website :: [T] -> Html
website paperlist = html $ do
pageTitle
body $ do
Main.address "myemail.gif"
largeBreak
bio
largeBreak
cv
largeBreak
teachingFall2016
largeBreak
-- papersDisclaimer
papersList paperlist
largeBreak
software
-- pubkey
dropChars :: String -> String
dropChars = Prelude.reverse . (Prelude.drop 1) . Prelude.reverse . (Prelude.drop 1)
software :: Html
software = html $ do
h3 "Software"
"Some code you might find useful: "
br
"A "
a ! href (textValue (pack "https://www.github.com/maksym-radziwill/zetacalc")) $ toHtml $ pack "port"
" to the GPU of Bober-Hiary's implementation of Hiary's algorithm for computing the Riemann zeta-function."
br
a ! href (textValue (pack "https://www.github.com/maksym-radziwill/LargeSieveEigenvalues")) $ toHtml $ pack "Code"
" for computing quickly the eigenvalues and eigenvectors of the large sieve matrix that I investigated with Florin Boca"
br
"The Haskell "
a ! href (textValue (pack "./webpage2.hs")) $ toHtml $ pack " code "
"that was used to generate this web-page from a "
a ! href (textValue (pack "./list.bib")) $ toHtml $ pack ".bib"
" file"
--processAss = do
-- w <- System.Directory.getDirectoryContents "~/public_html/Analysis3"
main = do
[filename] <- getArgs
w <- readFile filename >>= (return . join . rights . (\x -> [x]) . bibTexParse)
putStrLn $ dropChars $ Prelude.filter (\x -> x /= '\\') $ ((show . renderHtml . website) w)