A music player that connects to your cloud/distributed storage.
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 36811c66ea8861375d11c411069c8b9e599453f2 222 lines 5.4 kB view raw
1module Build exposing ( main ) 2 3import About.Layout 4import Bytes exposing ( Bytes ) 5import Bytes.Decode 6import Bytes.Encode 7import Dict 8import Json.Encode 9import Markdown 10import Shikensu 11import Shikensu.Bundle as Bundle 12import Shikensu.Contrib as Shikensu 13import Shikensu.Definition as Definition 14import Shikensu.Focus exposing ( Focus(..) ) 15import Shikensu.Path as Path exposing (..) 16import Shikensu.Path.Encapsulated as Path.Encapsulated 17import Task 18import Transmutable.Html 19 20 21 22-- | (• ◡•)| (❍ᴥ❍ʋ) 23 24 25main = 26 Shikensu.programs 27 [ -- Copy static files to dist 28 copy (staticDir "Favicons") 29 , copy (staticDir "Hosting") 30 , copyInto "fonts" (staticDir "Fonts") 31 , copyInto "images" (staticDir "Images") 32 33 , -- Copy more static files with some alterations 34 copyWithAlterations 35 { focus = staticDir "Html" 36 , alt = Shikensu.rename (filePath "Application.html") (filePath "index.html") 37 } 38 , copyWithAlterations 39 { focus = staticDir "Manifests" 40 , alt = Shikensu.rename (filePath "manifest.json") (filePath "site.webmanifest") 41 } 42 43 , -- Render about pages 44 about 45 46 , -- Make a file tree so the service worker knows what to cache 47 tree 48 ] 49 50 51 52-- FOCUSES & PATHS 53 54 55dist = 56 Relative 57 (Path.directory 58 [ "dist" 59 ] 60 ) 61 62 63filePath path = 64 path 65 |> Path.fromPosix 66 |> Path.Encapsulated.toFile 67 |> Maybe.withDefault (Path.file (Array.singleton path)) 68 69 70staticDir dirName = 71 Relative 72 (Path.directory 73 [ "src" 74 , "Static" 75 , dirName 76 ] 77 ) 78 79 80 81-- PROGRAMS 82 83 84about = 85 { focus = staticDir "About" 86 , sequence = read >> Task.map aboutAlts >> write 87 } 88 89 90copy focus = 91 { focus = focus 92 , sequence = read >> write 93 } 94 95 96copyInto dirName focus = 97 { focus = focus 98 , sequence = read >> Task.map (prefixDirname dirName) >> write 99 } 100 101 102copyWithAlterations { focus, alt } = 103 { focus = focus 104 , sequence = read >> Task.map alt >> write 105 } 106 107 108tree = 109 { focus = dist 110 , sequence = 111 Task.map 112 (\bundle -> 113 bundle.compendium 114 |> Array.map 115 (\def -> 116 def 117 |> Definition.relativePath 118 |> Path.toPosix 119 { absolute = False 120 } 121 ) 122 |> Json.Encode.array Json.Encode.string 123 |> Json.Encode.encode 0 124 |> stringToBytes 125 |> (\content -> 126 { baseName = "tree" 127 , content = Just content 128 , directoryPath = Path.directory [] 129 , extensionName = Just "json" 130 , metadata = Dict.empty 131 } 132 ) 133 |> (\def -> 134 { bundle 135 | compendium = 136 [ def 137 ] 138 } 139 ) 140 ) 141 >> write 142 } 143 144 145 146-- ALTERATIONS 147 148 149aboutAlts bundle = 150 bundle 151 |> Shikensu.withExtension "md" 152 |> lowerCasePath 153 |> prefixDirname "about" 154 |> Shikensu.renameExtension "md" "html" 155 |> Shikensu.permalink "index" 156 |> Shikensu.renderContent 157 (\def -> 158 def.content 159 |> Maybe.andThen bytesToString 160 |> Maybe.withDefault "" 161 |> Markdown.parse 162 { frontmatter = Nothing 163 } 164 |> (\{ blocks } -> Array.map Markdown.toHtml blocks) 165 |> About.Layout.layout 166 { pathToRoot = 167 def.directoryPath 168 |> Path.unwrap 169 |> Array.map (\_ -> "..") 170 |> String.join "/" 171 |> (\a -> a ++ "/") 172 } 173 |> Transmutable.Html.arrayToString 174 |> stringToBytes 175 |> Just 176 ) 177 178 179lowerCasePath = 180 (\def -> 181 def 182 |> Definition.relativePath 183 |> Path.map (Array.map String.toLower) 184 |> (\path -> Definition.fork path def) 185 ) 186 |> Array.map 187 |> Bundle.mapCompendium 188 189 190prefixDirname dirName = 191 (\def -> { def | directoryPath = Path.map (Array.pushFirst dirName) def.directoryPath }) 192 |> Array.map 193 |> Bundle.mapCompendium 194 195 196 197-- TASKS 198 199 200read = 201 Task.andThen Shikensu.read 202 203 204write = 205 Task.andThen (Shikensu.write dist) 206 207 208 209-- 🛠️ 210 211 212bytesToString : Bytes -> Maybe String 213bytesToString bytes = 214 bytes 215 |> Bytes.width 216 |> Bytes.Decode.string 217 |> (\decoder -> Bytes.Decode.decode decoder bytes) 218 219 220stringToBytes : String -> Bytes 221stringToBytes = 222 Bytes.Encode.string >> Bytes.Encode.encode