<commit_before>{-# LANGUAGE OverloadedStrings #-}
module Web.Views.Site where

import Model.CoreTypes

import Control.Monad
import Text.Blaze.XHtml5 ((!))
import qualified Data.Text as T
import qualified Text.Blaze.Bootstrap as H
import qualified Text.Blaze.XHtml5 as H
import qualified Text.Blaze.XHtml5.Attributes as A

data SiteView
   = SiteView
   { sv_blogName :: T.Text
   , sv_blogDesc :: T.Text
   , sv_user :: Maybe User
   }

siteView :: SiteView -> H.Html -> H.Html
siteView sv body =
    H.html $
    do H.head $
        do H.title (H.toHtml $ sv_blogName sv)
           H.meta ! A.charset "utf-8"
           H.meta ! A.name "viewport" ! A.content "width=device-width, initial-scale=1"
           H.link ! A.href "/css/main.css" ! A.rel "stylesheet"
       H.body $
        do H.div ! A.class_ "blog-masthead" $
            H.div ! A.class_ "container" $
             H.nav ! A.class_ "blog-nav" $
              do H.a ! A.class_ "blog-nav-item" ! A.href "/" $ "Home"
                 H.a ! A.class_ "blog-nav-item" ! A.href "/about" $ "About"
                 case sv_user sv of
                   Nothing ->
                       do H.a ! A.class_ "blog-nav-item" ! A.href "/login" $ "Login"
                          H.a ! A.class_ "blog-nav-item" ! A.href "/register" $ "Register"
                   Just user ->
                       do when (userIsAdmin user || userIsAuthor user) $
                               H.a ! A.class_ "blog-nav-item" ! A.href "/write" $ "Write"
                          when (userIsAdmin user) $
                               H.a ! A.class_ "blog-nav-item" ! A.href "/manage" $ "Manage"
                          H.a ! A.class_ "blog-nav-item" ! A.href "/logout" $ "Logout"
           H.div ! A.class_ "container" $ body

panelWithErrorView :: T.Text -> Maybe T.Text -> H.Html -> H.Html
panelWithErrorView title mError ct =
    H.div ! A.class_ "panel panel-info" ! A.style "margin-top: 30px;" $
     do H.div ! A.class_ "panel-heading" $<commit_msg>Removed registration link from home page.<commit_after>{-# LANGUAGE OverloadedStrings #-}
module Web.Views.Site where

import Model.CoreTypes

import Control.Monad
import Text.Blaze.XHtml5 ((!))
import qualified Data.Text as T
import qualified Text.Blaze.Bootstrap as H
import qualified Text.Blaze.XHtml5 as H
import qualified Text.Blaze.XHtml5.Attributes as A

data SiteView
   = SiteView
   { sv_blogName :: T.Text
   , sv_blogDesc :: T.Text
   , sv_user :: Maybe User
   }

siteView :: SiteView -> H.Html -> H.Html
siteView sv body =
    H.html $
    do H.head $
        do H.title (H.toHtml $ sv_blogName sv)
           H.meta ! A.charset "utf-8"
           H.meta ! A.name "viewport" ! A.content "width=device-width, initial-scale=1"
           H.link ! A.href "/css/main.css" ! A.rel "stylesheet"
       H.body $
        do H.div ! A.class_ "blog-masthead" $
            H.div ! A.class_ "container" $
             H.nav ! A.class_ "blog-nav" $
              do H.a ! A.class_ "blog-nav-item" ! A.href "/" $ "Home"
                 H.a ! A.class_ "blog-nav-item" ! A.href "/about" $ "About"
                 case sv_user sv of
                   Nothing ->
                       do H.a ! A.class_ "blog-nav-item" ! A.href "/login" $ "Login"
                   Just user ->
                       do when (userIsAdmin user || userIsAuthor user) $
                               H.a ! A.class_ "blog-nav-item" ! A.href "/write" $ "Write"
                          when (userIsAdmin user) $
                               H.a ! A.class_ "blog-nav-item" ! A.href "/manage" $ "Manage"
                          H.a ! A.class_ "blog-nav-item" ! A.href "/logout" $ "Logout"
           H.div ! A.class_ "container" $ body

panelWithErrorView :: T.Text -> Maybe T.Text -> H.Html -> H.Html
panelWithErrorView title mError ct =
    H.div ! A.class_ "panel panel-info" ! A.style "margin-top: 30px;" $
     do H.div ! A.class_ "panel-heading" $
{'fraction_non_alphanumeric': 0.13353643056613354, 'fraction_numerical': 0.003554201574003554, 'mean_word_length': 1.7097661623108666, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4188433', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1302, 'n_words': 331}