clean up
This commit is contained in:
parent
57ea8d17b6
commit
80c2c7baab
25 changed files with 0 additions and 1995 deletions
File diff suppressed because one or more lines are too long
|
@ -1,2 +0,0 @@
|
|||
{
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"message0": "Hello World!",
|
||||
"message1": "This is another message. Hello World!"
|
||||
}
|
2
backend/.gitignore
vendored
2
backend/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
.stack-work/
|
||||
*~
|
|
@ -1,11 +0,0 @@
|
|||
# Changelog for `hs-server`
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to the
|
||||
[Haskell Package Versioning Policy](https://pvp.haskell.org/).
|
||||
|
||||
## Unreleased
|
||||
|
||||
## 0.1.0.0 - YYYY-MM-DD
|
|
@ -1,26 +0,0 @@
|
|||
Copyright 2025 Author name here
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@ -1,2 +0,0 @@
|
|||
# hs-server
|
||||
this is a custom-built single-purpose server infrastructure based on Scorry, Warp, and Wai. It holds up MTGmonkey's personal website
|
|
@ -1,2 +0,0 @@
|
|||
import Distribution.Simple
|
||||
main = defaultMain
|
|
@ -1,108 +0,0 @@
|
|||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
module Main (main) where
|
||||
|
||||
import ElmskellTypes
|
||||
import Data.Text.Lazy (Text)
|
||||
import Network.Wai.Handler.Warp (Port)
|
||||
import Network.Wai.Middleware.RequestLogger (logStdoutDev)
|
||||
import Text.Blaze ((!))
|
||||
import Text.Blaze.Html.Renderer.Text (renderHtml)
|
||||
|
||||
import Network.HTTP.Types
|
||||
import Network.Wai.Middleware.Gzip
|
||||
import Web.Scotty as S
|
||||
|
||||
import qualified Control.Exception as E
|
||||
import qualified Text.Blaze.Html5 as H
|
||||
import qualified Text.Blaze.Html5.Attributes as A
|
||||
|
||||
-- HTML
|
||||
index :: H.Html -> Text
|
||||
index compiledElmApp = renderHtml $ do
|
||||
H.docTypeHtml $ do
|
||||
H.head $ do
|
||||
H.title "TESTING Scotty+Elm"
|
||||
H.meta ! A.charset "utf-8"
|
||||
H.style "body{margin:0px;}"
|
||||
(H.body ! A.id "body") $ do
|
||||
embedJs compiledElmApp
|
||||
|
||||
-- CONF
|
||||
port :: Port
|
||||
port = 8080
|
||||
|
||||
adminContact :: String
|
||||
adminContact = "[Matrix] @mtgmonkey:calitabby.net"
|
||||
|
||||
compiledElmAppFile :: AssetPath
|
||||
compiledElmAppFile = "/js/main.js"
|
||||
|
||||
boilerplateJsFile :: AssetPath
|
||||
boilerplateJsFile = "/js/init.js"
|
||||
|
||||
assetsFolder :: FilePath
|
||||
assetsFolder = "/home/mtgmonkey/elmskell/assets"
|
||||
|
||||
-- MAIN
|
||||
main :: IO ()
|
||||
main = do
|
||||
|
||||
generateElmskellTypes
|
||||
|
||||
compiledElmAppOrExc <- E.try $ readFile $ assetsFolder ++ compiledElmAppFile :: IO (Either E.IOException String)
|
||||
let compiledElmApp = case compiledElmAppOrExc of
|
||||
Left e -> serverErrorReadFile e
|
||||
Right contents -> H.toHtml $ contents
|
||||
|
||||
boilerplateJsOrExc <- E.try $ readFile $ assetsFolder ++ boilerplateJsFile :: IO (Either E.IOException String)
|
||||
let boilerplateJs = case boilerplateJsOrExc of
|
||||
Left e -> serverErrorReadFile e
|
||||
Right contents -> H.toHtml $ contents
|
||||
|
||||
let anyRoute = regex "^.*$"
|
||||
scotty port $ do
|
||||
|
||||
middleware $ gzip $ def { gzipFiles = GzipCompress }
|
||||
middleware logStdoutDev
|
||||
|
||||
-- GET requests
|
||||
get "/" $ do
|
||||
shortCache
|
||||
status ok200
|
||||
S.html $ index $ do
|
||||
compiledElmApp
|
||||
boilerplateJs
|
||||
|
||||
get "/favicon.ico/" $ do
|
||||
shortCache
|
||||
status notFound404
|
||||
S.html $ "you want a favi-<i>what</i>now!?"
|
||||
|
||||
-- ERR
|
||||
notFound $ do
|
||||
noCache
|
||||
status methodNotAllowed405
|
||||
S.text "Verb disallowed; OR, route doesn't exist :("
|
||||
|
||||
|
||||
-- FUNC
|
||||
serverErrorReadFile :: E.IOException -> Js
|
||||
serverErrorReadFile e = H.toHtml $ "document.getElementById('body').innerHTML='Server-side error occurred: "
|
||||
++ (show e)
|
||||
++ "; report this to a site administrator: "
|
||||
++ adminContact
|
||||
++ "';"
|
||||
|
||||
shortCache :: ActionM ()
|
||||
shortCache = addHeader "Cache-Control" "max-age=21600"
|
||||
|
||||
noCache :: ActionM ()
|
||||
noCache = addHeader "Cache-Control" "no-cache"
|
||||
|
||||
embedJs :: Js -> H.Html
|
||||
embedJs js = H.script $ js
|
||||
|
||||
-- TYPES
|
||||
type AssetPath = FilePath
|
||||
type Js = H.Html
|
|
@ -1,91 +0,0 @@
|
|||
cabal-version: 2.2
|
||||
|
||||
-- This file has been generated from package.yaml by hpack version 0.37.0.
|
||||
--
|
||||
-- see: https://github.com/sol/hpack
|
||||
|
||||
name: hs-server
|
||||
version: 0.1.0.0
|
||||
description: Please see README.md
|
||||
author: mtgmonkey
|
||||
maintainer: mtgmonkey
|
||||
copyright: 2025 mtgmonkey
|
||||
license: BSD-3-Clause
|
||||
license-file: LICENSE
|
||||
build-type: Simple
|
||||
extra-source-files:
|
||||
README.md
|
||||
CHANGELOG.md
|
||||
|
||||
library
|
||||
exposed-modules:
|
||||
ElmskellTypes
|
||||
other-modules:
|
||||
Paths_hs_server
|
||||
autogen-modules:
|
||||
Paths_hs_server
|
||||
hs-source-dirs:
|
||||
src
|
||||
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints
|
||||
build-depends:
|
||||
aeson >=2.2.3 && <2.3
|
||||
, base >=4.19.2 && <4.20
|
||||
, blaze-html >=0.9.2 && <0.10
|
||||
, blaze-markup >=0.8.3 && <0.9
|
||||
, directory >=1.3.8 && <1.4
|
||||
, elm-street >=0.2.2 && <0.3
|
||||
, http-types >=0.12.4 && <0.13
|
||||
, scotty ==0.22.*
|
||||
, text >=2.1.1 && <2.2
|
||||
, wai-extra >=3.1.16 && <3.2
|
||||
, warp >=3.4.7 && <3.5
|
||||
default-language: Haskell2010
|
||||
|
||||
executable hs-server-exe
|
||||
main-is: Main.hs
|
||||
other-modules:
|
||||
Paths_hs_server
|
||||
autogen-modules:
|
||||
Paths_hs_server
|
||||
hs-source-dirs:
|
||||
app
|
||||
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
|
||||
build-depends:
|
||||
aeson >=2.2.3 && <2.3
|
||||
, base >=4.19.2 && <4.20
|
||||
, blaze-html >=0.9.2 && <0.10
|
||||
, blaze-markup >=0.8.3 && <0.9
|
||||
, directory >=1.3.8 && <1.4
|
||||
, elm-street >=0.2.2 && <0.3
|
||||
, hs-server
|
||||
, http-types >=0.12.4 && <0.13
|
||||
, scotty ==0.22.*
|
||||
, text >=2.1.1 && <2.2
|
||||
, wai-extra >=3.1.16 && <3.2
|
||||
, warp >=3.4.7 && <3.5
|
||||
default-language: Haskell2010
|
||||
|
||||
test-suite hs-server-test
|
||||
type: exitcode-stdio-1.0
|
||||
main-is: Spec.hs
|
||||
other-modules:
|
||||
Paths_hs_server
|
||||
autogen-modules:
|
||||
Paths_hs_server
|
||||
hs-source-dirs:
|
||||
test
|
||||
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
|
||||
build-depends:
|
||||
aeson >=2.2.3 && <2.3
|
||||
, base >=4.19.2 && <4.20
|
||||
, blaze-html >=0.9.2 && <0.10
|
||||
, blaze-markup >=0.8.3 && <0.9
|
||||
, directory >=1.3.8 && <1.4
|
||||
, elm-street >=0.2.2 && <0.3
|
||||
, hs-server
|
||||
, http-types >=0.12.4 && <0.13
|
||||
, scotty ==0.22.*
|
||||
, text >=2.1.1 && <2.2
|
||||
, wai-extra >=3.1.16 && <3.2
|
||||
, warp >=3.4.7 && <3.5
|
||||
default-language: Haskell2010
|
|
@ -1,68 +0,0 @@
|
|||
name: hs-server
|
||||
version: 0.1.0.0
|
||||
license: BSD-3-Clause
|
||||
author: "mtgmonkey"
|
||||
maintainer: "mtgmonkey"
|
||||
copyright: "2025 mtgmonkey"
|
||||
|
||||
extra-source-files:
|
||||
- README.md
|
||||
- CHANGELOG.md
|
||||
|
||||
# Metadata used when publishing your package
|
||||
# synopsis: Short description of your package
|
||||
# category: Web
|
||||
|
||||
# To avoid duplicated efforts in documentation and dealing with the
|
||||
# complications of embedding Haddock markup inside cabal files, it is
|
||||
# common to point users to the README.md file.
|
||||
description: Please see README.md
|
||||
|
||||
dependencies:
|
||||
- aeson >= 2.2.3 && < 2.3
|
||||
- base >= 4.19.2 && < 4.20
|
||||
- blaze-html >= 0.9.2 && < 0.10
|
||||
- blaze-markup >= 0.8.3 && < 0.9
|
||||
- directory >= 1.3.8 && < 1.4
|
||||
- elm-street >= 0.2.2 && < 0.3
|
||||
- http-types >= 0.12.4 && < 0.13
|
||||
- scotty >= 0.22 && < 0.23
|
||||
- text >= 2.1.1 && < 2.2
|
||||
- wai-extra >= 3.1.16 && < 3.2
|
||||
- warp >= 3.4.7 && < 3.5
|
||||
|
||||
ghc-options:
|
||||
- -Wall
|
||||
- -Wcompat
|
||||
- -Widentities
|
||||
- -Wincomplete-record-updates
|
||||
- -Wincomplete-uni-patterns
|
||||
- -Wmissing-export-lists
|
||||
- -Wmissing-home-modules
|
||||
- -Wpartial-fields
|
||||
- -Wredundant-constraints
|
||||
|
||||
library:
|
||||
source-dirs: src
|
||||
|
||||
executables:
|
||||
hs-server-exe:
|
||||
main: Main.hs
|
||||
source-dirs: app
|
||||
ghc-options:
|
||||
- -threaded
|
||||
- -rtsopts
|
||||
- -with-rtsopts=-N
|
||||
dependencies:
|
||||
- hs-server
|
||||
|
||||
tests:
|
||||
hs-server-test:
|
||||
main: Spec.hs
|
||||
source-dirs: test
|
||||
ghc-options:
|
||||
- -threaded
|
||||
- -rtsopts
|
||||
- -with-rtsopts=-N
|
||||
dependencies:
|
||||
- hs-server
|
|
@ -1,74 +0,0 @@
|
|||
# This file was automatically generated by 'stack init'
|
||||
#
|
||||
# Some commonly used options have been documented as comments in this file.
|
||||
# For advanced use and comprehensive documentation of the format, please see:
|
||||
# https://docs.haskellstack.org/en/stable/yaml_configuration/
|
||||
|
||||
# A 'specific' Stackage snapshot or a compiler version.
|
||||
# A snapshot resolver dictates the compiler version and the set of packages
|
||||
# to be used for project dependencies. For example:
|
||||
#
|
||||
# snapshot: lts-22.28
|
||||
# snapshot: nightly-2024-07-05
|
||||
# snapshot: ghc-9.6.6
|
||||
#
|
||||
# The location of a snapshot can be provided as a file or url. Stack assumes
|
||||
# a snapshot provided as a file might change, whereas a url resource does not.
|
||||
#
|
||||
# snapshot: ./custom-snapshot.yaml
|
||||
# snapshot: https://example.com/snapshots/2024-01-01.yaml
|
||||
snapshot:
|
||||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/23/19.yaml
|
||||
|
||||
# User packages to be built.
|
||||
# Various formats can be used as shown in the example below.
|
||||
#
|
||||
# packages:
|
||||
# - some-directory
|
||||
# - https://example.com/foo/bar/baz-0.0.2.tar.gz
|
||||
# subdirs:
|
||||
# - auto-update
|
||||
# - wai
|
||||
#
|
||||
# packages is represented in package.yaml
|
||||
packages:
|
||||
- .
|
||||
|
||||
nix:
|
||||
enable: true
|
||||
packages: [zlib]
|
||||
|
||||
# Dependency packages to be pulled from upstream that are not in the snapshot.
|
||||
# These entries can reference officially published versions as well as
|
||||
# forks / in-progress versions pinned to a git hash. For example:
|
||||
#
|
||||
# extra-deps:
|
||||
# - acme-missiles-0.3
|
||||
# - git: https://github.com/commercialhaskell/stack.git
|
||||
# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
|
||||
#
|
||||
# extra-deps: []
|
||||
|
||||
# Override default flag values for project packages and extra-deps
|
||||
# flags: {}
|
||||
|
||||
# Extra package databases containing global packages
|
||||
# extra-package-dbs: []
|
||||
|
||||
# Control whether we use the GHC we find on the path
|
||||
# system-ghc: true
|
||||
#
|
||||
# Require a specific version of Stack, using version ranges
|
||||
# require-stack-version: -any # Default
|
||||
# require-stack-version: ">=3.1"
|
||||
#
|
||||
# Override the architecture used by Stack, especially useful on Windows
|
||||
# arch: i386
|
||||
# arch: x86_64
|
||||
#
|
||||
# Extra directories used by Stack for building
|
||||
# extra-include-dirs: [/path/to/dir]
|
||||
# extra-lib-dirs: [/path/to/dir]
|
||||
#
|
||||
# Allow a newer minor version of GHC than the snapshot specifies
|
||||
# compiler-check: newer-minor
|
|
@ -1,13 +0,0 @@
|
|||
# This file was autogenerated by Stack.
|
||||
# You should not edit this file by hand.
|
||||
# For more information, please see the documentation at:
|
||||
# https://docs.haskellstack.org/en/stable/lock_files
|
||||
|
||||
packages: []
|
||||
snapshots:
|
||||
- completed:
|
||||
sha256: 296a7960c37efa382432ab497161a092684191815eb92a608c5d6ea5f894ace3
|
||||
size: 683835
|
||||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/23/19.yaml
|
||||
original:
|
||||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/23/19.yaml
|
41
flake.lock
generated
41
flake.lock
generated
|
@ -1,41 +0,0 @@
|
|||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
<<<<<<< HEAD
|
||||
"lastModified": 1748708770,
|
||||
"narHash": "sha256-q8jG2HJWgooWa9H0iatZqBPF3bp0504e05MevFmnFLY=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a59eb7800787c926045d51b70982ae285faa2346",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-25.05",
|
||||
"type": "indirect"
|
||||
=======
|
||||
"lastModified": 1747958103,
|
||||
"narHash": "sha256-qmmFCrfBwSHoWw7cVK4Aj+fns+c54EBP8cGqp/yK410=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "fe51d34885f7b5e3e7b59572796e1bcb427eccb1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
>>>>>>> master
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,9 +0,0 @@
|
|||
{pkgs ? import <nixpkgs> {}}:
|
||||
pkgs.mkShell {
|
||||
nativeBuildInputs = [
|
||||
pkgs.elmPackages.elm
|
||||
pkgs.elmPackages.elm-format
|
||||
pkgs.uglify-js
|
||||
pkgs.ungoogled-chromium
|
||||
];
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
module ElmskellTypes.Generated.Decoder exposing (..)
|
||||
|
||||
import Iso8601 as Iso
|
||||
import Json.Decode as D exposing (..)
|
||||
import Json.Decode.Pipeline as D exposing (required)
|
||||
|
||||
import ElmskellTypes.Generated.ElmStreet exposing (..)
|
||||
import ElmskellTypes.Generated.Types as T
|
||||
|
||||
|
||||
decodeCommand : Decoder T.Command
|
||||
decodeCommand = elmStreetDecodeEnum T.readCommand
|
||||
|
||||
decodeCookiesKept : Decoder T.CookiesKept
|
||||
decodeCookiesKept = D.succeed T.CookiesKept
|
||||
|> required "keepFont" D.bool
|
||||
|> required "keepPrompt" D.bool
|
||||
|> required "keepTheme" D.bool
|
||||
|
||||
decodeCoreColor : Decoder T.CoreColor
|
||||
decodeCoreColor = elmStreetDecodeEnum T.readCoreColor
|
||||
|
||||
decodeFont : Decoder T.Font
|
||||
decodeFont = D.succeed T.Font
|
||||
|> required "fontSize" D.float
|
||||
|
||||
decodeInput : Decoder T.Input
|
||||
decodeInput = D.succeed T.Input
|
||||
|> required "command" decodeCommand
|
||||
|> required "args" (D.list D.string)
|
||||
|
||||
decodePrompt : Decoder T.Prompt
|
||||
decodePrompt = D.succeed T.Prompt
|
||||
|> required "prompt" D.string
|
||||
|
||||
decodeTheme : Decoder T.Theme
|
||||
decodeTheme = elmStreetDecodeEnum T.readTheme
|
||||
|
||||
decodeThemeColor : Decoder T.ThemeColor
|
||||
decodeThemeColor = elmStreetDecodeEnum T.readThemeColor
|
|
@ -1,52 +0,0 @@
|
|||
module ElmskellTypes.Generated.ElmStreet exposing (..)
|
||||
|
||||
import Json.Encode as E exposing (Value)
|
||||
import Json.Decode as D exposing (Decoder)
|
||||
import Json.Decode.Pipeline as D exposing (..)
|
||||
|
||||
|
||||
elmStreetEncodeMaybe : (a -> Value) -> Maybe a -> Value
|
||||
elmStreetEncodeMaybe enc = Maybe.withDefault E.null << Maybe.map enc
|
||||
|
||||
elmStreetEncodeEither : (a -> Value) -> (b -> Value) -> Result a b -> Value
|
||||
elmStreetEncodeEither encA encB res = E.object <| case res of
|
||||
Err a -> [("Left", encA a)]
|
||||
Ok b -> [("Right", encB b)]
|
||||
|
||||
elmStreetEncodePair : (a -> Value) -> (b -> Value) -> (a, b) -> Value
|
||||
elmStreetEncodePair encA encB (a, b) = E.list identity [encA a, encB b]
|
||||
|
||||
elmStreetEncodeTriple : (a -> Value) -> (b -> Value) -> (c -> Value) -> (a, b, c) -> Value
|
||||
elmStreetEncodeTriple encA encB encC (a, b, c) = E.list identity [encA a, encB b, encC c]
|
||||
|
||||
elmStreetEncodeNonEmpty : (a -> Value) -> (a, List a) -> Value
|
||||
elmStreetEncodeNonEmpty encA (a, xs) = E.list encA <| a :: xs
|
||||
|
||||
decodeStr : (String -> Maybe a) -> String -> Decoder a
|
||||
decodeStr readX x = case readX x of
|
||||
Just a -> D.succeed a
|
||||
Nothing -> D.fail "Constructor not matched"
|
||||
|
||||
elmStreetDecodeEnum : (String -> Maybe a) -> Decoder a
|
||||
elmStreetDecodeEnum r = D.andThen (decodeStr r) D.string
|
||||
|
||||
elmStreetDecodeChar : Decoder Char
|
||||
elmStreetDecodeChar = D.andThen (decodeStr (Maybe.map Tuple.first << String.uncons)) D.string
|
||||
|
||||
elmStreetDecodeEither : Decoder a -> Decoder b -> Decoder (Result a b)
|
||||
elmStreetDecodeEither decA decB = D.oneOf
|
||||
[ D.field "Left" (D.map Err decA)
|
||||
, D.field "Right" (D.map Ok decB)
|
||||
]
|
||||
|
||||
elmStreetDecodePair : Decoder a -> Decoder b -> Decoder (a, b)
|
||||
elmStreetDecodePair decA decB = D.map2 Tuple.pair (D.index 0 decA) (D.index 1 decB)
|
||||
|
||||
elmStreetDecodeTriple : Decoder a -> Decoder b -> Decoder c -> Decoder (a, b, c)
|
||||
elmStreetDecodeTriple decA decB decC = D.map3 (\a b c -> (a,b,c)) (D.index 0 decA) (D.index 1 decB) (D.index 2 decC)
|
||||
|
||||
elmStreetDecodeNonEmpty : Decoder a -> Decoder (a, List a)
|
||||
elmStreetDecodeNonEmpty decA = D.list decA |> D.andThen (\xs -> case xs of
|
||||
h::t -> D.succeed (h, t)
|
||||
_ -> D.fail "Expecting non-empty array")
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
module ElmskellTypes.Generated.Encoder exposing (..)
|
||||
|
||||
import Iso8601 as Iso
|
||||
import Json.Encode as E exposing (..)
|
||||
|
||||
import ElmskellTypes.Generated.ElmStreet exposing (..)
|
||||
import ElmskellTypes.Generated.Types as T
|
||||
|
||||
|
||||
encodeCommand : T.Command -> Value
|
||||
encodeCommand = E.string << T.showCommand
|
||||
|
||||
encodeCookiesKept : T.CookiesKept -> Value
|
||||
encodeCookiesKept x = E.object
|
||||
[ ("tag", E.string "CookiesKept")
|
||||
, ("keepFont", E.bool x.keepFont)
|
||||
, ("keepPrompt", E.bool x.keepPrompt)
|
||||
, ("keepTheme", E.bool x.keepTheme)
|
||||
]
|
||||
|
||||
encodeCoreColor : T.CoreColor -> Value
|
||||
encodeCoreColor = E.string << T.showCoreColor
|
||||
|
||||
encodeFont : T.Font -> Value
|
||||
encodeFont x = E.object
|
||||
[ ("tag", E.string "Font")
|
||||
, ("fontSize", E.float x.fontSize)
|
||||
]
|
||||
|
||||
encodeInput : T.Input -> Value
|
||||
encodeInput x = E.object
|
||||
[ ("tag", E.string "Input")
|
||||
, ("command", encodeCommand x.command)
|
||||
, ("args", (E.list E.string) x.args)
|
||||
]
|
||||
|
||||
encodePrompt : T.Prompt -> Value
|
||||
encodePrompt x = E.object
|
||||
[ ("tag", E.string "Prompt")
|
||||
, ("prompt", E.string x.prompt)
|
||||
]
|
||||
|
||||
encodeTheme : T.Theme -> Value
|
||||
encodeTheme = E.string << T.showTheme
|
||||
|
||||
encodeThemeColor : T.ThemeColor -> Value
|
||||
encodeThemeColor = E.string << T.showThemeColor
|
|
@ -1,197 +0,0 @@
|
|||
module ElmskellTypes.Generated.Types exposing (..)
|
||||
|
||||
import Time exposing (Posix)
|
||||
import Json.Decode exposing (Value)
|
||||
|
||||
|
||||
type Command
|
||||
= ClearCommand
|
||||
| ColorsCommand
|
||||
| CookiesCommand
|
||||
| DebugCommand
|
||||
| FontCommand
|
||||
| HelloCommand
|
||||
| HelpCommand
|
||||
| PromptCommand
|
||||
| ThemeCommand
|
||||
| TodoCommand
|
||||
|
||||
showCommand : Command -> String
|
||||
showCommand x = case x of
|
||||
ClearCommand -> "ClearCommand"
|
||||
ColorsCommand -> "ColorsCommand"
|
||||
CookiesCommand -> "CookiesCommand"
|
||||
DebugCommand -> "DebugCommand"
|
||||
FontCommand -> "FontCommand"
|
||||
HelloCommand -> "HelloCommand"
|
||||
HelpCommand -> "HelpCommand"
|
||||
PromptCommand -> "PromptCommand"
|
||||
ThemeCommand -> "ThemeCommand"
|
||||
TodoCommand -> "TodoCommand"
|
||||
|
||||
readCommand : String -> Maybe Command
|
||||
readCommand x = case x of
|
||||
"ClearCommand" -> Just ClearCommand
|
||||
"ColorsCommand" -> Just ColorsCommand
|
||||
"CookiesCommand" -> Just CookiesCommand
|
||||
"DebugCommand" -> Just DebugCommand
|
||||
"FontCommand" -> Just FontCommand
|
||||
"HelloCommand" -> Just HelloCommand
|
||||
"HelpCommand" -> Just HelpCommand
|
||||
"PromptCommand" -> Just PromptCommand
|
||||
"ThemeCommand" -> Just ThemeCommand
|
||||
"TodoCommand" -> Just TodoCommand
|
||||
_ -> Nothing
|
||||
|
||||
universeCommand : List Command
|
||||
universeCommand = [ ClearCommand
|
||||
, ColorsCommand
|
||||
, CookiesCommand
|
||||
, DebugCommand
|
||||
, FontCommand
|
||||
, HelloCommand
|
||||
, HelpCommand
|
||||
, PromptCommand
|
||||
, ThemeCommand
|
||||
, TodoCommand ]
|
||||
|
||||
type alias CookiesKept =
|
||||
{ keepFont : Bool
|
||||
, keepPrompt : Bool
|
||||
, keepTheme : Bool
|
||||
}
|
||||
|
||||
type CoreColor
|
||||
= Red
|
||||
| Green
|
||||
| Yellow
|
||||
| Blue
|
||||
| Magenta
|
||||
| Cyan
|
||||
| BrightRed
|
||||
| BrightGreen
|
||||
| BrightYellow
|
||||
| BrightBlue
|
||||
| BrightMagenta
|
||||
| BrightCyan
|
||||
|
||||
showCoreColor : CoreColor -> String
|
||||
showCoreColor x = case x of
|
||||
Red -> "Red"
|
||||
Green -> "Green"
|
||||
Yellow -> "Yellow"
|
||||
Blue -> "Blue"
|
||||
Magenta -> "Magenta"
|
||||
Cyan -> "Cyan"
|
||||
BrightRed -> "BrightRed"
|
||||
BrightGreen -> "BrightGreen"
|
||||
BrightYellow -> "BrightYellow"
|
||||
BrightBlue -> "BrightBlue"
|
||||
BrightMagenta -> "BrightMagenta"
|
||||
BrightCyan -> "BrightCyan"
|
||||
|
||||
readCoreColor : String -> Maybe CoreColor
|
||||
readCoreColor x = case x of
|
||||
"Red" -> Just Red
|
||||
"Green" -> Just Green
|
||||
"Yellow" -> Just Yellow
|
||||
"Blue" -> Just Blue
|
||||
"Magenta" -> Just Magenta
|
||||
"Cyan" -> Just Cyan
|
||||
"BrightRed" -> Just BrightRed
|
||||
"BrightGreen" -> Just BrightGreen
|
||||
"BrightYellow" -> Just BrightYellow
|
||||
"BrightBlue" -> Just BrightBlue
|
||||
"BrightMagenta" -> Just BrightMagenta
|
||||
"BrightCyan" -> Just BrightCyan
|
||||
_ -> Nothing
|
||||
|
||||
universeCoreColor : List CoreColor
|
||||
universeCoreColor = [ Red
|
||||
, Green
|
||||
, Yellow
|
||||
, Blue
|
||||
, Magenta
|
||||
, Cyan
|
||||
, BrightRed
|
||||
, BrightGreen
|
||||
, BrightYellow
|
||||
, BrightBlue
|
||||
, BrightMagenta
|
||||
, BrightCyan ]
|
||||
|
||||
type alias Font =
|
||||
{ fontSize : Float
|
||||
}
|
||||
|
||||
type alias Input =
|
||||
{ command : Command
|
||||
, args : List String
|
||||
}
|
||||
|
||||
type alias Prompt =
|
||||
{ prompt : String
|
||||
}
|
||||
|
||||
type Theme
|
||||
= Pit
|
||||
| Dim
|
||||
| Sky
|
||||
| Sun
|
||||
|
||||
showTheme : Theme -> String
|
||||
showTheme x = case x of
|
||||
Pit -> "Pit"
|
||||
Dim -> "Dim"
|
||||
Sky -> "Sky"
|
||||
Sun -> "Sun"
|
||||
|
||||
readTheme : String -> Maybe Theme
|
||||
readTheme x = case x of
|
||||
"Pit" -> Just Pit
|
||||
"Dim" -> Just Dim
|
||||
"Sky" -> Just Sky
|
||||
"Sun" -> Just Sun
|
||||
_ -> Nothing
|
||||
|
||||
universeTheme : List Theme
|
||||
universeTheme = [Pit, Dim, Sky, Sun]
|
||||
|
||||
type ThemeColor
|
||||
= Background
|
||||
| Foreground
|
||||
| Cursor
|
||||
| Black
|
||||
| White
|
||||
| BrightBlack
|
||||
| BrightWhite
|
||||
|
||||
showThemeColor : ThemeColor -> String
|
||||
showThemeColor x = case x of
|
||||
Background -> "Background"
|
||||
Foreground -> "Foreground"
|
||||
Cursor -> "Cursor"
|
||||
Black -> "Black"
|
||||
White -> "White"
|
||||
BrightBlack -> "BrightBlack"
|
||||
BrightWhite -> "BrightWhite"
|
||||
|
||||
readThemeColor : String -> Maybe ThemeColor
|
||||
readThemeColor x = case x of
|
||||
"Background" -> Just Background
|
||||
"Foreground" -> Just Foreground
|
||||
"Cursor" -> Just Cursor
|
||||
"Black" -> Just Black
|
||||
"White" -> Just White
|
||||
"BrightBlack" -> Just BrightBlack
|
||||
"BrightWhite" -> Just BrightWhite
|
||||
_ -> Nothing
|
||||
|
||||
universeThemeColor : List ThemeColor
|
||||
universeThemeColor = [ Background
|
||||
, Foreground
|
||||
, Cursor
|
||||
, Black
|
||||
, White
|
||||
, BrightBlack
|
||||
, BrightWhite ]
|
File diff suppressed because it is too large
Load diff
32
justfile
32
justfile
|
@ -1,32 +0,0 @@
|
|||
produce: produce-elm haskell
|
||||
echo "REMEMBER to RESTART elmskell.service TO UPDATE SITE IN PLACE"
|
||||
echo "REMEMBER to RUN sudo iptables-apply -t 60 /etc/iptables/iptables.rules IF YOU HAVEN'T SINCE RESTART"
|
||||
|
||||
types: haskell
|
||||
rm -rf frontend/src/ElmskellTypes/Generated
|
||||
stack exec ~/.local/bin/hs-server-exe
|
||||
|
||||
compile: elm haskell
|
||||
|
||||
run: produce exec
|
||||
|
||||
exec:
|
||||
stack exec ~/.local/bin/hs-server-exe
|
||||
|
||||
haskell:
|
||||
cd backend && stack install
|
||||
|
||||
elm:
|
||||
cd frontend && elm make src/Main.elm --output=../assets/js/main.js
|
||||
rm -rf frontend/elm-stuff
|
||||
|
||||
produce-elm:
|
||||
cd frontend && elm make src/Main.elm --optimize --output=tmp.js
|
||||
mv frontend/tmp.js assets/js/tmp.js
|
||||
rm -rf frontend/elm-stuff
|
||||
rm assets/js/main.js
|
||||
esbuild assets/js/tmp.js --minify --target=es5 --outfile=assets/js/main.js
|
||||
rm assets/js/tmp.js
|
||||
|
||||
format-elm:
|
||||
elm-format frontend/src/Main.elm --yes
|
Loading…
Add table
Add a link
Reference in a new issue