This repository has been archived by the owner on Apr 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.go
817 lines (712 loc) · 19.4 KB
/
main.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
package main
import (
"context"
"encoding/json"
"errors"
"flag"
"fmt"
"html/template"
"log"
"math/rand"
"net/http"
"os"
"os/signal"
"path"
"strconv"
"strings"
"syscall"
"time"
"database/sql"
"cloud.google.com/go/storage"
_ "github.com/go-sql-driver/mysql"
"github.com/leemcloughlin/logfile"
"golang.org/x/exp/slices"
"golang.org/x/oauth2/google"
"google.golang.org/api/option"
"gopkg.in/Iwark/spreadsheet.v2"
cron "gopkg.in/robfig/cron.v2"
"github.com/mtgban/go-mtgban/mtgban"
"github.com/mtgban/go-mtgban/mtgmatcher"
)
type PageVars struct {
Nav []NavElem
ExtraNav []NavElem
PatreonId string
PatreonURL string
PatreonLogin bool
ShowPromo bool
Title string
ErrorMessage string
WarningMessage string
InfoMessage string
LastUpdate string
AllKeys []string
SearchQuery string
SearchBest bool
SearchSort string
CondKeys []string
FoundSellers map[string]map[string][]SearchEntry
FoundVendors map[string]map[string][]SearchEntry
Metadata map[string]GenericCard
PromoTags []string
NoSort bool
CanShowAll bool
CleanSearchQuery string
ScraperShort string
HasAffiliate bool
CanDownloadCSV bool
Arb []Arbitrage
ArbitOptKeys []string
ArbitOptConfig map[string]FilterOpt
ArbitFilters map[string]bool
ArbitOptTests map[string]bool
SortOption string
GlobalMode bool
ReverseMode bool
Page string
ToC []NewspaperPage
Headings []Heading
Cards []GenericCard
Table [][]string
HasReserved bool
HasStocks bool
HasSypList bool
IsOneDay bool
CanSwitchDay bool
TotalIndex int
CurrentIndex int
PrevIndex int
NextIndex int
SortDir string
LargeTable bool
OffsetCards int
FilterSet string
Editions []string
FilterRarity string
Rarities []string
CardHashes []string
EditionsMap map[string]EditionEntry
CanFilterByPrice bool
FilterMinPrice float64
FilterMaxPrice float64
CanFilterByPercentage bool
FilterMinPercChange float64
FilterMaxPercChange float64
Sleepers map[string][]string
SleepersKeys []string
SleepersColors []string
Headers []string
OtherTable [][]string
CurrentTime time.Time
Uptime string
DiskStatus string
MemoryStatus string
LatestHash string
CacheSize int
Tiers []string
DemoKey string
AxisLabels []string
Datasets []*Dataset
ChartID string
Alternative string
StocksURL string
AltEtchedId string
EditionSort []string
EditionList map[string][]EditionEntry
IsSealed bool
IsSets bool
TotalSets int
TotalCards int
TotalUnique int
ScraperKeys []string
IndexKeys []string
SellerKeys []string
VendorKeys []string
UploadEntries []UploadEntry
IsBuylist bool
TotalEntries map[string]float64
EnabledSellers []string
EnabledVendors []string
CanBuylist bool
CanChangeStores bool
RemoteLinkURL string
TotalQuantity int
Optimized map[string][]OptimizedUploadEntry
OptimizedTotals map[string]float64
HighestTotal float64
MissingCounts map[string]int
MissingPrices map[string]float64
ResultPrices map[string]map[string]float64
OptimizedEditions map[string][]OptimizedUploadEntry
}
type NavElem struct {
// Whether or not this the current active tab
Active bool
// For subtabs, define which is the current active sub-tab
Class string
// Endpoint of this page
Link string
// Name of this page
Name string
// Icon or seller shorthand
Short string
// Response handler
Handle func(w http.ResponseWriter, r *http.Request)
// Which page to render
Page string
// Whether this tab should always be enabled in DevMode
AlwaysOnForDev bool
// Allow to receive POST requests
CanPOST bool
}
var startTime = time.Now()
var DefaultNav = []NavElem{
NavElem{
Name: "Home",
Short: "🏡",
Link: "/",
Page: "home.html",
},
}
// List of keys that may be present or not, and when present they are
// guaranteed not to be user-editable)
var OptionalFields = []string{
"UserName",
"UserEmail",
"UserTier",
"SearchDisabled",
"SearchBuylistDisabled",
"SearchSealed",
"SearchDownloadCSV",
"ArbitEnabled",
"ArbitDisabledVendors",
"NewsEnabled",
"UploadBuylistEnabled",
"UploadChangeStoresEnabled",
"UploadOptimizer",
"UploadNoLimit",
"AnyEnabled",
"AnyExperimentsEnabled",
"APImode",
}
// The key matches the query parameter of the permissions defined in sign()
// These enable/disable the relevant pages
var OrderNav = []string{
"Search",
"Newspaper",
"Sleepers",
"Upload",
"Global",
"Arbit",
"Reverse",
"Admin",
}
// The Loggers where each page may log to
var LogPages map[string]*log.Logger
// All the page properties
var ExtraNavs map[string]NavElem
func init() {
ExtraNavs = map[string]NavElem{
"Search": NavElem{
Name: "Search",
Short: "🔍",
Link: "/search",
Handle: Search,
Page: "search.html",
},
"Newspaper": NavElem{
Name: "Newspaper",
Short: "🗞️",
Link: "/newspaper",
Handle: Newspaper,
Page: "news.html",
},
"Sleepers": NavElem{
Name: "Sleepers",
Short: "💤",
Link: "/sleepers",
Handle: Sleepers,
Page: "sleep.html",
},
"Upload": NavElem{
Name: "Upload",
Short: "🚢",
Link: "/upload",
Handle: Upload,
Page: "upload.html",
CanPOST: true,
},
"Global": NavElem{
Name: "Global",
Short: "🌍",
Link: "/global",
Handle: Global,
Page: "arbit.html",
},
"Arbit": NavElem{
Name: "Arbitrage",
Short: "📈",
Link: "/arbit",
Handle: Arbit,
Page: "arbit.html",
},
"Reverse": NavElem{
Name: "Reverse",
Short: "📉",
Link: "/reverse",
Handle: Reverse,
Page: "arbit.html",
},
"Admin": NavElem{
Name: "Admin",
Short: "❌",
Link: "/admin",
Handle: Admin,
Page: "admin.html",
AlwaysOnForDev: true,
},
}
}
var Config struct {
Port string `json:"port"`
DBAddress string `json:"db_address"`
RedisAddr string `json:"redis_addr"`
DiscordHook string `json:"discord_hook"`
DiscordNotifHook string `json:"discord_notif_hook"`
DiscordInviteLink string `json:"discord_invite_link"`
Affiliate map[string]string `json:"affiliate"`
AffiliatesList []string `json:"affiliates_list"`
Api map[string]string `json:"api"`
DiscordToken string `json:"discord_token"`
DiscordAllowList []string `json:"discord_allowlist"`
DevSellers []string `json:"dev_sellers"`
ArbitDefaultSellers []string `json:"arbit_default_sellers"`
ArbitBlockVendors []string `json:"arbit_block_vendors"`
SearchRetailBlockList []string `json:"search_block_list"`
SearchBuylistBlockList []string `json:"search_buylist_block_list"`
SleepersBlockList []string `json:"sleepers_block_list"`
GlobalAllowList []string `json:"global_allow_list"`
GlobalProbeList []string `json:"global_probe_list"`
Patreon struct {
Secret map[string]string `json:"secret"`
Emails map[string]string `json:"emails"`
} `json:"patreon"`
ApiUserSecrets map[string]string `json:"api_user_secrets"`
GoogleCredentials string `json:"google_credentials"`
ACL map[string]map[string]map[string]string `json:"acl"`
Uploader struct {
ServiceAccount string `json:"service_account"`
BucketName string `json:"bucket_name"`
} `json:"uploader"`
/* The location of the configuation file */
filePath string
}
var DevMode bool
var SigCheck bool
var SkipInitialRefresh bool
var SkipPrices bool
var BenchMode bool
var LogDir string
var LastUpdate string
var DatabaseLoaded bool
var Sellers []mtgban.Seller
var Vendors []mtgban.Vendor
var Infos map[string]mtgban.InventoryRecord
var SealedEditionsSorted []string
var SealedEditionsList map[string][]EditionEntry
var AllEditionsKeys []string
var AllEditionsMap map[string]EditionEntry
var TreeEditionsKeys []string
var TreeEditionsMap map[string][]EditionEntry
var ReprintsKeys []string
var ReprintsMap map[string][]ReprintEntry
var TotalSets, TotalCards, TotalUnique int
var Newspaper3dayDB *sql.DB
var Newspaper1dayDB *sql.DB
var GoogleDocsClient *http.Client
var GCSBucketClient *storage.Client
const (
DefaultConfigPort = "8080"
DefaultSecret = "NotVerySecret!"
)
func Favicon(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "img/misc/favicon.ico")
}
// FileSystem custom file system handler
type FileSystem struct {
httpfs http.FileSystem
}
// Open opens file
func (fs *FileSystem) Open(path string) (http.File, error) {
f, err := fs.httpfs.Open(path)
if err != nil {
return nil, err
}
s, err := f.Stat()
if err != nil {
return nil, err
}
if s.IsDir() {
index := strings.TrimSuffix(path, "/") + "/index.html"
_, err := fs.httpfs.Open(index)
if err != nil {
return nil, err
}
}
return f, nil
}
func genPageNav(activeTab, sig string) PageVars {
exp := GetParamFromSig(sig, "Expires")
expires, _ := strconv.ParseInt(exp, 10, 64)
msg := ""
showPatreonLogin := false
if sig != "" {
if expires < time.Now().Unix() {
msg = ErrMsgExpired
}
} else {
showPatreonLogin = true
}
// These values need to be set for every rendered page
// In particular the Patreon variables are needed because the signature
// could expire in any page, and the button url needs these parameters
pageVars := PageVars{
Title: "BAN " + activeTab,
ErrorMessage: msg,
LastUpdate: LastUpdate,
PatreonId: PatreonClientId,
PatreonURL: PatreonHost,
PatreonLogin: showPatreonLogin,
}
// Allocate a new navigation bar
pageVars.Nav = make([]NavElem, len(DefaultNav))
copy(pageVars.Nav, DefaultNav)
// Enable buttons according to the enabled features
if expires > time.Now().Unix() || (DevMode && !SigCheck) {
for _, feat := range OrderNav {
param := GetParamFromSig(sig, feat)
allowed, _ := strconv.ParseBool(param)
if DevMode && ExtraNavs[feat].AlwaysOnForDev {
allowed = true
}
if allowed || (DevMode && !SigCheck) {
pageVars.Nav = append(pageVars.Nav, ExtraNavs[feat])
}
}
}
mainNavIndex := 0
for i := range pageVars.Nav {
if pageVars.Nav[i].Name == activeTab {
mainNavIndex = i
break
}
}
pageVars.Nav[mainNavIndex].Active = true
pageVars.Nav[mainNavIndex].Class = "active"
return pageVars
}
func loadVars(cfg string) error {
// Load from command line
file, err := os.Open(cfg)
if err != nil {
return err
}
defer file.Close()
d := json.NewDecoder(file)
err = d.Decode(&Config)
if err != nil {
return err
}
Config.filePath = cfg
if Config.Port == "" {
Config.Port = DefaultConfigPort
}
// Load from env
v := os.Getenv("BAN_SECRET")
if v == "" {
log.Printf("BAN_SECRET not set, using a default one")
os.Setenv("BAN_SECRET", DefaultSecret)
}
return nil
}
func openDBs() (err error) {
Newspaper3dayDB, err = sql.Open("mysql", Config.DBAddress+"/three_day_newspaper")
if err != nil {
return err
}
Newspaper1dayDB, err = sql.Open("mysql", Config.DBAddress+"/newspaper")
if err != nil {
return err
}
return nil
}
func loadGoogleCredentials(credentials string) (*http.Client, error) {
data, err := os.ReadFile(credentials)
if err != nil {
return nil, err
}
conf, err := google.JWTConfigFromJSON(data, spreadsheet.Scope)
if err != nil {
return nil, err
}
return conf.Client(context.Background()), nil
}
const DefaultConfigPath = "config.json"
func main() {
config := flag.String("cfg", DefaultConfigPath, "Load configuration file")
devMode := flag.Bool("dev", false, "Enable developer mode")
sigCheck := flag.Bool("sig", false, "Enable signature verification")
skipInitialRefresh := flag.Bool("skip", true, "Skip initial refresh")
noload := flag.Bool("noload", false, "Do not load price data")
logdir := flag.String("log", "logs", "Directory for scrapers logs")
port := flag.String("port", "", "Override server port")
flag.Parse()
DevMode = *devMode
SkipPrices = *noload
SigCheck = true
if DevMode {
SigCheck = *sigCheck
SkipInitialRefresh = *skipInitialRefresh
}
LogDir = *logdir
// load necessary environmental variables
err := loadVars(*config)
if err != nil {
log.Fatalln("unable to load config file:", err)
}
if *port != "" {
Config.Port = *port
}
_, err = os.Stat(LogDir)
if errors.Is(err, os.ErrNotExist) {
err = os.MkdirAll(LogDir, 0700)
}
if err != nil {
log.Fatalln("unable to create necessary folders", err)
}
LogPages = map[string]*log.Logger{}
GoogleDocsClient, err = loadGoogleCredentials(Config.GoogleCredentials)
if err != nil {
if DevMode {
log.Println("error creating a Google client:", err)
} else {
log.Fatalln("error creating a Google client:", err)
}
}
GCSBucketClient, err = storage.NewClient(context.Background(), option.WithCredentialsFile(Config.Uploader.ServiceAccount))
if err != nil {
if DevMode {
log.Println("error creating the GCSBucketClient:", err)
} else {
log.Fatalln("error creating the GCSBucketClient:", err)
}
}
err = openDBs()
if err != nil {
if DevMode {
log.Println("error opening databases:", err)
} else {
log.Fatalln("error opening databases:", err)
}
}
// load website up
go func() {
var err error
log.Println("Loading MTGJSONv5")
err = loadDatastore()
if err != nil {
log.Fatalln("error loading mtgjson:", err)
}
err = loadScrapersNG()
if err != nil {
log.Println("error loading config:", err)
loadScrapers()
}
DatabaseLoaded = true
// Nothing else to do if hacking around
if DevMode {
return
}
// Set up new refreshes as needed
c := cron.New()
// Times are in UTC
// Refresh everything daily at 2am (after MTGJSON update)
c.AddFunc("35 11 * * *", loadScrapers)
// Refresh CK at every 4th hour, 40 minutes past the hour (six times in total)
c.AddFunc("40 */4 * * *", reloadCK)
// Refresh TCG at every 4th hour, 45 minutes past the hour (six times in total)
c.AddFunc("45 */4 * * *", reloadTCG)
// Refresh SCG every day at 2:15pm (twice in total)
c.AddFunc("15 14 * * *", reloadSCG)
// MTGJSON builds go live 7am EST, pull the update 30 minutes after
c.AddFunc("30 11 * * *", func() {
log.Println("Reloading MTGJSONv5")
err := loadDatastore()
if err != nil {
log.Println(err)
}
})
// Slean up the csv cache every 3 days
c.AddFunc("0 0 */3 * *", deleteOldCache)
c.Start()
}()
err = setupDiscord()
if err != nil {
log.Println("Error connecting to discord", err)
}
// Set seed in case we need to do random operations
rand.Seed(time.Now().UnixNano())
// serve everything in known folders as a file
http.Handle("/css/", http.StripPrefix("/css/", http.FileServer(&FileSystem{http.Dir("css")})))
http.Handle("/img/", http.StripPrefix("/img/", http.FileServer(&FileSystem{http.Dir("img")})))
http.Handle("/js/", http.StripPrefix("/js/", http.FileServer(&FileSystem{http.Dir("js")})))
// custom redirector
http.HandleFunc("/go/", Redirect)
http.HandleFunc("/random", RandomSearch)
http.HandleFunc("/randomsealed", RandomSealedSearch)
http.HandleFunc("/discord", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, Config.DiscordInviteLink, http.StatusFound)
})
// when navigating to /home it should serve the home page
http.Handle("/", noSigning(http.HandlerFunc(Home)))
for key, nav := range ExtraNavs {
// Set up logging
logFile, err := logfile.New(&logfile.LogFile{
FileName: path.Join(LogDir, key+".log"),
MaxSize: 500 * 1024,
Flags: logfile.FileOnly,
OldVersions: 2,
})
if err != nil {
log.Printf("Failed to create logFile for %s: %s", key, err)
LogPages[key] = log.New(os.Stderr, "", log.LstdFlags)
} else {
LogPages[key] = log.New(logFile, "", log.LstdFlags)
}
// Set up the handler
http.Handle(nav.Link, enforceSigning(http.HandlerFunc(nav.Handle)))
}
http.Handle("/sets", enforceSigning(http.HandlerFunc(Search)))
http.Handle("/sealed", enforceSigning(http.HandlerFunc(Search)))
http.Handle("/api/mtgban/", enforceAPISigning(http.HandlerFunc(PriceAPI)))
http.Handle("/api/mtgjson/ck.json", enforceAPISigning(http.HandlerFunc(API)))
http.Handle("/api/tcgplayer/lastsold/", enforceSigning(http.HandlerFunc(TCGLastSoldAPI)))
http.Handle("/api/cardkingdom/pricelist.json", noSigning(http.HandlerFunc(CKMirrorAPI)))
http.HandleFunc("/favicon.ico", Favicon)
http.HandleFunc("/auth", Auth)
srv := &http.Server{
Addr: ":" + Config.Port,
}
done := make(chan os.Signal, 1)
signal.Notify(done, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
go func() {
err := srv.ListenAndServe()
if err != nil && err != http.ErrServerClosed {
log.Fatalf("listen: %s\n", err)
}
}()
<-done
// Close any zombie connection and perform any extra cleanup
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer func() {
cleanupDiscord()
cancel()
log.Println("BAN Server shut down")
}()
err = srv.Shutdown(ctx)
if err != nil {
log.Fatalf("Server Shutdown Failed: %s", err.Error())
}
log.Println("BAN Server shutting down...")
}
func render(w http.ResponseWriter, tmpl string, pageVars PageVars) {
funcMap := template.FuncMap{
"inc": func(i, j int) int {
return i + j
},
"dec": func(i, j int) int {
return i - j
},
"mul": func(i float64, j int) float64 {
return i * float64(j)
},
"print_perc": func(s string) string {
n, _ := strconv.ParseFloat(s, 64)
return fmt.Sprintf("%0.2f %%", n*100)
},
"print_price": func(s string) string {
n, _ := strconv.ParseFloat(s, 64)
return fmt.Sprintf("$ %0.2f", n)
},
"scraper_name": func(s string) string {
return ScraperNames[s]
},
"slice_has": func(s []string, p string) bool {
return slices.Contains(s, p)
},
"has_prefix": func(s, p string) bool {
return strings.HasPrefix(s, p)
},
"contains": func(s, p string) bool {
return strings.Contains(s, p)
},
"triple_column_start": func(i int, length int) bool {
return i == 0 || i == length/3 || i == length*2/3
},
"triple_column_end": func(i int, length int) bool {
return i == length/3-1 || i == length*2/3-1 || i == length-1
},
"tolower": func(s string) string {
return strings.ToLower(s)
},
"load_partner": func(s string) string {
return Config.Affiliate[s]
},
"uuid2ckid": func(s string) string {
for _, vendor := range Vendors {
if vendor == nil || vendor.Info().Shorthand != "CK" {
continue
}
bl, err := vendor.Buylist()
if err != nil {
return ""
}
entries, found := bl[s]
if !found {
return ""
}
return entries[0].CustomFields["CKID"]
}
return ""
},
"uuid2tcgid": func(s string) string {
co, err := mtgmatcher.GetUUID(s)
if err != nil {
return ""
}
tcgId := co.Identifiers["tcgplayerProductId"]
if co.Etched {
id, found := co.Identifiers["tcgplayerEtchedProductId"]
if found {
tcgId = id
}
}
return tcgId
},
}
// Give each template a name
name := path.Base(tmpl)
// Prefix the name passed in with templates/
tmpl = fmt.Sprintf("templates/%s", tmpl)
// Parse the template file held in the templates folder, add any Funcs to parsing
t, err := template.New(name).Funcs(funcMap).ParseFiles(tmpl)
if err != nil {
log.Print("template parsing error: ", err)
return
}
// Execute the template and pass in the variables to fill the gaps
err = t.Execute(w, pageVars)
if err != nil {
log.Print("template executing error: ", err)
}
}