-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
gos.gxml
executable file
·2644 lines (1917 loc) · 86.2 KB
/
gos.gxml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="UTF-8"?>
<gos>
<!--Stating the deployment type GoS should compile -->
<!-- Curent valid types are webapp,shell and precursor -->
<!-- Shell = cli, sort of a GoS(Ghost) in the Shell -->
<deploy>webapp</deploy>
<port>8884</port>
<!-- Using import within different tags will have different results -->
<!-- We going to make the goPkg Mongo Db Driver available to our application -->
<!-- Using <import/> within the <go/> tag is similar to using the import call within a .go file -->
<!-- To be less dramating, GoS will skip packages that it has already imported -->
<import src="reflect" />
<import src="encoding/gob" />
<import src="io/ioutil" />
<import src="crypto/sha512" />
<!--<import src="encoding/xml" />-->
<import src="log" />
<import src="html" />
<import src="time" />
<import src="gopkg.in/mgo.v2/bson"/>
<import src="github.com/cheikhshift/gos/core"/>
<import src="os" />
<import src="strconv" />
<import src="strings" />
<import src="github.com/gorilla/websocket" />
<import src="path/filepath" />
<import src="runtime"/>
<import src="github.com/adlane/exec"/>
<output>server_out.go</output>
<var type="bool">Windows</var>
<var type="string">autocompletePath</var>
<var type="">upgrader = websocket.Upgrader{}</var>
<var type="">portCount = 35000</var>
<var type="string">dfd</var>
<key>something-secretive-is-what-a-gorrilla-needs</key>
<domain></domain>
<!-- The <init/> tag is similar to the init function within Go, -->
<!-- -->
<main>
dfd = os.ExpandEnv("$GOPATH")
Windows = strings.Contains(runtime.GOOS, "windows")
trailerEx := ""
fmt.Println("Using $GOPATH @ home/workspace")
if Windows {
os.Chdir( os.ExpandEnv("$USERPROFILE") )
trailerEx = ".exe"
} else {
os.Chdir( os.ExpandEnv("$HOME") )
}
err := os.MkdirAll("workspace/",0700)
if err != nil {
fmt.Println(err.Error())
} else {
//download go
os.MkdirAll("workspace/src",0700)
os.MkdirAll("workspace/bin",0700)
os.MkdirAll("workspace/cache",0700)
os.MkdirAll("workspace/userData",0700)
cwd, _ := os.Getwd()
cwd = cwd + "/workspace"
os.Setenv("GOPATH", cwd)
pathbin := os.ExpandEnv("$PATH")
if Windows {
os.Setenv("PATH", pathbin + ":" + strings.Replace(cwd + "/bin", "/" , "\\", -1 ) )
} else {
os.Setenv("PATH", pathbin + ":" + cwd + "/bin")
}
dfd = cwd
}
if _, err := os.Stat(os.ExpandEnv("$GOPATH") + "/bin/gocode" + trailerEx); os.IsNotExist(err) {
fmt.Println("Go code completion not present, installing from github.com/mdempsky/gocode")
if Windows {
//
core.RunCmdSmart("go get -u -ldflags -H=windowsgui github.com/mdempsky/gocode")
} else {
_ , err1 := core.RunCmdSmart("go install github.com/mdempsky/gocode@latest")
if err1 != nil {
log.Fatal(err1)
}
}
}
if _, err := os.Stat(os.ExpandEnv("$GOPATH") + "/bin/dlv" + trailerEx); os.IsNotExist(err) {
fmt.Println("Delve not present, installing from github.com/go-delve/delve/cmd/dlv")
_, err1 := core.RunCmdSmart("go install github.com/go-delve/delve/cmd/dlv@latest")
if err1 != nil {
log.Fatal(err1)
}
}
if _, err := os.Stat(os.ExpandEnv("$GOPATH") + "/bin/golint" + trailerEx); os.IsNotExist(err) {
fmt.Println("Golint not present, installing from golang.org/x/lint/golint")
_, err1 := core.RunCmdSmart("go install golang.org/x/lint/golint@latest")
if err1 != nil {
log.Fatal(err1)
}
}
autocompletePath = filepath.Join(os.ExpandEnv("$GOPATH"), "strukture-autocomplete")
if _, err := os.Stat(autocompletePath); os.IsNotExist(err) {
fmt.Println("Creating autocomplete resource folder at " + autocompletePath)
os.MkdirAll(autocompletePath, 0700)
}
apps := methods.GetApps()
newapps := []App{}
for _, app := range apps {
if app.Name != "" {
app.Pid = ""
newapps = append(newapps, app)
}
}
methods.SaveApps(newapps)
log.Println("Strukture up on port 8884")
if len(os.Args) == 1 {
go func(){
dataDir := filepath.Join(dfd, "userData")
cache := filepath.Join(dfd, "cache")
c := chrome.Command("http://localhost:8884", dataDir, cache)
err := c.Run()
if err != nil {
log.Fatal(err)
}
os.Exit(0)
}()
}
</main>
<init>
gob.Register(&types.SoftUser{})
</init>
<!-- Contains interfaces and structs
that will be used by the GoS application -->
<header>
<!-- remember to Jumpline when stating methods or different struct attributes, it is vital for our parser \n trick -->
<struct name="FSCs">
Path string
Hide bool
Form Forms
</struct>
<struct name="SearchResult">
File, Snippet string
Matches [][]int
</struct>
<struct name="Dex">
Misc string
Text string
Link string
</struct>
<struct name="SoftUser">
Username string
Email string
Password []byte
Apps []App
Docker string
TrialEnd int64
StripeID,FLogin string
</struct>
<struct name="USettings">
LastPaid string
Email string
StripeID string
</struct>
<struct name="App">
Type string
Name string
PublicName string
Css []string
Groups []string
Passed,Running bool
LatestBuild,Pid string
</struct>
<struct name="TemplateEdits">
SavesTo,PKG,PreviewLink,ID,Mime string
File []byte
Settings RPut
</struct>
<struct name="WebRootEdits">
SavesTo,Type,PreviewLink,ID,PKG string
Faas bool
File []byte
BreakPoints []byte
</struct>
<struct name="TEditor">
PKG,Type,LType string
CreateForm RPut
</struct>
<!-- Boostrap -->
<struct name="Navbars">
Mode string
ID string
</struct>
<struct name="sModal">
Title string
Body string
Color string
Buttons []SButton
Form Forms
</struct>
<struct name="Forms">
Link string
Inputs []Inputs
Buttons []SButton
CTA string
Class string
</struct>
<struct name="SButton">
Text string
Class string
Link string
</struct>
<struct name="sTab">
Buttons []SButton
</struct>
<struct name="DForm">
Text,Link string
</struct>
<struct name="Alertbs">
Type string
Text string
Redirect string
</struct>
<struct name="Inputs">
Misc string
Text string
Name string
Type string
Options []string
Value string
</struct>
<struct name="Aput">
Link,Param,Value string
</struct>
<struct name="rPut">
Link string
DLink string
Inputs []Inputs
Count string
ListLink string
</struct>
<struct name="sSWAL">
Title,Type,Text string
</struct>
<struct name="sPackageEdit">
Type,Mainf,Shutdown,Initf,Sessionf string
IType,Package,Port,Key,Name,Ffpage,Erpage,Domain Aput
Css RPut
Imports []RPut
Variables []RPut
CssFiles []RPut
CreateVar RPut
CreateImport RPut
TName string
</struct>
<struct name="DebugObj">
PKG,Id,Username,RawLog,Time string
Bugs []DebugNode
</struct>
<struct name="DebugNode">
Action,Line,CTA string
</struct>
<!-- JSstree struct -->
<struct name="PkgItem">
ID string `json:"id"`
Icon string `json:"icon"`
Text string `json:"text"`
Children []PkgItem `json:"children"`
isXml bool `json:"isXml"`
Parent string `json:"parent"`
Link string `json:"link"`
Type string `json:"type"`
DType string `json:"dtype"`
RType string `json:"rtype"`
NType string `json:"ntype"`
MType string `json:"mtype"`
CType string `json:"ctype"`
AppID string `json:"appid"`
</struct>
<!-- Panels for packages -->
<struct name="sROC">
Name string
CompLog []byte
Build bool
Time,Pid string
</struct>
<struct name="vHuf">
Type,PKG string
Edata []byte
</struct>
<object struct="Dex" name="myDemoObject">
</object>
</header>
<methods>
<!-- Vars are defined as usual except within the var attribute for example : -->
<!-- If there is a basic go function : func hackfmt(data string, data2 string) -->
<!-- the attribute names would be called as such var="data string,data2 string" -->
<!-- Similar to a go function decleration-->
<!-- if a method matches the criteria for an interface it will be used as an interface method -->
<!-- To prevent that use the autoface attribute and set it to "false" By default it is true -->
<!-- Use the keep-local="true" attribute to limit a method within a Go file -->
<!-- Sometimes your method will return data -->
<!-- And to do so we will need to add a return var list by using the return attribute -->
<method name="BindMisc" var="misc,nav" return="Dex">
Nav := nav.(Dex)
Nav.Misc = misc.(string)
return Nav
</method>
<method name="ListPlugins" var="" return="[]string">
return GetPlugins()
</method>
<method name="BindID" var="id,nav" return="Dex">
Nav := nav.(Dex)
Nav.Misc = id.(string)
return Nav
</method>
<method name="RandTen" return="string">
return core.NewLen(10)
</method>
<!-- Package methods
ID string `json:"id"`
Icon string `json:"icon"`
Text string `json:"text"`
Children []PkgItem `json:"children"`
isXml bool `json:"isXml"`
Link string `json:"link"`
Type string `json:"type"`
Uses string -->
<method name="Fragmentize" var="inn" return="(finall string)">
finall = strings.Replace(inn.(string), ".tmpl","",-1)
return
</method>
<method name="parseLog" var="cline" return="string">
calls := strings.Split(cline.(string) , ":")
actionText := ""
if calls[0] == "service" {
actionText = "The line is located in Web service ( " + calls[1] + ") at line: " + calls[2]
} else if calls[0] == "init" {
actionText = "The line is located in your package Init func at line: " + calls[1]
} else if calls[0] == "main" {
actionText = "The line is located in your package Main func at line: " + calls[1]
} else if calls[0] == "structs" {
actionText = "The line is located in your package Interfaces at line: " + calls[1]
} else if calls[0] == "meth" {
actionText = "The line is located in your package template pipelines at line: " + calls[1]
}
return actionText
</method>
<method name="AnyBugs" var="packge" return="(ajet bool)" >
ajet = false //,err := DebugLogs.Find(bson.M{"pkg":packge.(string), "username":usernam.(string)}).Count()
bugs := GetLogs(packge.(string))
// local to package invoke directly
sapp := net_getApp(GetApps(), packge.(string))
if len(bugs) > 0 {
ajet = true
}
if sapp.Pid != "" {
ajet = true
}
return
</method>
<method name="PluginJS" var="" return="string">
plugins := GetPlugins()
jsstring := ""
for _, v := range plugins {
data, err := ioutil.ReadFile(os.ExpandEnv("$GOPATH") + "/src/" + v + "/index.js")
if err != nil {
fmt.Println("Error loading " , v)
} else {
jsstring = jsstring + "\n" + string(data)
}
}
return "<script>" + jsstring + "</script>"
</method>
<method name="FindmyBugs" var="packge" return="(ajet []DebugObj)">
ajet = GetLogs(packge.(string))
sapp := net_getApp(GetApps(), packge.(string))
if sapp.Pid != "" {
activLog := DebugObj{Time:"Server", Bugs:[]DebugNode{} }
ajet = append([]DebugObj{activLog}, ajet...)
}
return
</method>
<method name="isExpired" var="current,strip" return="bool">
if time.Now().Unix() > current.(int64) {
if strip.(string) == "" {
return true
} else {
return false
}
}
return false
</method>
<method name="getTemplate" return="core.Template" var="templates, name">
s := reflect.ValueOf(templates)
slice := make([]App,s.Len())
for i,_ := range slice {
v := s.Index(i).Interface().(core.Template)
if v.Name == name.(string) {
return v
}
}
return core.Template{}
</method>
<method name="mConsole">
</method>
<method name="mPut">
//response = "OK"
</method>
<method return="[]App" var="apps,name,app" name="updateApp">
s := reflect.ValueOf(apps)
n := make([]App, s.Len())
slice := make([]App,s.Len())
for i,_ := range slice {
v := s.Index(i).Interface().(App)
if v.Name == name.(string) {
n = append(n,app.(App))
} else if v.Name != "" {
n = append(n, v)
}
}
return n
</method>
<method return="App" var="apps,name" name="getApp">
s := reflect.ValueOf(apps)
slice := make([]App,s.Len())
for i,_ := range slice {
v := s.Index(i).Interface().(App)
if v.Name == name.(string) {
return v
}
}
return App{}
</method>
</methods>
<templates>
<template name="Css" tmpl="css" struct="Dex" desc="Little Bootstrap override" />
<template name="JS" tmpl="js" struct="Dex" desc="JS End tag" />
<template name="FA" tmpl="ui/fa" struct="Dex" desc="JS End tag" />
<template name="PluginList" tmpl="ui/pluginlist" struct="" />
<!-- Dialogs -->
<template name="Login" tmpl="ui/login" struct="Dex" desc="Login Prompt" />
<template name="Modal" tmpl="ui/modal" struct="sModal" desc="Modal" />
<template name="xButton" tmpl="ui/sbutton" struct="sButton" desc="Button Gen" />
<template name="jButton" tmpl="ui/user/forms/jbutton" struct="sButton" desc="Button Gen" />
<template name="PUT" tmpl="ui/user/forms/aput" struct="Aput" desc="Button Gen" />
<template name="Group" tmpl="ui/user/forms/tab" struct="sTab" desc="Button Gen" />
<template name="Register" tmpl="ui/register" struct="Dex" desc="Register Prompt" />
<template name="Alert" tmpl="ui/alert" struct="Alertbs" desc="Amovible alert" />
<template name="StructEditor" tmpl="editor/structs" struct="vHuf" desc="Amovible alert" />
<template name="MethodEditor" tmpl="editor/methods" struct="vHuf" desc="Amovible alert" />
<template name="ObjectEditor" tmpl="editor/objects" struct="vHuf" desc="Amovible alert" />
<template name="EndpointEditor" tmpl="editor/endpoints" struct="TEditor"/>
<template name="TimerEditor" tmpl="editor/timers" struct="TEditor"/>
<template name="FSC" tmpl="ui/fsc" struct="FSCs" desc="Amovible alert" />
<template name="MV" tmpl="ui/mv" struct="FSCs" desc="Amovible alert" />
<template name="RM" tmpl="ui/user/rm" struct="FSCs" />
<template name="WebRootEdit" tmpl="ui/user/panel/webrootedit" struct="WebRootEdits" desc="Amovible alert" />
<template name="WebRootEdittwo" tmpl="ui/user/panel/webtwo" struct="WebRootEdits" desc="Amovible alert" />
<template name="uSettings" tmpl="editor/settings" struct="USettings" desc="Amovible alert" />
<!-- User forms -->
<template name="Form" tmpl="ui/user/forms/form" struct="Forms" desc="" />
<template name="SWAL" tmpl="ui/user/forms/swal" struct="sSWAL" desc="" />
<!-- Panels for users ui/user/panel/ -->
<template name="ROC" tmpl="ui/user/panel/roc" struct="sROC" desc="" />
<template name="RPUT" tmpl="ui/user/forms/rput" struct="rPut" desc="" />
<template name="PackageEdit" tmpl="ui/user/panel/package" struct="sPackageEdit" desc="" />
<template name="Delete" tmpl="ui/user/panel/delete" struct="DForm" desc="" />
<template name="Welcome" tmpl="ui/welcome" struct="Dex" desc="" />
<template name="Stripe" tmpl="ui/stripe" struct="Dex" desc="" />
<template name="Debugger" tmpl="ui/debugger" struct="DebugObj" desc="" />
<template name="TemplateEdit" tmpl="ui/user/panel/templateEditor" struct="TemplateEdits" desc="" />
<template name="TemplateEditTwo" tmpl="ui/user/panel/tpetwo" struct="TemplateEdits" desc="" />
<!-- Dex Elements (Generic) -->
<template name="Input" tmpl="ui/input" struct="Inputs" desc="Input Gen" />
<template name="DebuggerNode" tmpl="ui/debugnode" struct="DebugObj" desc="Input Gen" />
<template name="Button" tmpl="ui/button" struct="Dex" desc="Button Gen" />
<template name="Submit" tmpl="ui/submit" struct="Dex" desc="Submit Gen" />
<template name="Logo" tmpl="logo" struct="Dex" desc="Strukture logo" />
<template name="Navbar" tmpl="ui/navbar" struct="Dex" desc="Navbar" />
<template name="NavCustom" tmpl="ui/navbars" struct="Navbars" desc="Navbar Special..." />
<template name="NavMain" tmpl="ui/navmain" struct="Dex" desc="Home Page Menu" />
<template name="NavPKG" tmpl="ui/navpkg" struct="Dex" desc="Package Page Menu" />
<template name="CrashedPage" tmpl="ui/crashedpage" struct="Dex" desc="Package Page Menu" />
<template name="EndpointTesting" tmpl="ui/endpointtester" struct="Dex" />
<template name="KanBan" tmpl="ui/kanban" struct="Dex" />
<template name="Docker" tmpl="ui/docker" struct="Dex" />
<template name="SearchProject" tmpl="ui/search" struct="Dex" />
<template name="NavPromo" tmpl="ui/navpromo" struct="Dex" desc="Package Page Menu" />
</templates>
<endpoints>
<!-- Package methods -->
<end path="/api/dockerfile" type="POST" >
imageName := r.FormValue("image")
strat := r.FormValue("strat")
port := r.FormValue("port")
pkg := r.FormValue("pkg")
dockerFilePath := filepath.Join(os.ExpandEnv("$GOPATH"), "src", pkg, "Dockerfile")
var dockerfile string
if strat == "Fast" {
dockerfile = fmt.Sprintf(methods.DockerLarge, imageName, port, port)
} else {
dockerfile = fmt.Sprintf(methods.DockerSmall, imageName, port, port)
}
err := ioutil.WriteFile(dockerFilePath, []byte(dockerfile),0700)
if err != nil {
log.Println(err)
}
response = "OK"
</end>
<end path="/api/composer" type="POST" >
methods.GenerateComposeFile(r)
response = "OK"
</end>
<end path="/api/golint" type="POST" >
pkg := r.FormValue("pkg")
file := r.FormValue("path")
path := filepath.Join(os.ExpandEnv("$GOPATH"), "src", pkg, file)
cmd := exec.Command("golint", path)
stOut, _ := cmd.CombinedOutput()
res := Dex{ Text : string(stOut) }
response = mResponse (res)
</end>
<end path="/api/govet" type="POST" >
pkg := r.FormValue("pkg")
path := filepath.Join(os.ExpandEnv("$GOPATH"), "src", pkg)
os.Chdir(path)
cmd := exec.Command("go", "vet")
stOut, _ := cmd.CombinedOutput()
res := Dex{ Text : string(stOut) }
response = mResponse (res)
</end>
<end path="/api/socket" type="star" >
c, err := upgrader.Upgrade(w, r, nil)
if err != nil {
log.Print("upgrade:", err)
return
}
defer c.Close()
methods.AddConnection(c)
for {
_, message, err := c.ReadMessage()
if err != nil {
log.Println("read:", err)
break
}
if len(message) != 0 {
methods.Broadcast(message)
}
}
</end>
<end path="/api/pkg-bugs" type="GET">
bugs := methods.GetLogs(r.FormValue("pkg"))
sapp := net_getApp(methods.GetApps(), r.FormValue("pkg") )
if len(bugs) == 0 || sapp.Passed {
response = "{}"
} else {
response = mResponse(bugs[0])
}
</end>
<end path="/api/kanban" type="GET">
pkgName := r.FormValue("pkg")
response = mResponse(methods.GetKanBan(pkgName))
</end>
<end path="/api/git" type="POST">
pkgName := r.FormValue("pkg")
cmd := r.FormValue("cmd")
if cmd == "commit" {
mess := r.FormValue("message")
response = mResponse(methods.CommitGit(pkgName, mess))
}
if cmd == "push" {
methods.PushGit(pkgName)
response = mResponse(false)
}
</end>
<end path="/api/kanban" type="POST">
pkgName := r.FormValue("pkg")
payload := r.FormValue("payload")
methods.SaveKanBan(pkgName, payload)
response = "OK"
</end>
<end path="/api/empty" type="GET" >
methods.ClearLogs(r.FormValue("pkg"))
response = net_bAlert(Alertbs{Type:"success",Text:"Your build logs are cleared." })
</end>
<end path="/api/search_project" type="f" >
path := filepath.Join(os.ExpandEnv("$GOPATH"), "src", r.FormValue("pkg"), r.FormValue("path") )
search := r.FormValue("text")
if r.FormValue("caseS") == "false" {
search = "(?i)" + search
}
rg, err := regexp.Compile(search)
if err != nil {
response = fmt.Sprintf("%s", err)
callmet = true
return
}
results := []SearchResult{}
walkfunc := func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if info.IsDir() {
return nil
}
if !strings.Contains( info.Name(), ".go") {
return nil
}
fData, err := ioutil.ReadFile(path)
if err != nil {
return err
}
sData := string(fData)
matches := rg.FindAllStringSubmatchIndex(sData, -1)
if len(matches) > 0 {
ent := SearchResult{
File : path,
Snippet : sData,
Matches : matches,
}
results = append(results, ent)
//fmt.Println(path, info.Size())
}
return nil
}
// file snippet matches
if r.FormValue("top") == "true" {
files, err := ioutil.ReadDir(path)
if err != nil {
log.Fatal(err)
return
}
for _, f := range files {
if f.IsDir() {
continue
}
if !strings.Contains( f.Name(), ".go") {
continue
}
pathf := filepath.Join(path, f.Name())
fData, err := ioutil.ReadFile(pathf)
if err != nil {
continue
}
sData := string(fData)
matches := rg.FindAllStringSubmatchIndex(sData, -1)
if len(matches) > 0 {
ent := SearchResult{
File : f.Name(),
Snippet : sData,
Matches : matches,
}
results = append(results, ent)
// fmt.Println(f.Name())
}
}
} else {
err = filepath.Walk(path, walkfunc)
if err != nil {
fmt.Println(err)
}
}
response = mResponse(results)
callmet = true
</end>
<end path="/api/get" method="mGet" type="f" >
me := SoftUser{Email:"Strukture user", Username:"Strukture user"}
if r.FormValue("type") == "0" {
mpk := []bson.M{}
apps := methods.GetApps()
for _, v := range apps {
if v.Name != "" {
appCo := []PkgItem{}
Childtm := []PkgItem{}
var folders []PkgItem
var pkgpath = core.TrimSuffix(os.ExpandEnv("$GOPATH"), "/")+"/src/"+v.Name+"/"
if Windows {
pkgpath = strings.Replace(pkgpath,"/", "\\", -1)
}
if _, errr := os.Stat(pkgpath + "gos.gxml"); !os.IsNotExist(errr) {
gos, _ := core.PLoadGos(os.ExpandEnv("$GOPATH") + "/src/" + v.Name + "/gos.gxml")
for _, b := range v.Groups {
tmpls := []PkgItem{}
for _, tm := range gos.Templates.Templates {
if tm.Bundle == b {
tmpls = append(tmpls, PkgItem{Type: "5", AppID: v.Name, Icon: "fa fa-page", DType: "5&tmpl=" + b + "/" + tm.Name, Text: tm.Name, ID: v.Name + "@pkg:" + b + "/" + tm.Name})
}
}
Childtm = append(Childtm, PkgItem{AppID: v.Name, Text: b, Icon: "fa fa-square", CType: "4&bundle=" + b, DType: "4&bundle=" + b, RType: "4&bundle=" + b, Children: tmpls})
}
_ = filepath.Walk(pkgpath + "web", func(path string, file os.FileInfo, _ error) error {
//fmt.Println(path)
if file.IsDir() {
lpathj := strings.Replace(path, pkgpath + "web", "", -1)
loca := PkgItem{AppID: v.Name, Text: lpathj, Icon: "fa fa-folder", Children: []PkgItem{}}
loca.CType = "5&path=" + lpathj
loca.DType = "6&isDir=Yes&path=" + lpathj
loca.MType = "6&path=" + lpathj
files, _ := ioutil.ReadDir(path)
for _, f := range files {
if !f.IsDir() && !strings.Contains(f.Name(), "go-breakpoints") {
var mjk string
mjk =strings.Replace(path, pkgpath +"web" , "",-1) + "/" + f.Name()
if Windows {
mjk = strings.Replace(mjk, "/", "\\", -1)
}
loca.Children = append(loca.Children, PkgItem{AppID: v.Name, Text: f.Name(), Icon: "fa fa-page", Type: "6", ID: v.Name + "@pkg:" + mjk, MType: "6&path=" + mjk, DType: "6&isDir=No&path=" + mjk})
}
}
folders = append(folders, loca)
}
//fmt.Println(file,path,file.Name,file.IsDir())
// var loca PkgItem = PkgItem{AppID:v.Name,Text: file.Name(),Icon: "fa fa-folder"}
return nil
})
appCo = append(appCo, PkgItem{AppID: v.Name, Text: "Template bundles", Icon: "fa fa-pencil-square", CType: "3", Children: Childtm})
appCo = append(appCo, PkgItem{AppID:v.Name,Text: "Web Resources",CType:"5&path=/",Children:folders,Icon: "fa fa-folder"} )
//appCo = append(appCo, PkgItem{AppID:v.Name,Type:"18",Text: "Testing",Icon: "fa fa-flask"} )
appCo = append(appCo, PkgItem{AppID:v.Name,Type:"8",Text: "Structs",Icon: "fa fa-share-alt"} )
//appCo = append(appCo, PkgItem{AppID:v.Name,Type:"9",Text: "Interface funcs",Icon: "fa fa-share-alt-square"} )
appCo = append(appCo, PkgItem{Type:"10",AppID:v.Name,Text: "Template pipelines",Icon: "fa fa-exchange"} )
appCo = append(appCo, PkgItem{AppID:v.Name,Type:"11",Text: "Web services",Icon: "fa fa-circle-o-notch"} )
}
var goFiles,ymlFiles []PkgItem
_ = filepath.Walk(pkgpath, func(path string, file os.FileInfo, _ error) error {
//fmt.Println(path)
if file.IsDir() {
lpathj := strings.Replace(path, pkgpath, "", -1)
loca := PkgItem{AppID: v.Name, Text: lpathj, Icon: "fa fa-circle", Children: []PkgItem{}}
hasgo := false
files, _ := ioutil.ReadDir(path)
for _, f := range files {
if !f.IsDir() && strings.Contains(f.Name(), ".go") && !strings.Contains(f.Name(), ".go-breakpoints") {
var mjk string
mjk = strings.Replace(path, pkgpath, "", -1) + "/" + f.Name()
if Windows {
mjk = strings.Replace(mjk, "/", "\\", -1)
}
hasgo = true
loca.Children = append(loca.Children, PkgItem{AppID: v.Name, Text: f.Name(), Icon: "fa fa-code", Type: "60", ID: v.Name + "@pkg:" + mjk, MType: "60&path=" + mjk, DType: "60&isDir=No&path=" + mjk})
}
}
loca.CType = "50&path=" + lpathj
loca.DType = "60&isDir=Yes&path=" + lpathj
loca.MType = "60&path=" + lpathj
if hasgo {
goFiles = append(goFiles, loca)
}
}