Commits

Luke Plant committed 8854e48

Changed various instances of underscores to camelCase, so they can be used in templates

Also corrected textraw and textformatted to textRaw and textFormatted

Comments (0)

Files changed (9)

     , timestamp :: Int
     , name :: LB.ByteString
     , email :: LB.ByteString
-    , textraw :: LB.ByteString
-    , textformatted :: LB.ByteString
+    , textRaw :: LB.ByteString
+    , textFormatted :: LB.ByteString
     , format :: Format
     , hidden :: Bool
     , response :: LB.ByteString
           , entryUpdated = formatTimestamp $ P.timestamp post
           , entryAuthors = authors
           , entryCategories = []
-          , entryContent = Just $ HTMLContent $ UTF8.toString $ P.post_formatted post
+          , entryContent = Just $ HTMLContent $ UTF8.toString $ P.postFormatted post
           , entryContributor = []
           , entryLinks = [ htmlLink $ postUrl post
                          ]
           , entryPublished = Just $ formatTimestamp $ P.timestamp post
           , entryRights = Nothing
           , entrySource = Nothing
-          , entrySummary = Just $ HTMLString $ UTF8.toString $ P.summary_formatted post
+          , entrySummary = Just $ HTMLString $ UTF8.toString $ P.summaryFormatted post
           , entryInReplyTo = Nothing
           , entryInReplyTotal = Nothing
           , entryAttrs = []
           , entryUpdated = formatTimestamp $ Cm.timestamp comment
           , entryAuthors = [commentAuthor $ UTF8.toString $ Cm.name comment]
           , entryCategories = []
-          , entryContent = Just $ HTMLContent $ UTF8.toString $ Cm.textformatted comment
+          , entryContent = Just $ HTMLContent $ UTF8.toString $ Cm.textFormatted comment
           , entryContributor = []
           , entryLinks = [ htmlLink $ commentUrl comment post
                          ]
                , timestamp = undefined
                , name = LB.empty
                , email = LB.empty
-               , textraw = LB.empty
-               , textformatted = undefined
+               , textRaw = LB.empty
+               , textFormatted = undefined
                , format = Plaintext
                , hidden = False
                , response = LB.empty
                     , timestamp = ts
                     , name = utf8 name
                     , email = utf8 email
-                    , textraw = utf8 text
-                    , textformatted = utf8 $ getFormatter format $ text
+                    , textRaw = utf8 text
+                    , textFormatted = utf8 $ getFormatter format $ text
                     , format = format
                     , hidden = False
                     , response = LB.empty
 emptyPost = P.Post { uid = undefined
                    , title = LB.empty
                    , slug = undefined
-                   , post_raw = LB.empty
-                   , post_formatted = undefined
-                   , summary_raw = LB.empty
-                   , summary_formatted = undefined
+                   , postRaw = LB.empty
+                   , postFormatted = undefined
+                   , summaryRaw = LB.empty
+                   , summaryFormatted = undefined
                    , format = RST
                    , timestamp = undefined
                    , comments_open = True
 validatePost req basePost = do
   let title = getPOST req "title" `captureOrDefault` ""
   let categories = catMaybes $ map capture $ getPOSTlist req "categories" :: [Int]
-  let summary_raw = getPOST req "summary_raw" `captureOrDefault` ""
-  let post_raw = getPOST req "post_raw" `captureOrDefault` ""
+  let summaryRaw = getPOST req "summaryRaw" `captureOrDefault` ""
+  let postRaw = getPOST req "postRaw" `captureOrDefault` ""
   let format = getPOST req "format" `captureOrDefault` Plaintext
   let comments_open = hasPOST req "comments_open"
   let tests = [ (null title,
                  ("title", "'Title' is a required field."))
-              , (null summary_raw,
+              , (null summaryRaw,
                   ("summary", "'Summary' is a required field."))
-              , (null post_raw,
+              , (null postRaw,
                  ("post", "'Full post' is a required field."))
               ]
   let errors = map snd $ filter fst $ tests
   return (basePost { P.title = utf8 title
-                   , P.summary_raw = utf8 summary_raw
-                   , P.summary_formatted = utf8 $ getFormatter Plaintext $ summary_raw
-                   , P.post_raw = utf8 post_raw
-                   , P.post_formatted = utf8 $ getFormatter format $ post_raw
+                   , P.summaryRaw = utf8 summaryRaw
+                   , P.summaryFormatted = utf8 $ getFormatter Plaintext $ summaryRaw
+                   , P.postRaw = utf8 postRaw
+                   , P.postFormatted = utf8 $ getFormatter format $ postRaw
                    , P.format = format
                    , P.comments_open = comments_open
                    }
                   ]
 postColumnValues p = [ toSql $ P.title p
                      , toSql $ P.slug p
-                     , toSql $ P.post_raw p
-                     , toSql $ P.post_formatted p
-                     , toSql $ P.summary_raw p
-                     , toSql $ P.summary_formatted p
+                     , toSql $ P.postRaw p
+                     , toSql $ P.postFormatted p
+                     , toSql $ P.summaryRaw p
+                     , toSql $ P.summaryFormatted p
                      , toSql $ fromEnum $ P.format p
                      , toSql $ P.timestamp p
                      , toSql $ P.comments_open p
                          , toSql $ Cm.timestamp cm
                          , toSql $ Cm.name cm
                          , toSql $ Cm.email cm
-                         , toSql $ Cm.textraw cm
-                         , toSql $ Cm.textformatted cm
+                         , toSql $ Cm.textRaw cm
+                         , toSql $ Cm.textFormatted cm
                          , toSql $ fromEnum $ Cm.format cm
                          , toSql $ Cm.hidden cm
                          , toSql $ Cm.response cm
     P.Post { P.uid = fromSql (row !! 0)
            , P.title = fromSql (row !! 1)
            , P.slug = fromSql (row !! 2)
-           , P.post_raw = fromSql (row !! 3)
-           , P.post_formatted = fromSql (row !! 4)
-           , P.summary_raw = fromSql (row !! 5)
-           , P.summary_formatted = fromSql (row !! 6)
+           , P.postRaw = fromSql (row !! 3)
+           , P.postFormatted = fromSql (row !! 4)
+           , P.summaryRaw = fromSql (row !! 5)
+           , P.summaryFormatted = fromSql (row !! 6)
            , P.format = toEnum $ fromSql (row !! 7)
            , P.timestamp = fromSql (row !! 8)
            , P.comments_open = fromSql (row !! 9)
                , Cm.timestamp = fromSql (row !! 2)
                , Cm.name = fromSql (row !! 3)
                , Cm.email = fromSql (row !! 4)
-               , Cm.textraw = fromSql (row !! 5)
-               , Cm.textformatted = fromSql (row !! 6)
+               , Cm.textRaw = fromSql (row !! 5)
+               , Cm.textFormatted = fromSql (row !! 6)
                , Cm.format = toEnum $ fromSql (row !! 7)
                , Cm.hidden = fromSql (row !! 8)
                , Cm.response = fromSql (row !! 9)
     P.Post { P.uid = undefined
            , P.title = title
            , P.slug = slug
-           , P.post_raw = undefined
-           , P.post_formatted = undefined
-           , P.summary_raw = undefined
-           , P.summary_formatted = undefined
+           , P.postRaw = undefined
+           , P.postFormatted = undefined
+           , P.summaryRaw = undefined
+           , P.summaryFormatted = undefined
            , P.format = undefined
            , P.timestamp = undefined
            , P.comments_open = undefined
       uid :: Int,
       title :: LB.ByteString,
       slug :: LB.ByteString,
-      post_raw :: LB.ByteString,
-      post_formatted :: LB.ByteString,
-      summary_raw :: LB.ByteString,
-      summary_formatted :: LB.ByteString,
+      postRaw :: LB.ByteString,
+      postFormatted :: LB.ByteString,
+      summaryRaw :: LB.ByteString,
+      summaryFormatted :: LB.ByteString,
       format :: Format,
       timestamp :: Int,
       comments_open :: Bool

src/Blog/Templates.hs

 postTemplateInfo :: P.Post -> Map.Map String ToSElemD
 postTemplateInfo p = Map.fromList [ ("title", ToSElemD $ P.title p)
                                   , ("date", ToSElemD $ showDate $ P.timestamp p)
-                                  , ("summary", ToSElemD $ P.summary_formatted p)
-                                  , ("full", ToSElemD $ P.post_formatted p)
+                                  , ("summary", ToSElemD $ P.summaryFormatted p)
+                                  , ("full", ToSElemD $ P.postFormatted p)
                                   , ("url", ToSElemD $ postUrl p)
                                   , ("commentsOpen", ToSElemD $ P.comments_open p)
                                   , ("adminUrl", ToSElemD $ adminEditPostUrl p)
                                       , ("formattedName", ToSElemD $ formatName $ Cm.name cm)
                                       , ("isAuthor", ToSElemD $ Cm.name cm == utf8 Settings.blog_author_name)
                                       , ("date", ToSElemD $ showDate $ Cm.timestamp cm)
-                                      , ("textFormatted", ToSElemD $ Cm.textformatted cm)
+                                      , ("textFormatted", ToSElemD $ Cm.textFormatted cm)
                                       , ("email", ToSElemD $ Cm.email cm)
                                       , ("uid", ToSElemD $ Cm.uid cm)
                                       , ("hidden", ToSElemD $ Cm.hidden cm)
     where mkPost row = P.Post { P.uid = read (row !! 0)
                               , P.title = LB.pack $ row !! 1
                               , P.slug = LB.empty
-                              , P.post_raw = LB.empty
-                              , P.post_formatted = LB.empty
-                              , P.summary_raw = fixCodes $ row !! 4
-                              , P.summary_formatted = fixCodes $ row !! 4
+                              , P.postRaw = LB.empty
+                              , P.postFormatted = LB.empty
+                              , P.summaryRaw = fixCodes $ row !! 4
+                              , P.summaryFormatted = fixCodes $ row !! 4
                               , P.format = Formats.Rawhtml
                               , P.timestamp = read (row !! 2)
                               , P.comments_open = True
           addFullText p = do let dataFile = Settings.old_data_path ++ "posts/" ++ (show $ P.uid p)
                              f <- readFile dataFile
                              let fixed = fixCodes f
-                             return p { P.post_raw = fixed,
-                                        P.post_formatted = fixed }
-          fixEmptyFullTexts p = if LB.null $ P.post_raw p
-                                then p { P.post_raw = P.summary_raw p
-                                       , P.post_formatted = P.summary_formatted p
+                             return p { P.postRaw = fixed,
+                                        P.postFormatted = fixed }
+          fixEmptyFullTexts p = if LB.null $ P.postRaw p
+                                then p { P.postRaw = P.summaryRaw p
+                                       , P.postFormatted = P.summaryFormatted p
                                        }
                                 else p
 
                                      , Cm.timestamp = read (row !! 2)
                                      , Cm.name = fixCodes $ row !! 3
                                      , Cm.email = LB.pack $ row !! 4
-                                     , Cm.textraw = fixCodes $ row !! 5
-                                     , Cm.textformatted = fixCodes $ row !! 5
+                                     , Cm.textRaw = fixCodes $ row !! 5
+                                     , Cm.textFormatted = fixCodes $ row !! 5
                                      , Cm.format = Formats.Rawhtml
                                      , Cm.hidden = False
                                      , Cm.response = utf8 ""

src/templates/admin_post.st

 <div class="postpreview">
 <h1 class="posttitle">$post.title$</h1>
 <div class="post">
-  $post.post_formatted:noescape()$
+  $post.postFormatted:noescape()$
 </div>
 </div>
 $endif$
   <tr>
     <td colspan="2">
       <label for="id_summary">Summary</label><br />
-      <textarea id="id_summary_raw" name="summary_raw" cols="80" rows="5">$post.summary_raw$</textarea>
+      <textarea id="id_summaryRaw" name="summaryRaw" cols="80" rows="5">$post.summaryRaw$</textarea>
     </td>
   </tr>
     <td colspan="2">
       <label for="id_text">Full post</label><br />
-      <textarea id="id_post_raw" name="post_raw" cols="80" rows="30">$post.post_raw$</textarea>
+      <textarea id="id_postRaw" name="postRaw" cols="80" rows="30">$post.postRaw$</textarea>
     </td>
   </tr>
   <tr>

src/templates/post.st

         </tr>
       </table>
 
-      <div><textarea name="message" id="id_message" cols="80" rows="25">$commentData.textraw$</textarea></div>
+      <div><textarea name="message" id="id_message" cols="80" rows="25">$commentData.textRaw$</textarea></div>
       <div><input type="hidden" id="id_spamcheck" name="spamcheck" value="$commentExtra$">
       </div>
       <div>