on master help sign in
Add fun emoji icons

- TODO: Replace in the feature with website favicon

commitb69ee0d7de95d25ebb3813a5e6995495011833ab authorEvangelos Lamprou <e.lamprou@upnet.gr> dateMon 23 Oct 2023, 00:40 (3 years ago) parent711dede
2 files changed+25−1
frontend/elm.json+4 frontend/src/Main.elm+21−1
frontend/elm.json+4
@@ -7,6 +7,7 @@
77 "elm-version": "0.19.1",
88 "dependencies": {
99 "direct": {
10+ "Evelios/elm-hash": "1.0.0",
1011 "TSFoster/elm-bytes-extra": "1.3.0",
1112 "avh4/elm-color": "1.0.0",
1213 "cmditch/elm-bigint": "2.0.1",
@@ -44,6 +45,8 @@
4445 "AdrianRibao/elm-derberos-date": "1.2.3",
4546 "NoRedInk/elm-string-conversions": "1.0.1",
4647 "bitsoflogic/elm-radixint": "2.0.0",
48+ "bonzaico/murmur3": "1.0.0",
49+ "chain-partners/elm-bignum": "1.0.1",
4750 "elm/file": "1.0.5",
4851 "elm/parser": "1.1.0",
4952 "elm/random": "1.0.0",
@@ -56,6 +59,7 @@
5659 "ianmackenzie/elm-interval": "3.1.0",
5760 "ianmackenzie/elm-units-interval": "3.2.0",
5861 "ktonon/elm-word": "2.1.2",
62+ "myrho/elm-round": "1.0.5",
5963 "robinheghan/murmur3": "1.0.0"
6064 }
6165 },
frontend/src/Main.elm+21−1
@@ -34,6 +34,7 @@ import Ur.Types exposing (Noun(..))
3434import Url
3535import ElmEscapeHtml
3636import Json.Encode
37+import Hash
3738
3839url : String
3940url =
@@ -192,6 +193,18 @@ aboutView = row [ centerX, padding 10, spacing 10]
192193 ]
193194
194195
196+titleEmoji : String -> String
197+titleEmoji title =
198+ let maxUnicode = 0x1F3F0
199+ minUnicode = 0x1F300
200+ in title |> Hash.fromString
201+ |> Hash.toString
202+ |> String.toInt
203+ |> Maybe.withDefault 0
204+ |> (\x -> ((modBy (maxUnicode - minUnicode) x) + minUnicode))
205+ |> Char.fromCode
206+ |> String.fromChar
207+ |> (\x -> x ++ " ")
195208
196209
197210view : Model -> Element Msg
@@ -309,7 +322,14 @@ view model =
309322 (Html.a
310323 [ Html.Attributes.href link
311324 , Html.Attributes.class "result-title" ]
312− [ Html.text (Maybe.withDefault "" (Url.percentDecode (ElmEscapeHtml.unescape (stripTags title)))) ]
325+ [ Html.text
326+ (Maybe.withDefault ""
327+ (Url.percentDecode
328+ (ElmEscapeHtml.unescape
329+ (stripTags
330+ ((titleEmoji title) ++ title)
331+ ))))
332+ ]
313333 )
314334 )
315335 , text link