Skip to content

Commit

Permalink
bug fix + more screenshots + better CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaniv Eliash committed Sep 22, 2019
1 parent b8fff1b commit ec59376
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 11 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ Trying to execute this file on a disconnected machine will result in error.
Once the app is running, add it to your services in your local node,
the server publish port 80.

![alt text](https://github.com/geostant/aredn_discovery/raw/master/example.png "Logo Title Text 1")
Setup the directory service as any other service (I like to name my host as `directory`)
![alt text](service_setup.png)

<br><br><br>
How the screen will looks like, populated with nodes and services
![alt text](example.png)

<br>
**I'm always happy to receive any feedback (negative and positive) and other ideas on enhancing this tool.**
Binary file modified example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 29 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log"
"net/http"
"os"
"regexp"
"strconv"
)

Expand Down Expand Up @@ -49,6 +50,12 @@ func getUrl(url string) []byte {
return respByte
}

func extractHost(s string) string {
var r = regexp.MustCompile("http://([^:]+)")
res := r.FindStringSubmatch(s)
return res[1]
}

// getServices list all the visible services in the network
func getService() string {
var services Services
Expand All @@ -64,7 +71,8 @@ func getService() string {
result = result + (services.Services[i].Link)
result = result + "/\">"
result = result + (services.Services[i].Name)
result = result + "</a></th>"
result = result + "</a><br><small>by " + extractHost(services.Services[i].Link)
result = result + "</small></th>"
// New table line for each 5 records
if (i+1)%5 == 0 {
result = result + "</tr><tr>"
Expand Down Expand Up @@ -109,31 +117,43 @@ func getNodes() string {
return result
}

func main() {
// Check or Create static directory
if _, err := os.Stat("static/"); os.IsNotExist(err) {
os.Mkdir("static/", 0755)
func generateCSS() {
if _, err := os.Stat("static/style/"); os.IsNotExist(err) {
os.Mkdir("static/style", 0755)
}

style, err := os.Create("static/style/style.css")
check(err)
defer style.Close()

ws := bufio.NewWriter(style)

// Generating CSS Style file
ws.WriteString(".content { \n")
ws.WriteString(" max-width: 500px; \n")
ws.WriteString(" margin: auto; \n}\n\n")
ws.WriteString("body {\n")
ws.WriteString(" font-family:verdana;\n}\n\n")
ws.WriteString(".content {\n")
ws.WriteString(" max-width: 1024px;\n")
ws.WriteString(" margin: auto;\n}\n\n")
ws.WriteString("table { \n")
ws.WriteString(" border-collapse: collapse; \n}\n\n")
ws.WriteString("table, th, td { \n")
ws.WriteString(" border: 1px solid black; \n}\n\n")
ws.WriteString("th, td { \n")
ws.WriteString(" padding: 15px; \n")
ws.WriteString(" text-align: left; \n}\n")
ws.WriteString(" text-align: left; \n}\n\n")
ws.WriteString("small {\n")
ws.WriteString(" font-size: smaller;\n}\n")

ws.Flush()
}

func main() {
// Check or Create static directory
if _, err := os.Stat("static/"); os.IsNotExist(err) {
os.Mkdir("static/", 0755)
}

generateCSS()

html, err := os.Create("static/index.html")
check(err)
Expand Down
Binary file added service_setup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ec59376

Please sign in to comment.