Skip to content

Commit

Permalink
Fix startup issue
Browse files Browse the repository at this point in the history
Update automated installer to play nice with Go modules
  • Loading branch information
cheikhshift committed Mar 14, 2022
1 parent 5f39581 commit 1e4730c
Show file tree
Hide file tree
Showing 58 changed files with 6,397 additions and 1,512 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Go lang IDE. Built with [GopherSauce](http://gophersauce.com)
## About project
IDE runs as a server and is accessed via web browser. Being a web server, the IDE boasts a web (HTML) interface is accessible from any device on your network.Compared to Microsoft VS Code and Eclipse CHE, this IDE is very minimalistic. It features :
- Web application resource management.
- Autocomplete between different files.
- Autocomplete between different files. ( This feature is broken as of now.)
- Syntax correction.
- Server process management.
- Interactive terminal via web socket.
Expand All @@ -22,7 +22,16 @@ IDE runs as a server and is accessed via web browser. Being a web server, the ID

## Requirements
- Go v1.15+.
- Git. Git present as a command on your system.

## First Launch

If the server launch hangs on startup, close it and install the additional requirements manually. Prior to running the commands, set your GOPATH to `$home/workspace`. You can do this on Windows with `set GOPATH=%USERPROFILE%\workspace`.
Run the following command :

go get github.com/nsf/gocode

To add debug support, you must install delve. You can find the guide here. (Don't worry it is quick) [Install Delve](https://github.com/go-delve/delve/tree/master/Documentation/installation)

## Install

Expand Down
1,693 changes: 835 additions & 858 deletions api/assets/bindata.go

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion api/handlers/rest_ApiComplete.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ func ApiComplete(w http.ResponseWriter, r *http.Request, session *sessions.Sessi

res, _ := core.RunCmdSmart(cmd)
response = res
os.Remove(tempFile)
fmt.Println(tempFile, prefx)
//os.Remove(tempFile)

}

Expand Down
2 changes: 1 addition & 1 deletion api/handlers/rest_POSTApiNew.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func POSTApiNew(w http.ResponseWriter, r *http.Request, session *sessions.Sessio
inputs := []types.Inputs{}
inputs = append(inputs, types.Inputs{Type: "text", Name: "name", Misc: "required", Text: "Package Name"})
inputs = append(inputs, types.Inputs{Type: "hidden", Name: "type", Value: "0"})
inputs = append(inputs, types.Inputs{Type: "select", Misc: "Project type", Name: "usegos", Value: "Scratch", Options: []string{"Scratch", "Build with GopherSauce", "Existing package", "faas"}})
inputs = append(inputs, types.Inputs{Type: "select", Misc: "Project type", Name: "usegos", Value: "Scratch", Options: []string{"Scratch", "Existing package", "faas"}})

response = templates.Modal(types.SModal{Body: "", Title: "Add Package", Color: "#ededed", Form: types.Forms{Link: "/api/act", CTA: "Add Package", Class: "warning btn-block", Buttons: []types.SButton{}, Inputs: inputs}})

Expand Down
120 changes: 107 additions & 13 deletions api/templates/template_Alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,147 @@
package templates

import (
"bytes"
"encoding/json"
"fmt"
"html"
"html/template"
"log"

"github.com/fatih/color"
"github.com/thestrukture/IDE/api/assets"
"github.com/thestrukture/IDE/types"
)

// Template path
var templateIDAlert = "tmpl/ui/alert.tmpl"

//
// Renders HTML of template
// Alert with struct types.Alertbs
func Alert(d types.Alertbs) string {
return netbAlert(d)
}

// recovery function used to log a
// panic.
func templateFNAlert(localid string, d interface{}) {
if n := recover(); n != nil {
color.Red(fmt.Sprintf("Error loading template in path (ui/alert) : %s", localid))
// log.Println(n)
DebugTemplatePath(localid, d)
}
}

var templateIDAlert = "tmpl/ui/alert.tmpl"

// Render template with JSON string as
// data.
func netAlert(args ...interface{}) string {

// Get data from JSON
var d = netcAlert(args...)
return netbAlert(d)
localid := templateIDAlert
var d *types.Alertbs
defer templateFNAlert(localid, d)
if len(args) > 0 {
jso := args[0].(string)
var jsonBlob = []byte(jso)
err := json.Unmarshal(jsonBlob, d)
if err != nil {
return err.Error()
}
} else {
d = &types.Alertbs{}
}

output := new(bytes.Buffer)

if _, ok := templateCache.Get(localid); !ok || !Prod {

body, er := assets.Asset(localid)
if er != nil {
return ""
}
var localtemplate = template.New("Alert")
localtemplate.Funcs(TemplateFuncStore)
var tmpstr = string(body)
localtemplate.Parse(tmpstr)
body = nil
templateCache.Put(localid, localtemplate)
}

erro := templateCache.JGet(localid).Execute(output, d)
if erro != nil {
color.Red(fmt.Sprintf("Error processing template %s", localid))
DebugTemplatePath(localid, d)
}
var outps = output.String()
var outpescaped = html.UnescapeString(outps)
d = nil
output.Reset()
output = nil
args = nil
return outpescaped

}

// alias of template render function.
func bAlert(d types.Alertbs) string {
return netbAlert(d)
}

//

// template render function
func netbAlert(d types.Alertbs) string {
localid := templateIDAlert
name := "Alert"
defer templateRecovery(name, localid, &d)
defer templateFNAlert(localid, d)
output := new(bytes.Buffer)

// render and return template result
return executeTemplate(name, localid, &d)
if _, ok := templateCache.Get(localid); !ok || !Prod {

body, er := assets.Asset(localid)
if er != nil {
return ""
}
var localtemplate = template.New("Alert")
localtemplate.Funcs(TemplateFuncStore)
var tmpstr = string(body)
localtemplate.Parse(tmpstr)
body = nil
templateCache.Put(localid, localtemplate)
}

erro := templateCache.JGet(localid).Execute(output, d)
if erro != nil {
log.Println(erro)
}
var outps = output.String()
var outpescaped = html.UnescapeString(outps)
d = types.Alertbs{}
output.Reset()
output = nil
return outpescaped
}

// Unmarshal a json string to the template's struct
// type
func netcAlert(args ...interface{}) (d types.Alertbs) {

if len(args) > 0 {
jsonData := args[0].(string)
err := parseJSON(jsonData, &d)
var jsonBlob = []byte(args[0].(string))
err := json.Unmarshal(jsonBlob, &d)
if err != nil {
log.Println("error:", err)
return
}
} else {
d = types.Alertbs{}
}
return
}

// Create a struct variable of template.
func cAlert(args ...interface{}) (d types.Alertbs) {
if len(args) > 0 {
d = netcAlert(args[0])
} else {
d = netcAlert()
}
return
}
120 changes: 107 additions & 13 deletions api/templates/template_Button.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,147 @@
package templates

import (
"bytes"
"encoding/json"
"fmt"
"html"
"html/template"
"log"

"github.com/fatih/color"
"github.com/thestrukture/IDE/api/assets"
"github.com/thestrukture/IDE/types"
)

// Template path
var templateIDButton = "tmpl/ui/button.tmpl"

//
// Renders HTML of template
// Button with struct types.Dex
func Button(d types.Dex) string {
return netbButton(d)
}

// recovery function used to log a
// panic.
func templateFNButton(localid string, d interface{}) {
if n := recover(); n != nil {
color.Red(fmt.Sprintf("Error loading template in path (ui/button) : %s", localid))
// log.Println(n)
DebugTemplatePath(localid, d)
}
}

var templateIDButton = "tmpl/ui/button.tmpl"

// Render template with JSON string as
// data.
func netButton(args ...interface{}) string {

// Get data from JSON
var d = netcButton(args...)
return netbButton(d)
localid := templateIDButton
var d *types.Dex
defer templateFNButton(localid, d)
if len(args) > 0 {
jso := args[0].(string)
var jsonBlob = []byte(jso)
err := json.Unmarshal(jsonBlob, d)
if err != nil {
return err.Error()
}
} else {
d = &types.Dex{}
}

output := new(bytes.Buffer)

if _, ok := templateCache.Get(localid); !ok || !Prod {

body, er := assets.Asset(localid)
if er != nil {
return ""
}
var localtemplate = template.New("Button")
localtemplate.Funcs(TemplateFuncStore)
var tmpstr = string(body)
localtemplate.Parse(tmpstr)
body = nil
templateCache.Put(localid, localtemplate)
}

erro := templateCache.JGet(localid).Execute(output, d)
if erro != nil {
color.Red(fmt.Sprintf("Error processing template %s", localid))
DebugTemplatePath(localid, d)
}
var outps = output.String()
var outpescaped = html.UnescapeString(outps)
d = nil
output.Reset()
output = nil
args = nil
return outpescaped

}

// alias of template render function.
func bButton(d types.Dex) string {
return netbButton(d)
}

//

// template render function
func netbButton(d types.Dex) string {
localid := templateIDButton
name := "Button"
defer templateRecovery(name, localid, &d)
defer templateFNButton(localid, d)
output := new(bytes.Buffer)

// render and return template result
return executeTemplate(name, localid, &d)
if _, ok := templateCache.Get(localid); !ok || !Prod {

body, er := assets.Asset(localid)
if er != nil {
return ""
}
var localtemplate = template.New("Button")
localtemplate.Funcs(TemplateFuncStore)
var tmpstr = string(body)
localtemplate.Parse(tmpstr)
body = nil
templateCache.Put(localid, localtemplate)
}

erro := templateCache.JGet(localid).Execute(output, d)
if erro != nil {
log.Println(erro)
}
var outps = output.String()
var outpescaped = html.UnescapeString(outps)
d = types.Dex{}
output.Reset()
output = nil
return outpescaped
}

// Unmarshal a json string to the template's struct
// type
func netcButton(args ...interface{}) (d types.Dex) {

if len(args) > 0 {
jsonData := args[0].(string)
err := parseJSON(jsonData, &d)
var jsonBlob = []byte(args[0].(string))
err := json.Unmarshal(jsonBlob, &d)
if err != nil {
log.Println("error:", err)
return
}
} else {
d = types.Dex{}
}
return
}

// Create a struct variable of template.
func cButton(args ...interface{}) (d types.Dex) {
if len(args) > 0 {
d = netcButton(args[0])
} else {
d = netcButton()
}
return
}
Loading

0 comments on commit 1e4730c

Please sign in to comment.