diff --git a/.gitignore b/.gitignore index e78bdff..e378ffc 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ /node_modules .DS_Store *.pem -/static/main.css \ No newline at end of file +/static/main.css +/temp \ No newline at end of file diff --git a/src/Components/Footer.elm b/src/Components/Footer.elm new file mode 100644 index 0000000..329d234 --- /dev/null +++ b/src/Components/Footer.elm @@ -0,0 +1,59 @@ +module Components.Footer exposing (..) + +import Html exposing (Html) +import Html.Attributes exposing (class, href, src) +import Utils.Constants exposing (IconLink, Link, footerLinks) + + +singleLink : Link -> Html msg +singleLink link = + Html.li [] + [ Html.a + [ href link.url + , class "mr-4 md:mr-6 underline decoration-cyan-500 hover:decoration-pink-500" + ] + [ Html.text link.text ] + ] + + +iconedLink : IconLink -> Html msg +iconedLink iconLink = + Html.a [ href iconLink.url, class "hover:text-pink-500 inline-flex text-2xl p-3 no-underline" ] + [ Html.i [ class iconLink.icon ] [] + ] + + +footerLinksToSide : Html msg +footerLinksToSide = + Html.div [ class "fixed bottom-0 left-0 bg-neutral-900 z-20 p-4 w-full md:flex md:items-center md:justify-between md:p-4" ] + [ Html.ul [ class "flex flex-wrap items-center mt-3 text-xl sm:mt-0 text-gray-400" ] + (List.map singleLink <| + { text = "Home", url = "/" } + :: footerLinks + ) + ] + + +iconLinkToCenter : Html msg +iconLinkToCenter = + Html.div [ class "flex justify-center flex-wrap" ] (List.map iconedLink Utils.Constants.iconLinks) + + +avatarAndLinks : Html msg +avatarAndLinks = + Html.div [] + [ Html.div [ class "flex flex-col md:space-y-0 md:space-x-6 md:flex-row border-t border-neutral-700" ] + [ Html.img + [ class "self-center flex-shrink-0 w-24 h-24 border rounded-full md:justify-self-start" + , src "https://github.com/avinal.png" + ] + [] + , Html.div [ class "flex flex-col self-center" ] + [ Html.h4 [ class "text-xl font-semibold sm:justify-self-start" ] [ Html.text "Avinal Kumar" ] + , Html.p [ class "text-gray-400" ] + [ Html.text "I am a Associate Software Engineer at Red Hat and I work for Hybrid Cloud Engineering. I contribute to Open Source projects and write blogs in tech and literature." + ] + ] + ] + , Html.div [ class "flex justify-center align-center text-neutral-700 text-xl" ] (List.map iconedLink Utils.Constants.iconLinks) + ] diff --git a/src/Layouts/Blog.elm b/src/Layouts/Blog.elm index e9804bc..8865499 100644 --- a/src/Layouts/Blog.elm +++ b/src/Layouts/Blog.elm @@ -1,8 +1,9 @@ module Layouts.Blog exposing (Model, Msg, Settings, layout) +import Components.Footer exposing (footerLinksToSide) import Effect exposing (Effect) -import Html exposing (Html) -import Html.Attributes exposing (class, href) +import Html +import Html.Attributes exposing (class) import Layout exposing (Layout) import Route exposing (Route) import Shared @@ -15,7 +16,7 @@ type alias Settings = layout : Settings -> Shared.Model -> Route () -> Layout Model Msg mainMsg -layout settings shared route = +layout settings _ _ = Layout.new { init = init settings , update = update @@ -33,7 +34,7 @@ type alias Model = init : Settings -> () -> ( Model, Effect Msg ) -init settings _ = +init _ _ = ( {} , Effect.none ) @@ -55,7 +56,7 @@ update msg model = subscriptions : Model -> Sub Msg -subscriptions model = +subscriptions _ = Sub.none @@ -72,30 +73,12 @@ view : { fromMsg : Msg -> mainMsg, content : View mainMsg, model : Model } -> Vi view { fromMsg, model, content } = { title = content.title , body = - let - footerLinkToLeft : Link -> Html msg - footerLinkToLeft link = - Html.li [] - [ Html.a - [ href link.url - , class "mr-4 md:mr-6 underline decoration-cyan-500 hover:decoration-pink-500" - ] - [ Html.text link.text ] - ] - in [ Html.div [ class "min-h-screen py-4 flex flex-col justify-center relative overflow-hidden " ] [ Html.div [ class "relative w-full py-4 bg-neutral md:max-w-3xl md:mx-auto lg:max-w-4xl lg:pb-28" ] [ Html.article [ class blogTheme ] content.body ] ] - , Html.div [ class "fixed bottom-0 left-0 bg-neutral-900 z-20 p-4 w-full md:flex md:items-center md:justify-between md:p-4" ] - [ Html.ul - [ class "flex flex-wrap items-center mt-3 text-xl text-neutral-500 sm:mt-0" ] - (List.map footerLinkToLeft <| - { text = "Home", url = "/" } - :: Utils.Constants.footerLinks - ) - ] + , footerLinksToSide ] } diff --git a/src/Layouts/Home.elm b/src/Layouts/Home.elm index fe56009..163fc57 100644 --- a/src/Layouts/Home.elm +++ b/src/Layouts/Home.elm @@ -1,5 +1,6 @@ module Layouts.Home exposing (Model, Msg, Settings, layout) +import Components.Footer exposing (iconLinkToCenter) import Effect exposing (Effect) import Html exposing (Html) import Html.Attributes exposing (class, href) @@ -15,7 +16,7 @@ type alias Settings = layout : Settings -> Shared.Model -> Route () -> Layout Model Msg mainMsg -layout settings shared route = +layout _ _ _ = Layout.new { init = init , update = update @@ -57,7 +58,7 @@ update msg model = subscriptions : Model -> Sub Msg -subscriptions model = +subscriptions _ = Sub.none @@ -75,18 +76,12 @@ view { fromMsg, model, content } = , class "underline decoration-cyan-500 hover:decoration-pink-500 inline-flex text-xl p-3" ] [ Html.text link.text ] - - iconLinkToCenter : IconLink -> Html msg - iconLinkToCenter iconLink = - Html.a [ href iconLink.url, class " hover:text-pink-500 inline-flex text-2xl p-3" ] - [ Html.i [ class iconLink.icon ] [] ] in { title = content.title , body = - [ Html.section [ class "flex items-center justify-center flex-col h-screen text-neutral-400" ] + [ Html.section [ class "flex items-center justify-center flex-col h-screen text-gray-400" ] [ Html.header [ class "object-cover object-center p-8" ] content.body - , Html.div [ class "flex justify-center flex-wrap" ] - (List.map iconLinkToCenter Utils.Constants.iconLinks) + , iconLinkToCenter , Html.div [ class "text-center text-xl p-2" ] [ Html.text "I'm Avinal and I work at Red Hat as an Associate Software Engineer for Hybrid Cloud Engineering." ] , Html.footer [ class "flex justify-center flex-wrap" ] (List.map footerLinkToCenter Utils.Constants.footerLinks) diff --git a/src/Pages/Home_.elm b/src/Pages/Home_.elm index a7c33c3..d98a222 100644 --- a/src/Pages/Home_.elm +++ b/src/Pages/Home_.elm @@ -17,7 +17,7 @@ import View exposing (View) page : Shared.Model -> Route () -> Page Model Msg -page model route = +page _ _ = Page.new { init = init , update = update @@ -32,7 +32,7 @@ page model route = layout : Model -> Layouts.Layout -layout model = +layout _ = Layouts.Home { home = {} } diff --git a/src/Pages/Meet.elm b/src/Pages/Meet.elm new file mode 100644 index 0000000..725be2b --- /dev/null +++ b/src/Pages/Meet.elm @@ -0,0 +1,12 @@ +module Pages.Meet exposing (page) + +import Components.Footer exposing (footerLinksToSide) +import Html +import View exposing (View) + + +page : View msg +page = + { title = "Schedule a meet with me" + , body = [ footerLinksToSide, Html.node "calcom" [] [] ] + } diff --git a/src/Pages/Pages/AboutMe.elm b/src/Pages/Pages/AboutMe.elm index b7d8282..12ea3cb 100644 --- a/src/Pages/Pages/AboutMe.elm +++ b/src/Pages/Pages/AboutMe.elm @@ -1,6 +1,5 @@ module Pages.Pages.AboutMe exposing (page) -import Html exposing (Html) import View exposing (View) diff --git a/src/Pages/Pages/Projects.elm b/src/Pages/Pages/Projects.elm index bfa896d..1891f0e 100644 --- a/src/Pages/Pages/Projects.elm +++ b/src/Pages/Pages/Projects.elm @@ -2,14 +2,13 @@ module Pages.Pages.Projects exposing (Model, Msg, page) import Effect exposing (Effect) import Route exposing (Route) -import Html import Page exposing (Page) import Shared import View exposing (View) page : Shared.Model -> Route () -> Page Model Msg -page shared route = +page _ _ = Page.new { init = init , update = update @@ -55,7 +54,7 @@ update msg model = subscriptions : Model -> Sub Msg -subscriptions model = +subscriptions _ = Sub.none @@ -64,5 +63,5 @@ subscriptions model = view : Model -> View Msg -view model = +view _ = View.fromString "Pages.Pages.Projects" diff --git a/src/Pages/Posts.elm b/src/Pages/Posts.elm index 26cf750..e5b537c 100644 --- a/src/Pages/Posts.elm +++ b/src/Pages/Posts.elm @@ -1,8 +1,9 @@ module Pages.Posts exposing (Model, Msg, page) +import Components.Footer exposing (footerLinksToSide) import Effect exposing (Effect) import Html exposing (Html) -import Html.Attributes exposing (class, href, src, target) +import Html.Attributes exposing (class, datetime, href, src, target) import Http import Json.Decode as Json import Page exposing (Page) @@ -15,7 +16,7 @@ import View exposing (View) page : Shared.Model -> Route () -> Page Model Msg -page shared route = +page _ _ = Page.new { init = init , update = update @@ -86,7 +87,7 @@ update msg model = subscriptions : Model -> Sub Msg -subscriptions model = +subscriptions _ = Sub.none @@ -108,7 +109,7 @@ view model = [ Html.a [ href <| "/posts/" ++ first.category ++ "/" ++ first.slug ] [ Html.h3 [ class "text-2xl font-semibold sm:text-4xl group-hover:underline group-focus:underline" ] [ Html.text first.title ] - , Html.span [ class "text-gray-400" ] [ Html.text first.date ] + , Html.time [ class "text-gray-400", datetime first.date ] [ Html.text <| UU.getFormattedDate first.date ] , Html.p [] [ Html.text <| String.left 200 first.description ] ] , Html.a [ href <| "/posts/" ++ first.category, target "_blank" ] [ UU.categoryNtags first.category [] ] @@ -127,22 +128,12 @@ view model = , Html.div [ class "p-6 space-y-2" ] [ Html.a [ href <| "/posts/" ++ blog.category ++ "/" ++ blog.slug ] [ Html.h3 [ class "text-2xl font-semibold group-hover:underline group-focus:underline" ] [ Html.text blog.title ] - , Html.span [ class " text-gray-400" ] [ Html.text <| UU.getFormattedDate blog.date ] + , Html.time [ class " text-gray-400", datetime blog.date ] [ Html.text <| UU.getFormattedDate blog.date ] , Html.p [] [ Html.text <| String.left 200 blog.description ] ] , Html.a [ href <| "/posts/" ++ blog.category, target "_blank" ] [ UU.categoryNtags blog.category [] ] ] ] - - footerLinkToLeft : Link -> Html msg - footerLinkToLeft link = - Html.li [] - [ Html.a - [ href link.url - , class "mr-4 md:mr-6 underline decoration-cyan-500 hover:decoration-pink-500" - ] - [ Html.text link.text ] - ] in case model.blogList of Just blogList -> @@ -151,14 +142,7 @@ view model = [ Html.section [ class "text-gray-100" ] [ Html.h1 [ class "text-5xl font-bold mb-6 mt-12 text-center text-white" ] [ Html.text <| "Welcome to my blog" ] , maincard blogList - , Html.div [ class "fixed bottom-0 left-0 bg-neutral-900 z-20 p-4 w-full md:flex md:items-center md:justify-between md:p-4" ] - [ Html.ul - [ class "flex flex-wrap items-center mt-3 text-xl text-neutral-500 sm:mt-0" ] - (List.map footerLinkToLeft <| - { text = "Home", url = "/" } - :: Utils.Constants.footerLinks - ) - ] + , footerLinksToSide ] ] } diff --git a/src/Pages/Posts/Category_.elm b/src/Pages/Posts/Category_.elm index 52fadde..e9184c2 100644 --- a/src/Pages/Posts/Category_.elm +++ b/src/Pages/Posts/Category_.elm @@ -1,8 +1,9 @@ module Pages.Posts.Category_ exposing (Model, Msg, page) +import Components.Footer exposing (footerLinksToSide) import Effect exposing (Effect) import Html exposing (Html) -import Html.Attributes exposing (class, href, src) +import Html.Attributes exposing (class, datetime, href, src) import Http import Json.Decode as Json import Page exposing (Page) @@ -14,7 +15,7 @@ import View exposing (View) page : Shared.Model -> Route { category : String } -> Page Model Msg -page shared route = +page _ route = Page.new { init = init route , update = update @@ -87,7 +88,7 @@ update msg model = subscriptions : Model -> Sub Msg -subscriptions model = +subscriptions _ = Sub.none @@ -108,20 +109,10 @@ view model = ] , Html.div [ class "grow-0 shrink-0 basis-auto w-full md:w-9/12 xl:w-7/12 p-3 md:mb-0 mr-auto bg-neutral-900" ] [ Html.h5 [ class "text-2xl font-bold mb-2" ] [ Html.text blog.title ] - , Html.span [ class "text-gray-400 text-sm" ] [ Html.text blog.date ] + , Html.time [ class "text-gray-400 text-sm", datetime blog.date ] [ Html.text <| UU.getFormattedDate blog.date ] , Html.p [ class "text-gray-500 mt-4 text-md" ] [ Html.text <| String.left 200 blog.description ] ] ] - - footerLinkToLeft : Link -> Html msg - footerLinkToLeft link = - Html.li [] - [ Html.a - [ href link.url - , class "mr-4 md:mr-6 underline decoration-cyan-500 hover:decoration-pink-500" - ] - [ Html.text link.text ] - ] in case model.blogList of Just blogList -> @@ -142,14 +133,7 @@ view model = [ Html.section [ class "mb-32 text-gray-200 text-center md:text-left" ] <| Html.h1 [ class "text-5xl font-bold mb-12 mt-12 text-center text-white" ] [ Html.text "Posts in ", Html.i [ class "text-pink-600" ] [ Html.text model.category ], Html.text " category" ] :: List.map card clist - , Html.div [ class "fixed bottom-0 left-0 bg-neutral-900 z-20 p-4 w-full md:flex md:items-center md:justify-between md:p-4" ] - [ Html.ul - [ class "flex flex-wrap items-center mt-3 text-xl text-neutral-500 sm:mt-0" ] - (List.map footerLinkToLeft <| - { text = "Home", url = "/" } - :: Utils.Constants.footerLinks - ) - ] + , footerLinksToSide ] ] } diff --git a/src/Pages/Posts/Category_/Post_.elm b/src/Pages/Posts/Category_/Post_.elm index 7a6521b..91d3160 100644 --- a/src/Pages/Posts/Category_/Post_.elm +++ b/src/Pages/Posts/Category_/Post_.elm @@ -1,8 +1,9 @@ module Pages.Posts.Category_.Post_ exposing (Model, Msg, page) +import Components.Footer exposing (avatarAndLinks) import Effect exposing (Effect) import Html exposing (Html) -import Html.Attributes exposing (class, href, rel, src) +import Html.Attributes exposing (class, datetime, href, rel, src) import Http import Layouts import Page exposing (Page) @@ -11,14 +12,13 @@ import Shared import Svg exposing (path, svg) import Svg.Attributes as SvgAttr import Url exposing (Protocol(..)) -import Utils.Constants import Utils.Utils as UU import View exposing (View) import Yaml.Decode as Yaml page : Shared.Model -> Route { category : String, post : String } -> Page Model Msg -page shared route = +page _ route = Page.new { init = init route , update = update @@ -33,7 +33,7 @@ page shared route = layout : Model -> Layouts.Layout -layout model = +layout _ = Layouts.Blog { blog = {} @@ -113,7 +113,7 @@ update msg model = subscriptions : Model -> Sub Msg -subscriptions model = +subscriptions _ = Sub.none @@ -134,32 +134,13 @@ view model = [] , articleNode blog.content model.fragment , Html.div [ class "text-center text-neutral-300 border-t border-dashed border-teal-500 p-2" ] - [ Html.text <| "Published on " ++ blog.meta.date ++ " under " + [ Html.time [ datetime blog.meta.date ] [ Html.text <| "Published on " ++ UU.getFormattedDate blog.meta.date ++ " under " ] , Html.a [ href "https://www.mozilla.org/en-US/MPL/2.0/" ] [ Html.text "Mozilla Public License 2.0" ] , Html.text " if you found an issue with the page, please report it " , Html.a [ href <| "https://github.com/avinal/avinal.github.io/issues/new?title=bug:+" ++ String.replace " " "+" blog.meta.title ] [ Html.text "here." ] ] , UU.categoryNtags blog.meta.category blog.meta.tags - , Html.div [ class "flex flex-col space-y-2 md:space-y-0 md:space-x-6 md:flex-row border-t border-neutral-700" ] - [ Html.img - [ class "self-center flex-shrink-0 w-24 h-24 border rounded-full md:justify-self-start" - , src "https://github.com/avinal.png" - ] - [] - , Html.div [ class "flex flex-col self-center" ] - [ Html.h4 [ class "text-xl font-semibold " ] [ Html.text "Avinal Kumar" ] - , Html.p [ class "text-gray-400" ] - [ Html.text "I am a Associate Software Engineer at Red Hat and I work for Hybrid Cloud Engineering. I contribute to Open Source projects and write blogs in tech and literature." - ] - ] - ] - , Html.div [ class "flex justify-center space-x-4 align-center text-neutral-600 text-xl" ] - (List.map - (\iconlink -> - Html.a [ href iconlink.url, class "hover:text-pink-500" ] [ Html.i [ class iconlink.icon ] [] ] - ) - Utils.Constants.iconLinks - ) + , avatarAndLinks ] } diff --git a/src/Utils/Utils.elm b/src/Utils/Utils.elm index c23af20..c56f4a4 100644 --- a/src/Utils/Utils.elm +++ b/src/Utils/Utils.elm @@ -1,6 +1,7 @@ module Utils.Utils exposing (..) -import Array exposing (Array) +import Array + import Html exposing (Html) import Html.Attributes exposing (class, href, target) import Http exposing (Error(..)) @@ -8,50 +9,42 @@ import Parser exposing (..) import Utils.Constants exposing (..) -type alias Date = - { day : Int +type alias DateTime = + { year : Int , month : Int - , year : Int + , day : Int + , hour : Int + , minute : Int } -day : Parser Int -day = - succeed identity - |= int - - -month : Parser Int -month = - succeed identity - |= int - - -year : Parser Int -year = - succeed identity - |= int - - getFormattedDate : String -> String getFormattedDate dateString = case Parser.run dateParser dateString of Ok date -> (Maybe.withDefault "Month" <| Array.get (date.month - 1) months) ++ " " ++ String.fromInt date.day ++ ", " ++ String.fromInt date.year - Err err -> + Err _ -> "Invalid date!!" -dateParser : Parser Date +dateParser : Parser DateTime dateParser = - succeed Date - |= day - |. symbol "-" - |= month - |. symbol "-" - |= year - + succeed DateTime + |= int + |. token "-" + |. chompWhile (\c -> c == '0') + |= int + |. token "-" + |. chompWhile (\c -> c == '0') + |= int + |. spaces + |. chompWhile (\c -> c == '0') + |= int + |. token ":" + |. chompWhile (\c -> c == '0') + |= int + |. end categoryNtags : String -> List String -> Html msg diff --git a/src/View.elm b/src/View.elm index dbfa592..bf22137 100644 --- a/src/View.elm +++ b/src/View.elm @@ -14,7 +14,7 @@ module View exposing import Browser import Html exposing (Html) -import Html.Attributes exposing (class, href) +import Html.Attributes exposing (class) import Route exposing (Route) import Shared.Model