@@ -433,6 +433,9 @@ var ( | |||||
AuthUser string | AuthUser string | ||||
AuthPassword string | AuthPassword string | ||||
//home page | |||||
RecommentRepoAddr string | |||||
//labelsystem config | //labelsystem config | ||||
LabelTaskName string | LabelTaskName string | ||||
LabelDatasetDeleteQueue string | LabelDatasetDeleteQueue string | ||||
@@ -1229,6 +1232,9 @@ func NewContext() { | |||||
LabelDatasetDeleteQueue = sec.Key("LabelDatasetDeleteQueue").MustString("LabelDatasetDeleteQueue") | LabelDatasetDeleteQueue = sec.Key("LabelDatasetDeleteQueue").MustString("LabelDatasetDeleteQueue") | ||||
DecompressOBSTaskName = sec.Key("DecompressOBSTaskName").MustString("LabelDecompressOBSQueue") | DecompressOBSTaskName = sec.Key("DecompressOBSTaskName").MustString("LabelDecompressOBSQueue") | ||||
sec = Cfg.Section("homepage") | |||||
RecommentRepoAddr = sec.Key("Address").MustString("https://git.openi.org.cn/OpenIOSSG/promote/raw/branch/master/") | |||||
sec = Cfg.Section("cloudbrain") | sec = Cfg.Section("cloudbrain") | ||||
CBAuthUser = sec.Key("USER").MustString("") | CBAuthUser = sec.Key("USER").MustString("") | ||||
CBAuthPassword = sec.Key("PWD").MustString("") | CBAuthPassword = sec.Key("PWD").MustString("") | ||||
@@ -7,6 +7,8 @@ package routers | |||||
import ( | import ( | ||||
"bytes" | "bytes" | ||||
"fmt" | |||||
"io/ioutil" | |||||
"net/http" | "net/http" | ||||
"strings" | "strings" | ||||
@@ -511,3 +513,43 @@ func NotFound(ctx *context.Context) { | |||||
ctx.Data["Title"] = "Page Not Found" | ctx.Data["Title"] = "Page Not Found" | ||||
ctx.NotFound("home.NotFound", nil) | ctx.NotFound("home.NotFound", nil) | ||||
} | } | ||||
func RecommendOrgFromPromote(ctx *context.Context) { | |||||
url := setting.RecommentRepoAddr + "organizations" | |||||
recommendFromPromote(ctx, url) | |||||
} | |||||
func recommendFromPromote(ctx *context.Context, url string) { | |||||
resp, err := http.Get(url) | |||||
if err != nil { | |||||
log.Info("Get organizations url error=" + err.Error()) | |||||
ctx.ServerError("QueryTrainJobList:", err) | |||||
return | |||||
} | |||||
bytes, err := ioutil.ReadAll(resp.Body) | |||||
resp.Body.Close() | |||||
if err != nil { | |||||
log.Info("Get organizations url error=" + err.Error()) | |||||
ctx.ServerError("QueryTrainJobList:", err) | |||||
return | |||||
} | |||||
allLineStr := string(bytes) | |||||
lines := strings.Split(allLineStr, "\n") | |||||
result := make([]string, len(lines)) | |||||
for i, line := range lines { | |||||
tmpIndex := strings.Index(line, ".") | |||||
log.Info("i=" + fmt.Sprint(i) + " line=" + line + " tmpIndex=" + fmt.Sprint(tmpIndex)) | |||||
if tmpIndex == -1 { | |||||
result[i] = strings.Trim(line, " ") | |||||
} else { | |||||
result[i] = strings.Trim(line[tmpIndex+1:], " ") | |||||
} | |||||
} | |||||
ctx.JSON(http.StatusOK, result) | |||||
} | |||||
func RecommendRepoFromPromote(ctx *context.Context) { | |||||
url := setting.RecommentRepoAddr + "projects" | |||||
recommendFromPromote(ctx, url) | |||||
} |
@@ -315,6 +315,8 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
}) | }) | ||||
m.Get("/", routers.Home) | m.Get("/", routers.Home) | ||||
m.Get("/dashboard", routers.Dashboard) | m.Get("/dashboard", routers.Dashboard) | ||||
m.Get("/recommend/org", routers.RecommendOrgFromPromote) | |||||
m.Get("/recommend/repo", routers.RecommendRepoFromPromote) | |||||
m.Group("/explore", func() { | m.Group("/explore", func() { | ||||
m.Get("", func(ctx *context.Context) { | m.Get("", func(ctx *context.Context) { | ||||
ctx.Redirect(setting.AppSubURL + "/explore/repos") | ctx.Redirect(setting.AppSubURL + "/explore/repos") | ||||