changing medium description to markdown
This commit is contained in:
parent
ded1d9d99e
commit
a29af90503
8 changed files with 23 additions and 10 deletions
|
@ -17,6 +17,8 @@
|
||||||
module Handler.AdminMediumSettings where
|
module Handler.AdminMediumSettings where
|
||||||
|
|
||||||
import Import
|
import Import
|
||||||
|
import Yesod.Text.Markdown
|
||||||
|
import Text.Markdown
|
||||||
import Handler.Commons
|
import Handler.Commons
|
||||||
import System.FilePath
|
import System.FilePath
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
|
@ -94,7 +96,7 @@ adminMediumSetForm medium = Medium
|
||||||
<*> pure (mediumMime medium)
|
<*> pure (mediumMime medium)
|
||||||
<*> pure (mediumTime medium)
|
<*> pure (mediumTime medium)
|
||||||
<*> pure (mediumOwner 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)
|
<*> areq tagField (bfs ("Tags" :: T.Text)) (Just $ mediumTags medium)
|
||||||
<*> pure (mediumAlbum medium)
|
<*> pure (mediumAlbum medium)
|
||||||
<*> pure (mediumPreview medium)
|
<*> pure (mediumPreview medium)
|
||||||
|
|
|
@ -21,7 +21,8 @@ import Data.Time
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import System.FilePath
|
import System.FilePath
|
||||||
import Yesod.Markdown
|
import Text.Markdown
|
||||||
|
import Yesod.Text.Markdown
|
||||||
import Yesod.RssFeed
|
import Yesod.RssFeed
|
||||||
import Yesod.AtomFeed
|
import Yesod.AtomFeed
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
module Handler.MediumSettings where
|
module Handler.MediumSettings where
|
||||||
|
|
||||||
import Import
|
import Import
|
||||||
|
import Yesod.Text.Markdown
|
||||||
import Handler.Commons
|
import Handler.Commons
|
||||||
import System.FilePath
|
import System.FilePath
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
|
@ -70,7 +71,7 @@ mediumSettingsForm medium = Medium
|
||||||
<*> pure (mediumMime medium)
|
<*> pure (mediumMime medium)
|
||||||
<*> pure (mediumTime medium)
|
<*> pure (mediumTime medium)
|
||||||
<*> pure (mediumOwner 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)
|
<*> areq tagField (bfs ("Tags" :: T.Text)) (Just $ mediumTags medium)
|
||||||
<*> pure (mediumAlbum medium)
|
<*> pure (mediumAlbum medium)
|
||||||
<*> pure (mediumPreview medium)
|
<*> pure (mediumPreview medium)
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
module Handler.RootFeed where
|
module Handler.RootFeed where
|
||||||
|
|
||||||
import Import
|
import Import
|
||||||
|
import Text.Markdown
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import qualified Data.Text.Lazy as LT
|
import qualified Data.Text.Lazy as LT
|
||||||
import qualified Data.List as L
|
import qualified Data.List as L
|
||||||
|
@ -59,7 +60,7 @@ commentFeedBuilder mId = do
|
||||||
|]
|
|]
|
||||||
, feedLanguage = "en"
|
, feedLanguage = "en"
|
||||||
, feedUpdated = time
|
, 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
|
, feedEntries = es
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +192,7 @@ mediumToEntry ent = do
|
||||||
{ feedEntryLink = MediumR (entityKey ent)
|
{ feedEntryLink = MediumR (entityKey ent)
|
||||||
, feedEntryUpdated = mediumTime (entityVal ent)
|
, feedEntryUpdated = mediumTime (entityVal ent)
|
||||||
, feedEntryTitle = mediumTitle (entityVal ent)
|
, feedEntryTitle = mediumTitle (entityVal ent)
|
||||||
, feedEntryContent = toHtml (fromMaybe (Textarea "") $ mediumDescription $ entityVal ent)
|
, feedEntryContent = toHtml (fromMaybe (Markdown "") $ mediumDescription $ entityVal ent)
|
||||||
, feedEntryEnclosure = Just $ EntryEnclosure
|
, feedEntryEnclosure = Just $ EntryEnclosure
|
||||||
(StaticR $ StaticRoute (drop 2 $ map T.pack $ splitDirectories $ mediumPreview $ entityVal ent) [])
|
(StaticR $ StaticRoute (drop 2 $ map T.pack $ splitDirectories $ mediumPreview $ entityVal ent) [])
|
||||||
size
|
size
|
||||||
|
@ -203,3 +204,6 @@ getSize path = do
|
||||||
stat <- P.getFileStatus path
|
stat <- P.getFileStatus path
|
||||||
P.COff raw <- return $ P.fileSize stat
|
P.COff raw <- return $ P.fileSize stat
|
||||||
return $ (fromIntegral raw :: Int)
|
return $ (fromIntegral raw :: Int)
|
||||||
|
|
||||||
|
unMarkdown :: Markdown -> LT.Text
|
||||||
|
unMarkdown (Markdown t) = t
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
module Handler.Upload where
|
module Handler.Upload where
|
||||||
|
|
||||||
import Import as I
|
import Import as I
|
||||||
|
import Yesod.Text.Markdown
|
||||||
|
import Text.Markdown
|
||||||
import Handler.Commons
|
import Handler.Commons
|
||||||
import Data.Time
|
import Data.Time
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
@ -213,7 +215,7 @@ dUploadForm userId user albumId = FileBulk
|
||||||
<*> areq multiFileField "Select file(s)" Nothing
|
<*> areq multiFileField "Select file(s)" Nothing
|
||||||
<*> lift (liftIO getCurrentTime)
|
<*> lift (liftIO getCurrentTime)
|
||||||
<*> pure userId
|
<*> 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 tagField (bfs ("Enter tags" :: T.Text)) Nothing
|
||||||
<*> pure albumId
|
<*> pure albumId
|
||||||
<*> areq (selectField licences) (bfs ("Licence" :: T.Text)) (defLicence)
|
<*> areq (selectField licences) (bfs ("Licence" :: T.Text)) (defLicence)
|
||||||
|
@ -228,7 +230,7 @@ data FileBulk = FileBulk
|
||||||
, fileBulkFiles :: [FileInfo]
|
, fileBulkFiles :: [FileInfo]
|
||||||
, fileBulkTime :: UTCTime
|
, fileBulkTime :: UTCTime
|
||||||
, fileBulkOwner :: UserId
|
, fileBulkOwner :: UserId
|
||||||
, fileBulkDesc :: Maybe Textarea
|
, fileBulkDesc :: Maybe Markdown
|
||||||
, fileBulkTags :: [T.Text]
|
, fileBulkTags :: [T.Text]
|
||||||
, fileBulkAlbum :: AlbumId
|
, fileBulkAlbum :: AlbumId
|
||||||
, fileBulkLicence :: Int
|
, 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
|
<*> areq multiFileField "Select file(s)" Nothing
|
||||||
<*> lift (liftIO getCurrentTime)
|
<*> lift (liftIO getCurrentTime)
|
||||||
<*> pure userId
|
<*> 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 tagField (bfs ("Enter tags" :: T.Text)) Nothing
|
||||||
<*> areq (selectField licences) (bfs ("Licence" :: T.Text)) (defLicence)
|
<*> areq (selectField licences) (bfs ("Licence" :: T.Text)) (defLicence)
|
||||||
<* bootstrapSubmit ("Upload" :: BootstrapSubmit T.Text)
|
<* bootstrapSubmit ("Upload" :: BootstrapSubmit T.Text)
|
||||||
|
|
3
Model.hs
3
Model.hs
|
@ -18,7 +18,8 @@ module Model where
|
||||||
|
|
||||||
import ClassyPrelude.Yesod
|
import ClassyPrelude.Yesod
|
||||||
import Database.Persist.Quasi
|
import Database.Persist.Quasi
|
||||||
import Yesod.Markdown
|
import Text.Markdown
|
||||||
|
import Yesod.Text.Markdown
|
||||||
import qualified System.FilePath as FP
|
import qualified System.FilePath as FP
|
||||||
|
|
||||||
-- You can define all of your database entities in the entities file.
|
-- You can define all of your database entities in the entities file.
|
||||||
|
|
|
@ -48,7 +48,7 @@ Medium
|
||||||
mime Text
|
mime Text
|
||||||
time UTCTime
|
time UTCTime
|
||||||
owner UserId
|
owner UserId
|
||||||
description Textarea Maybe
|
description Markdown Maybe
|
||||||
tags Texts
|
tags Texts
|
||||||
album AlbumId
|
album AlbumId
|
||||||
preview FP.FilePath
|
preview FP.FilePath
|
||||||
|
|
|
@ -114,6 +114,8 @@ library
|
||||||
, cryptonite
|
, cryptonite
|
||||||
-- , imagemagick
|
-- , imagemagick
|
||||||
, yesod-markdown >= 0.10
|
, yesod-markdown >= 0.10
|
||||||
|
, yesod-text-markdown >= 0.1.8
|
||||||
|
, markdown
|
||||||
, blaze-markup >= 0.7
|
, blaze-markup >= 0.7
|
||||||
, wai >= 3.0
|
, wai >= 3.0
|
||||||
, yesod-newsfeed >= 1.6
|
, yesod-newsfeed >= 1.6
|
||||||
|
|
Loading…
Reference in a new issue