From 0a75e96f27f864465228d2dd7602dc6ca89872ec Mon Sep 17 00:00:00 2001 From: towards-a-new-leftypol Date: Mon, 22 Jan 2024 15:20:43 -0500 Subject: [PATCH] Get ready to have file details in CatalogGrid - update posts type (new fields not yet used) --- src/Common | 2 +- src/Component/CatalogGrid.hs | 16 ++++++++-------- src/Network/CatalogPostType.hs | 34 ++++++++++++++++++++-------------- src/Network/Http.hs | 6 +++++- static/style.css | 2 +- 5 files changed, 35 insertions(+), 25 deletions(-) diff --git a/src/Common b/src/Common index a5d90ea..9e9d7ba 160000 --- a/src/Common +++ b/src/Common @@ -1 +1 @@ -Subproject commit a5d90ea96195ed6a5a7e3196d5b0e32b65af5058 +Subproject commit 9e9d7babe6352b2fdf19d4ab43a557c71ca2e2ff diff --git a/src/Component/CatalogGrid.hs b/src/Component/CatalogGrid.hs index e4f545a..05d5bb8 100644 --- a/src/Component/CatalogGrid.hs +++ b/src/Component/CatalogGrid.hs @@ -13,15 +13,15 @@ import Data.List (intercalate) import Data.Maybe (maybeToList) import Data.JSString (append) import Miso - ( View , div_ , class_ , img_ , href_ , a_ - , src_ , alt_ , title_ , strong_ , span_ - , p_ , br_ , id_ , Effect , noEff - , text, rawHtml + ( View, div_ , class_ , img_ , href_ , a_ + , src_ , title_ , strong_ , span_ + , p_ , br_ , id_ , Effect , noEff, width_ + , height_, text, rawHtml ) +import Miso.String (toMisoString, MisoString) import Network.CatalogPostType (CatalogPost) import qualified Network.CatalogPostType as CatalogPost -import Miso.String (toMisoString, MisoString) data Model = Model { displayItems :: [ CatalogPost ] @@ -43,7 +43,7 @@ update -> Model -> Effect a Model update _ (DisplayItems xs) m = noEff (m { displayItems = xs }) -update _ _ m = noEff m +-- update _ _ m = noEff m view :: Interface a -> Model -> View a view iface model = @@ -68,7 +68,6 @@ gridItem post = [ img_ [ class_ "thread-image" , src_ "/a/thumb/1111111111111.png" - , alt_ "Opening post image" , title_ ( toMisoString $ show $ CatalogPost.bump_time post ) ] ] @@ -79,7 +78,8 @@ gridItem post = , p_ [ class_ "intro" ] [ span_ - [ class_ "subject" ]subject + [ class_ "subject" ] + subject ] ] ++ body ) diff --git a/src/Network/CatalogPostType.hs b/src/Network/CatalogPostType.hs index c1c4ee0..de90a58 100644 --- a/src/Network/CatalogPostType.hs +++ b/src/Network/CatalogPostType.hs @@ -10,21 +10,27 @@ import Data.Aeson (FromJSON, ToJSON) import Data.Time.Clock (UTCTime) -- Required for timestamp with time zone import Data.Int (Int64) import Data.Text (Text) +-- import Common.AttachmentType (Dimension) data CatalogPost = CatalogPost - { post_id :: Maybe Int64 - , board_post_id :: Int64 - , board_thread_id :: Int64 - , creation_time :: UTCTime - , bump_time :: UTCTime - , body :: Maybe Text - , name :: Maybe Text - , subject :: Maybe Text - , email :: Maybe Text - , thread_id :: Int - -- , post_count :: Int + { post_id :: Maybe Int64 + , board_post_id :: Int64 + , board_thread_id :: Int64 + , creation_time :: UTCTime + , bump_time :: UTCTime + , body :: Maybe Text + , name :: Maybe Text + , subject :: Maybe Text + , email :: Maybe Text + , thread_id :: Int + -- , post_count :: Int , estimated_post_count :: Int - , site_name :: String - , pathpart :: String - --, site_id :: Int + , site_name :: String + , pathpart :: String + -- , site_id :: Int + , file_mimetype :: Maybe Text + , file_illegal :: Maybe Bool + -- , file_resolution :: Maybe Dimension + , file_sha256_hash :: Maybe Text + , file_extension :: Maybe Text } deriving (Show, Generic, FromJSON, ToJSON, Eq) diff --git a/src/Network/Http.hs b/src/Network/Http.hs index 6838ea9..b6d14ec 100644 --- a/src/Network/Http.hs +++ b/src/Network/Http.hs @@ -30,6 +30,8 @@ import GHCJS.DOM.Types (XMLHttpRequest, JSString) import Data.JSString.Text (textToJSString) import GHCJS.DOM.EventM (onAsync) import GHCJS.DOM.XMLHttpRequestEventTarget (load, abortEvent, error) +import GHCJS.DOM.Types (toJSString) +import Miso (consoleLog) data HttpMethod = GET | PUT | POST | DELETE | PATCH deriving Show @@ -68,7 +70,9 @@ mkResult xhr = do Just bs -> do let parse_result = eitherDecodeStrict bs case parse_result of - Left _ -> return Error + Left err -> do + consoleLog $ toJSString $ show err + return Error Right x -> return HttpResponse { status_code = status_code_int , status_text = st diff --git a/static/style.css b/static/style.css index d89d0cc..8c90ca7 100644 --- a/static/style.css +++ b/static/style.css @@ -30,6 +30,7 @@ html, body { .post-image{ max-width: 94%!important; } + select{ float:right; } @@ -47,7 +48,6 @@ div.boardlist.bottom { } img.banner, img.board_image { - max-width: 100vw; }