diff options
Diffstat (limited to 'handler.go')
| -rw-r--r-- | handler.go | 31 | 
1 files changed, 4 insertions, 27 deletions
| @@ -7,6 +7,7 @@ import (  	"os"  	"path/filepath"  	"regexp" +	"sort"  	"strconv"  ) @@ -22,35 +23,11 @@ type Recipe struct {  }  func indexGet(w http.ResponseWriter, r *http.Request) { +	list := getRecipeList() -	recipes := make([]Recipe, 0) +	sort.Sort(list) -	entries, err := os.ReadDir(filepath.Join(config.Data, "recipes")) -	if err == nil { -		for _, v := range entries { -			if v.IsDir() == false { -				continue -			} - -			_, err = strconv.Atoi(v.Name()) -			if err != nil { -				continue -			} - -			textpath := filepath.Join(config.Data, "recipes", v.Name(), "text") -			data, _ := ioutil.ReadFile(textpath) -			markup := Markup(data) - -			recipes = append(recipes, Recipe{ -				v.Name(), -				markup.title(), -				string(data), -				"", -			}) -		} -	} - -	ServeTemplate(w, "index.html", recipes) +	ServeTemplate(w, "index.html", list)  }  func recipeGet(w http.ResponseWriter, r *http.Request) { | 
