smth
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing

This commit is contained in:
Arnas Udovicius 2022-08-21 01:34:53 +03:00
parent 2c25bab053
commit a235a1adc1
3 changed files with 33 additions and 9 deletions

View file

@ -1,18 +1,21 @@
package main
import (
zord_tree "g.arns.lt/zordsdavini/zord-tree"
zordTree "g.arns.lt/zordsdavini/zord-tree"
"strings"
)
func FormatTreeSummery(tree zord_tree.Tree) Tree {
ts := Tree{}
func FormatTreeSummery(tree zordTree.Tree) Tree {
path := strings.Replace(tree.Path, dest, "", 1)
pathParts := strings.Split(path, "/")
rootPath := strings.Join(pathParts[:len(pathParts)-1], "/")
ts := Tree{RootPath: rootPath, Path: path}
readTree(tree, &ts, true)
return ts
}
func readTree(tree zord_tree.Tree, ts *Tree, isRoot bool) {
func readTree(tree zordTree.Tree, ts *Tree, isRoot bool) {
for _, subtree := range tree.Dirs {
readTree(subtree, ts, false)
category := strings.Replace(subtree.Path, tree.Path, "", 1)
@ -50,7 +53,7 @@ func readTree(tree zord_tree.Tree, ts *Tree, isRoot bool) {
}
}
func populateTreeFileData(newFile *TreeFile, file zord_tree.File) {
func populateTreeFileData(newFile *TreeFile, file zordTree.File) {
newFile.Name = file.Name
newFile.Category = file.Category
newFile.Description = file.Meta["description"]
@ -61,8 +64,8 @@ func populateTreeFileData(newFile *TreeFile, file zord_tree.File) {
newFile.Tags = file.Tags
}
func GetContent(file zord_tree.File) FileContent {
content, _ := zord_tree.ReadFileContent(file)
func GetContent(file zordTree.File) FileContent {
content, _ := zordTree.ReadFileContent(file)
newFile := TreeFile{}
populateTreeFileData(&newFile, file)

View file

@ -234,6 +234,8 @@ type Tree struct {
RootFiles []*TreeFile `protobuf:"bytes,4,rep,name=rootFiles,proto3" json:"rootFiles,omitempty"`
Tags map[string]int32 `protobuf:"bytes,2,rep,name=tags,proto3" json:"tags,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
Categories map[string]int32 `protobuf:"bytes,3,rep,name=categories,proto3" json:"categories,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
Path string `protobuf:"bytes,5,opt,name=path,proto3" json:"path,omitempty"`
RootPath string `protobuf:"bytes,6,opt,name=rootPath,proto3" json:"rootPath,omitempty"`
}
func (x *Tree) Reset() {
@ -296,6 +298,20 @@ func (x *Tree) GetCategories() map[string]int32 {
return nil
}
func (x *Tree) GetPath() string {
if x != nil {
return x.Path
}
return ""
}
func (x *Tree) GetRootPath() string {
if x != nil {
return x.RootPath
}
return ""
}
type FileContent struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -434,7 +450,7 @@ var file_tree_proto_rawDesc = []byte{
0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73,
0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x18, 0x0a, 0x07,
0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63,
0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x22, 0xb8, 0x02, 0x0a, 0x04, 0x54, 0x72, 0x65, 0x65, 0x12,
0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x22, 0xe8, 0x02, 0x0a, 0x04, 0x54, 0x72, 0x65, 0x65, 0x12,
0x24, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e,
0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x54, 0x72, 0x65, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x05,
0x66, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x2c, 0x0a, 0x09, 0x72, 0x6f, 0x6f, 0x74, 0x46, 0x69, 0x6c,
@ -446,7 +462,10 @@ var file_tree_proto_rawDesc = []byte{
0x0a, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28,
0x0b, 0x32, 0x1a, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x54, 0x72, 0x65, 0x65, 0x2e, 0x43, 0x61,
0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x63,
0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x1a, 0x37, 0x0a, 0x09, 0x54, 0x61, 0x67,
0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74,
0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x1a, 0x0a,
0x08, 0x72, 0x6f, 0x6f, 0x74, 0x50, 0x61, 0x74, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52,
0x08, 0x72, 0x6f, 0x6f, 0x74, 0x50, 0x61, 0x74, 0x68, 0x1a, 0x37, 0x0a, 0x09, 0x54, 0x61, 0x67,
0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75,
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02,

View file

@ -42,6 +42,8 @@ message Tree {
repeated TreeFile rootFiles = 4;
map<string, int32> tags = 2;
map<string, int32> categories = 3;
string path = 5;
string rootPath = 6;
}
message FileContent {