From b8a8a28195d57ead484c9f0c0ed7b9c9c844464b Mon Sep 17 00:00:00 2001 From: nek0 Date: Thu, 27 Aug 2015 20:58:28 +0200 Subject: [PATCH] Meda mediua descriptions non-obligatory --- Handler/AdminMediumSettings.hs | 2 +- Handler/MediumSettings.hs | 2 +- Handler/RootFeed.hs | 10 ++++++++-- Handler/Upload.hs | 7 +++---- config/models | 2 +- templates/medium.hamlet | 7 +++++-- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Handler/AdminMediumSettings.hs b/Handler/AdminMediumSettings.hs index b96e1a2..c63cc24 100644 --- a/Handler/AdminMediumSettings.hs +++ b/Handler/AdminMediumSettings.hs @@ -91,7 +91,7 @@ adminMediumSetForm medium = renderDivs $ Medium <*> pure (mediumMime medium) <*> pure (mediumTime medium) <*> pure (mediumOwner medium) - <*> areq textareaField "Description" (Just $ mediumDescription medium) + <*> aopt textareaField "Description" (Just $ mediumDescription medium) <*> areq tagField "Tags" (Just $ mediumTags medium) <*> pure (mediumWidth medium) <*> pure (mediumThumbWidth medium) diff --git a/Handler/MediumSettings.hs b/Handler/MediumSettings.hs index 0c66223..b4f238e 100644 --- a/Handler/MediumSettings.hs +++ b/Handler/MediumSettings.hs @@ -66,7 +66,7 @@ mediumSettingsForm medium = renderDivs $ Medium <*> pure (mediumMime medium) <*> pure (mediumTime medium) <*> pure (mediumOwner medium) - <*> areq textareaField "Description" (Just $ mediumDescription medium) + <*> aopt textareaField "Description" (Just $ mediumDescription medium) <*> areq tagField "tags" (Just $ mediumTags medium) <*> pure (mediumWidth medium) <*> pure (mediumThumbWidth medium) diff --git a/Handler/RootFeed.hs b/Handler/RootFeed.hs index bca90e3..de28221 100644 --- a/Handler/RootFeed.hs +++ b/Handler/RootFeed.hs @@ -84,7 +84,10 @@ instance RepFeed RepAtom where > #{fromJust $ lookup mediumId $ fromRight [] links} #{iso8601 $ utcToZonedTime tz $ mediumTime medium} - #{mediumDescription medium} + $maybe d <- mediumDescription medium + #{d} + $nothing + No description given @@ -139,7 +142,10 @@ instance RepFeed RepRss where #{mediumTitle medium} <link>#{fromJust $ lookup mediumId $ fromRight [] links} <language>en - <description>#{mediumDescription medium} + $maybe d <- mediumDescription medium + <description>#{d} + $nothing + <description>No description given <guid isPermaLink="true">#{fromJust $ lookup mediumId $ fromRight [] links} <pubDate>#{rfc822 $ mediumTime medium} <image> diff --git a/Handler/Upload.hs b/Handler/Upload.hs index 45b222e..396fc02 100644 --- a/Handler/Upload.hs +++ b/Handler/Upload.hs @@ -133,7 +133,6 @@ generateThumb path userId albumId = do FP.</> newName (iWidth, tWidth) <- liftIO $ withMagickWandGenesis $ do (_ , w) <- magickWand - p <- pixelWand readImage w (decodeString path) w1 <- getImageWidth w h1 <- getImageHeight w @@ -166,7 +165,7 @@ dUploadForm userId albumId = renderDivs $ FileBulk <*> areq multiFileField "Select file(s)" Nothing <*> lift (liftIO getCurrentTime) <*> pure userId - <*> areq textareaField "Description" Nothing + <*> aopt textareaField "Description" Nothing <*> areq tagField "Enter tags" Nothing <*> pure albumId @@ -175,7 +174,7 @@ data FileBulk = FileBulk , fileBulkFiles :: [FileInfo] , fileBulkTime :: UTCTime , fileBulkOwner :: UserId - , fileBulkDesc :: Textarea + , fileBulkDesc :: Maybe Textarea , fileBulkTags :: [Text] , fileBulkAlbum :: AlbumId } @@ -208,7 +207,7 @@ bulkUploadForm userId = renderDivs $ (\a b c d e f g -> FileBulk b c d e f g a) <*> areq multiFileField "Select file(s)" Nothing <*> lift (liftIO getCurrentTime) <*> pure userId - <*> areq textareaField "Description" Nothing + <*> aopt textareaField "Description" Nothing <*> areq tagField "Enter tags" Nothing where albums = do diff --git a/config/models b/config/models index 2621798..4403479 100644 --- a/config/models +++ b/config/models @@ -48,7 +48,7 @@ Medium mime Text time UTCTime owner UserId - description Textarea + description Textarea Maybe tags Texts width Int thumbWidth Int diff --git a/templates/medium.hamlet b/templates/medium.hamlet index 46b3e79..8678510 100644 --- a/templates/medium.hamlet +++ b/templates/medium.hamlet @@ -12,8 +12,11 @@ <div class="inner"> <p class="desc"> Uploaded on: #{formatTime defaultTimeLocale "%A %F %H:%M" (mediumTime medium)}<br> - Description:<br> - #{mediumDescription medium} + $maybe d <- mediumDescription medium + Description:<br> + #{d} + $nothing + No description given <div class="tags"> <p>