add URL to Page struct
This commit is contained in:
parent
dd3b4159ec
commit
06b03d7480
14
main.go
14
main.go
|
@ -15,6 +15,7 @@ type hlink struct {
|
||||||
type Page struct {
|
type Page struct {
|
||||||
Body string
|
Body string
|
||||||
Links []hlink
|
Links []hlink
|
||||||
|
URL string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Game struct {
|
type Game struct {
|
||||||
|
@ -80,15 +81,18 @@ func fparse(fname string) Game{
|
||||||
case len(line) == 0:
|
case len(line) == 0:
|
||||||
pcount++
|
pcount++
|
||||||
case string(line[0]) == ":":
|
case string(line[0]) == ":":
|
||||||
game.Pages = append(game.Pages, Page{Body:cutFirstWord(line)})
|
sline := strings.Split(line, " ")
|
||||||
fmt.Println(cutFirstWord(line))
|
url := sline[0][1:] + ".html"
|
||||||
|
fmt.Println(url)
|
||||||
|
body := strings.Join(sline[1:]," ")
|
||||||
|
fmt.Println(body)
|
||||||
|
game.Pages = append(game.Pages, Page{Body:body,
|
||||||
|
URL: url})
|
||||||
|
//game.Pages = append(game.Pages, Page{Body:cutFirstWord(line)})
|
||||||
case string(line[0]) == "-":
|
case string(line[0]) == "-":
|
||||||
newLink := line2link(line)
|
newLink := line2link(line)
|
||||||
game.Pages[pcount].Links = append(game.Pages[pcount].Links, newLink)
|
game.Pages[pcount].Links = append(game.Pages[pcount].Links, newLink)
|
||||||
}
|
}
|
||||||
|
|
||||||
//fmt.Println(firstchar)
|
|
||||||
//game.Pages = append(game.Pages()
|
|
||||||
}
|
}
|
||||||
return game
|
return game
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue