@@ -14,16 +14,16 @@ import (
1414
1515// Config represents the TOML configuration structure.
1616type Config struct {
17- Listen int `toml:"listen"`
18- ServerName string `toml:"server_name"`
19- CustomKeywords []KeywordRule `toml:"custom_keywords"`
17+ Listen int `toml:"listen"`
18+ ServerName string `toml:"server_name"`
19+ CustomKeywords []KeywordRule `toml:"custom_keywords"`
2020}
2121
2222// TemplateData combines the parsed configuration with the destination
2323// to URL mappings used to construct the final nginx file.
2424type TemplateData struct {
25- Config
26- Targets map [string ]string
25+ Config
26+ Targets map [string ]string
2727}
2828
2929// KeywordRule maps a phrase to a destination.
@@ -73,29 +73,29 @@ func loadConfig(path string) (Config, error) {
7373// generateNginx assembles the nginx configuration using heuristics
7474// and any custom keyword rules from the configuration file.
7575func generateNginx (cfg Config ) (string , error ) {
76- tmpl , err := template .New ("nginx.conf.tmpl" ).Funcs (template.FuncMap {
77- "escape" : escapeSpace ,
78- }).ParseFS (templateFS , "nginx.conf.tmpl" )
79- if err != nil {
80- return "" , err
81- }
76+ tmpl , err := template .New ("nginx.conf.tmpl" ).Funcs (template.FuncMap {
77+ "escape" : escapeSpace ,
78+ }).ParseFS (templateFS , "nginx.conf.tmpl" )
79+ if err != nil {
80+ return "" , err
81+ }
8282
83- data := TemplateData {
84- Config : cfg ,
85- Targets : map [string ]string {
86- "google" : "https://www.google.com/search?q=$arg_q" ,
87- "chatgpt" : "https://chat.openai .com/?q=$arg_q" ,
88- "wikipedia" : "https://en.wikipedia.org/wiki/$arg_q" ,
89- "google_images" : "https://www.google.com/search?tbm=isch&q=$arg_q" ,
90- "google_maps" : "https://www.google.com/maps/search/?q=$arg_q" ,
91- },
92- }
83+ data := TemplateData {
84+ Config : cfg ,
85+ Targets : map [string ]string {
86+ "google" : "https://www.google.com/search?q=$arg_q" ,
87+ "chatgpt" : "https://chatgpt .com/?q=$arg_q" ,
88+ "wikipedia" : "https://en.wikipedia.org/wiki/$arg_q" ,
89+ "google_images" : "https://www.google.com/search?tbm=isch&q=$arg_q" ,
90+ "google_maps" : "https://www.google.com/maps/search/?q=$arg_q" ,
91+ },
92+ }
9393
94- var b bytes.Buffer
95- if err := tmpl .Execute (& b , data ); err != nil {
96- return "" , err
97- }
98- return b .String (), nil
94+ var b bytes.Buffer
95+ if err := tmpl .Execute (& b , data ); err != nil {
96+ return "" , err
97+ }
98+ return b .String (), nil
9999}
100100
101101func escapeSpace (s string ) string {
0 commit comments