change port; fix categories
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Arnas Udovicius 2022-08-17 14:32:20 +03:00
parent c48b8c6531
commit 5f9b822a02
2 changed files with 21 additions and 8 deletions

View file

@ -1,6 +1,9 @@
package main
import zord_tree "g.arns.lt/zordsdavini/zord-tree"
import (
zord_tree "g.arns.lt/zordsdavini/zord-tree"
"strings"
)
type FSummery struct {
Name string
@ -8,12 +11,15 @@ type FSummery struct {
Description string
Id string
Lang string
Created string
Copyright string
Tags []string
}
type TSummery struct {
Files []FSummery
Tags map[string]int
Files []FSummery
Tags map[string]int
Categories map[string]int
}
type FileContent struct {
@ -22,15 +28,20 @@ type FileContent struct {
}
func FormatTreeSummery(tree zord_tree.Tree) TSummery {
ts := TSummery{Tags: map[string]int{}}
readTree(tree, &ts)
ts := TSummery{Tags: map[string]int{}, Categories: map[string]int{}}
readTree(tree, &ts, true)
return ts
}
func readTree(tree zord_tree.Tree, ts *TSummery) {
func readTree(tree zord_tree.Tree, ts *TSummery, isRoot bool) {
for _, subtree := range tree.Dirs {
readTree(subtree, ts)
readTree(subtree, ts, false)
category := strings.Replace(subtree.Path, tree.Path, "", 1)
category = strings.Replace(category, "/", "", 1)
if isRoot {
ts.Categories[category]++
}
}
for _, file := range tree.Files {
@ -40,6 +51,8 @@ func readTree(tree zord_tree.Tree, ts *TSummery) {
Description: file.Meta["description"],
Id: file.Id,
Lang: file.Meta["lang"],
Created: file.Meta["created"],
Copyright: file.Meta["copyright"],
Tags: file.Tags,
})
for _, tag := range file.Tags {

View file

@ -32,7 +32,7 @@ func Run() {
panic(err)
}
ln, err := net.Listen("tcp", ":8001")
ln, err := net.Listen("tcp", ":8301")
if err != nil {
fmt.Println("Error starting server: " + err.Error())
}