Skip to content

Commit f74ace6

Browse files
committed
fixup! fixup! fixup! fixup! fixup! fixup! fixup! ci: Fixes
1 parent ffefba2 commit f74ace6

File tree

5 files changed

+127
-128
lines changed

5 files changed

+127
-128
lines changed

.github/workflows/ci.yaml renamed to .github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919
steps:
2020
- uses: actions/checkout@v4
21-
- run: go version
21+
- run: go version
2222
- uses: actions/setup-go@v4
2323
with:
2424
go-version-file: ./go.mod
@@ -33,7 +33,7 @@ jobs:
3333
go-version-file: ./go.mod
3434
- run: ./ci/test.sh
3535
- uses: actions/upload-artifact@v2
36-
if: always()
36+
if: always()
3737
with:
3838
name: coverage.html
3939
path: ./ci/out/coverage.html

ci/fmt.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ npx [email protected] \
1010
--write \
1111
--log-level=warn \
1212
--print-width=90 \
13-
--use-tabs \
1413
--no-semi \
1514
--single-quote \
1615
--arrow-parens=avoid \

examples/chat/index.css

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,81 @@
11
body {
2-
width: 100vw;
3-
min-width: 320px;
2+
width: 100vw;
3+
min-width: 320px;
44
}
55

66
#root {
7-
padding: 40px 20px;
8-
max-width: 600px;
9-
margin: auto;
10-
height: 100vh;
7+
padding: 40px 20px;
8+
max-width: 600px;
9+
margin: auto;
10+
height: 100vh;
1111

12-
display: flex;
13-
flex-direction: column;
14-
align-items: center;
15-
justify-content: center;
12+
display: flex;
13+
flex-direction: column;
14+
align-items: center;
15+
justify-content: center;
1616
}
1717

1818
#root > * + * {
19-
margin: 20px 0 0 0;
19+
margin: 20px 0 0 0;
2020
}
2121

2222
/* 100vh on safari does not include the bottom bar. */
2323
@supports (-webkit-overflow-scrolling: touch) {
24-
#root {
25-
height: 85vh;
26-
}
24+
#root {
25+
height: 85vh;
26+
}
2727
}
2828

2929
#message-log {
30-
width: 100%;
31-
flex-grow: 1;
32-
overflow: auto;
30+
width: 100%;
31+
flex-grow: 1;
32+
overflow: auto;
3333
}
3434

3535
#message-log p:first-child {
36-
margin: 0;
36+
margin: 0;
3737
}
3838

3939
#message-log > * + * {
40-
margin: 10px 0 0 0;
40+
margin: 10px 0 0 0;
4141
}
4242

4343
#publish-form-container {
44-
width: 100%;
44+
width: 100%;
4545
}
4646

4747
#publish-form {
48-
width: 100%;
49-
display: flex;
50-
height: 40px;
48+
width: 100%;
49+
display: flex;
50+
height: 40px;
5151
}
5252

5353
#publish-form > * + * {
54-
margin: 0 0 0 10px;
54+
margin: 0 0 0 10px;
5555
}
5656

5757
#publish-form input[type='text'] {
58-
flex-grow: 1;
58+
flex-grow: 1;
5959

60-
-moz-appearance: none;
61-
-webkit-appearance: none;
62-
word-break: normal;
63-
border-radius: 5px;
64-
border: 1px solid #ccc;
60+
-moz-appearance: none;
61+
-webkit-appearance: none;
62+
word-break: normal;
63+
border-radius: 5px;
64+
border: 1px solid #ccc;
6565
}
6666

6767
#publish-form input[type='submit'] {
68-
color: white;
69-
background-color: black;
70-
border-radius: 5px;
71-
padding: 5px 10px;
72-
border: none;
68+
color: white;
69+
background-color: black;
70+
border-radius: 5px;
71+
padding: 5px 10px;
72+
border: none;
7373
}
7474

7575
#publish-form input[type='submit']:hover {
76-
background-color: red;
76+
background-color: red;
7777
}
7878

7979
#publish-form input[type='submit']:active {
80-
background-color: red;
80+
background-color: red;
8181
}

examples/chat/index.html

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
<!doctype html>
22
<html lang="en-CA">
3-
<head>
4-
<meta charset="UTF-8" />
5-
<title>nhooyr.io/websocket - Chat Example</title>
6-
<meta name="viewport" content="width=device-width" />
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>nhooyr.io/websocket - Chat Example</title>
6+
<meta name="viewport" content="width=device-width" />
77

8-
<link href="https://unpkg.com/sanitize.css" rel="stylesheet" />
9-
<link href="https://unpkg.com/sanitize.css/typography.css" rel="stylesheet" />
10-
<link href="https://unpkg.com/sanitize.css/forms.css" rel="stylesheet" />
11-
<link href="/index.css" rel="stylesheet" />
12-
</head>
13-
<body>
14-
<div id="root">
15-
<div id="message-log"></div>
16-
<div id="publish-form-container">
17-
<form id="publish-form">
18-
<input name="message" id="message-input" type="text" />
19-
<input value="Submit" type="submit" />
20-
</form>
21-
</div>
22-
</div>
23-
<script type="text/javascript" src="/index.js"></script>
24-
</body>
8+
<link href="https://unpkg.com/sanitize.css" rel="stylesheet" />
9+
<link href="https://unpkg.com/sanitize.css/typography.css" rel="stylesheet" />
10+
<link href="https://unpkg.com/sanitize.css/forms.css" rel="stylesheet" />
11+
<link href="/index.css" rel="stylesheet" />
12+
</head>
13+
<body>
14+
<div id="root">
15+
<div id="message-log"></div>
16+
<div id="publish-form-container">
17+
<form id="publish-form">
18+
<input name="message" id="message-input" type="text" />
19+
<input value="Submit" type="submit" />
20+
</form>
21+
</div>
22+
</div>
23+
<script type="text/javascript" src="/index.js"></script>
24+
</body>
2525
</html>

examples/chat/index.js

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,76 @@
11
;(() => {
2-
// expectingMessage is set to true
3-
// if the user has just submitted a message
4-
// and so we should scroll the next message into view when received.
5-
let expectingMessage = false
6-
function dial() {
7-
const conn = new WebSocket(`ws://${location.host}/subscribe`)
2+
// expectingMessage is set to true
3+
// if the user has just submitted a message
4+
// and so we should scroll the next message into view when received.
5+
let expectingMessage = false
6+
function dial() {
7+
const conn = new WebSocket(`ws://${location.host}/subscribe`)
88

9-
conn.addEventListener('close', ev => {
10-
appendLog(`WebSocket Disconnected code: ${ev.code}, reason: ${ev.reason}`, true)
11-
if (ev.code !== 1001) {
12-
appendLog('Reconnecting in 1s', true)
13-
setTimeout(dial, 1000)
14-
}
15-
})
16-
conn.addEventListener('open', ev => {
17-
console.info('websocket connected')
18-
})
9+
conn.addEventListener('close', ev => {
10+
appendLog(`WebSocket Disconnected code: ${ev.code}, reason: ${ev.reason}`, true)
11+
if (ev.code !== 1001) {
12+
appendLog('Reconnecting in 1s', true)
13+
setTimeout(dial, 1000)
14+
}
15+
})
16+
conn.addEventListener('open', ev => {
17+
console.info('websocket connected')
18+
})
1919

20-
// This is where we handle messages received.
21-
conn.addEventListener('message', ev => {
22-
if (typeof ev.data !== 'string') {
23-
console.error('unexpected message type', typeof ev.data)
24-
return
25-
}
26-
const p = appendLog(ev.data)
27-
if (expectingMessage) {
28-
p.scrollIntoView()
29-
expectingMessage = false
30-
}
31-
})
32-
}
33-
dial()
20+
// This is where we handle messages received.
21+
conn.addEventListener('message', ev => {
22+
if (typeof ev.data !== 'string') {
23+
console.error('unexpected message type', typeof ev.data)
24+
return
25+
}
26+
const p = appendLog(ev.data)
27+
if (expectingMessage) {
28+
p.scrollIntoView()
29+
expectingMessage = false
30+
}
31+
})
32+
}
33+
dial()
3434

35-
const messageLog = document.getElementById('message-log')
36-
const publishForm = document.getElementById('publish-form')
37-
const messageInput = document.getElementById('message-input')
35+
const messageLog = document.getElementById('message-log')
36+
const publishForm = document.getElementById('publish-form')
37+
const messageInput = document.getElementById('message-input')
3838

39-
// appendLog appends the passed text to messageLog.
40-
function appendLog(text, error) {
41-
const p = document.createElement('p')
42-
// Adding a timestamp to each message makes the log easier to read.
43-
p.innerText = `${new Date().toLocaleTimeString()}: ${text}`
44-
if (error) {
45-
p.style.color = 'red'
46-
p.style.fontStyle = 'bold'
47-
}
48-
messageLog.append(p)
49-
return p
50-
}
51-
appendLog('Submit a message to get started!')
39+
// appendLog appends the passed text to messageLog.
40+
function appendLog(text, error) {
41+
const p = document.createElement('p')
42+
// Adding a timestamp to each message makes the log easier to read.
43+
p.innerText = `${new Date().toLocaleTimeString()}: ${text}`
44+
if (error) {
45+
p.style.color = 'red'
46+
p.style.fontStyle = 'bold'
47+
}
48+
messageLog.append(p)
49+
return p
50+
}
51+
appendLog('Submit a message to get started!')
5252

53-
// onsubmit publishes the message from the user when the form is submitted.
54-
publishForm.onsubmit = async ev => {
55-
ev.preventDefault()
53+
// onsubmit publishes the message from the user when the form is submitted.
54+
publishForm.onsubmit = async ev => {
55+
ev.preventDefault()
5656

57-
const msg = messageInput.value
58-
if (msg === '') {
59-
return
60-
}
61-
messageInput.value = ''
57+
const msg = messageInput.value
58+
if (msg === '') {
59+
return
60+
}
61+
messageInput.value = ''
6262

63-
expectingMessage = true
64-
try {
65-
const resp = await fetch('/publish', {
66-
method: 'POST',
67-
body: msg,
68-
})
69-
if (resp.status !== 202) {
70-
throw new Error(`Unexpected HTTP Status ${resp.status} ${resp.statusText}`)
71-
}
72-
} catch (err) {
73-
appendLog(`Publish failed: ${err.message}`, true)
74-
}
75-
}
63+
expectingMessage = true
64+
try {
65+
const resp = await fetch('/publish', {
66+
method: 'POST',
67+
body: msg,
68+
})
69+
if (resp.status !== 202) {
70+
throw new Error(`Unexpected HTTP Status ${resp.status} ${resp.statusText}`)
71+
}
72+
} catch (err) {
73+
appendLog(`Publish failed: ${err.message}`, true)
74+
}
75+
}
7676
})()

0 commit comments

Comments
 (0)