diff --git a/bbs.conf.sample b/bbs.conf.sample index 07c9bf8..1f07ef5 100644 --- a/bbs.conf.sample +++ b/bbs.conf.sample @@ -495,34 +495,35 @@ address = 127.0.0.1:2513 ; and tags ({yellow}, {bright}, {reset} ...: docs/wiki/Customization.md). ; screen = NAME shows that display file instead of the list of items ;[menu main] -;title = @BBS@ +;title = {cyan}{bright}@BBS@{reset} ;screen = mainmenu ;m = areas Message areas -;e = mail E-mail (@NEWMAIL@ new) +;e = mail E-mail ({yellow}@NEWMAIL@{default} new) ;f = files File areas ;d = doors Doors ;c = chat Chat ;s = page Page the sysop ;w = who Who's online -;b = screen:bulletins Bulletins +;b = screen:bulletins {green}Bulletins{reset} ;x = menu:extras Extras -;g = logoff Goodbye +;g = logoff {red}Goodbye{reset} ; ;[menu extras] -;title = Extras -;prompt = "Extras> " +;title = {cyan}Extras{reset} +;prompt = "{cyan}Extras{default}> " ;u = users User list ;p = profile Your profile ;i = info System info ;t = terminal Your terminal (3270) ;q = back Back -; The prompts and messages, with @-codes: +; The prompts and messages, with @-codes and tags (on 3270s, and in the +; welcome, tags are dropped): ;[strings] -;name_prompt = "Name: " -;new_name_prompt = "Name (or NEW): " -;password_prompt = "Password: " -;command_prompt = "Command: " -;pause = "[Press a key]" -;logoff_confirm = "Log off?" +;name_prompt = "{cyan}Name:{default} " +;new_name_prompt = "{cyan}Name{default} (or NEW): " +;password_prompt = "{cyan}Password:{default} " +;command_prompt = "{yellow}@USER@{default} @ {cyan}@BBS@{default} > " +;pause = "{blue}[Press a key]{reset}" +;logoff_confirm = "{red}Log off?{reset}" ;welcome = "Welcome, @USER@." diff --git a/internal/screens/samples_test.go b/internal/screens/samples_test.go new file mode 100644 index 0000000..99e23c3 --- /dev/null +++ b/internal/screens/samples_test.go @@ -0,0 +1,50 @@ +package screens + +import ( + "os" + "path/filepath" + "regexp" + "strings" + "testing" +) + +// TestSamples: every tag in the sample screens and in bbs.conf.sample's +// menus and strings is one (a typo would show its braces). +func TestSamples(t *testing.T) { + var texts []string + for _, pat := range []string{"*.asc", "*.3270"} { + files, _ := filepath.Glob(filepath.Join("..", "..", "screens.sample", pat)) + for _, f := range files { + b, err := os.ReadFile(f) + if err != nil { + t.Fatal(err) + } + texts = append(texts, string(b)) + } + } + conf, err := os.ReadFile(filepath.Join("..", "..", "bbs.conf.sample")) + if err != nil { + t.Fatal(err) + } + // the menus' and the strings' lines (other settings have {placeholders}) + c := string(conf) + from, to := strings.Index(c, ";[menu main]"), strings.Index(c, ";welcome = ") + if from < 0 || to < from { + t.Fatal("no sample menus and strings in bbs.conf.sample") + } + setting := regexp.MustCompile(`^;[a-z_]+ = `) + for _, l := range strings.Split(c[from:to], "\n") { + if setting.MatchString(l) && strings.Contains(l, "{") { + texts = append(texts, l) + } + } + if len(texts) < 10 { + t.Fatalf("only %d texts found", len(texts)) + } + any := func(string) (string, bool) { return "x", true } + for _, s := range texts { + if left := String(s, any); strings.ContainsAny(left, "{}") { + t.Errorf("an unknown tag in %q: %q", s, left) + } + } +} diff --git a/screens.sample/README b/screens.sample/README index fd4756d..9d2f8cf 100644 --- a/screens.sample/README +++ b/screens.sample/README @@ -8,7 +8,8 @@ bbs.conf.sample uses mainmenu and bulletins. Tags in a .asc ({clear}, {pause}, {red}, {on blue}, {bright}, {reset}...) are ANSI on an ANSI terminal, colors on a Commodore and a 3270, and -nothing on a plain terminal: bulletins.asc has a few. +nothing on a plain terminal: every .asc here has some, as do the sample +menus and strings in bbs.conf.sample. logon, newuser, welcome and goodbye are shown by themselves; others by the menus that name them. See the wiki's Customization page. diff --git a/screens.sample/goodbye.3270 b/screens.sample/goodbye.3270 index abace9a..aac625c 100644 --- a/screens.sample/goodbye.3270 +++ b/screens.sample/goodbye.3270 @@ -1 +1 @@ -{turquoise}{bright}Thanks for calling @BBS@, @USER@. Come back soon! +{turquoise}{bright}Thanks for calling @BBS@, @USER@. {yellow}Come back soon! diff --git a/screens.sample/goodbye.asc b/screens.sample/goodbye.asc index 0f00545..2cf2318 100644 --- a/screens.sample/goodbye.asc +++ b/screens.sample/goodbye.asc @@ -1,2 +1,2 @@ -Thanks for calling @BBS@, @USER@. Come back soon! +{cyan}Thanks for calling {bright}@BBS@{normal}, @USER@.{default} {yellow}Come back soon!{reset} diff --git a/screens.sample/logon.asc b/screens.sample/logon.asc index a38e204..cd7c7af 100644 --- a/screens.sample/logon.asc +++ b/screens.sample/logon.asc @@ -1,5 +1,5 @@ - @BBS@ - ---------------------------------------- - Node @NODE@, @VIA@. @ONLINE@ on now. + {cyan}{bright}@BBS@{reset} + {blue}----------------------------------------{reset} + Node {yellow}@NODE@{default}, @VIA@. {green}@ONLINE@{default} on now. diff --git a/screens.sample/welcome.asc b/screens.sample/welcome.asc index caf7d35..35d3681 100644 --- a/screens.sample/welcome.asc +++ b/screens.sample/welcome.asc @@ -1,4 +1,4 @@ - -Welcome back, @USER@. -Last call: @LASTON@ Calls: @CALLS@ Posts: @POSTS@ -New mail: @NEWMAIL@ +{clear} +{white}{bright}Welcome back, @USER@.{reset} +{cyan}Last call:{default} @LASTON@ {cyan}Calls:{default} @CALLS@ {cyan}Posts:{default} @POSTS@ +{cyan}New mail:{default} {yellow}{bright}@NEWMAIL@{reset}