<commit_before>{-# LANGUAGE OverloadedStrings #-}

module Dashdo.Rdash (rdash, charts, controls, inSidebar) where

import Dashdo
import Dashdo.Types
import Lucid
import Lucid.Bootstrap3
import qualified Lucid.Rdash as RD
import qualified Data.Text.Lazy as TL
import Data.Text hiding (map, intersperse, length)
import Data.Monoid
import Control.Applicative ((<$>))

sidebarMain, sidebarTitle :: (Monad m) => HtmlT m ()
sidebarTitle = span_ "Dashboards"
sidebarMain  = a_ [href_ "#"] $ do
  "Dashdo"
  span_ [class_ "menu-icon glyphicon glyphicon-transfer"] (return ())

sidebarList :: (Monad m) => [RDashdo] -> [HtmlT m ()]
sidebarList = map (\d->a_ [href_ (pack $ rdFid d), class_ "dashdo-link"] $ (toHtml $ rdTitle d) <> (i_ [class_ "fa fa-tachometer menu-icon"] mempty))

dashdo :: RDashdo -> IO (String, TL.Text)
dashdo (RDashdo fid _ d) = do
  t <- fst <$> dashdoGenOut d (initial d)
  return (fid, t)

rdash :: [RDashdo] -> Html () -> IO TL.Text
rdash rdashdos headExtra = do
  return $ renderText $ doctypehtml_ $ do
      head_ $ do
        meta_ [charset_ "utf-8"]
        cdnCSS
        cdnThemeCSS
        headExtra
      body_ $ do
        let sb  = do RD.mkSidebar sidebarMain sidebarTitle $ sidebarList rdashdos
            sbf = RD.mkSidebarFooter (rowEven XS
              [ a_ [href_ "https://github.com/filopodia/open"] (i_ [class_ "fa fa-lg fa-github"] mempty <> "Github")
              , a_ [href_ "#"] $ i_ [id_ "spinner", class_ "fa fa-cog fa-2x"] mempty
              ])
            sbw = RD.mkSidebarWrapper sb sbf
            cw  = RD.mkPageContent $ do
              RD.mkHeaderBar [RD.mkMetaBox [RD.mkMetaTitle (span_ [id_ "dashdo-title"] mempty)]]
              div_ [id_ "dashdo-main"] mempty
            pgw = form_ [id_ "dashdo-form", method_ "post"] $ RD.mkPageWrapperOpen sbw cw
        RD.mkIndexPage (RD.mkHead "Dashdo") (RD.mkBody pgw)
        cdnJqueryJS
        cdnBootstrapJS<commit_msg>cleaner implementation of sidebarList<commit_after>{-# LANGUAGE OverloadedStrings #-}

module Dashdo.Rdash (rdash, charts, controls, inSidebar) where

import Dashdo
import Dashdo.Types
import Lucid
import Lucid.Bootstrap3
import qualified Lucid.Rdash as RD
import qualified Data.Text.Lazy as TL
import Data.Text hiding (map, intersperse, length)
import Data.Monoid
import Control.Applicative ((<$>))

sidebarMain, sidebarTitle :: (Monad m) => HtmlT m ()
sidebarTitle = span_ "Dashboards"
sidebarMain  = a_ [href_ "#"] $ do
  "Dashdo"
  span_ [class_ "menu-icon glyphicon glyphicon-transfer"] (return ())

sidebarList :: Monad m => [RDashdo] -> [HtmlT m ()]
sidebarList = map sidebarListItem
  where 
    sidebarListItem = \rd ->
      a_ [href_ (pack $ rdFid rd), class_ "dashdo-link"] $
        (toHtml . rdTitle) rd <> i_ [class_ "fa fa-tachometer menu-icon"] mempty

dashdo :: RDashdo -> IO (String, TL.Text)
dashdo (RDashdo fid _ d) = do
  t <- fst <$> dashdoGenOut d (initial d)
  return (fid, t)

rdash :: [RDashdo] -> Html () -> IO TL.Text
rdash rdashdos headExtra = do
  return $ renderText $ doctypehtml_ $ do
      head_ $ do
        meta_ [charset_ "utf-8"]
        cdnCSS
        cdnThemeCSS
        headExtra
      body_ $ do
        let sb  = do RD.mkSidebar sidebarMain sidebarTitle $ sidebarList rdashdos
            sbf = RD.mkSidebarFooter (rowEven XS
              [ a_ [href_ "https://github.com/filopodia/open"] (i_ [class_ "fa fa-lg fa-github"] mempty <> "Github")
              , a_ [href_ "#"] $ i_ [id_ "spinner", class_ "fa fa-cog fa-2x"] mempty
              ])
            sbw = RD.mkSidebarWrapper sb sbf
            cw  = RD.mkPageContent $ do
              RD.mkHeaderBar [RD.mkMetaBox [RD.mkMetaTitle (span_ [id_ "dashdo-title"] mempty)]]
              div_ [id_ "dashdo-main"] mempty
            pgw = form_ [id_ "dashdo-form", method_ "post"] $ RD.mkPageWrapperOpen sbw cw
        RD.mkIndexPage (RD.mkHead "Dashdo") (RD.mkBody pgw)
        cdnJqueryJS
        cdnBootstrapJS
{'fraction_non_alphanumeric': 0.1217590238942552, 'fraction_numerical': 0.001525165226232842, 'mean_word_length': 2.812984496124031, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 25, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6243460', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1379, 'n_words': 386}