Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web app #116

Merged
merged 70 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
adca429
Initial web view
georgefst Aug 20, 2020
3c48dd7
Correct cabal file name
georgefst Aug 20, 2020
5574725
Work around GHCJS bug
georgefst Aug 21, 2020
c4defbc
Rainbow parens
georgefst Aug 21, 2020
2dbc8e4
Clean up HTML generation
georgefst Aug 21, 2020
c9c8687
Use no color options, since we set manually anyway
georgefst Aug 21, 2020
18f9f75
Style from CSS
georgefst Aug 21, 2020
749f138
Separate CSS file
georgefst Aug 22, 2020
3638c56
Use labels
georgefst Aug 22, 2020
07d72b0
Better colours
georgefst Aug 22, 2020
73a86b6
Add title
georgefst Aug 22, 2020
057b823
Formatting
georgefst Oct 20, 2020
e6b027d
Improve CSS styling
georgefst Oct 21, 2020
03efdd7
Merge branch 'master' into web
georgefst Sep 20, 2022
79794d0
Bump deps for GHC 9.2
georgefst Sep 20, 2022
d6303bc
Bump Miso
georgefst Sep 20, 2022
aecbd24
Set correct base bounds for GHCJS build
georgefst Sep 20, 2022
a05e1b1
Unconditional Miso bounds
georgefst Sep 20, 2022
3a518bd
Remove manual `index.html`
georgefst Sep 20, 2022
31c6e76
Bump Miso
georgefst Sep 20, 2022
4d963e3
Use upstream patch instead of allow-newer
georgefst Sep 20, 2022
c1eb7da
Add comment about patches
georgefst Sep 20, 2022
5d11e90
Add comment about shipping CSS
georgefst Sep 20, 2022
40bce24
Run Fourmolu
georgefst Sep 20, 2022
8532cd5
Widen base bound for CI
georgefst Sep 20, 2022
7b89800
Import/export lists
georgefst Sep 20, 2022
1a48dda
Use cabal-version supported by Miso
georgefst Sep 20, 2022
a510e0c
No unused bindings
georgefst Sep 20, 2022
eae19b2
Remove hie.yaml
georgefst Sep 20, 2022
b726082
Start with empty text box
georgefst Sep 20, 2022
4d9c1fd
Rename
georgefst Sep 20, 2022
d484833
refactor: Avoid GADT
georgefst Sep 21, 2022
d949896
Minor comment fix
georgefst Sep 21, 2022
e6632a2
Remove TODO
georgefst Sep 21, 2022
bb014a0
Simplify cabal.project
georgefst Sep 21, 2022
2e93964
Minor refactor
georgefst Sep 21, 2022
6b8cf7c
Minor refactor
georgefst Sep 21, 2022
dbb2f2b
Clarify comment
georgefst Sep 21, 2022
d45c8b2
Format default.nix
georgefst Sep 21, 2022
d99fc1a
Nix refactor
georgefst Sep 21, 2022
c1b4bec
Copy style.css alongside output files
georgefst Sep 21, 2022
06296bc
Add comment about GHCJS workaround
georgefst Sep 21, 2022
3771a4f
Remove `error` - log instead
georgefst Sep 21, 2022
882d149
Better logging
georgefst Sep 21, 2022
d30ae56
CSS improvements
georgefst Sep 22, 2022
6233522
Narrow scope of disabling selection
georgefst Sep 22, 2022
1a958f2
Widen base bound for CI
georgefst Sep 22, 2022
ad5be4d
Sort controls in more intuitive order
georgefst Sep 25, 2022
15808a6
Smaller gap between rows
georgefst Sep 25, 2022
3ee6fac
Set slider minimums as 0 when possible
georgefst Sep 25, 2022
bf6d597
Only build pretty-simple package in cabal CI. Build web with Nix in CI.
cdepillabout Sep 25, 2022
de4ade1
Workaround cabal solver not working on recent GHC with jsaddle.
cdepillabout Sep 25, 2022
a6a2cab
Add choice of example inputs
georgefst Sep 25, 2022
58130ed
Narrow scope of disabling selection
georgefst Sep 25, 2022
f3c54e4
Use consistent width for drop-downs
georgefst Sep 25, 2022
f7e5de9
Align options text with corresponding element
georgefst Sep 25, 2022
2a1fea9
Better padding etc.
georgefst Sep 25, 2022
7d004e1
Interesting examples only
georgefst Sep 25, 2022
e3baddc
Remove margins on `pre`
georgefst Sep 25, 2022
692919b
Set CSS mime type
georgefst Sep 25, 2022
ceaaa96
Try using miso cache for building web
cdepillabout Sep 27, 2022
a33d5e6
Merge pull request #117 from cdepillabout/web-ci
cdepillabout Sep 28, 2022
59e6741
Add deployment workflow
georgefst Sep 28, 2022
f85bf50
testing
georgefst Sep 28, 2022
ea06d7d
Add explanation how to run local web server
cdepillabout Sep 28, 2022
e0215b7
fix deploy path
georgefst Sep 28, 2022
877d419
no symlinks
georgefst Sep 28, 2022
f75fe08
right folder
georgefst Sep 28, 2022
cd50386
actual right folder
georgefst Sep 28, 2022
932887a
Merge pull request #119 from cdepillabout/web-explanation
cdepillabout Oct 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 35 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: CI

# Trigger the workflow on push or pull request, but only for the master branch
on:
pull_request:
push:
branches: [master]
# TODO use this trigger once deploy tested
# on:
# pull_request:
# push:
# branches: [master]

jobs:
cabal:
Expand All @@ -23,8 +24,9 @@ jobs:
- "8.4.4"
- "8.6.5"
- "8.8.4"
- "8.10.4"
- "9.0.1"
- "8.10.7"
- "9.0.2"
- "9.2.4"

steps:
- uses: actions/checkout@v2
Expand All @@ -46,11 +48,24 @@ jobs:
- name: Build
run: |
cabal update
cabal build all --enable-tests --enable-benchmarks --write-ghc-environment-files=always --flags="buildexample"
# TODO: We have a problem where cabal is not able to come up with a
# build plan on GHC-9.2 because the ./cabal.project file defines both
# pretty-simple, and ./web as packages. ./web uses a version of jsaddle
# that doesn't seem to work yet on GHC-9.2. It doesn't seem possible
# to tell cabal to just ignore the web package, and only run the solver
# for pretty-simple.
#
# This hacky workaround just deletes the cabal.project file, so that
# cabal doesn't realize there is another package in ./web.
#
# This workaround can likely be removed when we move to a more recent
# version of jsaddle.
rm ./cabal.project
cabal build package:pretty-simple --enable-tests --enable-benchmarks --write-ghc-environment-files=always --flags="buildexample"

- name: Test
run: |
cabal test all --enable-tests
cabal test package:pretty-simple --enable-tests

stack:
name: stack / ubuntu-latest
Expand Down Expand Up @@ -83,3 +98,15 @@ jobs:
run: |
stack test

nix-build-web:
name: Nix build GHCJS web
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v16
with:
extra_nix_config: |
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= miso-haskell.cachix.org-1:6N2DooyFlZOHUfJtAx1Q09H0P5XXYzoxxQYiwn6W1e8=
substituters = https://cache.nixos.org/ https://miso-haskell.cachix.org
- name: Build web
run: nix-build ./web
27 changes: 27 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# TODO use this trigger once tested
# on:
# push:
# branches:
# - master
on:
pull_request:

jobs:
deploy:
name: Nix build and deploy GHCJS web app
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v16
with:
extra_nix_config: |
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= miso-haskell.cachix.org-1:6N2DooyFlZOHUfJtAx1Q09H0P5XXYzoxxQYiwn6W1e8= haskell-pretty-simple.cachix.org-1:AWHkzPidwcDzWUIUjKcx/PYgud2OBAa9SNUEoIOsATY=
substituters = https://cache.nixos.org/ https://miso-haskell.cachix.org https://haskell-pretty-simple.cachix.org
- name: Build
run: |
nix-build ./web
cp -rL result result-no-symlinks
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: result-no-symlinks/bin/web.jsexe
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ cabal.sandbox.config
*.hp
*.eventlog
.stack-work/
web/result
12 changes: 12 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
packages:
.
web

constraints: miso +jsaddle

-- https://github.com/ghcjs/jsaddle/pull/133
source-repository-package
type: git
location: https://github.com/avanov/jsaddle
tag: 838a2133f15085c5b6b75bdd0647ac5033c59380
subdir: jsaddle jsaddle-warp
9 changes: 6 additions & 3 deletions src/Text/Pretty/Simple/Internal/Printer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,11 @@ hCheckTTY h options = liftIO $ conv <$> tty
-- suitable for passing to any /prettyprinter/ backend.
-- Used by 'Simple.pString' etc.
layoutString :: OutputOptions -> String -> SimpleDocStream Style
layoutString opts =
annotateStyle opts
. removeTrailingWhitespace
layoutString opts = annotateStyle opts . layoutStringAbstract opts

layoutStringAbstract :: OutputOptions -> String -> SimpleDocStream Annotation
layoutStringAbstract opts =
removeTrailingWhitespace
. layoutSmart defaultLayoutOptions
{layoutPageWidth = AvailablePerLine (outputOptionsPageWidth opts) 1}
. indent (outputOptionsInitialIndent opts)
Expand Down Expand Up @@ -302,6 +304,7 @@ data Annotation
| Quote
| String
| Num
deriving (Eq, Show)

-- | Replace non-printable characters with hex escape sequences.
--
Expand Down
16 changes: 16 additions & 0 deletions web/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

# pretty-simple Web Page

This directory contains an interactive web page that can be compiled with GHCJS
to show how `pretty-simple` works.

This Haskell package can be built with GHCJS with the command `nix-build`.
You'll need Nix [installed](https://nixos.org/download.html) for this to work.
You'll also need to setup the Miso Nix cache, as explained
[here](https://github.com/cdepillabout/pretty-simple/pull/117#issuecomment-1258023974).

This Haskell package can also be built with GHC with the command `cabal build web`.
Running this executable with `cabal run web` will start a web server listening on
`0.0.0.0:8000`. You should be able to see the web page by opening
<http://localhost:8000> in a web browser. _Note_ that you will need to run
`cabal run web` within this current directory.
40 changes: 40 additions & 0 deletions web/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
with (import
(builtins.fetchTarball {
url =
"https://github.com/dmjio/miso/archive/refs/tags/1.8.3.tar.gz";
sha256 = "0kcr5agbcynm003zj70yfkhsc169ahdcp9pkyr795p5mc3ykycjl";
})
{ });
#TODO we can remove all these patches once we're not stuck on such old tools
# unfortunately GHCJS 8.10.7 has serious performance issues: https://github.com/dmjio/miso/pull/693
let
hp = pkgs.haskell.packages.ghcjs86.override {
all-cabal-hashes = builtins.fetchurl {
url =
"https://github.com/commercialhaskell/all-cabal-hashes/archive/ead1bd926a1b10b04a5c07c8f15827091fa98b38.tar.gz";
sha256 = "15i7ia241wb3s9f6l9n2bqldb4ii73xrj49rfr02q43iqbmdjddv";
};
};
prettyprinter = hp.callHackage "prettyprinter" "1.7.0" { };
prettyprinter-ansi-terminal =
hp.callHackage "prettyprinter-ansi-terminal" "1.1.2" {
prettyprinter = prettyprinter;
};
app = hp.callCabal2nix "web" ./. {
prettyprinter = prettyprinter;
pretty-simple = hp.callCabal2nix "pretty-simple" ./.. {
prettyprinter = prettyprinter;
prettyprinter-ansi-terminal = prettyprinter-ansi-terminal;
};
};
in
pkgs.buildEnv {
name = "pretty-simple-web";
paths = [
app
(pkgs.runCommand "css" { } ''
mkdir -p $out/bin/web.jsexe
cp ${./style.css} $out/bin/web.jsexe/style.css
'')
];
}
Loading