Commits

Luke Plant  committed 126cf66

Removed use of 'widgets' for comment form where they added no value.

There is no nice way to do the format widget just using template logic, so
it stayed as it was.

  • Participants
  • Parent commits 7bb9587

Comments (0)

Files changed (4)

File src/Blog/Forms.hs

 import Blog.Model (checkPassword)
 import Control.Monad (liftM)
 import Data.Maybe (fromJust, isNothing)
-import Ella.Forms.Widgets.TextInput (TextInput(..))
-import Ella.Forms.Widgets.Textarea  (Textarea(..))
 import Ella.GenUtils (exactParse, getTimestamp)
 import Ella.Param (captureOrDefault, Param(..))
 import Data.String.Utils (strip)
 import qualified Blog.Settings as Settings
 import qualified Data.Map as Map
 import qualified Ella.Forms.Widgets.RadioButtonList as RBL
-import qualified Ella.Forms.Widgets.TextInput as TI
-import qualified Ella.Forms.Widgets.Textarea as TA
 import qualified Text.XHtml as X
 
 -- Widgets
-
-nameWidget = TextInput { value = ""
-                       , size = Just 20
-                       , maxlength = Just Settings.max_comment_name_size
-                       , name = "name"
-                       , identifier = "id_name"
-                       , password = False
-                       }
-
-emailWidget = TextInput { value = ""
-                        , size = Just 20
-                        , maxlength = Just $ Settings.max_comment_email_size
-                        , name = "email"
-                        , identifier = "id_email"
-                        , password = False
-                        }
-
 commentAllowedFormats =  [Plaintext, RST]
 
 formatWidget = RBL.RadioButtonList { value = ""
                                    , captions = map X.toHtml ["Plain text", "Restructured text"]
                                    }
 
-messageWidget = Textarea { value = ""
-                         , cols = Just 80
-                         , rows = Just 25
-                         , name = "message"
-                         , identifier = "id_message"
-                         }
-
 -- | Enum for the different stages of submitting a comment
 data CommentStage = NoComment
                   | CommentPreview

File src/Blog/Templates.hs

 module Blog.Templates
 where
 
-import Blog.Forms (emailWidget, nameWidget, messageWidget, formatWidget, CommentStage(..))
+import Blog.Forms (formatWidget, CommentStage(..))
 import Blog.Links
 import Blog.Utils (escapeHtmlStringT)
 import Data.Maybe (fromJust)
 
 -- Widgets
 
-commentNameLabel       = makeLabel "Name:" nameWidget
-commentNameWidget c    = setVal (Cm.name c) nameWidget
-commentEmailLabel      = makeLabel "Email:" emailWidget
-commentEmailWidget c   = setVal (Cm.email c) emailWidget
-commentFormatLabel     = "Format:"
 commentFormatWidget c  = setVal (show $ fromEnum $ Cm.format c) formatWidget
-commentMessageLabel    = "Message:"
-commentMessageWidget c = setVal (Cm.text_raw c) messageWidget
-commentSubmitButton    = submit "submit" "Post"
-commentPreviewButton   = submit "preview" "Preview"
 
 -- General HTML fragments
 

File src/Blog/Views.hs

                         ("hasComments", not $ null comments)
                         ("related", map postTemplateInfo related)
                         ("hasRelated", not $ null related)
-                        ("nameLabel", X.toHtml $ commentNameLabel)
-                        ("nameWidget", X.toHtml $ commentNameWidget commentData)
-                        ("emailLabel", X.toHtml $ commentEmailLabel)
-                        ("emailWidget", X.toHtml $ commentEmailWidget commentData)
-                        ("formatLabel", X.toHtml $ commentFormatLabel)
+                        ("commentData", commentData)
                         ("formatWidget", X.toHtml $ commentFormatWidget commentData)
-                        ("messageLabel", X.toHtml $ commentMessageLabel)
-                        ("messageWidget", X.toHtml $ commentMessageWidget commentData)
                         ("commentExtra", commentExtra)
                        )
   where

File src/templates/post.st

     $csrffield:noescape()$
       <table>
         <tr>
-          <td>$nameLabel:noescape()$</td>
-          <td>$nameWidget:noescape()$</td>
+          <td><label for="id_name">Name:</label></td>
+          <td><input type="text" name="name" value="$commentData.name$" id="id_name" maxlength="100" size="20" /></td>
         </tr>
         <tr>
-          <td>$emailLabel:noescape()$</td>
-          <td>$emailWidget:noescape()$</td>
+          <td><label for="id_email">Email:</label></td>
+          <td><input type="text" name="email" value="$commentData.email$" id="id_email" maxlength="320" size="20" /></td>
         </tr>
         <tr>
-          <td>$formatLabel:noescape()$</td>
+          <td>Format:</td>
           <td>$formatWidget:noescape()$</td>
         </tr>
       </table>
-      <div>$messageWidget:noescape()$</div>
-      <div><input type="hidden" id="id_spamcheck" name="spamcheck" value="$commentExtra$" />
+
+      <div><textarea name="message" id="id_message" cols="80" rows="25">$commentData.text_raw$</textarea></div>
+      <div><input type="hidden" id="id_spamcheck" name="spamcheck" value="$commentExtra$">
       </div>
       <div>
         <input type="submit" name="submit" value="Submit" />