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

trying to merge main to dolora5 #90

Closed
wants to merge 76 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
d9052fd
Add first section
kharus May 29, 2023
466356c
Add text
kharus May 29, 2023
1819a30
Add simple proxy section
kharus May 29, 2023
294a6ec
Add coloring
kharus May 29, 2023
fe991a5
Add 18xxx redirect section
kharus May 29, 2023
b7b551f
WebSocket setup
kharus May 29, 2023
e1ffd2a
Tweaks
kharus May 29, 2023
b49383c
Tweaks
kharus May 29, 2023
e2e89c1
Tweaks
kharus May 29, 2023
4d8fa16
Re-written text
kharus May 29, 2023
710eb18
more verbose explanation of why we use CCLAW_HTTPS
mengwong May 29, 2023
f58e18f
Docs: say not to set CCLAW_HTTPS on your local dev environment.
mengwong May 29, 2023
f238798
Merge pull request #84 from smucclaw/20230529-toggle-https
mengwong May 29, 2023
2417f63
WIP: start to import the ladder-diagram library
mengwong May 23, 2023
0ebcbc9
starting work on integrating ladder diagrams into Vue
mengwong May 28, 2023
4d2eaa6
WIP: start to import the ladder-diagram library
mengwong May 23, 2023
8fd459b
added a few type signatures to clarify functions
May 24, 2023
aecc569
Revert "added a few type signatures to clarify functions"
joewatt95 May 26, 2023
b68e78b
starting work on integrating ladder diagrams into Vue
mengwong May 28, 2023
8a9de76
ladder diagram routing is good to go
mengwong May 28, 2023
ae8548b
restore original QuestionDiagram.vue
mengwong May 28, 2023
1cb8737
silence warning about clippath being a customElement
mengwong May 28, 2023
bc567ba
initial integration working, need to support canvas next
mengwong May 28, 2023
00c0659
ladder diagram reflects the questions via the Store
mengwong May 28, 2023
e5f3ea6
diagram live-updates on the main Questions page.
mengwong May 28, 2023
39a6361
reduce verbosity
mengwong May 28, 2023
dfbe8ab
uncomment https
mengwong May 29, 2023
bc8e577
rev ladder-diagram github commit point
mengwong May 29, 2023
ae2ec52
add nested routes /lang/question
Meowyam May 30, 2023
c523205
updated routes to be nested routes and show/hide ladder etc. for diff…
Meowyam Jun 1, 2023
192963f
update full names of languages
Meowyam Jun 1, 2023
176014b
reinstated the Notification in Questions
Meowyam Jun 1, 2023
25964ee
update package.json to pull latest HEAD from smucclaw/ladder-diagram
mengwong Jun 1, 2023
53bd933
Fix ladder diagram rendering
lczm Jun 1, 2023
ec02d0a
Merge pull request #86 from smucclaw/jules/fix-ladder-diagram-rendering
lczm Jun 1, 2023
f724386
remove devServer stanza again, that was a rogue commit
mengwong Jun 2, 2023
90a0a8d
Merge pull request #87 from smucclaw/20230602-remove-devServer-again
mengwong Jun 2, 2023
cee47a1
clicking on diagram mutates form state by cycling through markings
mengwong Jun 2, 2023
87480ff
Merge pull request #88 from smucclaw/20230602-click-on-diagrams
mengwong Jun 2, 2023
f5220ef
revise vue-pure-pdpa vue-big vue-small setup instructions to work fro…
mengwong Jun 6, 2023
4586058
reminder about gunicorn
mengwong Jun 6, 2023
b8a709d
include alias for / path
Meowyam Jun 6, 2023
7b425c9
Merge pull request #91 from smucclaw/dolora5
maxloosmu Jun 6, 2023
0beee35
Fix clickable ladder diagram
lczm Jun 7, 2023
42dd7d1
Merge pull request #92 from smucclaw/jules/add-clicking-to-ladder
mengwong Jun 8, 2023
0a0df2e
grey out disabled buttons
Meowyam Jun 12, 2023
c78a589
PDPADBNO becomes Interview
joewatt95 Jun 14, 2023
e906ecd
Merge pull request #93 from smucclaw/pdpadbno-becomes-interview
joewatt95 Jun 14, 2023
fd7ed8a
Revert "PDPADBNO becomes Interview"
joewatt95 Jun 14, 2023
a5d4ed6
Merge pull request #94 from smucclaw/revert-93-pdpadbno-becomes-inter…
joewatt95 Jun 14, 2023
c2fe966
docs: quick documentation note for anyall pointing to the haskell side
mengwong Jun 14, 2023
0aba42e
switch RuleLib/PDPADBNO to RuleLib/Interview to match dsl repo
mengwong Jun 14, 2023
f374392
Initial commit.
joewatt95 Jun 15, 2023
6171913
fix compilation
joewatt95 Jun 15, 2023
dbe29f7
rename PDPADBNO to fix merge conflict
joewatt95 Jun 15, 2023
5c3503e
Merge branch '20230608-develop' into orderedmap-becomes-hashmap
joewatt95 Jun 15, 2023
2f4e90f
no need to import Data.Hashable
joewatt95 Jun 15, 2023
96c3c94
Merge pull request #95 from smucclaw/orderedmap-becomes-hashmap
joewatt95 Jun 15, 2023
228b1e0
Change schedule1_part1 to interviewRules
joewatt95 Jun 15, 2023
6133cac
Merge pull request #96 from smucclaw/20230608-develop
joewatt95 Jun 15, 2023
87a1116
Revert to 0aba42e72c7544128acac2df179a8195e7e05180
joewatt95 Jun 15, 2023
50bcb1f
Merge pull request #97 from smucclaw/revert-to-0aba
joewatt95 Jun 15, 2023
e98b4ee
update pdpa to interview and related variables
Meowyam Jun 15, 2023
24cb568
updated routes with questions
Meowyam Jun 15, 2023
c6eb402
update spago to v21, try to add source maps to spago
mengwong Jun 15, 2023
dfec706
Merge pull request #98 from smucclaw/20230615-add-sourcemaps
mengwong Jun 15, 2023
e1e338f
Add config for proxied version
kharus Jul 7, 2023
c6ab738
Merge pull request #99 from smucclaw/proxy-433
mengwong Jul 13, 2023
45ffb0f
Merge pull request #100 from smucclaw/document-https
kharus Sep 4, 2023
1a2190f
Add variables to configure WebSocket host and protocol
kharus Oct 2, 2023
c5369dc
Merge pull request #101 from smucclaw/wss-vars
kharus Oct 2, 2023
b5bdda4
bump deps
joewatt95 Jul 8, 2024
63c83b5
Merge pull request #102 from smucclaw/deps
joewatt95 Jul 8, 2024
664e02c
bump github actions and nodejs
joewatt95 Jul 9, 2024
2a9da8e
bump nvmrc
joewatt95 Jul 9, 2024
9dc0244
Merge pull request #103 from smucclaw/gh-workflows
joewatt95 Jul 9, 2024
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
4 changes: 2 additions & 2 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ runs:
using: "composite"
steps:
- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "16.x"
node-version: "20.x"
- name: Install Dependencies
run: npm install
shell: bash
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
- name: Build
Expand All @@ -18,7 +18,7 @@ jobs:
VUE_APP_BROWSER_NAME: "CCLAW"
VUE_APP_NAME: "PDPA DBNO PoC - Draft"
- name: Deploy
uses: crazy-max/ghaction-github-pages@v3
uses: crazy-max/ghaction-github-pages@v4
with:
target_branch: gh-pages
build_dir: dist
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
- name: Test Purescript
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19.1.0
20.5.1
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ NVM is a version manager for node. Follow the instructions on the [nvm github](h

First, install nvm from https://nvm.sh/

Then run the following set of install scripts:
Then run the following set of install scripts, from inside the vue-pure-pdpa directory:

```shell
$ echo 18.16.0 > .nvmrc
$ nvm use
$ nvm install
$ nvm use
$ nvm exec
$ npm install -g node-gyp@latest
$ npm install
Expand Down Expand Up @@ -90,15 +89,19 @@ You only have to do this once:
```
mkdir ~/v8kworkdir
cd ~/v8kworkdir
export V8K_WORKDIR=~/v8kworkdir
rsync -va ~/src/smucclaw/vue-pure-pdpa/ vue-big/
export V8K_WORKDIR=$HOME/v8kworkdir
git clone git://github.com/smucclaw/vue-pure-pdpa
rsync -va vue-pure-pdpa/ vue-big/
(cd vue-big; npm i; npm run deps)
rsync -va --exclude={.spago,.git,node_modules} vue-big/ vue-small/
cd vue-small
ln -s ../vue-big/.git .
ln -s ../vue-big/node_modules .
ln -s ../vue-big/.spago .
```

Remember to update your gunicorn conf file to set V8K_WORKDIR to the path as above.

This sets you up with `vue-small`, which is a copy of `vue-big`, which is a copy of the `vue-pure-pdpa` repo.

`vue-small` takes up a bit less space, by taking advantage of symlinks to reuse existing files that don't change across copies.
Expand Down
158 changes: 158 additions & 0 deletions bin/https.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
## Initial state.
In the initial state, both Gunicorn and Vue expose HTTPS on both the loopback (127.0.0.1)
and network (172.x.x.x) interfaces and manage their own HTTPS configuration.

```mermaid
flowchart RL
subgraph network
network_port_8400(172:8400)-- https ---id1(( ))
network_port_8401(172:8401)-- https ---id2(( ))
end
subgraph localhost
loop_port_8400(127:8400)-- https ---id3(( ))
loop_port_8401(127:8401)-- https ---id4(( ))
end
gunicorn[[ gunicorn ]]---network_port_8400
gunicorn---loop_port_8400
vue[[ vue ]]---network_port_8401
vue---loop_port_8401
```

This creates a hassle during local development as HTTPS either needs to be disabled or configured.
Disabling HTTPS, while easy, creates unnecessary differences in GitHub.
Configuring HTTPS for local development is unnecessary work.

## Terminate https
I thought it might be beneficial to terminate HTTPS on Nginx and have Gunicorn and Vue always use plain HTTP.

```mermaid
flowchart LR
subgraph network
direction LR
id1(( )) -- HTTPS --- network_port_8400(172:8400)
id2(( )) -- HTTPS --- network_port_8401(172:8401)
end
nginx[[nginx]]
network_port_8400 --- nginx
network_port_8401 --- nginx

subgraph localhost
direction LR
id3(( )) -- http --- loop_port_8400(127:8400)
id4(( ))-- http --- loop_port_8401(127:8401)
end
gunicorn[[ gunicorn ]]
loop_port_8400---gunicorn
vue[[ vue ]]
loop_port_8401---vue
nginx---id3
nginx---id4
linkStyle 0 stroke:red;
linkStyle 1 stroke:red;
linkStyle 4 stroke:blue;
linkStyle 5 stroke:blue;
```

## Complication #1: Vue doesn't give up the network port.

Unfortunately, Vue doesn't give up the network port. So, after encountering some troubles,
I had to set up a less straightforward scheme where Nginx proxies the ports by adding 1 to the port number.
So HTTPS:8400 is forwarded to HTTP:18400.

```mermaid
flowchart LR
subgraph network
direction LR
https_172_8400(( )) -- HTTPS --- network_port_8400(172:8400)
https_172_8401(( )) -- HTTPS --- network_port_8401(172:8401)
https_172_18401(( )) -- HTTP --- network_port_18401(172:18401)
end
nginx[[nginx]]
network_port_8400 --- nginx
network_port_8401 --- nginx

subgraph localhost
direction LR
http_127_8400(( )) -- http --- loop_port_18400(127:18400)
http_127_8401(( ))-- http --- loop_port_18401(127:18401)
end
gunicorn[[ gunicorn ]]
loop_port_18400---gunicorn
vue[[ vue ]]
loop_port_18401---vue
nginx---http_127_8400
nginx---http_127_8401
network_port_18401---vue
linkStyle 0 stroke:red;
linkStyle 1 stroke:red;
linkStyle 2 stroke:blue;
linkStyle 5 stroke:blue;
linkStyle 6 stroke:blue;
```

Respective redirect config for nginx
```
proxy_pass http://127.0.0.1:1$server_port;
```
Might confuse people as this is an unusual redirect setup.

## Complication #2: Vue needs to proxy WebSockets too.
Vue relies on WebSockets for communication between the client (web browser) and the server in development mode.
Therefore, WebSockets need to be proxied as well.

```mermaid
flowchart LR
subgraph network
direction LR
https_172_8400(( )) -- HTTPS --- network_port_8400(172:8400)
https_172_8401(( )) -- HTTPS --- network_port_8401(172:8401)
wss_172_8401(( )) -- WSS --- network_port_8401(172:18401)
http_172_8401(( )) -- HTTP --- network_port_18401(172:18401)
ws_172_18401(( )) -- WS --- network_port_18401(172:18401)
end
nginx[[nginx]]
network_port_8400 --- nginx
network_port_8401 --- nginx

subgraph localhost
direction LR
http_127_8400(( )) -- http --- loop_port_18400(127:18400)
http_127_8401(( ))-- http --- loop_port_18401(127:18401)
ws_127_8401(( ))-- WS --- loop_port_18401(127:18401)
end
gunicorn[[ gunicorn ]]
loop_port_18400---gunicorn
vue[[ vue ]]
loop_port_18401---vue
nginx---http_127_8400
nginx---http_127_8401
nginx---ws_127_8401
network_port_18401---vue
linkStyle 0 stroke:red;
linkStyle 1 stroke:red;
linkStyle 2 stroke:red;
linkStyle 3 stroke:blue;
linkStyle 4 stroke:blue;
linkStyle 7 stroke:blue;
linkStyle 8 stroke:blue;
linkStyle 9 stroke:blue;
```

This creates a further complication that when Vue is started in HTTP mode,
it creates a dynamically unsecured WebSocket backlink. By default, the Vue client in the
browser will try to communicate with the Vue server on `ws://host:18401`, which is not served.
This can be explicitly configured in `vue.config.js`:

```javascript
devServer: {
client: {
webSocketURL: 'wss://cclaw.legalese.com:8408/ws'
}
}
```
However, it needs to know the port on the proxy. This can still be done by templating `vue.config`
during the generation of the `vue-0xx` work directory, as the external port is known at the time of
`vue-0xx` generation. But it further complicates the setup and adds some more "magic".

Basically, what was expected to be a simple proxy setup that simplifies the configuration turned
out to be a rather complex setup relying on non-standard configurations and runtime template generation.
4 changes: 2 additions & 2 deletions bin/v8k
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def do_up(args: argparse.Namespace, workdir: str):
print("refreshing the purs file", file=sys.stderr)
# [TODO] do this in a more atomic way with a tmp file and a rename, because the vue server may try to
# reread the file too soon, when the cp hasn't completed.
purs_file = join(e['dir'], "src", "RuleLib", "PDPADBNO.purs")
purs_file = join(e['dir'], "src", "RuleLib", "Interview.purs")
print(f"cp {args.filename} {purs_file}", file=sys.stderr)
subprocess.run(["cp", args.filename, purs_file])
subprocess.run(["touch", join(e['dir'], "v8k.json")])
Expand Down Expand Up @@ -184,7 +184,7 @@ def do_up(args: argparse.Namespace, workdir: str):
rsync_command = f"rsync -a {workdir}/vue-small/ {server_config['dir']}/"
print(rsync_command, file=sys.stderr)
subprocess.run([rsync_command], shell=True)
subprocess.run(["cp", args.filename, join(server_config['dir'], "src", "RuleLib", "PDPADBNO.purs")])
subprocess.run(["cp", args.filename, join(server_config['dir'], "src", "RuleLib", "Interview.purs")])

with open(join(server_config['dir'], "v8k.json"), "w") as write_file:
json.dump(server_config, write_file)
Expand Down
Loading