diff --git a/gendates.go b/gendates.go index ffafa73..ec795b3 100644 --- a/gendates.go +++ b/gendates.go @@ -2,11 +2,14 @@ package main import ( "flag" + "fmt" + "log" "os" "strings" "text/template" "time" + "github.com/gobuffalo/packd" "github.com/gobuffalo/packr/v2" "github.com/BurntSushi/toml" @@ -15,10 +18,10 @@ import ( const layout = "2006-01-02" var tplMap = map[string]string{ - "assignments": "tpl/assignments.adoc.tpl", - "schedule": "tpl/schedule.adoc.tpl", - "syllabus": "tpl/syllabus.adoc.tpl", - "course": "tpl/course.task.tpl", + "assignments": "assignments.adoc.tpl", + "schedule": "schedule.adoc.tpl", + "syllabus": "syllabus.adoc.tpl", + "course": "course.task.tpl", } type DayMap map[int]time.Time @@ -96,7 +99,7 @@ type Config struct { Days []Day Assignments []Assignment - Resources []Link + Resources string Evaluation []Eval EvalText string @@ -114,6 +117,13 @@ func main() { box = packr.New("templates", "./tpl") + log.Println("semestergen 0.02") + + box.Walk(func(s string, file packd.File) error { + log.Printf("box file: %s", s) + return nil + }) + for i := 0; i < flag.NArg(); i++ { c := mkConfig(flag.Arg(i)) if err := writeSyllabus(c); err != nil { @@ -141,7 +151,7 @@ func writeTaskPaper(c Config) error { "getDate": c.GetDate, "dueTime": func() string { return c.DueTime }, } - tplName := "course" + tplName := tplMap["course"] src, _ := box.FindString(tplName) tpl, err := template.New(tplName).Funcs(funcs).Parse(src) if err != nil { @@ -160,7 +170,7 @@ func writeAssignments(c Config) error { funcs := template.FuncMap{ "getDate": c.GetDate, } - tplName := "assignments" + tplName := tplMap["assignments"] src, _ := box.FindString(tplName) tpl, err := template.New(tplName).Funcs(funcs).Parse(src) if err != nil { @@ -176,10 +186,14 @@ func writeSchedule(c Config) error { if err != nil { return err } - tplName := "schedule" - src, _ := box.FindString(tplName) + tplName := tplMap["schedule"] + src, err := box.FindString(tplName) + if err != nil { + return fmt.Errorf("error finding template: %w", err) + } tpl, err := template.New(tplName).Parse(src) if err != nil { + return fmt.Errorf("error parsing template: %w", err) return err } err = tpl.Execute(f, c) @@ -192,7 +206,7 @@ func writeSyllabus(c Config) error { if err != nil { return err } - tplName := "syllabus" + tplName := tplMap["syllabus"] src, _ := box.FindString(tplName) tpl, err := template.New(tplName).Parse(src) if err != nil { diff --git a/go.mod b/go.mod index 90ca7ab..572335a 100644 --- a/go.mod +++ b/go.mod @@ -4,5 +4,6 @@ go 1.13 require ( github.com/BurntSushi/toml v0.3.1 + github.com/gobuffalo/packd v0.3.0 github.com/gobuffalo/packr/v2 v2.7.1 ) diff --git a/main-packr.go b/main-packr.go deleted file mode 100644 index f69c713..0000000 --- a/main-packr.go +++ /dev/null @@ -1,8 +0,0 @@ -// +build !skippackr -// Code generated by github.com/gobuffalo/packr/v2. DO NOT EDIT. - -// You can use the "packr clean" command to clean up this, -// and any other packr generated files. -package main - -import _ "code.chrissexton.org/cws/semestergen/packrd" diff --git a/packrd/packed-packr.go b/packrd/packed-packr.go deleted file mode 100644 index 4912b91..0000000 --- a/packrd/packed-packr.go +++ /dev/null @@ -1,36 +0,0 @@ -// +build !skippackr -// Code generated by github.com/gobuffalo/packr/v2. DO NOT EDIT. - -// You can use the "packr2 clean" command to clean up this, -// and any other packr generated files. -package packrd - -import ( - "github.com/gobuffalo/packr/v2" - "github.com/gobuffalo/packr/v2/file/resolver" -) - -var _ = func() error { - const gk = "c9e827b4061650cbf988ca40f20bbedc" - g := packr.New(gk, "") - hgr, err := resolver.NewHexGzip(map[string]string{ - "12a06dbb0f20fae85eca99c5d1a77f0d": "1f8b08000000000000ffa459dd721cb7b1be9fa7e8e45c24d990b3942cc7f6ba587568c9725465d92a933e392e162fb040cf0e420c7a849f5d8d299eca6be42ecf9247c9939cea06667749c9c9491ddd6816d303f4efd75f83e77077d75ed9e4f0febe5925d22b70d8a5c67606bbd56aadf42d7a73daa7c17d7a7dd3a037b65badae6f1e0b8ca6bbbe69569e12efb56a56a3e94e639a1cae20f538603b0deee8f3d59ae87605cefadb559fd21857cbe56eb76bd5a07e26df6a1a96665c9e3df9e4932f9e7d72f6f4bf97cdeaecececc9a32f3ae534796543bbb1a9cfebd6d2f2e9d9934f97674f969f9c2d350d2345eb379a7c0a4aa7d8b221cdc7943f76c44dd39c9fc32bdf511854b2e49b66b178e5630a59270a8bc58a850f0bf7f72cf07dd7598df565f9515ebce9c9cfebf25c96bf1e9475bcccff275addddb5b2747f7f7d78bc81df5649b011d618d3af168bdff1e7af1193f59b58379e7fcade57f82e95657ee2a5f373784e39446c9abbbbf605461decc8a6d59797ba47931d36cd779470058bd7ca4f401d072fa2783dc2a02658231854a65dc0558f13ecac73bce6ec1661d7a3871d4240a57bfeb261c7a34f10700c18d127342dbc71a822828ab7b0b50ab05827470564335533aa90acce4e05e8ac43186ce4384217686039d0620ca45e25883d6567662dda061aebb5cb0657ab58cd6a95217d7dd340737e7e0e1731da8d1fd0a7d81c64d56175166fae7a1b61de8455636b549263c46d3420bcfc0f081829078d91dd1b94df20b43fcc6b707a7fdfdcdd9db28ded8f3f7c2bbfdacba442bcbfe720c9daf571feb134ba881f88cea52a02de3c786285be09cab0a32eb5e260be3f3f3f6fdecb2ac21b0c9ad5df20bc876f31250cf54df31ebe383b7d727606877fefe1e2e8178b7c7e76faf917f040e4ab47229f9d9d7ef648e4f923913f9c9dfee191c88b472267a79f3e9080f7f0f2a1089bd55cc0ef97a7fb0c54c6a0818e82e4471e470c4b473b0c90760423599f2227b4e4e646cc0e1847d41c4d37b525f34b4629782ec1ee39f3bc1df250bf505ae398ea39dfa994837270a92d7a8df002370131b647d5065f6f95cb1543446b0e574d90c3bbfbfbe63d2c1687f82e1662f5dd5dfb5fcae587012fc6dfddb5dfe246b91af73fd2803b0ab74dd3ee9fe128a341d31603a8802ac244193ca2814470eb6907ca1b181920adc6b669e132af079ba0df6f94c4176bdc58ef39bda803ed548c4001d613243b208c14d933d6c373e5b72a72ba9377d6cb963f510e1079df182d7918724c1cb689d769e7810f6a2bf09e3ee7cdd996af395ae528469f5e6d119407eb4fcb223a64fb4ad834653635d14e0553c27710dc3b9bb5b912543bf68fa49127d149626d4e609d131424b2a37c3aa7d13ee7f82034bca368fc485ac4948b24b2725871506258d12ae186c234e78b4176eb65ca860dfac16efa144fe0078c23f968d7d6d964314aac9e933759a7a6f98932c7543259a41c4a6a7254394eec82573ffe9f373f39debd056eb3b52fdbdca2c9cbffd16470c9c8386f151eeb473971ccab9d8cd486c320200b175a191cac86d736ea728c1cf9064324afdcd17afb51e1ba5104dda3e28677029d5a07abc5e327303ab5b12ad8389c80f5094387818bf304b6965c090b276fa9ce90dd6c74a7345b207b829a4f363672c38e696a3fa6e3411d2617bcf1380b0d07a135a51ec8cb31d47590bddd6288364d30061a31f0eeaf369e826218294db7e8c628c449a9c060873e96b6730e6ff66636cde199a50d76e27d15a1b65c3628d280e4517aca6fa2d4da49557e4e132974ea80b80d432ce165e74420cf1fd1ceb770e127b0864184020c2a61b0ca4548ea167de9cecad71da4f94936a295955db029a1e72f89713347dcc340979d9b40694e5c8766c3e597bdc33897f19e8bb1919a86813cec855bf813d7bfbcf1d11a0c68e0d78fa57e2d10626cd76128bace2c82ea53cb4da59a5e5413e71b1a136bcd2c864cd6585c7002345a6fc9c71356928254102b9a1dbfdd0435f656b35c80d1ea94034a92cc2e2ac9023b9b7acae9c87a86a4161ea9b2618aa5031a9b5863760b05bbb15e394ea5397405218e3c09d61b5c27349ebdc91c0db71856f0c206d4c94df03653c9fa076afde32f7f95b4ceca716e9878c2df8a80448ff601fd127e8cbff0fd077e2aed595cf525bc51eca1a0e2510ef239ffecab839dff449faf288402801d17e609442eec98e66058e7724c4188dc3e8bbfe437df7372f08787dc5631e2b07668f8bd26e750739f5b4fb3bf2bd071e0050202fd19050ef6e26cc52f86f97945b255d3cc8f8f32399506e241a584c328e1e7e2e1b40ab4b506217b95534fc1fe2cb51f6d4c4a606f6fc7c97111891738bb2650d68809ccf7c5044e9ffa7b8f83f80e83b6e548f45b1b48dae68c46e89563f06f9ac5de1c46bcfe634ce4141cc55207cecd1db5f03675cc39588d0e22272b9e80824e59c7fb16263613bdb9701f1efc36db9f7fc67f75164bfdffcec1776af857a7b0ccbf7bca11837c43ceeaeadb3a3919125cea3172c312fc2a43d4804cd5ea3ca97711df25f2ff6973e4e67dfd78e186353ae6821b4c92cc9475cf7d9cf34fbaa51ac62cf97cb44832e142cf5ab6f06acf897a358e13efc63391dbf2d41433c6a3518f530f13e4111470f21268e5dc7e0f43304c32ead65d46f2a29e5045d9a21493f5f0f45951004c96aa5de76805e6caea6bf2464d90fa4079d3c3559f43348abb6d925ec06d8b9de6c86f7850381c47a5a67788b7e84de4b8bf4474d005c4b9fc441fa7c644e37cbe70cd16aed42dfff2942a61ebc8b902488acf12f5f745255d5ec126a04ab053e2bc98d404e8376a83a648d7ade7e1794bd670bad55dfd040975efc9d16612ed043434cfa78a698cdc7f30fb65d4fd90d1d6d15e06a6071cb5e47c3df516712c66ef798ea661cc520e06b796a75df210ade3b64501b6761d54923d5e0934ae1d0e11486ba6fd61cec0aaa9758e299c9ca5c927a51387c70e031aab12ba0922c10e412b0f061386c1fa1a084918923b8d588fe39d6562d89f5bfcfe36db91b1687f96433947662126fdfc61bd5510fa3eeba2e6965d07a2623c06e8d18d06e3ed03555582df7efee4e9efe08b674f4e9f3e7bf6590b571c23ab959bab82c9fb62e1292d160cf0f84e73ec180e1c57b60c45c7f715f2013381421bd8005f9abf4365ca2096880d5675b0855285e9d1c947511d0355e83a86694edb195562541b8c82333ee68065c48e75a650dea860e06bbf7136f62795d432b20d830a855e6b0acc36208ee818f764202cf5ee88753880e63e587312f2d0da3e88a726af31f8086a4d255ca5f9cb3c30078b753cbe5aaca8b7ac82a71a793e585effa9fc86e7f2fb467450d27eb34b75625cd4f9ee82f985e1ceba02b8483c5b5d524e3daa984ea43d97b75cd181f32cc885d7c72a8e03e9c99f0694d15ccda39b5a471e5824403f51fec75ffe1a4a02abb593ca162c8c8885a5f80946ee1093701c2cb1e30c853839a7d639b67fff1bbc543abb34ede7b072ab77f4c521b4ece4ec0d06661066a6c8f86e445dbc11b906a5b3b1285762cc5a63410d0945f9460efec0473bac25e9944641b007f3506d76d502eb378e41781d6d424015ad0c091a23bb41283c37d469be71a8cab2740b977618dd048e687f81e1b04be0d5d66e4a28d62a94ec7456df0a61f948be6c309d727d2faf2fab9deaa151372599d9139df5a65e9672902ce3bfd4e90cef0699aa761cc72ebb8773cd3c8e35cd62017fa41d6f5170fe30d516752b0361b917362a99bd27b8c42008cccb2fbfbdf8e6921fae72a2d29a24bde565f5d637d99a2a6dbdf2da2a0717d6f0c225becb0f265df98cb28fe8eac10fcb46f41a98370c14f057cddfffd6fcbe793d1de74db951ab6913706b71f7d1d06b15b08c83bf98941ccb9af5727545b15c7d70d1e2db2cf523c55487fe3a5e944f382ddf7cd8638ee0858bea6dc658b2bd600caf3dd6766a99945d3086a9755c1ea1e7b2a39087b8ac3c749930a6b8c4a4db3d4fa2912766c11a41ed9df586760c220ce5919b8dcfc39ac79baed299cacca5e8b933c70732464db16d7edfbc209d07b96ae77e2a6ca8de6592afe53326819ba36ec37c92bb99c33a0a1ef58299dc584696513a0fabdac2f7327d055491fdf4916dfe0db7cc1701f86e744a6e30ea8c1b7972eb0a7999ef46ecfe4f2f3c0452e58da8999ace43e16005248e5b5a25390333ee3cb6f0956068acb52f00c18eef7027ce2ca3fad10ebf619e8960b833db088befbebf3aeada85b5bfb0513b65070c4d73e178e2dbf415a4b0eb2824e8558435a22f7a24828159289faed6b445703ca872c1163f629de7756622750283f59c34e6cf39a63d768ba3e63f537067893420a755048f0c972a4ca27b62faa4d8413202d6817deeb8e51635d028eeb9ea11de66e553bd5e78cc0e247a878b53eb35a702b6fb0bdc72a7c45ed7bdf21b2c5b6eea9f28a256ae182754a7d6b36c1798787829e7a478ccfcdf000000ffff630255dca71c0000", - "4951d53aa9929e12cb7cf9c80be9b5e1": "1f8b08000000000000ffd491d14af3401085af9ba7988b5e24f0276c73f70784080111440ad60718b2a721bad9c866562ccbbebbc446288a222282737918f8e69b935308c5d68d77682546aa1fd8b13130a9388f8c6af632ead122ddb399e6a01dade049d2ade11654d1e5ed4d46b57037bd8934f67069a936fff34d99978a94aa94ca92554ee7d3d477768095e984f84af82e32092127c7b603adef71f847eb47361e549d5171428c31a16566f9e352b1ebc5607ec0d7fd3cd2103a48c38285b570a063a410b4c7ae1f10e3f134581de3ac7fe158f7b6fbc3ea2fd5be936f3c3ef5be422bdee1b73a6ff8301baf563f5ff3b51f3e367d0e0000ffff571c41d453030000", - "7696face5e7d2485251ef6478fbb129f": "1f8b08000000000000ff8c50d16ed330147dcf575c55dd5b9a7463a43490876a15155561b015545495c98b6f12b7ae93c54eb6d6f1bfa378d9c6040ff8c1f6f539f71e9fa3f5004a225284fe0e0f2ef46bc22b8430026f22254bc51e8592c6387f102dc55b30b16b81506bef9a57a931217026766dfdfd6ad1b5a0a0af6ecefa244342b17493bcdc131515b276e39ccba8f7eb6c98b976fb100c696fe3345114390dcc588d02a081698530250a01daeae57b8ed6ff65a101d03a456567742e1e19488db143ffc2a7153e43ddd392298eaddb6759461f5ce8236f355fa7a3354b2c6ecc7bd0da66a0751fb98d0c1a284a2654023d7d224dcf98f523d8496cba0ee7e9b48938cb0c2502d6ad2d2025021340a0a86e398b21261c0525251cf20af6e400845250795b9690df8b1782cc13754f4a0c2153aa90a1ef17c17810134e49edb198e715f5e27cefdbc13243ea9ff9937fad2f1faf5677e9dbf174c682e3f8f4db723e78989d5e167823cbe105bbab2741f599b3e4b8a56f6aba18151517f45867e7fcd3ad1c6de3ed8fdd6a858beb517639673707753e1f073fdfadbf3ee902bb201cda4437ceef000000ffff91935188b0020000", - "a743af6161ac46e4b1617335f1ac44f0": "1f8b08000000000000ff9c90316bfb3010c5777d8a877136fd3de54fc0455bc690a14da7908288e54458b18d65879ad37df762a18666e9502d92ee77f78ef788fe61d0edc5206fcc2c91dfb59b0c4a8562ab67cf2c7e744456ec6cdb2ca0242adedc74612ee16cdb2cfff7d75d1a316df5f412c7d5d5e8ca0cb2ee869b1e55efeff2dc39afb28fff57b9de5472bdd1d94904a59408d8ea190187aeb7678f3f9f807d371a2f887e371900a2e46f3fdd98e3eca374b0a3338f6292b2d5a744ee1699e764886c1d31f30b88a27fa2dcc5b410d00fb61d6b64b4f29c311f234b2b4ea95f7cdf318eaf000000fffffe61f628a6010000", - }) - if err != nil { - panic(err) - } - g.DefaultResolver = hgr - - func() { - b := packr.New("templates", "./tpl") - b.SetResolver("assignments.adoc.tpl", packr.Pointer{ForwardBox: gk, ForwardPath: "7696face5e7d2485251ef6478fbb129f"}) - b.SetResolver("course.task.tpl", packr.Pointer{ForwardBox: gk, ForwardPath: "4951d53aa9929e12cb7cf9c80be9b5e1"}) - b.SetResolver("schedule.adoc.tpl", packr.Pointer{ForwardBox: gk, ForwardPath: "a743af6161ac46e4b1617335f1ac44f0"}) - b.SetResolver("syllabus.adoc.tpl", packr.Pointer{ForwardBox: gk, ForwardPath: "12a06dbb0f20fae85eca99c5d1a77f0d"}) - }() - - return nil -}() diff --git a/tpl/syllabus.adoc.tpl b/tpl/syllabus.adoc.tpl index d89edb4..de2f27f 100644 --- a/tpl/syllabus.adoc.tpl +++ b/tpl/syllabus.adoc.tpl @@ -45,13 +45,7 @@ This schedule is tentative. == Some F# resources -{{range .Resources -}} -{{- if .URL}} -{{.Stars}} {{.URL}}[{{.Title}}] -{{- else}} -{{.Stars}} {{.Title}} -{{- end}} -{{- end}} +{{.Resources}} == Grading Scale