Changeset 69 in code for trunk/cmd


Ignore:
Timestamp:
Sep 13, 2023, 10:49:50 AM (21 months ago)
Author:
Izuru Yakumo
Message:

Ready to release 0.6.0

Signed-off-by: Izuru Yakumo <yakumo.izuru@…>

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:18 yakumo_izuru Exp $
     1// $TheSupernovaDuo: cmd/aya/main.go,v 0.6.0 2023/9/13 07:50:00 yakumo_izuru Exp $
    22package main
    33
     
    1414        "time"
    1515
     16        "github.com/eknkc/amber"
    1617        "github.com/russross/blackfriday/v2"
     18        log "github.com/sirupsen/logrus"
     19        "github.com/yosssi/gcss"
    1720        "gopkg.in/yaml.v2"
    1821        "marisa.chaotic.ninja/aya"
    19         log "github.com/sirupsen/logrus"
    20         "github.com/eknkc/amber"
    21         "github.com/yosssi/gcss"
    2222)
    2323
    2424const (
    25         AYADIR  = ".aya"
     25        AYADIR = ".aya"
    2626        PUBDIR = ".pub"
    2727)
     
    173173                }
    174174        }
    175        
     175
    176176}
    177177
     
    187187        }
    188188        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),
    190190        ))
    191191        if w == nil {
     
    261261        return err
    262262}
     263
    263264// Compiles .gcss into .css
    264265func buildGCSS(path string, w io.Writer) error {
     
    300301        return err
    301302}
     303
    302304// This function passes the files to build to their corresponding functions
    303305func build(path string, w io.Writer, vars Vars) error {
     
    360362        }
    361363}
    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
     366func serve() {
     367        http.Handle("/", http.FileServer(http.Dir(PUBDIR)))
    367368        log.Fatal(http.ListenAndServe(":8000", nil))
    368369}
     370
    369371// Initialize the environment
    370372func init() {
     
    374376        os.Setenv("PATH", p)
    375377}
     378
    376379// Print usage notes
    377380func printUsage() {
     
    381384        fmt.Printf("\tbuild\tGenerate site\n")
    382385        fmt.Printf("\tclean\tRemoves the generated site directory\n")
    383         fmt.Printf("\tserve\tServe %v over HTTP\n", PUBDIR)
    384386        fmt.Printf("\tvar\tQuery variable(s) from a markdown file\n")
    385387        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")
    387389        fmt.Printf("\n")
    388390        fmt.Printf("Other commands may be dynamically added by plugins found in %v\n", AYADIR)
     
    410412                log.Println("Removing generated site directory")
    411413                os.RemoveAll(PUBDIR)
    412         case "serve":
    413                 servePubDir()
     414        case "help":
     415                printUsage()
    414416        case "var":
    415417                if len(args) == 0 {
     
    437439        case "watch":
    438440                buildAll(true)
     441                serve()
    439442        default:
    440443                if s, err := run(globals(), cmd, args...); err != nil {
Note: See TracChangeset for help on using the changeset viewer.