Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/2076 Reviewed-by: lewis <747342561@qq.com>pull/2078/head
@@ -237,6 +237,8 @@ page_recommend_repo_desc=Excellent AI projects recommendation. To show your proj | |||
page_recommend_repo_commit=Click here to submit. | |||
page_recommend_repo_go=Click here to | |||
page_recommend_repo_more=explore more projects. | |||
page_recommend_activity=Community Activities | |||
page_recommend_activity_desc=The community has prepared a wealth of activities, waiting for you to participate! | |||
page_dev_env=Collaborative Development Environment | |||
page_dev_env_desc=Provide a collaborative development environment for AI development, which is the biggest highlight that distinguishes the OpenI AI Collaboration Platform from other traditional Git platforms. | |||
page_dev_env_desc_title=Unified Management of Development Elements | |||
@@ -239,6 +239,8 @@ page_recommend_repo_desc=优秀的AI项目推荐;你的项目也想展示到 | |||
page_recommend_repo_commit=点此提交 | |||
page_recommend_repo_go=。进入 | |||
page_recommend_repo_more=项目广场 | |||
page_recommend_activity=社区活动 | |||
page_recommend_activity_desc=社区准备了丰富的活动,等你来参加! | |||
page_dev_env=协同开发环境 | |||
page_dev_env_desc=启智AI协作开发平台与传统git平台最大的不同就在于提供了面向AI开发的协同开发环境 | |||
page_dev_env_desc_title=开发要素统一管理 | |||
@@ -6,6 +6,7 @@ if(isEmpty(token)){ | |||
token = meta.attr("content"); | |||
} | |||
} | |||
var swiperNewMessage = new Swiper(".newslist", { | |||
direction: "vertical", | |||
slidesPerView: 10, | |||
@@ -15,6 +16,18 @@ var swiperNewMessage = new Swiper(".newslist", { | |||
disableOnInteraction: false, | |||
}, | |||
}); | |||
var swiperEvent = new Swiper(".event-list", { | |||
slidesPerView: 2, | |||
spaceBetween: 30, | |||
pagination: { | |||
el: ".swiper-pagination", | |||
clickable: true, | |||
}, | |||
autoplay: { | |||
delay: 2500, | |||
disableOnInteraction: false, | |||
}, | |||
}); | |||
var swiperRepo = new Swiper(".homepro-list", { | |||
slidesPerView: 1, | |||
slidesPerColumn: 2, | |||
@@ -433,6 +446,38 @@ function queryRecommendData(){ | |||
} | |||
}); | |||
$.ajax({ | |||
type:"GET", | |||
url:"/recommend/imageinfo", | |||
headers: { | |||
authorization:token, | |||
}, | |||
dataType:"json", | |||
async:false, | |||
success:function(json){ | |||
displayActivity(json); | |||
}, | |||
error:function(response) { | |||
} | |||
}); | |||
} | |||
function displayActivity(json){ | |||
var activityDiv = document.getElementById("recommendactivity"); | |||
var html = ""; | |||
if (json != null && json.length > 0){ | |||
for(var i = 0; i < json.length;i++){ | |||
var record = json[i] | |||
html += "<div class=\"swiper-slide\">"; | |||
html += "<a href=\"" + record["image_link"] + "\" class=\"ui fluid card\">"; | |||
html += " <div class=\"image\"><img src=\"" + record["url"] + "\"></div>" | |||
html += "</a>"; | |||
html += "</div>"; | |||
} | |||
} | |||
activityDiv.innerHTML = html; | |||
swiperEvent.updateSlides(); | |||
swiperEvent.updateProgress(); | |||
} | |||
function displayRepo(json){ | |||
@@ -8,6 +8,7 @@ package routers | |||
import ( | |||
"bytes" | |||
"net/http" | |||
"strconv" | |||
"strings" | |||
"code.gitea.io/gitea/services/repository" | |||
@@ -92,6 +93,8 @@ func setRecommendURL(ctx *context.Context) { | |||
ctx.Data["page_dev_yunlao_desc3"] = ctx.Tr("home.page_dev_yunlao_desc3") | |||
ctx.Data["page_dev_yunlao_desc4"] = ctx.Tr("home.page_dev_yunlao_desc4") | |||
ctx.Data["page_dev_yunlao_apply"] = ctx.Tr("home.page_dev_yunlao_apply") | |||
ctx.Data["page_recommend_activity"] = ctx.Tr("home.page_recommend_activity") | |||
ctx.Data["page_recommend_activity_desc"] = ctx.Tr("home.page_recommend_activity_desc") | |||
} | |||
func Dashboard(ctx *context.Context) { | |||
@@ -640,6 +643,87 @@ func GetRecommendOrg() ([]map[string]interface{}, error) { | |||
} | |||
return resultOrg, nil | |||
} | |||
func GetImageInfo() ([]map[string]interface{}, error) { | |||
url := setting.RecommentRepoAddr + "picture_info" | |||
result, err := repository.RecommendFromPromote(url) | |||
if err != nil { | |||
return nil, err | |||
} | |||
imageInfo := make([]map[string]interface{}, 0) | |||
for i := 0; i < (len(result) - 1); i++ { | |||
line := result[i] | |||
imageMap := make(map[string]interface{}) | |||
if line[0:4] == "url=" { | |||
url := line[4:] | |||
imageMap["url"] = url | |||
if result[i+1][0:11] == "image_link=" { | |||
image_link := result[i+1][11:] | |||
imageMap["image_link"] = image_link | |||
} | |||
} | |||
imageInfo = append(imageInfo, imageMap) | |||
i = i + 1 | |||
} | |||
return imageInfo, nil | |||
} | |||
func GetRankUser(index string) ([]map[string]interface{}, error) { | |||
url := setting.RecommentRepoAddr + "user_rank_" + index | |||
result, err := repository.RecommendFromPromote(url) | |||
if err != nil { | |||
return nil, err | |||
} | |||
resultOrg := make([]map[string]interface{}, 0) | |||
for _, userRank := range result { | |||
tmpIndex := strings.Index(userRank, " ") | |||
userName := userRank | |||
score := 0 | |||
if tmpIndex != -1 { | |||
userName = userRank[0:tmpIndex] | |||
tmpScore, err := strconv.Atoi(userRank[tmpIndex+1:]) | |||
if err != nil { | |||
log.Info("convert to int error.") | |||
} | |||
score = tmpScore | |||
} | |||
user, err := models.GetUserByName(userName) | |||
if err == nil { | |||
userMap := make(map[string]interface{}) | |||
userMap["Name"] = user.Name | |||
userMap["Description"] = user.Description | |||
userMap["FullName"] = user.FullName | |||
userMap["HomeLink"] = user.HomeLink() | |||
userMap["ID"] = user.ID | |||
userMap["Avatar"] = user.RelAvatarLink() | |||
userMap["Score"] = score | |||
resultOrg = append(resultOrg, userMap) | |||
} else { | |||
log.Info("query user error," + err.Error()) | |||
} | |||
} | |||
return resultOrg, nil | |||
} | |||
func GetImageInfoFromPromote(ctx *context.Context) { | |||
imageInfo, err := GetImageInfo() | |||
if err != nil { | |||
ctx.ServerError("500", err) | |||
return | |||
} | |||
ctx.JSON(200, imageInfo) | |||
} | |||
func GetUserRankFromPromote(ctx *context.Context) { | |||
index := ctx.Params("index") | |||
resultUserRank, err := GetRankUser(index) | |||
if err != nil { | |||
ctx.ServerError("500", err) | |||
return | |||
} | |||
ctx.JSON(200, resultUserRank) | |||
} | |||
func RecommendOrgFromPromote(ctx *context.Context) { | |||
resultOrg, err := GetRecommendOrg() | |||
@@ -325,6 +325,8 @@ func RegisterRoutes(m *macaron.Macaron) { | |||
m.Get("/action/notification", routers.ActionNotification) | |||
m.Get("/recommend/org", routers.RecommendOrgFromPromote) | |||
m.Get("/recommend/repo", routers.RecommendRepoFromPromote) | |||
m.Get("/recommend/userrank/:index", routers.GetUserRankFromPromote) | |||
m.Get("/recommend/imageinfo", routers.GetImageInfoFromPromote) | |||
m.Post("/all/search/", routers.Search) | |||
m.Get("/all/search/", routers.EmptySearch) | |||
m.Get("/all/dosearch/", routers.SearchApi) | |||
@@ -37,6 +37,20 @@ | |||
<div class="ui container homeorg"> | |||
<div class="ui stackable grid"> | |||
<div class="sixteen wide tablet four wide computer column homeorg-tit"> | |||
<h2>{{.page_recommend_activity}}</h2> | |||
<p><span class="ui text grey">{{.page_recommend_activity_desc}}</p> | |||
</div> | |||
<div class="sixteen wide tablet twelve wide computer column"> | |||
<div class="event-list"> | |||
<div class="swiper-wrapper" id="recommendactivity"> | |||
</div> | |||
<div class="swiper-pagination"></div> | |||
</div> | |||
</div> | |||
<div class="sixteen wide tablet four wide computer column homeorg-tit"> | |||
<h2>{{.page_recommend_org}}</h2> | |||
<p><span class="ui text grey">{{.page_recommend_org_desc}} </span><a href="{{.RecommendURL}}">{{.page_recommend_org_commit}}</a></p> | |||
<a href="{{AppSubUrl}}/explore/organizations" class="circular ui primary basic button">{{.page_recommend_org_more}} <i class="arrow circle right icon"></i></a> | |||