<commit_before>module View.Comment
    ( approveCommentFormWidget
    , closeCommentForm
    , closeCommentFormWidget
    , commentForestWidget
    , commentForm
    , commentFormWidget
    , commentNewTopicForm
    , commentNewTopicFormWidget
    , commentReplyForm
    , commentReplyFormWidget
    , commentTreeWidget
    , commentWidget
    , createCommentTagForm
    , deleteCommentFormWidget
    , disabledCommentForm
    , editCommentForm
    , editCommentFormWidget
    , flagCommentForm
    , flagCommentFormWidget
    , newCommentTagForm
    , orderingNewestFirst
    , rethreadCommentForm
    , rethreadCommentFormWidget
    , retractCommentForm
    , retractCommentFormWidget
    ) where

import Import

import Model.Comment
import Model.Comment.ActionPermissions
import Model.Comment.Routes
import Model.Tag
import Model.User
import View.User
import Widgets.Markdown
import Widgets.Tag
import Widgets.Time

import qualified Data.List as L
import qualified Data.Map  as M
import qualified Data.Text as T
import           Data.Tree (Forest, Tree(..))
import qualified Data.Tree as Tree

disabledCommentForm :: Form Markdown
disabledCommentForm = renderBootstrap3 $ areq snowdriftMarkdownField ("Reply" { fsAttrs = [("disabled",""), ("class","form-control")] }) Nothing

closureForm :: SomeMessage App -> Maybe Markdown -> Form NewClosure
closureForm label message = renderBootstrap3 $ NewClosure <$> areq' snowdriftMarkdownField label message

commentForm :: SomeMessage App -> Maybe Markdown -> Form NewComment
commentForm label content = renderBootstrap3 $ NewComment
    <$> areq' snowdriftMarkdownField label content
    <*> (toVisibility <$> areq' checkBoxField "Private?" Nothing)
  where
    toVisibility True = VisPrivate
    toVisibility _ = VisPublic

commentFormWidget :: SomeMessage App -> Maybe Markdown -> Widget
commentFormWidget label = commentFormWidget' . commentForm label

closureFormWidget' :: Form NewClosure -> Widget
closureFormWidget' form = do
    (widget, enctype) <- handlerToWidget $ generateFormPost form
    [whamlet|
        <div>
            <form method="POST" enctype=#{enctype}>
                ^{widget}
                <button type="submit" name="mode" value="preview">preview<commit_msg>turned off private checkbox for now<commit_after>module View.Comment
    ( approveCommentFormWidget
    , closeCommentForm
    , closeCommentFormWidget
    , commentForestWidget
    , commentForm
    , commentFormWidget
    , commentNewTopicForm
    , commentNewTopicFormWidget
    , commentReplyForm
    , commentReplyFormWidget
    , commentTreeWidget
    , commentWidget
    , createCommentTagForm
    , deleteCommentFormWidget
    , disabledCommentForm
    , editCommentForm
    , editCommentFormWidget
    , flagCommentForm
    , flagCommentFormWidget
    , newCommentTagForm
    , orderingNewestFirst
    , rethreadCommentForm
    , rethreadCommentFormWidget
    , retractCommentForm
    , retractCommentFormWidget
    ) where

import Import

import Model.Comment
import Model.Comment.ActionPermissions
import Model.Comment.Routes
import Model.Tag
import Model.User
import View.User
import Widgets.Markdown
import Widgets.Tag
import Widgets.Time

import qualified Data.List as L
import qualified Data.Map  as M
import qualified Data.Text as T
import           Data.Tree (Forest, Tree(..))
import qualified Data.Tree as Tree

disabledCommentForm :: Form Markdown
disabledCommentForm = renderBootstrap3 $ areq snowdriftMarkdownField ("Reply" { fsAttrs = [("disabled",""), ("class","form-control")] }) Nothing

closureForm :: SomeMessage App -> Maybe Markdown -> Form NewClosure
closureForm label message = renderBootstrap3 $ NewClosure <$> areq' snowdriftMarkdownField label message

commentForm :: SomeMessage App -> Maybe Markdown -> Form NewComment
commentForm label content = renderBootstrap3 $ NewComment
    <$> areq' snowdriftMarkdownField label content
    <*> pure VisPublic
    --    turn below back on and delete the pure line above
    --    to activate private commenting
--    <*> (toVisibility <$> areq' checkBoxField "Private?" Nothing)
--  where
--    toVisibility True = VisPrivate
--    toVisibility _ = VisPublic

commentFormWidget :: SomeMessage App -> Maybe Markdown -> Widget
commentFormWidget label = commentFormWidget' . commentForm label

closureFormWidget' :: Form NewClosure -> Widget
closureFormWidget' form = do
    (widget, enctype) <- handlerToWidget $ generateFormPost form
    [whamlet|
        <div>
            <form method="POST" enctype=#{enctype}>
                ^{widget}
                <button type="submit" name="mode" value="preview">preview
{'fraction_non_alphanumeric': 0.0763078253350627, 'fraction_numerical': 0.0012970168612191958, 'mean_word_length': 3.8654048370136698, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 32, 'https://': 0, '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': '7508013', 'n_tokens_mistral': 1236, 'n_tokens_neox': 1222, 'n_words': 340}