changing medium description to markdown

This commit is contained in:
nek0 2017-01-06 18:28:36 +01:00
parent ded1d9d99e
commit a29af90503
8 changed files with 23 additions and 10 deletions

View file

@ -17,6 +17,8 @@
module Handler.AdminMediumSettings where
import Import
import Yesod.Text.Markdown
import Text.Markdown
import Handler.Commons
import System.FilePath
import qualified Data.Text as T
@ -94,7 +96,7 @@ adminMediumSetForm medium = Medium
<*> pure (mediumMime medium)
<*> pure (mediumTime medium)
<*> pure (mediumOwner medium)
<*> aopt textareaField (bfs ("Description" :: T.Text)) (Just $ mediumDescription medium)
<*> aopt markdownField (bfs ("Description" :: T.Text)) (Just $ mediumDescription medium)
<*> areq tagField (bfs ("Tags" :: T.Text)) (Just $ mediumTags medium)
<*> pure (mediumAlbum medium)
<*> pure (mediumPreview medium)

View file

@ -21,7 +21,8 @@ import Data.Time
import Data.Maybe
import qualified Data.Text as T
import System.FilePath
import Yesod.Markdown
import Text.Markdown
import Yesod.Text.Markdown
import Yesod.RssFeed
import Yesod.AtomFeed

View file

@ -17,6 +17,7 @@
module Handler.MediumSettings where
import Import
import Yesod.Text.Markdown
import Handler.Commons
import System.FilePath
import qualified Data.Text as T
@ -70,7 +71,7 @@ mediumSettingsForm medium = Medium
<*> pure (mediumMime medium)
<*> pure (mediumTime medium)
<*> pure (mediumOwner medium)
<*> aopt textareaField (bfs ("Description" :: T.Text)) (Just $ mediumDescription medium)
<*> aopt markdownField (bfs ("Description" :: T.Text)) (Just $ mediumDescription medium)
<*> areq tagField (bfs ("Tags" :: T.Text)) (Just $ mediumTags medium)
<*> pure (mediumAlbum medium)
<*> pure (mediumPreview medium)

View file

@ -17,6 +17,7 @@
module Handler.RootFeed where
import Import
import Text.Markdown
import qualified Data.Text as T
import qualified Data.Text.Lazy as LT
import qualified Data.List as L
@ -59,7 +60,7 @@ commentFeedBuilder mId = do
|]
, feedLanguage = "en"
, feedUpdated = time
, feedLogo = Just (StaticR $ StaticRoute (drop 2 $ map T.pack $ splitDirectories $ mediumThumb medium) [], unTextarea $ fromMaybe (Textarea "") $ mediumDescription medium)
, feedLogo = Just (StaticR $ StaticRoute (drop 2 $ map T.pack $ splitDirectories $ mediumThumb medium) [], LT.toStrict $ unMarkdown $ fromMaybe (Markdown "") $ mediumDescription medium)
, feedEntries = es
}
@ -191,7 +192,7 @@ mediumToEntry ent = do
{ feedEntryLink = MediumR (entityKey ent)
, feedEntryUpdated = mediumTime (entityVal ent)
, feedEntryTitle = mediumTitle (entityVal ent)
, feedEntryContent = toHtml (fromMaybe (Textarea "") $ mediumDescription $ entityVal ent)
, feedEntryContent = toHtml (fromMaybe (Markdown "") $ mediumDescription $ entityVal ent)
, feedEntryEnclosure = Just $ EntryEnclosure
(StaticR $ StaticRoute (drop 2 $ map T.pack $ splitDirectories $ mediumPreview $ entityVal ent) [])
size
@ -203,3 +204,6 @@ getSize path = do
stat <- P.getFileStatus path
P.COff raw <- return $ P.fileSize stat
return $ (fromIntegral raw :: Int)
unMarkdown :: Markdown -> LT.Text
unMarkdown (Markdown t) = t

View file

@ -17,6 +17,8 @@
module Handler.Upload where
import Import as I
import Yesod.Text.Markdown
import Text.Markdown
import Handler.Commons
import Data.Time
import Data.Maybe
@ -213,7 +215,7 @@ dUploadForm userId user albumId = FileBulk
<*> areq multiFileField "Select file(s)" Nothing
<*> lift (liftIO getCurrentTime)
<*> pure userId
<*> aopt textareaField (bfs ("Description" :: T.Text)) Nothing
<*> aopt markdownField (bfs ("Description" :: T.Text)) Nothing
<*> areq tagField (bfs ("Enter tags" :: T.Text)) Nothing
<*> pure albumId
<*> areq (selectField licences) (bfs ("Licence" :: T.Text)) (defLicence)
@ -228,7 +230,7 @@ data FileBulk = FileBulk
, fileBulkFiles :: [FileInfo]
, fileBulkTime :: UTCTime
, fileBulkOwner :: UserId
, fileBulkDesc :: Maybe Textarea
, fileBulkDesc :: Maybe Markdown
, fileBulkTags :: [T.Text]
, fileBulkAlbum :: AlbumId
, fileBulkLicence :: Int
@ -263,7 +265,7 @@ bulkUploadForm userId user = (\a b c d e f g h -> FileBulk b c d e f g a h)
<*> areq multiFileField "Select file(s)" Nothing
<*> lift (liftIO getCurrentTime)
<*> pure userId
<*> aopt textareaField (bfs ("Description" :: T.Text)) Nothing
<*> aopt markdownField (bfs ("Description" :: T.Text)) Nothing
<*> areq tagField (bfs ("Enter tags" :: T.Text)) Nothing
<*> areq (selectField licences) (bfs ("Licence" :: T.Text)) (defLicence)
<* bootstrapSubmit ("Upload" :: BootstrapSubmit T.Text)

View file

@ -18,7 +18,8 @@ module Model where
import ClassyPrelude.Yesod
import Database.Persist.Quasi
import Yesod.Markdown
import Text.Markdown
import Yesod.Text.Markdown
import qualified System.FilePath as FP
-- You can define all of your database entities in the entities file.

View file

@ -48,7 +48,7 @@ Medium
mime Text
time UTCTime
owner UserId
description Textarea Maybe
description Markdown Maybe
tags Texts
album AlbumId
preview FP.FilePath

View file

@ -114,6 +114,8 @@ library
, cryptonite
-- , imagemagick
, yesod-markdown >= 0.10
, yesod-text-markdown >= 0.1.8
, markdown
, blaze-markup >= 0.7
, wai >= 3.0
, yesod-newsfeed >= 1.6