-
Notifications
You must be signed in to change notification settings - Fork 1
/
instructions.go
140 lines (137 loc) · 5.31 KB
/
instructions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package webserver
import (
"net/http"
"strconv"
"strings"
"github.com/rothskeller/packet/message"
"github.com/rothskeller/packet/xscmsg/plaintext"
"github.com/rothskeller/wppsvr/english"
"github.com/rothskeller/wppsvr/htmlb"
"github.com/rothskeller/wppsvr/store"
)
// serveInstructions displays the instructions for a session.
func (ws *webserver) serveInstructions(w http.ResponseWriter, r *http.Request) {
var (
session *store.Session
plainText bool
needHandling bool
needDestination bool
)
if sid, err := strconv.Atoi(r.FormValue("session")); err == nil {
session = ws.st.GetSession(sid)
}
if session == nil {
http.Error(w, "404 Not Found", http.StatusNotFound)
return
}
// Start the HTML page.
w.Header().Set("Cache-Control", "nostore")
w.Header().Set("Content-Type", "text/html; charset=utf-8")
html := htmlb.HTML(w)
defer html.Close()
html.E("meta charset=utf-8")
html.E("title>Weekly Packet Practice - Santa Clara County ARES/RACES")
html.E("meta name=viewport content='width=device-width, initial-scale=1'")
html.E("link rel=stylesheet href=/static/common.css")
html.E("link rel=stylesheet href=/static/instructions2.css")
html.E("div id=org>Santa Clara County ARES<sup>®</sup>/RACES")
html.E("div id=title").E("a href=/>Weekly Packet Practice")
html.E("div id=subtitle>%s — %s", session.Name, session.End.Format("January 2, 2006"))
// Write the main instructions.
main := html.E("div id=main")
para := main.E("p")
para.R("For this practice session, please send ")
switch msg := session.ModelMsg.(type) {
case nil:
var article string
var names []string
for i, tag := range session.MessageTypes {
if tag == "plain" {
plainText = true
} else {
needHandling, needDestination = true, true
}
if mt := message.RegisteredTypes[tag]; mt != nil {
if i == 0 {
article = mt.Article
}
names = append(names, mt.Name)
} else {
if i == 0 {
article = "a"
}
names = append(names, tag)
}
}
para.TF("%s %s", article, english.Conjoin(names, "or"))
case *plaintext.PlainText:
plainText = true
switch msg.Handling {
case "IMMEDIATE":
para.R("an immediate")
case "":
para.R("a")
default:
para.TF("a %s", strings.ToLower(msg.Handling))
}
para.R(" plain text message with the text shown below")
default:
var mb = msg.Base()
para.TF("the %s shown below", mb.Type.Name)
needHandling = mb.FHandling != nil && *mb.FHandling == ""
needDestination = (mb.FToICSPosition != nil && *mb.FToICSPosition == "") ||
(mb.FToLocation != nil && *mb.FToLocation == "")
}
para.TF(" to %s at the appropriate BBS. The message must be received there between %s and %s.",
session.CallSign, session.Start.Format("15:04 on Monday"), session.End.Format("15:04 on Monday"))
switch len(session.DownBBSes) {
case 0:
para.R(" There are no simulated BBS outages for this session.")
case 1:
para.TF(" Do not use or send to %s during this session; it has a simulated outage.", session.DownBBSes[0])
default:
para.TF(" Do not use or send to %s during this session; they have simulated outages.", english.Conjoin(session.DownBBSes, "or"))
}
if session.Instructions != "" {
main.R(session.Instructions)
}
if msg, ok := session.ModelMsg.(*plaintext.PlainText); ok {
grid := main.E("div id=plainmodel")
grid.E("div>Subject:")
grid.E("div>%s", strings.ReplaceAll(msg.Subject, "¡", ""))
grid.E("div>Message:")
grid.E("div>%s", strings.ReplaceAll(msg.Body, "¡", ""))
}
main.E("p style=margin-bottom:0>The following references may be helpful to you:")
list := main.E("ul style=margin-top:0")
list.E("li>The ").E("a href=https://www.scc-ares-races.org/freqs/packet-freqs.html target=_blank>Packet Frequency and BBS Listings").
P().TF(" will tell you which BBS to use to reach %s.", session.CallSign)
list.E("li>The “Standard Outpost Configuration Instructions”, available on the ").
E("a href=https://www.scc-ares-races.org/data/packet/index.html target=_blank>Packet BBS Service").
P().R(" page, will tell you how to configure Outpost to send messages following county standards.")
if plainText {
list.E("li>The “Standard Packet Message Subject Line”, available on the ").
E("a href=https://www.scc-ares-races.org/data/packet/index.html target=_blank>Packet BBS Service").
P().R(" page, will tell you how to construct the subject line of your message to conform to county standards.")
}
if needHandling || needDestination {
li := list.E("li>The “RACES Recommended Form Routing Cheat Sheet”, available on the ")
li.E("a href=https://www.scc-ares-races.org/operations/go-kit-forms.html target=_blank>Go Kit Forms")
li.R(" page, will tell you how to fill in the ")
if needHandling && needDestination {
li.R("handling and destination fields")
} else if needHandling {
li.R("handling field")
} else {
li.R("destination fields")
}
li.R(" for this message.")
}
list.E("li>The <kbd>packet@scc-ares-races.groups.io</kbd> mailing list is the best place to ask for help or report problems. To join that list, see the instructions on the ").
E("a href=https://www.scc-ares-races.org/discuss-groups.html target=_blank>Discussion Groups").
P().R(" page.")
count := ws.st.ModelImageCount(session.ID)
for pnum := 1; pnum <= count; pnum++ {
html.E("img class=modelimage src=/session/image?session=%d&page=%d", session.ID, pnum)
}
}