From d81f6a1c13ce15e7c5b7d219f1ad71eec29f0b74 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Thu, 29 Jan 2015 00:49:26 -0500 Subject: [PATCH] Remove tildelog --- README.md | 29 +--------- tildelog/entries/README.md | 4 -- tildelog/html/README.md | 4 -- tildelog/html/log.html | 0 tildelog/templates/log.html | 9 --- tildelog/tildelog.go | 111 ------------------------------------ 6 files changed, 1 insertion(+), 156 deletions(-) delete mode 100644 tildelog/entries/README.md delete mode 100644 tildelog/html/README.md delete mode 100644 tildelog/html/log.html delete mode 100644 tildelog/templates/log.html delete mode 100644 tildelog/tildelog.go diff --git a/README.md b/README.md index 4ccbec0..d0dc377 100644 --- a/README.md +++ b/README.md @@ -4,34 +4,7 @@ Various scripts and programs for the tildeverse. ## tildelog -Use **tildelog** to easily create a simple log for your tilde. [Create new posts](https://github.com/thebaer/tildes/tree/master/tildelog/entries#tildelog-entries) in the `tildelog/entries/` folder, then run this: - -```bash -cd tildelog -go build tildelog.go -./tildelog -template mytildelog -``` - -This will use any template in `tildelog/templates/` defined with _mytildelog_ (see below) to generate your full tildelog page. - -#### templates - -Your template should look like this. - -```html -{{define "mytildelog"}} - - - My ~log! - - -

~log

-

Welcome to my ~log.

- {{template "log" .}} - - -{{end}} -``` +tildelog has moved to **[squigglelog](https://github.com/thebaer/squigglelog)**. ## code Use **code** to generate a list of files contained within a given directory under their home folder. This was originally made to see who had a **Code** directory (this is the default), but you can specify whatever common directory you'd like to find. Do this: diff --git a/tildelog/entries/README.md b/tildelog/entries/README.md deleted file mode 100644 index 6f4f11c..0000000 --- a/tildelog/entries/README.md +++ /dev/null @@ -1,4 +0,0 @@ -tildelog entries -================ - -Create each entry as a new file here. Naming scheme: **YYYYMMDD**. Add formatting with HTML. diff --git a/tildelog/html/README.md b/tildelog/html/README.md deleted file mode 100644 index 63d49ad..0000000 --- a/tildelog/html/README.md +++ /dev/null @@ -1,4 +0,0 @@ -tildelog output -=============== - -Generated HTML will end up in this folder. diff --git a/tildelog/html/log.html b/tildelog/html/log.html deleted file mode 100644 index e69de29..0000000 diff --git a/tildelog/templates/log.html b/tildelog/templates/log.html deleted file mode 100644 index 27f31db..0000000 --- a/tildelog/templates/log.html +++ /dev/null @@ -1,9 +0,0 @@ -{{define "log"}} -
- {{range .}} -
-

{{.Date}}

-

{{printf "%s" .Body}}

- {{end}} -
-{{end}} diff --git a/tildelog/tildelog.go b/tildelog/tildelog.go deleted file mode 100644 index 2ca1c72..0000000 --- a/tildelog/tildelog.go +++ /dev/null @@ -1,111 +0,0 @@ -package main - -import ( - "fmt" - "io/ioutil" - "time" - "strconv" - "text/template" - "os" - "bufio" - "regexp" - "flag" -) - -const entriesPath = "./entries/" -const templatesPath = "./templates/" -const outputPath = "./html/" - -type Entry struct { - Date string - Body []byte -} - -func loadEntry(rawDate string) (*Entry, error) { - filename := entriesPath + rawDate - body, err := ioutil.ReadFile(filename) - if err != nil { - return nil, err - } - - // Get raw date parts for formatting - year := rawDate[:4] - month, moErr := strconv.Atoi(rawDate[4:6]) - if moErr != nil { - return nil, moErr - } - date, dateErr := strconv.Atoi(rawDate[6:8]) - if dateErr != nil { - return nil, dateErr - } - - formattedDate := fmt.Sprintf("%d %s %s", date, time.Month(month).String(), year) - - return &Entry{Date: formattedDate, Body: body}, nil -} - -func main() { - fmt.Println() - fmt.Println(" ~log generator v1.0") - fmt.Println() - - // Get any arguments - templateFilePtr := flag.String("template", "log", "Tildelog template file (defined name).") - flag.Parse() - - entryFiles := getEntries() - entries := make([]Entry, len(*entryFiles)) - i := 0 - for _, file := range *entryFiles { - entry, err := loadEntry(file) - if err != nil { - fmt.Printf("Error, skipping entry %s: %s\n", file, err) - continue - } - fmt.Printf("Adding entry %s...\n", file) - entries[i] = *entry - i++ - } - - fmt.Printf("Using template %s...\n", *templateFilePtr) - - generateLog(entries, *templateFilePtr) - - fmt.Printf("Finished! Saved to %slog.html\n", outputPath) -} - -var validFileFormat = regexp.MustCompile("^[0-9]{8}$") - -func getEntries() *[]string { - files, _ := ioutil.ReadDir(entriesPath) - fileList := make([]string, len(files)) - fileCount := 0 - // Traverse file list in reverse, i.e. newest to oldest - for i := len(files)-1; i >= 0; i-- { - file := files[i] - if validFileFormat.Match([]byte(file.Name())) { - fileList[fileCount] = file.Name() - fileCount++ - } - } - fileList = fileList[:fileCount] - return &fileList -} - -func generateLog(entries []Entry, templateFile string) { - file, err := os.Create(outputPath + "log.html") - if err != nil { - panic(err) - } - - defer file.Close() - - writer := bufio.NewWriter(file) - template, err := template.ParseGlob(templatesPath + "*.html") - if err != nil { - panic(err) - } - template.ExecuteTemplate(writer, templateFile, entries) - writer.Flush() -} -