Skip to content

Commit c82d6e0

Browse files
committed
move from src.d, implement quiqr_repo_show
1 parent d21fe2e commit c82d6e0

File tree

8 files changed

+661
-94
lines changed

8 files changed

+661
-94
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# embgit 4.0, June 7, 2022
2+
3+
- rename alladd to add_all
4+
- drop ls_remote
5+
- add quiqr_repo_show
6+
17
# embgit 3.7, June 3, 2022
28

39
- refactor code base

go.mod

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,48 @@
11
module src
22

3-
go 1.16
3+
go 1.18
44

55
require (
6+
github.com/davecgh/go-spew v1.1.1
67
github.com/go-git/go-git/v5 v5.4.2
8+
github.com/spf13/viper v1.12.0
79
github.com/urfave/cli/v2 v2.8.1
810
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e
11+
golang.org/x/exp v0.0.0-20220602145555-4a0574d9293f
12+
)
13+
14+
require (
15+
github.com/Microsoft/go-winio v0.4.16 // indirect
16+
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 // indirect
17+
github.com/acomagu/bufpipe v1.0.3 // indirect
18+
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
19+
github.com/emirpasic/gods v1.12.0 // indirect
20+
github.com/fsnotify/fsnotify v1.5.4 // indirect
21+
github.com/go-git/gcfg v1.5.0 // indirect
22+
github.com/go-git/go-billy/v5 v5.3.1 // indirect
23+
github.com/hashicorp/hcl v1.0.0 // indirect
24+
github.com/imdario/mergo v0.3.12 // indirect
25+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
26+
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
27+
github.com/magiconair/properties v1.8.6 // indirect
28+
github.com/mitchellh/go-homedir v1.1.0 // indirect
29+
github.com/mitchellh/mapstructure v1.5.0 // indirect
30+
github.com/pelletier/go-toml v1.9.5 // indirect
31+
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
32+
github.com/russross/blackfriday/v2 v2.1.0 // indirect
33+
github.com/sergi/go-diff v1.1.0 // indirect
34+
github.com/spf13/afero v1.8.2 // indirect
35+
github.com/spf13/cast v1.5.0 // indirect
36+
github.com/spf13/jwalterweatherman v1.1.0 // indirect
37+
github.com/spf13/pflag v1.0.5 // indirect
38+
github.com/subosito/gotenv v1.3.0 // indirect
39+
github.com/xanzy/ssh-agent v0.3.0 // indirect
40+
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
41+
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 // indirect
42+
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
43+
golang.org/x/text v0.3.7 // indirect
44+
gopkg.in/ini.v1 v1.66.4 // indirect
45+
gopkg.in/warnings.v0 v0.1.2 // indirect
46+
gopkg.in/yaml.v2 v2.4.0 // indirect
47+
gopkg.in/yaml.v3 v3.0.0 // indirect
948
)

go.sum

Lines changed: 450 additions & 11 deletions
Large diffs are not rendered by default.

src/cmd_add_all.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
func cmdAddAll() *cli.Command {
88

99
return &cli.Command{
10-
Name: "all_add",
11-
Usage: "all_add",
10+
Name: "add_all",
11+
Usage: "add_all",
1212
Action: func(c *cli.Context) error {
1313

1414
directory := c.Args().Get(0)

src/cmd_ls-remote.go

Lines changed: 0 additions & 79 deletions
This file was deleted.

src/cmd_quiqr_repo_show.go

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"github.com/davecgh/go-spew/spew"
6+
"path/filepath"
7+
"github.com/spf13/viper"
8+
"encoding/json"
9+
"golang.org/x/exp/slices"
10+
"strings"
11+
"bytes"
12+
"net/http"
13+
14+
"github.com/urfave/cli/v2"
15+
"github.com/go-git/go-git/v5"
16+
"github.com/go-git/go-git/v5/plumbing/object"
17+
"github.com/go-git/go-git/v5/storage/memory"
18+
19+
)
20+
21+
type responseDictType struct {
22+
HugoVersion string
23+
HugoTheme string
24+
QuiqrFormsEndPoints int
25+
QuiqrModel string
26+
Screenshot string
27+
}
28+
29+
30+
func cmdLsRemote() *cli.Command {
31+
32+
return &cli.Command{
33+
Name: "quiqr_repo_show",
34+
Usage: "quiqr_repo_show",
35+
Action: func(c *cli.Context) error {
36+
37+
url := c.Args().Get(0)
38+
showCase(url)
39+
return nil
40+
},
41+
}
42+
}
43+
44+
45+
func showCase(url string){
46+
47+
r, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
48+
URL: url,
49+
})
50+
51+
CheckIfError(err)
52+
53+
ref, err := r.Head()
54+
CheckIfError(err)
55+
56+
commit, err := r.CommitObject(ref.Hash())
57+
CheckIfError(err)
58+
59+
tree, err := commit.Tree()
60+
CheckIfError(err)
61+
62+
var hugover string;
63+
var hugotheme string;
64+
formEndPoints := 0;
65+
var screenshot1 string;
66+
var quiqrModel string;
67+
68+
tree.Files().ForEach(func(f *object.File) error {
69+
70+
//GET HUGO VERSIONS
71+
if(strings.HasPrefix(f.Name, "quiqr/model/base.")){
72+
73+
contents, _ := f.Contents()
74+
var extension = strings.TrimLeft(filepath.Ext(f.Name), ".")
75+
viper.SetConfigType(extension)
76+
viper.ReadConfig(bytes.NewBuffer([]byte(contents)))
77+
hugover, _ = viper.Get("hugover").(string)
78+
quiqrModel = "base"
79+
}
80+
81+
if(strings.HasPrefix(f.Name, "quiqr/model/includes/singles.")){
82+
quiqrModel = quiqrModel + " singles"
83+
}
84+
85+
if(strings.HasPrefix(f.Name, "quiqr/model/includes/collections.")){
86+
quiqrModel = quiqrModel + " collections"
87+
}
88+
89+
if(strings.HasPrefix(f.Name, "quiqr/model/includes/collections.")){
90+
quiqrModel = quiqrModel + " menu"
91+
}
92+
93+
if(strings.HasPrefix(f.Name, "quiqr/etalage/screenshots/")){
94+
95+
imgExts := []string{"jpg", "png", "git", "jpeg"}
96+
extension := strings.ToLower(strings.TrimLeft(filepath.Ext(f.Name), "."))
97+
if(slices.Contains(imgExts, extension)){
98+
spew.Dump(f.Name)
99+
contents, _ := f.Contents()
100+
contentsBytes := []byte(contents)
101+
102+
103+
var base64Encoding string
104+
105+
// Determine the content type of the image file
106+
mimeType := http.DetectContentType(contentsBytes)
107+
108+
// Prepend the appropriate URI scheme header depending
109+
// on the MIME type
110+
switch mimeType {
111+
case "image/jpeg":
112+
base64Encoding += "data:image/jpeg;base64,"
113+
case "image/png":
114+
base64Encoding += "data:image/png;base64,"
115+
}
116+
117+
// Append the base64 encoded output
118+
base64Encoding += toBase64(contentsBytes)
119+
120+
// Print the full base64 representation of the image
121+
screenshot1 = base64Encoding
122+
}
123+
}
124+
125+
if(strings.HasPrefix(f.Name, "quiqr/forms/")){
126+
formEndPoints++
127+
//spew.Dump(f.Name)
128+
}
129+
130+
if(strings.HasPrefix(f.Name, "config.")){
131+
contents, _ := f.Contents()
132+
var extension = strings.TrimLeft(filepath.Ext(f.Name), ".")
133+
viper.SetConfigType(extension)
134+
viper.ReadConfig(bytes.NewBuffer([]byte(contents)))
135+
hugotheme, _ = viper.Get("theme").(string)
136+
}
137+
138+
return nil
139+
})
140+
141+
responseDict := &responseDictType{
142+
HugoVersion: hugover,
143+
HugoTheme: hugotheme,
144+
QuiqrFormsEndPoints: formEndPoints,
145+
QuiqrModel: quiqrModel,
146+
Screenshot: screenshot1,
147+
}
148+
responseJson, _ := json.Marshal(responseDict)
149+
fmt.Println(string(responseJson))
150+
}
151+
152+
153+

src/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
ssh2 "github.com/go-git/go-git/v5/plumbing/transport/ssh"
1616
)
1717

18-
const version = "v0.3.7"
18+
const version = "v0.4.0"
1919

2020
func setAuth(keyfilepath string, ignoreHostkey bool) transport.AuthMethod {
2121
//var auth transport.AuthMethod

src/utils.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package main
2+
import (
3+
"encoding/base64"
4+
)
5+
6+
func toBase64(b []byte) string {
7+
return base64.StdEncoding.EncodeToString(b)
8+
}
9+

0 commit comments

Comments
 (0)