2024-12-18 20:11:04 -06:00
|
|
|
module Config.Helpers.Articles.Article exposing (..)
|
|
|
|
|
|
|
|
import Config.Data.Identity exposing (pageNames)
|
|
|
|
import Config.Helpers.Articles.Types exposing (References)
|
2024-12-27 01:30:21 -06:00
|
|
|
import Config.Helpers.Cards.Outer.Helpers exposing (cardMaker)
|
|
|
|
import Config.Helpers.Cards.Outer.Types as C
|
2024-12-18 20:11:04 -06:00
|
|
|
import Config.Helpers.Format exposing (..)
|
2024-12-22 04:36:03 -06:00
|
|
|
import Config.Helpers.Headers.Helpers exposing (..)
|
2024-12-18 20:11:04 -06:00
|
|
|
import Config.Helpers.Headers.Types exposing (Header)
|
|
|
|
import Config.Helpers.Markdown exposing (..)
|
|
|
|
import Config.Helpers.Response
|
|
|
|
exposing
|
|
|
|
( pageList
|
|
|
|
, topLevelContainer
|
|
|
|
)
|
|
|
|
import Config.Helpers.StrengthBar
|
|
|
|
exposing
|
|
|
|
( barMaker
|
|
|
|
, barPadding
|
|
|
|
)
|
|
|
|
import Config.Helpers.ToolTip exposing (..)
|
|
|
|
import Config.Helpers.Viewport exposing (resetViewport)
|
|
|
|
import Config.Pages.Blog.Types exposing (BlogArticle)
|
|
|
|
import Config.Pages.Contact.Types exposing (..)
|
|
|
|
import Config.Pages.Interviews.Types exposing (..)
|
|
|
|
import Config.Pages.Products.Types exposing (..)
|
2024-12-27 01:30:21 -06:00
|
|
|
import Config.Style.Colour.Helpers exposing (colourTheme)
|
2024-12-18 20:11:04 -06:00
|
|
|
import Config.Style.Transitions
|
|
|
|
exposing
|
|
|
|
( hoverFontDarkOrange
|
|
|
|
, transitionStyleFast
|
|
|
|
, transitionStyleSlow
|
|
|
|
)
|
|
|
|
import Effect exposing (Effect)
|
|
|
|
import Element as E exposing (..)
|
|
|
|
import Element.Background as B
|
|
|
|
import Element.Border as D
|
|
|
|
import Element.Font as F
|
|
|
|
import Html
|
|
|
|
import Html.Attributes as H exposing (style)
|
|
|
|
import Layouts
|
|
|
|
import Page exposing (Page)
|
|
|
|
import Route exposing (Route)
|
|
|
|
import Shared exposing (..)
|
|
|
|
import View exposing (View)
|
|
|
|
|
|
|
|
|
2024-12-21 04:07:50 -06:00
|
|
|
contentList : BlogArticle -> List (Element msg)
|
|
|
|
contentList article =
|
|
|
|
[ articleImage article.articleImage
|
|
|
|
, renderDeviceMarkdown article.articleBody
|
|
|
|
, case article.hasReferences of
|
|
|
|
True ->
|
|
|
|
articleReferences article
|
|
|
|
|
|
|
|
False ->
|
|
|
|
none
|
|
|
|
]
|
2024-12-18 20:11:04 -06:00
|
|
|
|
|
|
|
|
|
|
|
articleReferences : BlogArticle -> Element msg
|
|
|
|
articleReferences article =
|
|
|
|
el
|
|
|
|
[ width fill
|
|
|
|
, height fill
|
|
|
|
]
|
|
|
|
<|
|
|
|
|
column [ width fill, F.size 15, spacing 10 ] <|
|
|
|
|
List.map2 (\x y -> makeReference x y)
|
|
|
|
article.articleReferences
|
|
|
|
(List.range 1 (List.length article.articleReferences))
|
|
|
|
|
|
|
|
|
|
|
|
makeReference : References -> Int -> Element msg
|
|
|
|
makeReference references index =
|
|
|
|
el
|
|
|
|
[ F.regular
|
|
|
|
, F.alignLeft
|
|
|
|
]
|
|
|
|
<|
|
|
|
|
paragraph []
|
|
|
|
[ newTabLink
|
|
|
|
[ F.bold
|
|
|
|
, F.color colourTheme.textLightOrange
|
|
|
|
, hoverFontDarkOrange
|
|
|
|
, transitionStyleFast
|
|
|
|
]
|
|
|
|
{ url = references.link, label = text (String.fromInt index ++ ". ") }
|
|
|
|
, text (references.author ++ ", ")
|
|
|
|
, text (references.title ++ ", ")
|
|
|
|
, text (references.journal ++ ", ")
|
|
|
|
, text references.year
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
extractFirstWords : String -> String
|
|
|
|
extractFirstWords text =
|
|
|
|
let
|
|
|
|
words =
|
|
|
|
text
|
|
|
|
|> String.split " "
|
|
|
|
|> List.filter (not << String.isEmpty)
|
|
|
|
|
|
|
|
truncatedWords =
|
|
|
|
List.take 80 words
|
|
|
|
|
|
|
|
wasTextTruncated =
|
|
|
|
List.length words > 80
|
|
|
|
|
|
|
|
result =
|
|
|
|
String.join " " truncatedWords
|
|
|
|
in
|
|
|
|
if wasTextTruncated then
|
|
|
|
result ++ "..."
|
|
|
|
|
|
|
|
else
|
|
|
|
result
|