Something went wrong. Try again.
A music player that connects to your cloud/distributed storage. forked from tokono.ma/diffuse
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224module Build exposing ( main )
import About.Layoutimport Bytes exposing ( Bytes )import Bytes.Decodeimport Bytes.Encodeimport Dictimport Json.Encodeimport Markdownimport Shikensuimport Shikensu.Bundle as Bundleimport Shikensu.Contrib as Shikensuimport Shikensu.Definition as Definitionimport Shikensu.Focus exposing ( Focus(..) )import Shikensu.Path as Path exposing (..)import Shikensu.Path.Encapsulated as Path.Encapsulatedimport Taskimport Transmutable.Html
-- | (• ◡•)| (❍ᴥ❍ʋ)
main = Shikensu.programs [ -- Copy static files to dist copy (staticDir "Favicons") , copy (staticDir "Hosting") , copyInto "fonts" (staticDir "Fonts") , copyInto "images" (staticDir "Images")
, -- Copy more static files with some alterations copyWithAlterations { focus = staticDir "Html" , alt = Shikensu.rename (filePath "Application.html") (filePath "index.html") } , copyWithAlterations { focus = staticDir "Manifests" , alt = Shikensu.rename (filePath "manifest.json") (filePath "site.webmanifest") }
, -- Render about pages about
, -- Make a file tree so the service worker knows what to cache tree ]
-- FOCUSES & PATHS
dist = Relative (Path.directory [ "dist" ] )
filePath path = path |> Path.fromPosix |> Path.Encapsulated.toFile |> Maybe.withDefault (Path.file (Array.singleton path))
staticDir dirName = Relative (Path.directory [ "src" , "Static" , dirName ] )
-- PROGRAMS
about = { focus = staticDir "About" , sequence = read >> Task.map aboutAlts >> write }
copy focus = { focus = focus , sequence = read >> write }
copyInto dirName focus = { focus = focus , sequence = read >> Task.map (prefixDirname dirName) >> write }
copyWithAlterations { focus, alt } = { focus = focus , sequence = read >> Task.map alt >> write }
tree = { focus = dist , sequence = Task.map (\bundle -> bundle.compendium |> Array.map (\def -> def |> Definition.relativePath |> Path.toPosix { absolute = False } ) |> Array.filter (String.contains "images/Background/" >> (==) False) |> Json.Encode.array Json.Encode.string |> Json.Encode.encode 0 |> stringToBytes |> (\content -> { baseName = "tree" , content = Just content , directoryPath = Path.directory [] , extensionName = Just "json" , metadata = Dict.empty } ) |> (\def -> { bundle | compendium = [ def ] } ) ) >> write }
-- ALTERATIONS
aboutAlts bundle = bundle |> Shikensu.withExtension "md" |> lowerCasePath |> prefixDirname "about" |> Shikensu.renameExtension "md" "html" |> Shikensu.permalink "index" |> Shikensu.renderContent (\def -> def.content |> Maybe.andThen bytesToString |> Maybe.withDefault "" |> Markdown.parse { frontmatter = Nothing } |> (\{ blocks } -> Array.map Markdown.toHtml blocks) |> About.Layout.layout { pathToRoot = def.directoryPath |> Path.unwrap |> Array.map (\_ -> "..") |> String.join "/" |> (\a -> a ++ "/") } |> Transmutable.Html.arrayToString |> stringToBytes |> Just )
lowerCasePath = (\def -> def |> Definition.relativePath |> Path.map (Array.map String.toLower) |> (\path -> Definition.fork path def) ) |> Array.map |> Bundle.mapCompendium
prefixDirname dirName = (\def -> { def | directoryPath = Path.map (Array.pushFirst dirName) def.directoryPath }) |> Array.map |> Bundle.mapCompendium
-- TASKS
read = Task.andThen Shikensu.read
write = Task.andThen (Shikensu.write dist)
-- 🛠️
bytesToString : Bytes -> Maybe StringbytesToString bytes = bytes |> Bytes.width |> Bytes.Decode.string |> (\decoder -> Bytes.Decode.decode decoder bytes)
stringToBytes : String -> BytesstringToBytes = Bytes.Encode.string >> Bytes.Encode.encode