mirror of
https://github.com/avinal/avinal.github.io.git
synced 2026-07-04 07:40:09 +05:30
remove old vanila elm website
Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com>
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
module Base exposing (contentUrlPrefix, urlPrefix, websiteBase)
|
||||
|
||||
{-| The base URL for accessing the content for the site
|
||||
-}
|
||||
|
||||
|
||||
contentBase : String
|
||||
contentBase =
|
||||
"https://raw.githubusercontent.com"
|
||||
|
||||
|
||||
{-| The Github user name for the site
|
||||
-}
|
||||
user : String
|
||||
user =
|
||||
"avinal"
|
||||
|
||||
|
||||
urlPrefix : String
|
||||
urlPrefix =
|
||||
"avinal.github.io"
|
||||
|
||||
|
||||
contentUrlPrefix : String
|
||||
contentUrlPrefix =
|
||||
contentBase ++ "/" ++ user ++ "/" ++ urlPrefix ++ "/main/content/"
|
||||
|
||||
|
||||
websiteBase : String
|
||||
websiteBase =
|
||||
"https://avinal.space"
|
||||
-414
@@ -1,414 +0,0 @@
|
||||
port module Blog exposing (..)
|
||||
|
||||
import Base exposing (..)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (class, datetime, href, id, src, style)
|
||||
import Http exposing (Error(..))
|
||||
import Json.Decode as Json
|
||||
import Url exposing (Protocol(..))
|
||||
import Yaml.Decode as Yaml
|
||||
|
||||
|
||||
|
||||
-- MODEL
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ blog : Maybe Blog
|
||||
, requestUrl : String
|
||||
, success : Bool
|
||||
, fragment : String
|
||||
, error : Maybe String
|
||||
, bloglist : Maybe (List JsonMeta)
|
||||
}
|
||||
|
||||
|
||||
|
||||
-- Blog Post
|
||||
|
||||
|
||||
type alias Blog =
|
||||
{ meta : YamlMeta
|
||||
, content : String
|
||||
}
|
||||
|
||||
|
||||
initialModel : Model
|
||||
initialModel =
|
||||
{ blog = Nothing
|
||||
, requestUrl = ""
|
||||
, success = False
|
||||
, fragment = ""
|
||||
, error = Nothing
|
||||
, bloglist = Nothing
|
||||
}
|
||||
|
||||
|
||||
|
||||
-- PORT
|
||||
|
||||
|
||||
port sendString : String -> Cmd msg
|
||||
|
||||
|
||||
|
||||
-- port isRenderComplete : (Bool -> msg) -> Sub msg
|
||||
|
||||
|
||||
view : Model -> Html Msg
|
||||
view model =
|
||||
div [ class "foo-interface" ]
|
||||
[ div [ class "foo-console foo-terminal foo-active" ]
|
||||
[ div [ class "page-wrapper category-html document-page" ]
|
||||
[ div [ class "main-wrapper" ]
|
||||
[ main_ [ class "main-content", id "content" ]
|
||||
[ case model.blog of
|
||||
Just blog ->
|
||||
case blog.meta.image of
|
||||
Just image ->
|
||||
img [ src image ] []
|
||||
|
||||
Nothing ->
|
||||
text ""
|
||||
|
||||
Nothing ->
|
||||
text ""
|
||||
, div [] (viewBlogList model)
|
||||
, viewArticle model
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
viewToc : Bool -> Html Msg
|
||||
viewToc show =
|
||||
if show then
|
||||
div
|
||||
[ class "toc" ]
|
||||
[ aside [ class "document-toc-container" ]
|
||||
[ section [ class "document-toc" ]
|
||||
[ h2 [ class "document-toc-heading" ]
|
||||
[ if show then
|
||||
text "In this page"
|
||||
|
||||
else
|
||||
text ""
|
||||
]
|
||||
, ul
|
||||
[ class "document-toc-list", id "toc-entries" ]
|
||||
[]
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
else
|
||||
div [] []
|
||||
|
||||
|
||||
viewArticle : Model -> Html Msg
|
||||
viewArticle model =
|
||||
article
|
||||
[ class "main-page-content" ]
|
||||
[ div [ id "insert-here" ] []
|
||||
, viewMetadata model
|
||||
]
|
||||
|
||||
|
||||
viewMetadata : Model -> Html Msg
|
||||
viewMetadata model =
|
||||
aside
|
||||
[ class "metadata"
|
||||
, style "display"
|
||||
(if model.bloglist == Nothing && model.success then
|
||||
"block"
|
||||
|
||||
else
|
||||
"none"
|
||||
)
|
||||
]
|
||||
[ div [ class "metadata-content-container" ]
|
||||
[ div [ class "on-github" ]
|
||||
[ h3 [] [ text "Found a problem" ]
|
||||
, ul []
|
||||
[ li []
|
||||
[ a
|
||||
[ href
|
||||
("https://github.com/avinal/avinal.github.io/issues/new?title=blog:"
|
||||
++ (case model.blog of
|
||||
Just blog ->
|
||||
blog.meta.title
|
||||
|
||||
Nothing ->
|
||||
model.requestUrl
|
||||
)
|
||||
)
|
||||
]
|
||||
[ text "Open an issue on ", i [ class "fa-brands fa-github" ] [] ]
|
||||
]
|
||||
, li []
|
||||
[ a [ href "mailto:ripple+blog@avinal.space" ]
|
||||
[ text "Contact me via email" ]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
viewBlogListItem : JsonMeta -> Html Msg
|
||||
viewBlogListItem meta =
|
||||
div []
|
||||
[ hr [] []
|
||||
, br [] []
|
||||
, div [ class "foo-term-story" ]
|
||||
[ div []
|
||||
[ span []
|
||||
[ i [ class "fa-regular fa-clock" ] [ text " " ]
|
||||
, time [ datetime meta.date ] [ text meta.date ]
|
||||
, text " in "
|
||||
, i [ class "fa-regular fa-folder-open" ] [ text " " ]
|
||||
, a [ href ("/posts/" ++ meta.category) ]
|
||||
[ text meta.category ]
|
||||
]
|
||||
, h2 []
|
||||
[ a [ href ("/posts/" ++ meta.category ++ "/" ++ meta.slug) ]
|
||||
[ text meta.title ]
|
||||
]
|
||||
, p [] [ text meta.description ]
|
||||
]
|
||||
]
|
||||
, br [] []
|
||||
]
|
||||
|
||||
|
||||
viewBlogList : Model -> List (Html Msg)
|
||||
viewBlogList model =
|
||||
case model.bloglist of
|
||||
Just bloglist ->
|
||||
h1 [] [ text "Blog" ]
|
||||
:: List.map viewBlogListItem bloglist
|
||||
|
||||
Nothing ->
|
||||
[]
|
||||
|
||||
|
||||
type Msg
|
||||
= MdDataReceived (Result Http.Error String)
|
||||
| JsonDataReceived (Result Http.Error (List JsonMeta))
|
||||
| NoSuchPage
|
||||
|
||||
|
||||
{-| To maintain compatibility with old links
|
||||
|
||||
Old links: <https://avinal.space/posts/category/slug.html>
|
||||
New links: <https://avinal.space/posts/category/slug>
|
||||
|
||||
-}
|
||||
removeHtmlSuffix : String -> String
|
||||
removeHtmlSuffix slug =
|
||||
if String.right 5 slug == ".html" then
|
||||
String.dropRight 5 slug
|
||||
|
||||
else
|
||||
slug
|
||||
|
||||
|
||||
init : List String -> ( Model, Cmd Msg )
|
||||
init pathList =
|
||||
case pathList of
|
||||
[ category, slug, fragment ] ->
|
||||
let
|
||||
requestUrl =
|
||||
Base.contentUrlPrefix
|
||||
++ "posts/"
|
||||
++ category
|
||||
++ "/"
|
||||
++ removeHtmlSuffix slug
|
||||
++ ".md"
|
||||
in
|
||||
( { initialModel
|
||||
| requestUrl = requestUrl
|
||||
, fragment = fragment
|
||||
}
|
||||
, getMarkdown requestUrl
|
||||
)
|
||||
|
||||
[ category, slug ] ->
|
||||
let
|
||||
requestUrl =
|
||||
Base.contentUrlPrefix
|
||||
++ "posts/"
|
||||
++ category
|
||||
++ "/"
|
||||
++ removeHtmlSuffix slug
|
||||
++ ".md"
|
||||
in
|
||||
( { initialModel
|
||||
| requestUrl = requestUrl
|
||||
}
|
||||
, getMarkdown requestUrl
|
||||
)
|
||||
|
||||
-- [ category ] ->
|
||||
-- let
|
||||
-- requestUrl =
|
||||
-- Base.contentUrlPrefix
|
||||
-- ++ "posts/"
|
||||
-- ++ category
|
||||
-- ++ ".md"
|
||||
-- in
|
||||
-- ( { initialModel
|
||||
-- | requestUrl = requestUrl
|
||||
-- }
|
||||
-- , getMarkdown requestUrl
|
||||
-- )
|
||||
-- [ "categories" ] ->
|
||||
-- ( { blog = Nothing
|
||||
-- , requestUrl = urlPrefix ++ "/categories" ++ ".md"
|
||||
-- , markDown = ""
|
||||
-- , success = False
|
||||
-- , fragment = ""
|
||||
-- }
|
||||
-- , getMarkdown (urlPrefix ++ "/categories" ++ ".md")
|
||||
-- )
|
||||
[] ->
|
||||
( { initialModel | requestUrl = Base.contentUrlPrefix ++ "/posts/posts.json" }
|
||||
, getPostLists (Base.contentUrlPrefix ++ "/posts/posts.json")
|
||||
)
|
||||
|
||||
_ ->
|
||||
( initialModel, Cmd.none )
|
||||
|
||||
|
||||
type alias JsonMeta =
|
||||
{ title : String
|
||||
, date : String
|
||||
, description : String
|
||||
, category : String
|
||||
, slug : String
|
||||
}
|
||||
|
||||
|
||||
getPostLists : String -> Cmd Msg
|
||||
getPostLists url =
|
||||
Http.get
|
||||
{ url = url
|
||||
, expect = Http.expectJson JsonDataReceived (Json.list jsonMetaDecoder)
|
||||
}
|
||||
|
||||
|
||||
jsonMetaDecoder : Json.Decoder JsonMeta
|
||||
jsonMetaDecoder =
|
||||
Json.map5 JsonMeta
|
||||
(Json.field "title" Json.string)
|
||||
(Json.field "date" Json.string)
|
||||
(Json.field "description" Json.string)
|
||||
(Json.field "category" Json.string)
|
||||
(Json.field "slug" Json.string)
|
||||
|
||||
|
||||
getMarkdown : String -> Cmd Msg
|
||||
getMarkdown url =
|
||||
Http.get
|
||||
{ url = url
|
||||
, expect = Http.expectString MdDataReceived
|
||||
}
|
||||
|
||||
|
||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||
update msg model =
|
||||
case msg of
|
||||
-- GetMarkdown ->
|
||||
-- ( model, Http.get { url = model.requestUrl, expect = Http.expectString MdDataReceived } )
|
||||
MdDataReceived (Ok data) ->
|
||||
case splitMetaContent data of
|
||||
Ok blog ->
|
||||
( { model | blog = Just blog, success = True }, sendString blog.content )
|
||||
|
||||
Err err ->
|
||||
( { model | success = False, error = Just err }, Cmd.none )
|
||||
|
||||
MdDataReceived (Err err) ->
|
||||
( { model | success = False, error = Just (errorToString err) }, Cmd.none )
|
||||
|
||||
JsonDataReceived (Ok data) ->
|
||||
( { model | blog = Nothing, success = True, bloglist = Just data }, Cmd.none )
|
||||
|
||||
JsonDataReceived (Err err) ->
|
||||
( { model | success = False, error = Just (errorToString err) }, Cmd.none )
|
||||
|
||||
NoSuchPage ->
|
||||
( { model | success = False }, Cmd.none )
|
||||
|
||||
|
||||
errorToString : Http.Error -> String
|
||||
errorToString error =
|
||||
case error of
|
||||
BadUrl url ->
|
||||
"The URL " ++ url ++ " was invalid"
|
||||
|
||||
Timeout ->
|
||||
"Unable to reach the server, try again"
|
||||
|
||||
NetworkError ->
|
||||
"Unable to reach the server, check your network connection"
|
||||
|
||||
BadStatus 500 ->
|
||||
"The server had a problem, try again later"
|
||||
|
||||
BadStatus 400 ->
|
||||
"Verify your information and try again"
|
||||
|
||||
BadStatus _ ->
|
||||
"Unknown error"
|
||||
|
||||
BadBody errorMessage ->
|
||||
errorMessage
|
||||
|
||||
|
||||
type alias YamlMeta =
|
||||
{ title : String
|
||||
, date : String
|
||||
, description : Maybe String
|
||||
, tags : List String
|
||||
, category : String
|
||||
, image : Maybe String
|
||||
, modified : Maybe String
|
||||
}
|
||||
|
||||
|
||||
splitMetaContent : String -> Result String Blog
|
||||
splitMetaContent data =
|
||||
let
|
||||
headIndices : List Int
|
||||
headIndices =
|
||||
String.indices "---" data |> List.take 2
|
||||
|
||||
metadata =
|
||||
String.slice ((Maybe.withDefault 0 <| List.head headIndices) + 3)
|
||||
((Maybe.withDefault 0 <| List.head <| List.reverse headIndices) - 1)
|
||||
data
|
||||
|
||||
content =
|
||||
String.dropLeft ((Maybe.withDefault 0 <| List.head <| List.reverse headIndices) + 3) data
|
||||
in
|
||||
case Yaml.fromString metaDecoder metadata of
|
||||
Ok meta ->
|
||||
Ok { meta = meta, content = content }
|
||||
|
||||
Err err ->
|
||||
Err ("YAML front matter parsing failed: " ++ Yaml.errorToString err)
|
||||
|
||||
|
||||
metaDecoder : Yaml.Decoder YamlMeta
|
||||
metaDecoder =
|
||||
Yaml.map7 YamlMeta
|
||||
(Yaml.field "title" Yaml.string)
|
||||
(Yaml.field "date" Yaml.string)
|
||||
(Yaml.maybe (Yaml.field "description" Yaml.string))
|
||||
(Yaml.field "tags" (Yaml.list Yaml.string))
|
||||
(Yaml.field "category" Yaml.string)
|
||||
(Yaml.maybe (Yaml.field "image" Yaml.string))
|
||||
(Yaml.maybe (Yaml.field "modified" Yaml.string))
|
||||
-312
@@ -1,312 +0,0 @@
|
||||
module Main exposing (main)
|
||||
|
||||
import Base exposing (websiteBase)
|
||||
import Blog as Blog
|
||||
import Browser exposing (Document)
|
||||
import Browser.Navigation as Nav
|
||||
import Html exposing (Html, a, div, footer, header, img, li, text, ul)
|
||||
import Html.Attributes exposing (class, href, src, target)
|
||||
import Html.Lazy exposing (lazy)
|
||||
import Splash as Splash
|
||||
import Static as Static
|
||||
import Terminal as Terminal
|
||||
import Url exposing (Url)
|
||||
import Url.Parser as Parser exposing ((</>), Parser, s)
|
||||
|
||||
|
||||
|
||||
--MODEL
|
||||
|
||||
|
||||
{-| Model design
|
||||
Model
|
||||
Page: Page that currently is active
|
||||
-}
|
||||
type alias Model =
|
||||
{ page : Page
|
||||
, title : String
|
||||
, key : Nav.Key
|
||||
, url : Url
|
||||
}
|
||||
|
||||
|
||||
|
||||
-- PAGE
|
||||
|
||||
|
||||
{-| Page designs
|
||||
|
||||
BlogPage: Page design for blogs
|
||||
TerminalPage: Page design for terminal
|
||||
StaticPage: Page design for static pages
|
||||
NotFound: Page design for 404 page
|
||||
|
||||
-}
|
||||
type Page
|
||||
= SplashPage Splash.Model
|
||||
| BlogPage Blog.Model
|
||||
| TerminalPage Terminal.Model
|
||||
| StaticPage Static.Model
|
||||
| NotFound
|
||||
|
||||
|
||||
|
||||
-- VIEW
|
||||
|
||||
|
||||
view : Model -> Document Msg
|
||||
view model =
|
||||
let
|
||||
content =
|
||||
case model.page of
|
||||
SplashPage splashModel ->
|
||||
Splash.view splashModel
|
||||
|> Html.map GotSplashMsg
|
||||
|
||||
BlogPage blogs ->
|
||||
Blog.view blogs
|
||||
|> Html.map GotBlogMsg
|
||||
|
||||
TerminalPage terminal ->
|
||||
Terminal.view terminal
|
||||
|> Html.map GotTerminalMsg
|
||||
|
||||
StaticPage static ->
|
||||
Static.view static
|
||||
|> Html.map GotStaticMsg
|
||||
|
||||
NotFound ->
|
||||
Splash.view (Splash.notFound (Url.toString model.url))
|
||||
|> Html.map GotSplashMsg
|
||||
in
|
||||
{ title = model.title
|
||||
, body =
|
||||
[ div [ class "foo-content" ]
|
||||
[ lazy viewHeader model.page
|
||||
, content
|
||||
, lazy viewFooter model.page
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
type Msg
|
||||
= GotSplashMsg Splash.Msg
|
||||
| GotBlogMsg Blog.Msg
|
||||
| GotTerminalMsg Terminal.Msg
|
||||
| GotStaticMsg Static.Msg
|
||||
| ChangeUrl Url
|
||||
| ClickedLink Browser.UrlRequest
|
||||
|
||||
|
||||
viewHeader : Page -> Html msg
|
||||
viewHeader page =
|
||||
let
|
||||
headerContent =
|
||||
case page of
|
||||
SplashPage _ ->
|
||||
div [] []
|
||||
|
||||
_ ->
|
||||
header [ class "foo-logo" ]
|
||||
[ img [ src "/website/logo-static.svg", target websiteBase ]
|
||||
[]
|
||||
]
|
||||
in
|
||||
headerContent
|
||||
|
||||
|
||||
viewFooter : Page -> Html msg
|
||||
viewFooter page =
|
||||
let
|
||||
footerContent =
|
||||
case page of
|
||||
SplashPage _ ->
|
||||
div [] []
|
||||
|
||||
_ ->
|
||||
footer [ class "foo-footer" ]
|
||||
[ ul []
|
||||
[ li [] [ a [ href websiteBase ] [ text "Home" ] ]
|
||||
, li [] [ a [ href "https://avinal.space/pages/about-me" ] [ text "About me " ] ]
|
||||
, li [] [ a [ href "https://avinal.space/posts" ] [ text "Blog" ] ]
|
||||
, li [] [ a [ href "https://avinal.space/pages/projects" ] [ text "Projects" ] ]
|
||||
, li [] [ a [ href "https://gsoc.avinal.space" ] [ text "GSoC" ] ]
|
||||
]
|
||||
]
|
||||
in
|
||||
footerContent
|
||||
|
||||
|
||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||
update msg model =
|
||||
case msg of
|
||||
GotSplashMsg splashMsg ->
|
||||
case model.page of
|
||||
SplashPage splash ->
|
||||
toSplash model (Splash.update splashMsg splash)
|
||||
|
||||
_ ->
|
||||
( model, Cmd.none )
|
||||
|
||||
GotBlogMsg blogMsg ->
|
||||
case model.page of
|
||||
BlogPage blogModel ->
|
||||
let
|
||||
title =
|
||||
case blogModel.blog of
|
||||
Just blog ->
|
||||
blog.meta.title
|
||||
|
||||
Nothing ->
|
||||
"Blog"
|
||||
in
|
||||
toBlog
|
||||
{ model
|
||||
| title = title ++ " | " ++ model.title
|
||||
}
|
||||
(Blog.update blogMsg blogModel)
|
||||
|
||||
_ ->
|
||||
( model, Cmd.none )
|
||||
|
||||
GotTerminalMsg terminalMsg ->
|
||||
case model.page of
|
||||
TerminalPage terminal ->
|
||||
toTerminal model (Terminal.update terminalMsg terminal)
|
||||
|
||||
_ ->
|
||||
( model, Cmd.none )
|
||||
|
||||
GotStaticMsg staticMsg ->
|
||||
case model.page of
|
||||
StaticPage static ->
|
||||
toStatic model (Static.update staticMsg static)
|
||||
|
||||
_ ->
|
||||
( model, Cmd.none )
|
||||
|
||||
ChangeUrl url ->
|
||||
updateUrl { model | url = url }
|
||||
|
||||
ClickedLink urlRequest ->
|
||||
case urlRequest of
|
||||
Browser.Internal href ->
|
||||
( model, Nav.pushUrl model.key (Url.toString href) )
|
||||
|
||||
Browser.External url ->
|
||||
( model, Nav.load url )
|
||||
|
||||
|
||||
toSplash : Model -> ( Splash.Model, Cmd Splash.Msg ) -> ( Model, Cmd Msg )
|
||||
toSplash model ( splashModel, cmd ) =
|
||||
( { model | page = SplashPage splashModel }, Cmd.map GotSplashMsg cmd )
|
||||
|
||||
|
||||
toBlog : Model -> ( Blog.Model, Cmd Blog.Msg ) -> ( Model, Cmd Msg )
|
||||
toBlog model ( blogModel, cmd ) =
|
||||
( { model | page = BlogPage blogModel }, Cmd.map GotBlogMsg cmd )
|
||||
|
||||
|
||||
toTerminal : Model -> ( Terminal.Model, Cmd Terminal.Msg ) -> ( Model, Cmd Msg )
|
||||
toTerminal model ( terminalModel, cmd ) =
|
||||
( { model | page = TerminalPage terminalModel }, Cmd.map GotTerminalMsg cmd )
|
||||
|
||||
|
||||
toStatic : Model -> ( Static.Model, Cmd Static.Msg ) -> ( Model, Cmd Msg )
|
||||
toStatic model ( staticModel, cmd ) =
|
||||
( { model | page = StaticPage staticModel }, Cmd.map GotStaticMsg cmd )
|
||||
|
||||
|
||||
init : () -> Url -> Nav.Key -> ( Model, Cmd Msg )
|
||||
init _ url key =
|
||||
updateUrl { url = url, page = NotFound, title = "Be My SpaceTime", key = key }
|
||||
|
||||
|
||||
|
||||
-- PARSER
|
||||
|
||||
|
||||
type Route
|
||||
= Splash
|
||||
| Blog
|
||||
| BlogPost String String (Maybe String)
|
||||
| Terminal
|
||||
| Static
|
||||
|
||||
|
||||
|
||||
-- | BlogPost String String
|
||||
|
||||
|
||||
parser : Parser (Route -> a) a
|
||||
parser =
|
||||
Parser.oneOf
|
||||
[ Parser.map Splash Parser.top
|
||||
|
||||
-- , Parser.map Splash (s urlPrefix)
|
||||
, Parser.map Blog (s "posts")
|
||||
, Parser.map BlogPost (s "posts" </> Parser.string </> Parser.string </> Parser.fragment identity)
|
||||
, Parser.map Static (s "pages")
|
||||
, Parser.map Terminal (s "terminal")
|
||||
]
|
||||
|
||||
|
||||
updateUrl : Model -> ( Model, Cmd Msg )
|
||||
updateUrl model =
|
||||
case Parser.parse parser model.url of
|
||||
Just Splash ->
|
||||
Splash.init () False ""
|
||||
|> toSplash model
|
||||
|
||||
Just Blog ->
|
||||
Blog.init []
|
||||
|> toBlog model
|
||||
|
||||
Just (BlogPost category title fragment) ->
|
||||
case fragment of
|
||||
Just something ->
|
||||
Blog.init [ category, title, something ]
|
||||
|> toBlog model
|
||||
|
||||
Nothing ->
|
||||
Blog.init [ category, title ]
|
||||
|> toBlog model
|
||||
|
||||
Just Terminal ->
|
||||
Terminal.init ()
|
||||
|> toTerminal model
|
||||
|
||||
Just Static ->
|
||||
Static.init ()
|
||||
|> toStatic model
|
||||
|
||||
Nothing ->
|
||||
Splash.init () True (Url.toString model.url)
|
||||
|> toSplash model
|
||||
|
||||
|
||||
subscriptions : Model -> Sub Msg
|
||||
subscriptions model =
|
||||
case model.page of
|
||||
-- BlogPage blogModel ->
|
||||
-- Blog.subscriptions blogModel
|
||||
-- |> Sub.map GotBlogMsg
|
||||
_ ->
|
||||
Sub.none
|
||||
|
||||
|
||||
|
||||
-- ENTRYPOINT
|
||||
|
||||
|
||||
main : Program () Model Msg
|
||||
main =
|
||||
Browser.application
|
||||
{ init = init
|
||||
, view = view
|
||||
, update = update
|
||||
, subscriptions = subscriptions
|
||||
, onUrlChange = ChangeUrl
|
||||
, onUrlRequest = ClickedLink
|
||||
}
|
||||
-101
@@ -1,101 +0,0 @@
|
||||
module Splash exposing (..)
|
||||
|
||||
import Html exposing (Html, a, b, div, i, img, span, text)
|
||||
import Html.Attributes exposing (alt, class, height, href, src, width)
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ support_message : Html Msg
|
||||
, error_message : Html Msg
|
||||
}
|
||||
|
||||
|
||||
view : Model -> Html Msg
|
||||
view model =
|
||||
div [ class "foo-content" ]
|
||||
[ div [ class "foo-error" ]
|
||||
[ img
|
||||
[ class "foo-error__logo"
|
||||
, src "/website/logo-loading.svg"
|
||||
, alt "Finding the SpaceTime"
|
||||
, width 130
|
||||
, height 130
|
||||
]
|
||||
[]
|
||||
, div [ class "foo-support__message" ] [ model.support_message ]
|
||||
, div [ class "foo-error__message" ] [ model.error_message ]
|
||||
, withSpacing (div [ class "foo-support__message" ])
|
||||
[ a [ href "https://avinal.space/pages/about-me" ] [ b [ class "foo-term-blue" ] [ text "A" ], text "bout" ]
|
||||
, a [ href "https://avinal.space/posts" ] [ b [ class "foo-term-blue" ] [ text "B" ], text "log" ]
|
||||
, a [ href "https://avinal.space/pages/projects" ] [ b [ class "foo-term-blue" ] [ text "P" ], text "rojects" ]
|
||||
, a [ href "https://gsoc.avinal.space" ] [ b [ class "foo-term-blue" ] [ text "G" ], text "SoC" ]
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
type Msg
|
||||
= Nothing
|
||||
|
||||
|
||||
{-| How to get whitespace between html tags?
|
||||
|
||||
Link: <https://stackoverflow.com/a/55827562/11143805>
|
||||
|
||||
-}
|
||||
withSpacing : (List (Html msg) -> Html msg) -> List (Html msg) -> Html msg
|
||||
withSpacing element =
|
||||
List.intersperse (text " ") >> element
|
||||
|
||||
|
||||
notFound : String -> Model
|
||||
notFound error =
|
||||
{ support_message = default.support_message
|
||||
, error_message =
|
||||
withSpacing (span [])
|
||||
[ i [ class "fa-solid fa-triangle-exclamation foo-term-yellow" ] []
|
||||
, text "I could not find anything on this"
|
||||
, i [ class "fa-solid fa-link foo-term-red" ] []
|
||||
, a [ href error ] [ text error ]
|
||||
, text "If you think this is a mistake, please contact me."
|
||||
, i [ class "fa-solid fa-triangle-exclamation foo-term-yellow" ] []
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
default : Model
|
||||
default =
|
||||
{ support_message =
|
||||
withSpacing (span [])
|
||||
[ a [ href "https://github.com/avinal" ] [ i [ class "fa-brands fa-github" ] [] ]
|
||||
, a [ href "https://www.linkedin.com/in/avinal" ] [ i [ class "fa-brands fa-linkedin" ] [] ]
|
||||
, a [ href "https://instagram.com/avinal.k" ] [ i [ class "fa-brands fa-instagram" ] [] ]
|
||||
, a [ href "https://meet.avinal.space" ] [ i [ class "fa-solid fa-calendar-days" ] [] ]
|
||||
, a [ href "mailto:ripple+blog@avinal.space" ] [ i [ class "fa-solid fa-envelope" ] [] ]
|
||||
, a [ href "https://avinal.space/terminal" ] [ i [ class "fa-solid fa-terminal" ] [] ]
|
||||
]
|
||||
, error_message =
|
||||
withSpacing (span [])
|
||||
[ text "I'm"
|
||||
, b [ class "foo-term-pink" ] [ text "Avinal" ]
|
||||
, text "and I work at Red Hat"
|
||||
, i [ class "fa-brands fa-redhat foo-term-red" ] []
|
||||
, text "as an Associate Software Engineer for Hybrid Cloud Engineering."
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||
update msg model =
|
||||
case msg of
|
||||
Nothing ->
|
||||
( model, Cmd.none )
|
||||
|
||||
|
||||
init : () -> Bool -> String -> ( Model, Cmd Msg )
|
||||
init _ isError error =
|
||||
if isError then
|
||||
( notFound error, Cmd.none )
|
||||
|
||||
else
|
||||
( default, Cmd.none )
|
||||
@@ -1,36 +0,0 @@
|
||||
module Static exposing (..)
|
||||
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ title : String
|
||||
, url : String
|
||||
}
|
||||
|
||||
|
||||
view : Model -> Html Msg
|
||||
view model =
|
||||
div []
|
||||
[ h1 [] [ text model.title ]
|
||||
, a [ href model.url ] [ text model.url ]
|
||||
]
|
||||
|
||||
|
||||
type Msg
|
||||
= NoOp
|
||||
|
||||
|
||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||
update msg model =
|
||||
case msg of
|
||||
NoOp ->
|
||||
( model, Cmd.none )
|
||||
|
||||
|
||||
init : () -> ( Model, Cmd Msg )
|
||||
init _ =
|
||||
( Model "Hello World" "http://elm-lang.org"
|
||||
, Cmd.none
|
||||
)
|
||||
@@ -1,41 +0,0 @@
|
||||
module Terminal exposing (..)
|
||||
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (..)
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ title : String
|
||||
, url : String
|
||||
}
|
||||
|
||||
|
||||
view : Model -> Html Msg
|
||||
view model =
|
||||
div []
|
||||
[ h1 [] [ text model.title ]
|
||||
, input [ placeholder "Enter URL", onInput UrlEntered ] []
|
||||
, button [ onClick Go ] [ text "Go" ]
|
||||
, a [ href model.url ] [ text model.url ]
|
||||
]
|
||||
|
||||
|
||||
type Msg
|
||||
= UrlEntered String
|
||||
| Go
|
||||
|
||||
|
||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||
update msg model =
|
||||
case msg of
|
||||
UrlEntered url ->
|
||||
( { model | url = url }, Cmd.none )
|
||||
|
||||
Go ->
|
||||
( model, Cmd.none )
|
||||
|
||||
|
||||
init : () -> ( Model, Cmd Msg )
|
||||
init _ =
|
||||
( Model "Terminal" "", Cmd.none )
|
||||
Reference in New Issue
Block a user