on master help sign in
Optimized a bit
commitb90989ef82b96d0fb3c2327e51af5eae9d4178e9 authoriko <ilyakooo0@gmail.com> dateSat 30 Jul 2022, 18:32 (4 years ago) parent5bb1032
7 files changed+52−43
build.sh+7−3 clickable.yaml+1−2 frontend/FFI.elm+1−2 frontend/Main.elm+3−2 frontend/Pages/Ciphers.elm+5−2 frontend/Pages/Navigation.elm+34−31 frontend/Search.elm+1−1
build.sh+7−3
@@ -2,8 +2,12 @@
22
33set -e
44
5−cp -r "$SRC_DIR"/{appname.apparmor,appname.desktop,vanilla,index.html,style.css,manifest.json,logo.svg} "$INSTALL_DIR"
5+TEMP=$(mktemp -d)
66
7−elm make --debug "$SRC_DIR/frontend/Main.elm" --output="$INSTALL_DIR/elm.js"
7+cp -r "$SRC_DIR"/{vanilla,appname.apparmor,appname.desktop,manifest.json,logo.svg,index.html,style.css} "$INSTALL_DIR"
88
9−(cd "$SRC_DIR" && spago bundle-app --to "$INSTALL_DIR/backend.js")
9+elm make "$SRC_DIR/frontend/Main.elm" --optimize --output="$TEMP/elm.js"
10+
11+terser "$TEMP/elm.js" --ecma 2018 --compress 'pure_funcs=[F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9],pure_getters,keep_fargs=false,unsafe_comps,unsafe' | terser --ecma 2018 --mangle --compress --output "$INSTALL_DIR/elm.js"
12+
13+(cd "$SRC_DIR" && spago bundle-app --minify --to "$INSTALL_DIR/backend.js")
clickable.yaml+1−2
@@ -11,7 +11,6 @@ image_setup:
1111 run:
1212
1313 - (cd /tmp && curl -L -o elm.gz https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz && gunzip elm.gz && chmod +x elm && mv elm /usr/local/bin/)
14− - npm install -g spago esbuild purescript --unsafe-perm=true
15− - (cd / && curl https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.37.1.tar.xz >git.tar.gz && tar -xvf git.tar.gz && cd git-2.37.1 && ./configure --without-curl && make)
14+ - npm install -g spago esbuild purescript terser --unsafe-perm=true
1615
1716restrict_arch: all
frontend/FFI.elm+1−2
@@ -14,8 +14,7 @@ port bridgeCmd : D.Value -> Cmd msg
1414getBridge : (String -> msg) -> (Bridge.Sub -> msg) -> Sub msg
1515getBridge err f =
1616 bridgeSub
17− ((\v -> Debug.log (E.encode 1 v) v)
18− >> D.decodeValue Bridge.jsonDecSub
17+ (D.decodeValue Bridge.jsonDecSub
1918 >> (\res ->
2019 case res of
2120 Ok a ->
frontend/Main.elm+3−2
@@ -4,6 +4,7 @@ import Bridge
44import Browser
55import FFI exposing (getBridge, sendBridge)
66import Html exposing (..)
7+import Html.Lazy as Lazy
78import List.Nonempty as Nonempty exposing (Nonempty(..))
89import Notification
910import Pages.Cipher as Cipher
@@ -169,8 +170,8 @@ init =
169170view : Model -> Html Msg
170171view model =
171172 div []
172− (maybeList (List.head model.notifications) (Notification.notification CloseNotification)
173− ++ [ Navigation.showNavigationView model.pageStack showPage ]
173+ (maybeList (List.head model.notifications) (Lazy.lazy2 Notification.notification CloseNotification)
174+ ++ [ Lazy.lazy2 Navigation.showNavigationView model.pageStack showPage ]
174175 )
175176
176177
frontend/Pages/Ciphers.elm+5−2
@@ -4,6 +4,7 @@ import Bridge
44import Html exposing (..)
55import Html.Attributes as Attr
66import Html.Events as Ev
7+import Html.Keyed as Keyed
78import Page exposing (..)
89import Pages.Navigation as Navigation
910import Search
@@ -150,18 +151,20 @@ view { selected } liftMsg { ciphers, search, ciphersListFilter } =
150151 , Attr.attribute "autocomplete" "off"
151152 ]
152153 []
153− , ul [ Attr.class "p-list--divided" ]
154+ , Keyed.ul [ Attr.class "p-list--divided" ]
154155 (ciphers
155156 |> applyCipherFilter ciphersListFilter
156157 |> Search.searchList (cipherSearch search)
157158 |> List.map
158159 (\{ name, date, id } ->
159− li [ Attr.class "p-list__item cipher-row", Ev.onClick (selected id) ]
160+ ( id
161+ , li [ Attr.class "p-list__item cipher-row", Ev.onClick (selected id) ]
160162 [ div [ Attr.class "cipher-row-container" ]
161163 [ p [] [ text name ]
162164 , p [ Attr.class "p-text--small u-align-text--right u-text--muted" ] [ text date ]
163165 ]
164166 ]
167+ )
165168 )
166169 )
167170 ]
frontend/Pages/Navigation.elm+34−31
@@ -12,6 +12,7 @@ module Pages.Navigation exposing
1212import Html exposing (..)
1313import Html.Attributes as Attr
1414import Html.Events as Ev
15+import Html.Lazy as Lazy
1516import List.Nonempty as Nonempty exposing (Nonempty)
1617import Utils exposing (..)
1718
@@ -27,36 +28,38 @@ type alias Config msg =
2728 }
2829
2930
30−navigation : Config msg -> List (Html msg)
31+navigation : Config msg -> Html msg
3132navigation { topButton, title } =
32− (case topButton of
33− Just (MenuButton cfg) ->
34− [ menu cfg ]
35−
36− _ ->
37− []
38− )
39− ++ [ nav [ Attr.class "p-tabs p-tabs__list" ]
40− [ h3 [ Attr.class "" ]
41− [ case topButton of
42− Nothing ->
43− button
44− [ Attr.class "p-button--base is-inline u-no-margin", Attr.style "visibility" "hidden" ]
45− []
46−
47− Just (BackButton msg) ->
48− button
49− [ Attr.class "p-button--base is-inline u-no-margin", Ev.onClick msg ]
50− [ i [ Attr.class "p-icon--chevron-up ninety-counter" ] [] ]
51−
52− Just (MenuButton cfg) ->
53− button
54− [ Attr.class "p-button--base is-inline u-no-margin", Ev.onClick cfg.toggle ]
55− [ i [ Attr.class "p-icon--menu" ] [] ]
56− , text title
33+ div []
34+ ((case topButton of
35+ Just (MenuButton cfg) ->
36+ [ Lazy.lazy menu cfg ]
37+
38+ _ ->
39+ []
40+ )
41+ ++ [ nav [ Attr.class "p-tabs p-tabs__list" ]
42+ [ h3 []
43+ [ case topButton of
44+ Nothing ->
45+ button
46+ [ Attr.class "p-button--base is-inline u-no-margin", Attr.style "visibility" "hidden" ]
47+ []
48+
49+ Just (BackButton msg) ->
50+ button
51+ [ Attr.class "p-button--base is-inline u-no-margin", Ev.onClick msg ]
52+ [ i [ Attr.class "p-icon--chevron-up ninety-counter" ] [] ]
53+
54+ Just (MenuButton cfg) ->
55+ button
56+ [ Attr.class "p-button--base is-inline u-no-margin", Ev.onClick cfg.toggle ]
57+ [ i [ Attr.class "p-icon--menu" ] [] ]
58+ , text title
59+ ]
5760 ]
58− ]
59− ]
61+ ]
62+ )
6063
6164
6265type alias MenuConfig msg =
@@ -144,9 +147,9 @@ showNavigationView stack render =
144147 render (Nonempty.head stack)
145148 in
146149 div []
147− (navigation
150+ [ Lazy.lazy navigation
148151 { topButton = topButton
149152 , title = title
150153 }
151− ++ [ main_ [] body ]
152− )
154+ , main_ [] body
155+ ]
frontend/Search.elm+1−1
@@ -84,7 +84,7 @@ type Query
8484-}
8585constructQueries : String -> List Query
8686constructQueries =
87− prepareString >> String.words >> List.filter (String.isEmpty >> not) >> List.map Query
87+ prepareString >> String.words >> List.filter (String.isEmpty >> not) >> List.filter (String.length >> (<) 1) >> List.map Query
8888
8989
9090{-| Search a search term within a search entry.