- Timestamp:
- Sep 13, 2023, 10:49:50 AM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cmd/aya/main.go
r68 r69 1 // $TheSupernovaDuo: cmd/aya/main.go,v 0. 5.x 2023/5/8 18:6:18yakumo_izuru Exp $1 // $TheSupernovaDuo: cmd/aya/main.go,v 0.6.0 2023/9/13 07:50:00 yakumo_izuru Exp $ 2 2 package main 3 3 … … 14 14 "time" 15 15 16 "github.com/eknkc/amber" 16 17 "github.com/russross/blackfriday/v2" 18 log "github.com/sirupsen/logrus" 19 "github.com/yosssi/gcss" 17 20 "gopkg.in/yaml.v2" 18 21 "marisa.chaotic.ninja/aya" 19 log "github.com/sirupsen/logrus"20 "github.com/eknkc/amber"21 "github.com/yosssi/gcss"22 22 ) 23 23 24 24 const ( 25 AYADIR 25 AYADIR = ".aya" 26 26 PUBDIR = ".pub" 27 27 ) … … 173 173 } 174 174 } 175 175 176 176 } 177 177 … … 187 187 } 188 188 v["content"] = string(blackfriday.Run([]byte(content), 189 blackfriday.WithExtensions(blackfriday.CommonExtensions|blackfriday.AutoHeadingIDs ),189 blackfriday.WithExtensions(blackfriday.CommonExtensions|blackfriday.AutoHeadingIDs|blackfriday.Strikethrough|blackfriday.Footnotes), 190 190 )) 191 191 if w == nil { … … 261 261 return err 262 262 } 263 263 264 // Compiles .gcss into .css 264 265 func buildGCSS(path string, w io.Writer) error { … … 300 301 return err 301 302 } 303 302 304 // This function passes the files to build to their corresponding functions 303 305 func build(path string, w io.Writer, vars Vars) error { … … 360 362 } 361 363 } 362 // Serve the public directory over HTTP 363 func servePubDir() { 364 rootdir := http.Dir(PUBDIR) 365 http.Handle("/", http.FileServer(rootdir)) 366 log.Printf("Serving %v at port 8000, see http://localhost:8000", rootdir) 364 365 // Serve the public directory over HTTP and watch for changes 366 func serve() { 367 http.Handle("/", http.FileServer(http.Dir(PUBDIR))) 367 368 log.Fatal(http.ListenAndServe(":8000", nil)) 368 369 } 370 369 371 // Initialize the environment 370 372 func init() { … … 374 376 os.Setenv("PATH", p) 375 377 } 378 376 379 // Print usage notes 377 380 func printUsage() { … … 381 384 fmt.Printf("\tbuild\tGenerate site\n") 382 385 fmt.Printf("\tclean\tRemoves the generated site directory\n") 383 fmt.Printf("\tserve\tServe %v over HTTP\n", PUBDIR)384 386 fmt.Printf("\tvar\tQuery variable(s) from a markdown file\n") 385 387 fmt.Printf("\tversion\tPrint program version and exit\n") 386 fmt.Printf("\twatch\t(Re)generate site while looking for changes \n")388 fmt.Printf("\twatch\t(Re)generate site while looking for changes (it also serves on HTTP)\n") 387 389 fmt.Printf("\n") 388 390 fmt.Printf("Other commands may be dynamically added by plugins found in %v\n", AYADIR) … … 410 412 log.Println("Removing generated site directory") 411 413 os.RemoveAll(PUBDIR) 412 case " serve":413 servePubDir()414 case "help": 415 printUsage() 414 416 case "var": 415 417 if len(args) == 0 { … … 437 439 case "watch": 438 440 buildAll(true) 441 serve() 439 442 default: 440 443 if s, err := run(globals(), cmd, args...); err != nil {
Note:
See TracChangeset
for help on using the changeset viewer.