pr comments
This commit is contained in:
parent
7bea22e504
commit
65f97fc7be
2 changed files with 26 additions and 18 deletions
|
|
@ -443,8 +443,10 @@ func (w *watcher) handleRoot(hw http.ResponseWriter, r *http.Request) {
|
||||||
</html>`, filepath.Base(w.outputPath), w.devMode)
|
</html>`, filepath.Base(w.outputPath), w.devMode)
|
||||||
|
|
||||||
// if path is "/x.svg", we just want "x"
|
// if path is "/x.svg", we just want "x"
|
||||||
split := strings.Split(strings.TrimPrefix(r.URL.Path, "/"), ".")
|
boardPath := strings.TrimPrefix(r.URL.Path, "/")
|
||||||
boardPath := strings.Join(split[:len(split)-1], ".")
|
if idx := strings.LastIndexByte(boardPath, '.'); idx != -1 {
|
||||||
|
boardPath = boardPath[:idx]
|
||||||
|
}
|
||||||
if boardPath != w.boardPath {
|
if boardPath != w.boardPath {
|
||||||
w.boardPath = boardPath
|
w.boardPath = boardPath
|
||||||
w.requestCompile()
|
w.requestCompile()
|
||||||
|
|
|
||||||
|
|
@ -81,53 +81,59 @@ func (d *Diagram) GetBoard(boardPath string) *Diagram {
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
head := path[0]
|
return d.getBoard(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Diagram) getBoard(boardPath []string) *Diagram {
|
||||||
|
head := boardPath[0]
|
||||||
|
|
||||||
if head == "index" {
|
if head == "index" {
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
switch head {
|
switch head {
|
||||||
case "layers", "scenarios", "steps":
|
case "layers":
|
||||||
if len(path) < 2 {
|
if len(boardPath) < 2 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
switch head {
|
|
||||||
case "layers":
|
|
||||||
for _, b := range d.Layers {
|
for _, b := range d.Layers {
|
||||||
if b.Name == path[1] {
|
if b.Name == boardPath[1] {
|
||||||
return b.GetBoard(strings.Join(path[2:], string(os.PathSeparator)))
|
return b.getBoard(boardPath[2:])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "scenarios":
|
case "scenarios":
|
||||||
|
if len(boardPath) < 2 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
for _, b := range d.Scenarios {
|
for _, b := range d.Scenarios {
|
||||||
if b.Name == path[1] {
|
if b.Name == boardPath[1] {
|
||||||
return b.GetBoard(strings.Join(path[2:], string(os.PathSeparator)))
|
return b.getBoard(boardPath[2:])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "steps":
|
case "steps":
|
||||||
|
if len(boardPath) < 2 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
for _, b := range d.Steps {
|
for _, b := range d.Steps {
|
||||||
if b.Name == path[1] {
|
if b.Name == boardPath[1] {
|
||||||
return b.GetBoard(strings.Join(path[2:], string(os.PathSeparator)))
|
return b.getBoard(boardPath[2:])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, b := range d.Layers {
|
for _, b := range d.Layers {
|
||||||
if b.Name == head {
|
if b.Name == head {
|
||||||
return b.GetBoard(strings.Join(path[1:], string(os.PathSeparator)))
|
return b.getBoard(boardPath[2:])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, b := range d.Scenarios {
|
for _, b := range d.Scenarios {
|
||||||
if b.Name == head {
|
if b.Name == head {
|
||||||
return b.GetBoard(strings.Join(path[1:], string(os.PathSeparator)))
|
return b.getBoard(boardPath[2:])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, b := range d.Steps {
|
for _, b := range d.Steps {
|
||||||
if b.Name == head {
|
if b.Name == head {
|
||||||
return b.GetBoard(strings.Join(path[1:], string(os.PathSeparator)))
|
return b.getBoard(boardPath[2:])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue