1
0
mirror of https://github.com/thebaer/tildes.git synced 2018-07-20 07:15:21 +00:00

Unexport unnecessary types and functions

This commit is contained in:
Matt Baer 2015-02-14 19:57:21 -05:00
parent 5340a5f2c8
commit 8a41cc577e
2 changed files with 20 additions and 20 deletions

View File

@ -30,20 +30,20 @@ func main() {
} }
} }
type User struct { type user struct {
Name string Name string
Projects []Project Projects []project
} }
type Project struct { type project struct {
Name string Name string
Path string Path string
CssClass string CSSClass string
} }
func findProjects() map[string]User { func findProjects() map[string]user {
var files []string var files []string
users := make(map[string]User) users := make(map[string]user)
if len(searchDirs) > 1 { if len(searchDirs) > 1 {
for _, d := range searchDirs { for _, d := range searchDirs {
@ -59,7 +59,7 @@ func findProjects() map[string]User {
return users return users
} }
func mapFiles(files *[]string, users map[string]User) { func mapFiles(files *[]string, users map[string]user) {
for _, path := range *files { for _, path := range *files {
pparts := strings.Split(path, "/") pparts := strings.Split(path, "/")
uname := pparts[2] uname := pparts[2]
@ -91,12 +91,12 @@ func mapFiles(files *[]string, users map[string]User) {
cssClass = cssClass + " exec" cssClass = cssClass + " exec"
} }
proj := &Project{Name: fname, Path: strings.Replace(path, "/home/", "~", -1), CssClass: cssClass} proj := &project{Name: fname, Path: strings.Replace(path, "/home/", "~", -1), CSSClass: cssClass}
u, exists := users[uname] u, exists := users[uname]
if !exists { if !exists {
fmt.Printf("Found %s for ~%s.\n", pparts[3], uname) fmt.Printf("Found %s for ~%s.\n", pparts[3], uname)
projs := []Project{*proj} projs := []project{*proj}
u = User{Name: uname, Projects: projs} u = user{Name: uname, Projects: projs}
} else { } else {
u.Projects = append(u.Projects, *proj) u.Projects = append(u.Projects, *proj)
} }
@ -104,11 +104,11 @@ func mapFiles(files *[]string, users map[string]User) {
} }
} }
type Page struct { type page struct {
FolderName string FolderName string
Folders []string Folders []string
Host string Host string
Users map[string]User Users map[string]user
Updated string Updated string
UpdatedForHumans string UpdatedForHumans string
} }
@ -118,12 +118,12 @@ func graphicalName(n string) string {
return r.Replace(n) return r.Replace(n)
} }
func Split(s string, d string) []string { func split(s string, d string) []string {
arr := strings.Split(s, d) arr := strings.Split(s, d)
return arr return arr
} }
func ListDirs(dirs []string) string { func listDirs(dirs []string) string {
if len(dirs) > 1 { if len(dirs) > 1 {
for i := 0; i < len(dirs); i++ { for i := 0; i < len(dirs); i++ {
d := dirs[i] d := dirs[i]
@ -135,7 +135,7 @@ func ListDirs(dirs []string) string {
return fmt.Sprintf("<strong>%s</strong>", dirs[0]) return fmt.Sprintf("<strong>%s</strong>", dirs[0])
} }
func generate(users map[string]User, outputFile string) { func generate(users map[string]user, outputFile string) {
fmt.Println("Generating page.") fmt.Println("Generating page.")
f, err := os.Create(os.Getenv("HOME") + "/public_html/" + strings.ToLower(outputFile) + ".html") f, err := os.Create(os.Getenv("HOME") + "/public_html/" + strings.ToLower(outputFile) + ".html")
@ -146,8 +146,8 @@ func generate(users map[string]User, outputFile string) {
defer f.Close() defer f.Close()
funcMap := template.FuncMap { funcMap := template.FuncMap {
"Split": Split, "Split": split,
"ListDirs": ListDirs, "ListDirs": listDirs,
} }
w := bufio.NewWriter(f) w := bufio.NewWriter(f)
@ -163,8 +163,8 @@ func generate(users map[string]User, outputFile string) {
updated := curTime.Format(time.RFC3339) updated := curTime.Format(time.RFC3339)
// Generate the page // Generate the page
page := &Page{FolderName: searchDirs[0], Folders: searchDirs, Host: graphicalName(host), UpdatedForHumans: updatedReadable, Updated: updated, Users: users} p := &page{FolderName: searchDirs[0], Folders: searchDirs, Host: graphicalName(host), UpdatedForHumans: updatedReadable, Updated: updated, Users: users}
template.ExecuteTemplate(w, "code", page) template.ExecuteTemplate(w, "code", p)
w.Flush() w.Flush()
fmt.Println("DONE!") fmt.Println("DONE!")

View File

@ -31,7 +31,7 @@
<div class="links"> <div class="links">
<ul class="links"> <ul class="links">
{{range .Projects}} {{range .Projects}}
<li><span class="{{.CssClass}}">{{.Name}}</span> <span class="fullDir">&middot; {{.Path}}</span></li> <li><span class="{{.CSSClass}}">{{.Name}}</span> <span class="fullDir">&middot; {{.Path}}</span></li>
{{end}} {{end}}
</ul> </ul>
</div> </div>