Commits

Charles Deakins committed 5649e07

Minor fixes.

  • Participants
  • Parent commits 99d692d

Comments (0)

Files changed (4)

File CommonStuff.hs

     uploadDirCustom,
     myfromJust,
     indexHeader,
-    indexHeaderRedirect
+    indexHeaderRedirect,
+    theFooter
 )
 where
 
-import Network.FastCGI
 import Text.XHtml
-import System.Random 
-import Database.HDBC 
-import Database.HDBC.Sqlite3
-import Data.Time
-import System.Cmd
-import Data.List
-import Data.List.Split
 
 {- 
  - Html attribute media and onFocus are undefined in Text.XHtml so we define them here.
                             +++ meta ! [name "description", content "A free, simple web image upload service."]
                             +++ meta ! [httpequiv "REFRESH", content ("3,url=" ++ redirectTo)] 
 
+{-
+ - Footer.
+-}
+theFooter = thediv ! [identifier "footer"]
+                            << ("imgcons.com coded by " +++ anchor ! [href "http://www.imgcons.com/about.html"] << "ostochast" 
+                                +++ " in " +++ anchor ! [href "http://www.haskell.org"] << "Haskell")
+

File codeIndex.hs

 import CommonStuff
 
 {- 
- - Form for choosing a upload picture.
+ - Form for choosing an upload picture.
 -}
 inputForm :: Html
 inputForm = form ! [action "./upload.fcgi", method "post", enctype "multipart/form-data" ]
         +++ thediv ! [identifier "gallery"] 
                 << (thediv ! [theclass "screenshots"]
                     << ulist << (li << anchor ! [href ("view.fcgi?file=" ++ first)] 
-                                            << image ! [src (uploadDirCustom ++ "192x192!" ++ first), alt "image"] 
-                             +++ li << anchor ! [href ("view.fcgi?file=" ++ second)] 
-                                            << image ! [src (uploadDirCustom ++ "192x192!" ++ fourth), alt "image"])
+                                            << image ! [src (uploadDirCustom ++ "192x192!" ++ first), alt "image1"] 
+                             +++ li << anchor ! [href ("view.fcgi?file=" ++ fourth)] 
+                                            << image ! [src (uploadDirCustom ++ "192x192!" ++ fourth), alt "image4"])
                 +++ thediv ! [theclass "screenshots"]
-                    << ulist << (li << anchor ! [href ("view.fcgi?file=" ++ fourth)] 
-                                            << image ! [src (uploadDirCustom ++ "192x192!" ++ second), alt "image"] 
+                    << ulist << (li << anchor ! [href ("view.fcgi?file=" ++ second)] 
+                                            << image ! [src (uploadDirCustom ++ "192x192!" ++ second), alt "image2"] 
                              +++ li << anchor ! [href ("view.fcgi?file=" ++ fifth)] 
-                                            << image ! [src (uploadDirCustom ++ "192x192!" ++ fifth), alt "image"])
+                                            << image ! [src (uploadDirCustom ++ "192x192!" ++ fifth), alt "image5"])
                 +++ thediv ! [theclass "screenshots"]
-                    << ulist << (li << anchor ! [href ("view.fcgi?file=" ++ fourth)] 
-                                            << image ! [src (uploadDirCustom ++ "192x192!" ++ third), alt "image"] 
-                             +++ li << anchor ! [href ("view.fcgi?file=" ++ fifth)] 
-                                            << image ! [src (uploadDirCustom ++ "192x192!" ++ sixth), alt "image"]))
-        +++ thediv ! [identifier "footer"]
-                << ("imgcons.com coded by " +++ anchor ! [href "http://www.imgcons.com/about.html"] << "ostochast" 
-                    +++ " in " +++ anchor ! [href "http://www.haskell.org"] << "Haskell")
-
+                    << ulist << (li << anchor ! [href ("view.fcgi?file=" ++ third)] 
+                                            << image ! [src (uploadDirCustom ++ "192x192!" ++ third), alt "image3"] 
+                             +++ li << anchor ! [href ("view.fcgi?file=" ++ sixth)] 
+                                            << image ! [src (uploadDirCustom ++ "192x192!" ++ sixth), alt "image6"]))
+        +++ theFooter
 
 {- 
  - creates the final index page for display
 import Network.FastCGI
 import Text.XHtml
-import System.Random 
 import Database.HDBC 
 import Database.HDBC.Sqlite3
-import Data.Time
-import System.Cmd
-import Data.List
-import Data.List.Split
 import CommonStuff
 
 
 {-
  - Self explanatory.
 -}
-valueT :: [Char]
-valueT = "Input pixel size or chose from menu."
+valueT = paragraph ! [identifier "message"] << "Resize menu not available...."
 
 {-
  - List of resize options. 
                     +++ additionalImageResizes)
 --           +++ h3 << "Resize image to:" 
 --            +++ resizeImageForm file
---           +++ valueT 
+        +++ valueT 
+        +++ theFooter
 
 
 
  - Reads the resizedto field from the database for the provided file name, returns the list of the sizes the file was resized to.
 -}
 readCustomImageResizeSizes file conn = do
-                                    a    <- liftIO $ quickQuery' conn "SELECT resizedto FROM images WHERE name = ?" [toSql file]
-                                    return $ splitAtComma ((fromSql $ (concat a) !! 0):: String)
+                                            a <- liftIO $ quickQuery' conn "SELECT resizedto FROM images WHERE name = ?" [toSql file]
+                                            return $ splitAtComma ((fromSql $ (concat a) !! 0):: String)
 
 
 {-
 errorPage b   = header << indexHeaderRedirect "index.fcgi" +++ body << b
 
 successPage :: HTML a => a -> Html
-successPage b = header << indexHeader                 +++ body << b
+successPage b = header << indexHeader +++ body << b
 
 {-
  - Checks if the input file is 24 or 25 chars long, which is the length of file name that upload.fcgi created and stored in database.
 -}
 cgiMain = do 
             mn <- getInput "file"
-            let fileCheck = checkInputFile $ myfromJust mn
-            if (fileCheck == False) 
+            let passesFileCheck = checkInputFile $ myfromJust mn
+            if (not passesFileCheck) 
                 then output . renderHtml $ errorPage (paragraph << "Image not found/deleted. Redirecting to index page.")
                 else do
                         success <- liftIO $ showFile (myfromJust mn)
     background-color: #fafafa;
     color: #666;
 }
+
 a:link    {color:#666;text-decoration:none;}
 a:visited {color:#666;text-decoration:none;}
 a:active  {color:#666;text-decoration:none;}
 a:hover   {color:#666;text-decoration:none;}
 
-#header     { margin: 10px; }
-#header h1  { font-size: 2em; text-decoration: none;}
-#header h2  { font-size: 1.3em;}
-#intro-box  { background-color: #e2f2fe; padding: 15px; }
-#header h3  { 
+#header { 
+    margin: 10px; 
+}
+#header h1 { 
+    font-size: 2em; 
+    text-decoration: none;
+}
+#header h2 {
+    font-size: 1.3em;
+}
+#intro-box {
+    background-color: #e2f2fe;
+    padding: 15px; 
+}
+#header h3 { 
     font-size: 1em; 
     text-decoration: none;
     width: 720px; 
     padding: 20px;
 }
 
-#gallery           { width: 740px;margin-left: auto;margin-right: auto;}
-.screenshots ul    { list-style: none; float:left; }
-.screenshots ul li { padding: 5px;}
+#gallery { 
+    width: 740px;
+    margin-left: auto;
+    margin-right: auto;
+}
+.screenshots ul {
+    list-style: none;
+    float:left;
+}
+.screenshots ul li {
+    padding: 5px;
+}
 
 #footer { 
     clear:both;
     border-top: 1px dashed #ccc;
 }
 
-.arrow {font-size: 1.75em;}
-#uploadedimageseize {padding: 20px; border: none;}
+.arrow {
+    font-size: 1.75em;
+}
+#message {
+    padding: 20px; 
+    border: none;
+}