diff --git a/models/cloudbrain.go b/models/cloudbrain.go
index 4c7bf76a2..ebc18caf9 100755
--- a/models/cloudbrain.go
+++ b/models/cloudbrain.go
@@ -565,6 +565,17 @@ type FlavorInfo struct {
Desc string `json:"desc"`
}
+type SpecialPools struct {
+ Pools []*SpecialPool `json:"pools"`
+}
+type SpecialPool struct {
+ Org string `json:"org"`
+ Type string `json:"type"`
+ IsExclusive bool `json:"isExclusive"`
+ Pool []*GpuInfo `json:"pool"`
+ JobType []string `json:"jobType"`
+}
+
type ImageInfosModelArts struct {
ImageInfo []*ImageInfoModelArts `json:"image_info"`
}
diff --git a/models/custom_migrations.go b/models/custom_migrations.go
old mode 100644
new mode 100755
index 412bedce1..65b53f0f4
--- a/models/custom_migrations.go
+++ b/models/custom_migrations.go
@@ -15,13 +15,9 @@ type CustomMigrationStatic struct {
Migrate func(*xorm.Engine, *xorm.Engine) error
}
-var customMigrations = []CustomMigration{
- {"Custom v1 Topic struct change to support chinese", syncTopicStruct},
-}
+var customMigrations []CustomMigration
-var customMigrationsStatic = []CustomMigrationStatic{
- {"update issue_fixed_rate to 1 if num_issues is 0 ", updateIssueFixedRate},
-}
+var customMigrationsStatic []CustomMigrationStatic
func MigrateCustom(x *xorm.Engine) {
diff --git a/models/dataset.go b/models/dataset.go
index b7186ac0b..53b63185f 100755
--- a/models/dataset.go
+++ b/models/dataset.go
@@ -181,6 +181,7 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond {
if len(opts.DatasetIDs) > 0 {
subCon := builder.NewCond()
subCon = subCon.And(builder.In("dataset.id", opts.DatasetIDs))
+ subCon = generateFilterCond(opts, subCon)
cond = cond.Or(subCon)
}
@@ -460,5 +461,12 @@ func GetCollaboratorDatasetIdsByUserID(userID int64) []int64 {
_ = x.Table("dataset").Join("INNER", "collaboration", "dataset.repo_id = collaboration.repo_id and collaboration.mode>0 and collaboration.user_id=?", userID).
Cols("dataset.id").Find(&datasets)
return datasets
+}
+func GetTeamDatasetIdsByUserID(userID int64) []int64 {
+ var datasets []int64
+ _ = x.Table("dataset").Join("INNER", "team_repo", "dataset.repo_id = team_repo.repo_id").
+ Join("INNER", "team_user", "team_repo.team_id=team_user.team_id and team_user.uid=?", userID).
+ Cols("dataset.id").Find(&datasets)
+ return datasets
}
diff --git a/models/repo.go b/models/repo.go
index db2694617..4770e5415 100755
--- a/models/repo.go
+++ b/models/repo.go
@@ -2749,15 +2749,10 @@ func ReadLatestFileInRepo(userName, repoName, refName, treePath string) (*RepoFi
log.Error("ReadLatestFileInRepo: Close: %v", err)
}
}()
-
- buf := make([]byte, 1024)
- n, _ := reader.Read(buf)
- if n >= 0 {
- buf = buf[:n]
- }
+ d, _ := ioutil.ReadAll(reader)
commitId := ""
if blob != nil {
commitId = fmt.Sprint(blob.ID)
}
- return &RepoFile{CommitId: commitId, Content: buf}, nil
+ return &RepoFile{CommitId: commitId, Content: d}, nil
}
diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go
index 4cd3539d7..e058c0df8 100644
--- a/models/user_business_analysis.go
+++ b/models/user_business_analysis.go
@@ -955,6 +955,8 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time,
return err
}
userNewAddActivity := make(map[int64]map[int64]int64)
+ userAcitvateJsonMap := make(map[int64]map[int64]int64)
+ userCurrentDayRegistMap := make(map[int64]map[int64]int64)
ParaWeight := getParaWeight()
userMetrics := make(map[string]int)
var indexTotal int64
@@ -1028,7 +1030,10 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time,
log.Info("has activity." + userRecord.Name)
addUserToMap(userNewAddActivity, userRecord.CreatedUnix, dateRecord.ID)
}
-
+ if userRecord.IsActive {
+ addUserToMap(userAcitvateJsonMap, userRecord.CreatedUnix, dateRecord.ID)
+ }
+ addUserToMap(userCurrentDayRegistMap, userRecord.CreatedUnix, dateRecord.ID)
}
indexTotal += PAGE_SIZE
@@ -1064,36 +1069,61 @@ func CounDataByDateAndReCount(wikiCountMap map[string]int, startTime time.Time,
}
statictisSess.Insert(&useMetrics)
//update new user activity
- updateNewUserAcitivity(userNewAddActivity, statictisSess)
+ updateNewUserAcitivity(userNewAddActivity, userAcitvateJsonMap, userCurrentDayRegistMap, statictisSess)
return nil
}
-func updateNewUserAcitivity(currentUserActivity map[int64]map[int64]int64, statictisSess *xorm.Session) {
- for key, value := range currentUserActivity {
+func updateNewUserAcitivity(currentUserActivity map[int64]map[int64]int64, userAcitvateJsonMap map[int64]map[int64]int64, userCurrentDayRegistMap map[int64]map[int64]int64, statictisSess *xorm.Session) {
+ for key, value := range userCurrentDayRegistMap {
useMetrics := &UserMetrics{CountDate: key}
+ userAcitvateValue := userAcitvateJsonMap[key]
+ HuodongValue := currentUserActivity[key]
has, err := statictisSess.Get(useMetrics)
if err == nil && has {
- userIdArrays := strings.Split(useMetrics.HasActivityUserJson, ",")
- for _, userIdStr := range userIdArrays {
- userIdInt, err := strconv.ParseInt(userIdStr, 10, 64)
- if err == nil {
- value[userIdInt] = userIdInt
- }
- }
- userIdArray := ""
- for _, tmpValue := range value {
- userIdArray += fmt.Sprint(tmpValue) + ","
- }
- useMetrics.HasActivityUser = len(value)
- if len(userIdArray) > 0 {
- useMetrics.HasActivityUserJson = userIdArray[0 : len(userIdArray)-1]
- }
- updateSql := "update public.user_metrics set has_activity_user_json='" + useMetrics.HasActivityUserJson + "',regist_activity_user=" + fmt.Sprint(useMetrics.HasActivityUser) + " where count_date=" + fmt.Sprint(key)
+ ActivityUserArray, HuodongTotal := setUniqueUserId(useMetrics.HasActivityUserJson, HuodongValue)
+ useMetrics.HasActivityUser = HuodongTotal
+ useMetrics.HasActivityUserJson = ActivityUserArray
+
+ useMetrics.CurrentDayRegistUser = len(value)
+
+ RegistUserArray, lenRegistUser := setUniqueUserId(useMetrics.ActivityUserJson, userAcitvateValue)
+ useMetrics.ActivityUserJson = RegistUserArray
+ useMetrics.ActivateRegistUser = lenRegistUser
+
+ updateSql := "update public.user_metrics set has_activity_user_json='" + useMetrics.HasActivityUserJson +
+ "',regist_activity_user=" + fmt.Sprint(useMetrics.HasActivityUser) +
+ ",activity_user_json='" + useMetrics.ActivityUserJson + "'" +
+ ",activate_regist_user=" + fmt.Sprint(useMetrics.ActivateRegistUser) +
+ ",not_activate_regist_user=" + fmt.Sprint(useMetrics.CurrentDayRegistUser-useMetrics.ActivateRegistUser) +
+ ",current_day_regist_user=" + fmt.Sprint(useMetrics.CurrentDayRegistUser) +
+ " where count_date=" + fmt.Sprint(key)
+
statictisSess.Exec(updateSql)
}
}
}
+func setUniqueUserId(jsonString string, value map[int64]int64) (string, int) {
+ if value == nil {
+ value = make(map[int64]int64, 0)
+ }
+ userIdArrays := strings.Split(jsonString, ",")
+ for _, userIdStr := range userIdArrays {
+ userIdInt, err := strconv.ParseInt(userIdStr, 10, 64)
+ if err == nil {
+ value[userIdInt] = userIdInt
+ }
+ }
+ userIdArray := ""
+ for _, tmpValue := range value {
+ userIdArray += fmt.Sprint(tmpValue) + ","
+ }
+ if len(userIdArray) > 0 {
+ return userIdArray[0 : len(userIdArray)-1], len(value)
+ }
+ return userIdArray, len(value)
+}
+
func addUserToMap(currentUserActivity map[int64]map[int64]int64, registDate timeutil.TimeStamp, userId int64) {
CountDateTime := time.Date(registDate.Year(), registDate.AsTime().Month(), registDate.AsTime().Day(), 0, 1, 0, 0, registDate.AsTime().Location())
CountDate := CountDateTime.Unix()
@@ -1104,7 +1134,6 @@ func addUserToMap(currentUserActivity map[int64]map[int64]int64, registDate time
} else {
currentUserActivity[CountDate][userId] = userId
}
-
}
func setUserMetrics(userMetrics map[string]int, user *User, start_time int64, end_time int64, dateRecord UserBusinessAnalysis) {
diff --git a/models/user_business_struct.go b/models/user_business_struct.go
index fec361bca..870a64bc7 100644
--- a/models/user_business_struct.go
+++ b/models/user_business_struct.go
@@ -467,11 +467,11 @@ type UserAnalysisPara struct {
type UserMetrics struct {
CountDate int64 `xorm:"pk"`
- ActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"`
- NotActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"`
- ActivateIndex float64 `xorm:"NOT NULL DEFAULT 0"`
- RegistActivityUser int `xorm:"NOT NULL DEFAULT 0"`
- HasActivityUser int `xorm:"NOT NULL DEFAULT 0"`
+ ActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` //当天激活用户
+ NotActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"` //当天未激活用户
+ ActivateIndex float64 `xorm:"NOT NULL DEFAULT 0"` //激活比率
+ RegistActivityUser int `xorm:"NOT NULL DEFAULT 0"` //当天注册激活的人中,有贡献活动的人
+ HasActivityUser int `xorm:"NOT NULL DEFAULT 0"` //当天有贡献活动的人
TotalUser int `xorm:"NOT NULL DEFAULT 0"`
TotalRegistUser int `xorm:"-"`
TotalActivateRegistUser int `xorm:"NOT NULL DEFAULT 0"`
@@ -480,5 +480,7 @@ type UserMetrics struct {
DisplayDate string `xorm:"-"`
DataDate string `xorm:"NULL"`
DaysForMonth int `xorm:"NOT NULL DEFAULT 0"`
- HasActivityUserJson string `xorm:"text NULL"`
+ HasActivityUserJson string `xorm:"text NULL"` //贡献活动用户列表
+ ActivityUserJson string `xorm:"text NULL"` //激活用户列表
+ CurrentDayRegistUser int `xorm:"NOT NULL DEFAULT 0"` //当天注册用户
}
diff --git a/modules/auth/wechat/auto_reply.go b/modules/auth/wechat/auto_reply.go
new file mode 100644
index 000000000..440f6de6a
--- /dev/null
+++ b/modules/auth/wechat/auto_reply.go
@@ -0,0 +1,139 @@
+package wechat
+
+import (
+ "code.gitea.io/gitea/models"
+ "code.gitea.io/gitea/modules/log"
+ "code.gitea.io/gitea/modules/setting"
+ "encoding/json"
+ "github.com/patrickmn/go-cache"
+ "strings"
+ "time"
+)
+
+var WechatReplyCache = cache.New(2*time.Minute, 1*time.Minute)
+
+const (
+ WECHAT_REPLY_CACHE_KEY = "wechat_response"
+)
+
+const (
+ ReplyTypeText = "text"
+ ReplyTypeImage = "image"
+ ReplyTypeVoice = "voice"
+ ReplyTypeVideo = "video"
+ ReplyTypeMusic = "music"
+ ReplyTypeNews = "news"
+)
+
+type ReplyConfigType string
+
+const (
+ SubscribeReply ReplyConfigType = "subscribe"
+ AutoMsgReply ReplyConfigType = "autoMsg"
+)
+
+func (r ReplyConfigType) Name() string {
+ switch r {
+ case SubscribeReply:
+ return "subscribe"
+ case AutoMsgReply:
+ return "autoMsg"
+ }
+ return ""
+}
+
+func (r ReplyConfigType) TreePath() string {
+ switch r {
+ case SubscribeReply:
+ return setting.TreePathOfSubscribe
+ case AutoMsgReply:
+ return setting.TreePathOfAutoMsgReply
+ }
+ return ""
+}
+
+type WechatReplyContent struct {
+ Reply *ReplyContent
+ ReplyType string
+ KeyWords []string
+ IsFullMatch int
+}
+
+type ReplyContent struct {
+ Content string
+ MediaId string
+ Title string
+ Description string
+ MusicUrl string
+ HQMusicUrl string
+ ThumbMediaId string
+ Articles []ArticlesContent
+}
+
+func GetAutomaticReply(msg string) *WechatReplyContent {
+ r, err := LoadReplyFromCacheAndDisk(AutoMsgReply)
+ if err != nil {
+ return nil
+ }
+ if r == nil || len(r) == 0 {
+ return nil
+ }
+ for i := 0; i < len(r); i++ {
+ if r[i].IsFullMatch == 0 {
+ for _, v := range r[i].KeyWords {
+ if strings.Contains(msg, v) {
+ return r[i]
+ }
+ }
+ } else if r[i].IsFullMatch > 0 {
+ for _, v := range r[i].KeyWords {
+ if msg == v {
+ return r[i]
+ }
+ }
+ }
+ }
+ return nil
+
+}
+
+func loadReplyFromDisk(replyConfig ReplyConfigType) ([]*WechatReplyContent, error) {
+ log.Info("LoadReply from disk")
+ repo, err := models.GetRepositoryByOwnerAndAlias(setting.UserNameOfWechatReply, setting.RepoNameOfWechatReply)
+ if err != nil {
+ log.Error("get AutomaticReply repo failed, error=%v", err)
+ return nil, err
+ }
+ repoFile, err := models.ReadLatestFileInRepo(setting.UserNameOfWechatReply, repo.Name, setting.RefNameOfWechatReply, replyConfig.TreePath())
+ if err != nil {
+ log.Error("get AutomaticReply failed, error=%v", err)
+ return nil, err
+ }
+ res := make([]*WechatReplyContent, 0)
+ json.Unmarshal(repoFile.Content, &res)
+ if res == nil || len(res) == 0 {
+ return nil, err
+ }
+ return res, nil
+}
+
+func LoadReplyFromCacheAndDisk(replyConfig ReplyConfigType) ([]*WechatReplyContent, error) {
+ v, success := WechatReplyCache.Get(replyConfig.Name())
+ if success {
+ log.Info("LoadReply from cache,value = %v", v)
+ if v == nil {
+ return nil, nil
+ }
+ n := v.([]*WechatReplyContent)
+ return n, nil
+ }
+
+ content, err := loadReplyFromDisk(replyConfig)
+ if err != nil {
+ log.Error("LoadReply failed, error=%v", err)
+ WechatReplyCache.Set(replyConfig.Name(), nil, 30*time.Second)
+ return nil, err
+ }
+ WechatReplyCache.Set(replyConfig.Name(), content, 60*time.Second)
+ return content, nil
+}
diff --git a/modules/auth/wechat/client.go b/modules/auth/wechat/client.go
index 6734977a1..9ed4b543f 100644
--- a/modules/auth/wechat/client.go
+++ b/modules/auth/wechat/client.go
@@ -17,7 +17,8 @@ var (
const (
GRANT_TYPE = "client_credential"
ACCESS_TOKEN_PATH = "/cgi-bin/token"
- QR_CODE_Path = "/cgi-bin/qrcode/create"
+ QR_CODE_PATH = "/cgi-bin/qrcode/create"
+ GET_MATERIAL_PATH = "/cgi-bin/material/batchget_material"
ACTION_QR_STR_SCENE = "QR_STR_SCENE"
ERR_CODE_ACCESSTOKEN_EXPIRE = 42001
@@ -40,6 +41,11 @@ type QRCodeRequest struct {
Action_info ActionInfo `json:"action_info"`
Expire_seconds int `json:"expire_seconds"`
}
+type MaterialRequest struct {
+ Type string `json:"type"`
+ Offset int `json:"offset"`
+ Count int `json:"count"`
+}
type ActionInfo struct {
Scene Scene `json:"scene"`
@@ -97,7 +103,7 @@ func callQRCodeCreate(sceneStr string) (*QRCodeResponse, bool) {
SetQueryParam("access_token", GetWechatAccessToken()).
SetBody(bodyJson).
SetResult(&result).
- Post(setting.WechatApiHost + QR_CODE_Path)
+ Post(setting.WechatApiHost + QR_CODE_PATH)
if err != nil {
log.Error("create QR code failed,e=%v", err)
return nil, false
@@ -113,6 +119,37 @@ func callQRCodeCreate(sceneStr string) (*QRCodeResponse, bool) {
return &result, false
}
+//getMaterial
+// api doc: https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/Get_materials_list.html
+func getMaterial(mType string, offset, count int) (interface{}, bool) {
+ client := getWechatRestyClient()
+
+ body := &MaterialRequest{
+ Type: mType,
+ Offset: offset,
+ Count: count,
+ }
+ bodyJson, _ := json.Marshal(body)
+ r, err := client.R().
+ SetHeader("Content-Type", "application/json").
+ SetQueryParam("access_token", GetWechatAccessToken()).
+ SetBody(bodyJson).
+ Post(setting.WechatApiHost + GET_MATERIAL_PATH)
+ if err != nil {
+ log.Error("create QR code failed,e=%v", err)
+ return nil, false
+ }
+ a := r.Body()
+ resultMap := make(map[string]interface{}, 0)
+ json.Unmarshal(a, &resultMap)
+ errcode := resultMap["errcode"]
+ if errcode == fmt.Sprint(ERR_CODE_ACCESSTOKEN_EXPIRE) || errcode == fmt.Sprint(ERR_CODE_ACCESSTOKEN_INVALID) {
+ return nil, true
+ }
+ log.Info("%v", r)
+ return &resultMap, false
+}
+
func getErrorCodeFromResponse(r *resty.Response) int {
a := r.Body()
resultMap := make(map[string]interface{}, 0)
diff --git a/modules/auth/wechat/event_handle.go b/modules/auth/wechat/event_handle.go
index b40ab3101..27edf7343 100644
--- a/modules/auth/wechat/event_handle.go
+++ b/modules/auth/wechat/event_handle.go
@@ -18,7 +18,7 @@ import (
//
//
//
-type WechatEvent struct {
+type WechatMsg struct {
ToUserName string
FromUserName string
CreateTime int64
@@ -26,9 +26,13 @@ type WechatEvent struct {
Event string
EventKey string
Ticket string
+ Content string
+ MsgId string
+ MsgDataId string
+ Idx string
}
-type EventReply struct {
+type MsgReply struct {
XMLName xml.Name `xml:"xml"`
ToUserName string
FromUserName string
@@ -37,16 +41,97 @@ type EventReply struct {
Content string
}
+type TextMsgReply struct {
+ XMLName xml.Name `xml:"xml"`
+ ToUserName string
+ FromUserName string
+ CreateTime int64
+ MsgType string
+ Content string
+}
+type ImageMsgReply struct {
+ XMLName xml.Name `xml:"xml"`
+ ToUserName string
+ FromUserName string
+ CreateTime int64
+ MsgType string
+ Image ImageContent
+}
+type VoiceMsgReply struct {
+ XMLName xml.Name `xml:"xml"`
+ ToUserName string
+ FromUserName string
+ CreateTime int64
+ MsgType string
+ Voice VoiceContent
+}
+type VideoMsgReply struct {
+ XMLName xml.Name `xml:"xml"`
+ ToUserName string
+ FromUserName string
+ CreateTime int64
+ MsgType string
+ Video VideoContent
+}
+type MusicMsgReply struct {
+ XMLName xml.Name `xml:"xml"`
+ ToUserName string
+ FromUserName string
+ CreateTime int64
+ MsgType string
+ Music MusicContent
+}
+type NewsMsgReply struct {
+ XMLName xml.Name `xml:"xml"`
+ ToUserName string
+ FromUserName string
+ CreateTime int64
+ MsgType string
+ ArticleCount int
+ Articles ArticleItem
+}
+
+type ArticleItem struct {
+ Item []ArticlesContent
+}
+
+type ImageContent struct {
+ MediaId string
+}
+type VoiceContent struct {
+ MediaId string
+}
+type VideoContent struct {
+ MediaId string
+ Title string
+ Description string
+}
+type MusicContent struct {
+ Title string
+ Description string
+ MusicUrl string
+ HQMusicUrl string
+ ThumbMediaId string
+}
+type ArticlesContent struct {
+ XMLName xml.Name `xml:"item"`
+ Title string
+ Description string
+ PicUrl string
+ Url string
+}
+
const (
WECHAT_EVENT_SUBSCRIBE = "subscribe"
WECHAT_EVENT_SCAN = "SCAN"
)
const (
- WECHAT_MSG_TYPE_TEXT = "text"
+ WECHAT_MSG_TYPE_TEXT = "text"
+ WECHAT_MSG_TYPE_EVENT = "event"
)
-func HandleSubscribeEvent(we WechatEvent) string {
+func HandleScanEvent(we WechatMsg) string {
eventKey := we.EventKey
if eventKey == "" {
return ""
@@ -74,3 +159,11 @@ func HandleSubscribeEvent(we WechatEvent) string {
return BIND_REPLY_SUCCESS
}
+
+func HandleSubscribeEvent(we WechatMsg) *WechatReplyContent {
+ r, err := LoadReplyFromCacheAndDisk(SubscribeReply)
+ if err != nil || len(r) == 0 {
+ return nil
+ }
+ return r[0]
+}
diff --git a/modules/auth/wechat/material.go b/modules/auth/wechat/material.go
new file mode 100644
index 000000000..526156af5
--- /dev/null
+++ b/modules/auth/wechat/material.go
@@ -0,0 +1,13 @@
+package wechat
+
+import "code.gitea.io/gitea/modules/log"
+
+func GetWechatMaterial(mType string, offset, count int) interface{} {
+ result, retryFlag := getMaterial(mType, offset, count)
+ if retryFlag {
+ log.Info("retryGetWechatMaterial calling")
+ refreshAccessToken()
+ result, _ = getMaterial(mType, offset, count)
+ }
+ return result
+}
diff --git a/modules/grampus/grampus.go b/modules/grampus/grampus.go
index 57d65a593..e83ccccc6 100755
--- a/modules/grampus/grampus.go
+++ b/modules/grampus/grampus.go
@@ -1,12 +1,16 @@
package grampus
import (
+ "encoding/json"
+ "strings"
+
+ "code.gitea.io/gitea/modules/setting"
+
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification"
"code.gitea.io/gitea/modules/timeutil"
- "strings"
)
const (
@@ -15,12 +19,14 @@ const (
ProcessorTypeNPU = "npu.huawei.com/NPU"
ProcessorTypeGPU = "nvidia.com/gpu"
- CommandPrepareScript = "pwd;cd /cache;mkdir -p output;mkdir -p code;mkdir -p dataset;echo \"start loading script\";wget -q https://git.openi.org.cn/OpenIOSSG/script_for_grampus/archive/master.zip;" +
+ GpuWorkDir = "/tmp/"
+ NpuWorkDir = "/cache/"
+
+ CommandPrepareScript = ";mkdir -p output;mkdir -p code;mkdir -p dataset;echo \"start loading script\";wget -q https://git.openi.org.cn/OpenIOSSG/script_for_grampus/archive/master.zip;" +
"echo \"finish loading script\";unzip -q master.zip;cd script_for_grampus;chmod 777 downloader_for_obs uploader_for_obs downloader_for_minio uploader_for_minio;"
+ //CommandPrepareScript = "pwd;cd /cache;mkdir -p output;mkdir -p code;mkdir -p dataset;echo \"start loading script\";wget -q https://git.openi.org.cn/OpenIOSSG/script_for_grampus/archive/master.zip;" +
+ // "echo \"finish loading script\";unzip -q master.zip;cd script_for_grampus;chmod 777 downloader_for_obs uploader_for_obs downloader_for_minio uploader_for_minio;"
- //CommandPrepareScript = "bash;pwd;apt-get -y update;apt-get -y upgrade;apt-get -y install wget;apt-get -y install unzip;" +
- // "cd /tmp;mkdir -p output;mkdir -p code;mkdir -p dataset;wget -q https://git.openi.org.cn/OpenIOSSG/script_for_grampus/archive/master.zip;" +
- // "unzip -q master.zip;cd script_for_grampus;chmod 777 downloader_for_obs uploader_for_obs downloader_for_minio uploader_for_minio;"
CodeArchiveName = "master.zip"
)
@@ -28,6 +34,8 @@ var (
poolInfos *models.PoolInfos
FlavorInfos *models.FlavorInfos
ImageInfos *models.ImageInfosModelArts
+
+ SpecialPools *models.SpecialPools
)
type GenerateTrainJobReq struct {
@@ -63,6 +71,27 @@ type GenerateTrainJobReq struct {
func GenerateTrainJob(ctx *context.Context, req *GenerateTrainJobReq) (err error) {
createTime := timeutil.TimeStampNow()
+
+ var CenterID []string
+ var CenterName []string
+
+ if SpecialPools != nil {
+ for _, pool := range SpecialPools.Pools {
+ if !pool.IsExclusive && strings.Contains(req.ComputeResource, pool.Type) {
+ org, _ := models.GetOrgByName(pool.Org)
+ if org != nil {
+ isOrgMember, _ := models.IsOrganizationMember(org.ID, ctx.User.ID)
+ if isOrgMember {
+ for _, info := range pool.Pool {
+ CenterID = append(CenterID, info.Queue)
+ CenterName = append(CenterName, info.Value)
+ }
+ }
+ }
+ }
+ }
+ }
+
jobResult, err := createJob(models.CreateGrampusJobRequest{
Name: req.JobName,
Tasks: []models.GrampusTasks{
@@ -72,6 +101,8 @@ func GenerateTrainJob(ctx *context.Context, req *GenerateTrainJobReq) (err error
ResourceSpecId: req.ResourceSpecId,
ImageId: req.ImageId,
ImageUrl: req.ImageUrl,
+ CenterID: CenterID,
+ CenterName: CenterName,
ReplicaNum: 1,
},
},
@@ -136,3 +167,8 @@ func TransTrainJobStatus(status string) string {
return strings.ToUpper(status)
}
+func InitSpecialPool() {
+ if SpecialPools == nil && setting.Grampus.SpecialPools != "" {
+ json.Unmarshal([]byte(setting.Grampus.SpecialPools), &SpecialPools)
+ }
+}
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index abee77579..a7758831b 100755
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -530,10 +530,11 @@ var (
//grampus config
Grampus = struct {
- Env string
- Host string
- UserName string
- Password string
+ Env string
+ Host string
+ UserName string
+ Password string
+ SpecialPools string
}{}
//elk config
@@ -553,6 +554,13 @@ var (
WechatQRCodeExpireSeconds int
WechatAuthSwitch bool
+ //wechat auto reply config
+ UserNameOfWechatReply string
+ RepoNameOfWechatReply string
+ RefNameOfWechatReply string
+ TreePathOfAutoMsgReply string
+ TreePathOfSubscribe string
+
//nginx proxy
PROXYURL string
RadarMap = struct {
@@ -1380,6 +1388,11 @@ func NewContext() {
WechatAppSecret = sec.Key("APP_SECRET").MustString("e48e13f315adc32749ddc7057585f198")
WechatQRCodeExpireSeconds = sec.Key("QR_CODE_EXPIRE_SECONDS").MustInt(120)
WechatAuthSwitch = sec.Key("AUTH_SWITCH").MustBool(true)
+ UserNameOfWechatReply = sec.Key("AUTO_REPLY_USER_NAME").MustString("OpenIOSSG")
+ RepoNameOfWechatReply = sec.Key("AUTO_REPLY_REPO_NAME").MustString("promote")
+ RefNameOfWechatReply = sec.Key("AUTO_REPLY_REF_NAME").MustString("master")
+ TreePathOfAutoMsgReply = sec.Key("AUTO_REPLY_TREE_PATH").MustString("wechat/auto_reply.json")
+ TreePathOfSubscribe = sec.Key("SUBSCRIBE_TREE_PATH").MustString("wechat/subscribe_reply.json")
SetRadarMapConfig()
@@ -1400,6 +1413,8 @@ func GetGrampusConfig() {
Grampus.Host = sec.Key("SERVER_HOST").MustString("")
Grampus.UserName = sec.Key("USERNAME").MustString("")
Grampus.Password = sec.Key("PASSWORD").MustString("")
+ Grampus.SpecialPools = sec.Key("SPECIAL_POOL").MustString("")
+
}
func SetRadarMapConfig() {
diff --git a/modules/setting/webhook.go b/modules/setting/webhook.go
index 34cf8a62d..a14ad949f 100644
--- a/modules/setting/webhook.go
+++ b/modules/setting/webhook.go
@@ -6,6 +6,7 @@ package setting
import (
"net/url"
+ "strings"
"code.gitea.io/gitea/modules/log"
)
@@ -13,14 +14,18 @@ import (
var (
// Webhook settings
Webhook = struct {
- QueueLength int
- DeliverTimeout int
- SkipTLSVerify bool
- Types []string
- PagingNum int
- ProxyURL string
- ProxyURLFixed *url.URL
- ProxyHosts []string
+ QueueLength int
+ DeliverTimeout int
+ SkipTLSVerify bool
+ Types []string
+ PagingNum int
+ ProxyURL string
+ ProxyURLFixed *url.URL
+ ProxyHosts []string
+ Socks5Proxy string
+ Socks5UserName string
+ Socks5Password string
+ Socks5ProxyHosts []string
}{
QueueLength: 1000,
DeliverTimeout: 5,
@@ -39,6 +44,10 @@ func newWebhookService() {
Webhook.Types = []string{"gitea", "gogs", "slack", "discord", "dingtalk", "telegram", "msteams", "feishu", "matrix"}
Webhook.PagingNum = sec.Key("PAGING_NUM").MustInt(10)
Webhook.ProxyURL = sec.Key("PROXY_URL").MustString("")
+ Webhook.Socks5Proxy = sec.Key("SOCKS5_PROXY_URL").MustString("")
+ Webhook.Socks5UserName = sec.Key("SOCKS5_USER_NAME").MustString("")
+ Webhook.Socks5Password = sec.Key("SOCKS5_PASSWORD").MustString("")
+ Webhook.Socks5ProxyHosts = strings.Split(sec.Key("SOCKS5_PROXY_HOST").MustString(""), ";")
if Webhook.ProxyURL != "" {
var err error
Webhook.ProxyURLFixed, err = url.Parse(Webhook.ProxyURL)
diff --git a/modules/webhook/deliver.go b/modules/webhook/deliver.go
index 7b0c65173..8348e8641 100644
--- a/modules/webhook/deliver.go
+++ b/modules/webhook/deliver.go
@@ -16,6 +16,8 @@ import (
"sync"
"time"
+ "golang.org/x/net/proxy"
+
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/graceful"
"code.gitea.io/gitea/modules/log"
@@ -137,8 +139,10 @@ func Deliver(t *models.HookTask) error {
return
}
}()
+ match := isSocks5ProxyUrlMatch(req)
+
+ resp, err := makeReq(req, match)
- resp, err := webhookHTTPClient.Do(req)
if err != nil {
t.ResponseInfo.Body = fmt.Sprintf("Delivery: %v", err)
return err
@@ -161,6 +165,23 @@ func Deliver(t *models.HookTask) error {
return nil
}
+func makeReq(req *http.Request, proxyMatch bool) (*http.Response, error) {
+ if proxyMatch {
+ return webhookSocks5PoxyHTTPClient.Do(req)
+ }
+ return webhookHTTPClient.Do(req)
+}
+
+func isSocks5ProxyUrlMatch(req *http.Request) bool {
+
+ for _, v := range socks5HostMatchers {
+ if v.Match(req.URL.Host) {
+ return true
+ }
+ }
+ return false
+}
+
// DeliverHooks checks and delivers undelivered hooks.
// FIXME: graceful: This would likely benefit from either a worker pool with dummy queue
// or a full queue. Then more hooks could be sent at same time.
@@ -225,9 +246,11 @@ func DeliverHooks(ctx context.Context) {
}
var (
- webhookHTTPClient *http.Client
- once sync.Once
- hostMatchers []glob.Glob
+ webhookHTTPClient *http.Client
+ once sync.Once
+ hostMatchers []glob.Glob
+ webhookSocks5PoxyHTTPClient *http.Client
+ socks5HostMatchers []glob.Glob
)
func webhookProxy() func(req *http.Request) (*url.URL, error) {
@@ -274,5 +297,31 @@ func InitDeliverHooks() {
},
}
+ if setting.Webhook.Socks5Proxy != "" {
+ auth := proxy.Auth{
+ User: setting.Webhook.Socks5UserName,
+ Password: setting.Webhook.Socks5Password,
+ }
+
+ dialSocksProxy, err := proxy.SOCKS5("tcp", setting.Webhook.Socks5Proxy, &auth, proxy.Direct)
+ if err != nil {
+ fmt.Println("Error connecting to proxy:", err)
+ }
+ tr := &http.Transport{Dial: dialSocksProxy.Dial}
+
+ webhookSocks5PoxyHTTPClient = &http.Client{
+ Transport: tr,
+ }
+
+ for _, h := range setting.Webhook.Socks5ProxyHosts {
+ if g, err := glob.Compile(h); err == nil {
+ socks5HostMatchers = append(socks5HostMatchers, g)
+ } else {
+ log.Error("glob.Compile %s failed: %v", h, err)
+ }
+ }
+
+ }
+
go graceful.GetManager().RunWithShutdownContext(DeliverHooks)
}
diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini
index ce96c669f..8b465d3e0 100755
--- a/options/locale/locale_en-US.ini
+++ b/options/locale/locale_en-US.ini
@@ -1178,6 +1178,8 @@ model.manage.model_accuracy = Model Accuracy
grampus.train_job.ai_center = AI Center
grampus.dataset_path_rule = The code is storaged in /cache/code;the dataset is storaged in /cache/dataset;and please put your model into /cache/output, then you can download it online。
+grampus.gpu_dataset_path_rule = The code is storaged in /tmp/code;the dataset is storaged in /tmp/dataset;and please put your model into /tmp/output, then you can download it online。
+grampus.no_operate_right = You have no right to do this operation.
template.items = Template Items
template.git_content = Git Content (Default Branch)
diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini
index 4de0fa209..c317216e9 100755
--- a/options/locale/locale_zh-CN.ini
+++ b/options/locale/locale_zh-CN.ini
@@ -1192,6 +1192,9 @@ model.manage.model_accuracy = 模型精度
grampus.train_job.ai_center=智算中心
grampus.dataset_path_rule = 训练脚本存储在/cache/code中,数据集存储在/cache/dataset中,训练输出请存储在/cache/output中以供后续下载。
+grampus.gpu_dataset_path_rule = 训练脚本存储在/tmp/code中,数据集存储在/tmp/dataset中,训练输出请存储在/tmp/output中以供后续下载。
+
+grampus.no_operate_right = 您没有权限创建这类任务。
template.items=模板选项
template.git_content=Git数据(默认分支)
@@ -1423,7 +1426,7 @@ issues.label_templates.helper=选择标签模板
issues.label_templates.use=使用标签集
issues.label_templates.fail_to_load_file=加载标签模板文件 '%s' 时发生错误:%v
issues.add_label_at=添加了标签
%s
%s
-issues.remove_label_at=删除了 %s
label %s 标签
+issues.remove_label_at=删除了标签 %s
%s
issues.add_milestone_at=` %[2]s 添加了里程碑 %[1]s`
issues.change_milestone_at=`%[3]s 修改了里程碑从 %[1]s 到 %[2]s`
issues.remove_milestone_at=`%[2]s 删除了里程碑 %[1]s`
diff --git a/public/home/home.js b/public/home/home.js
index 7343dba0b..95ea3da4c 100755
--- a/public/home/home.js
+++ b/public/home/home.js
@@ -74,28 +74,30 @@ var swiperOrg = new Swiper(".homeorg-list", {
},
});
-var output = document.getElementById("newmessage");
-var url = "ws://" + document.location.host + "/action/notification";
-if(document.location.host == "git.openi.org.cn" || document.URL.startsWith("https")){
- url = "wss://" + document.location.host + "/action/notification"
-}
-var socket = new WebSocket(url);
-
-socket.onopen = function () {
- messageQueue = [];
- console.log("message has connected.");
-};
-
var maxSize = 20;
var html =document.documentElement;
var lang = html.attributes["lang"]
var isZh = true;
if(lang != null && lang.nodeValue =="en-US" ){
isZh=false;
-}else{
}
-socket.onmessage = function (e) {
+document.onreadystatechange = function () {
+ queryRecommendData();
+
+ var output = document.getElementById("newmessage");
+ var url = "ws://" + document.location.host + "/action/notification";
+ if(document.location.host == "git.openi.org.cn" || document.URL.startsWith("https")){
+ url = "wss://" + document.location.host + "/action/notification"
+ }
+ var socket = new WebSocket(url);
+
+ socket.onopen = function () {
+ messageQueue = [];
+ console.log("message has connected.");
+ };
+
+ socket.onmessage = function (e) {
var data =JSON.parse(e.data)
var html = "";
if (data != null){
@@ -154,7 +156,7 @@ socket.onmessage = function (e) {
html += recordPrefix + actionName;
html += " " + getRepotext(record) + ""
}
- else if(record.OpType == "24" || record.OpType == "26" || record.OpType == "27" || record.OpType == "28" || record.OpType == "30" || record.OpType == "31"){
+ else if(record.OpType == "24" || record.OpType == "26" || record.OpType == "27" || record.OpType == "28" || record.OpType == "30" || record.OpType == "31" || record.OpType == "32" || record.OpType == "33"){
html += recordPrefix + actionName;
html += " " + record.RefName + ""
}
@@ -176,7 +178,10 @@ socket.onmessage = function (e) {
output.innerHTML = html;
swiperNewMessage.updateSlides();
swiperNewMessage.updateProgress();
-};
+ };
+}
+
+
function getTaskLink(record){
var re = getRepoLink(record);
@@ -196,6 +201,8 @@ function getTaskLink(record){
re = re + "/modelmanage/show_model_info?name=" + record.RefName;
}else if(record.OpType == 31){
re = re + "/cloudbrain/train-job/" + record.Content;
+ }else if(record.OpType == 32 || record.OpType == 33){
+ re = re + "/grampus/train-job/" + record.Content;
}
re = encodeURI(re);
return re;
@@ -369,7 +376,9 @@ var actionNameZH={
"28":"创建了推理任务",
"29":"创建了评测任务",
"30":"导入了新模型",
- "31":"创建了CPU/GPU类型训练任务"
+ "31":"创建了CPU/GPU类型训练任务",
+ "32":"创建了NPU类型训练任务",
+ "33":"创建了CPU/GPU类型训练任务"
};
var actionNameEN={
@@ -396,6 +405,8 @@ var actionNameEN={
"29":" created profiling task",
"30":" created new model",
"31":" created CPU/GPU type training task",
+ "32":" created NPU type training task",
+ "33":" created CPU/GPU type training task"
};
var repoAndOrgZH={
@@ -437,7 +448,9 @@ function getAction(opType,isZh){
}
}
-queryRecommendData();
+
+
+
function queryRecommendData(){
$.ajax({
diff --git a/public/home/search.js b/public/home/search.js
index ea6006fba..86b2ad06e 100644
--- a/public/home/search.js
+++ b/public/home/search.js
@@ -1,80 +1,80 @@
var token;
if (isEmpty(token)) {
- var meta = $("meta[name=_uid]");
- if (!isEmpty(meta)) {
- token = meta.attr("content");
- }
+ var meta = $("meta[name=_uid]");
+ if (!isEmpty(meta)) {
+ token = meta.attr("content");
+ }
}
var html = document.documentElement;
-var lang = html.attributes["lang"]
+var lang = html.attributes["lang"];
var isZh = true;
if (lang != null && lang.nodeValue == "en-US") {
- isZh = false;
+ isZh = false;
} else {
}
function isEmpty(str) {
- if (typeof str == "undefined" || str == null || str == "") {
- return true;
- }
- return false;
+ if (typeof str == "undefined" || str == null || str == "") {
+ return true;
+ }
+ return false;
}
var itemType = {
- "1": "repository",
- "2": "issue",
- "3": "user",
- "4": "org",
- "5": "dataset",
- "6": "pr"
+ 1: "repository",
+ 2: "issue",
+ 3: "user",
+ 4: "org",
+ 5: "dataset",
+ 6: "pr",
};
var sortBy = {
- "10": "default",
- "11": "updated_unix.keyword",
- "12": "num_watches",
- "13": "num_stars",
- "14": "num_forks",
- "20": "default",
- "21": "updated_unix.keyword",
- "30": "default",
- "31": "name.keyword",
- "32": "name.keyword",
- "33": "created_unix.keyword",
- "34": "created_unix.keyword",
- "40": "default",
- "41": "name.keyword",
- "42": "name.keyword",
- "43": "created_unix.keyword",
- "44": "created_unix.keyword",
- "50": "default",
- "51": "download_times",
- "60": "default",
- "61": "updated_unix.keyword"
+ 10: "default",
+ 11: "updated_unix.keyword",
+ 12: "num_watches",
+ 13: "num_stars",
+ 14: "num_forks",
+ 20: "default",
+ 21: "updated_unix.keyword",
+ 30: "default",
+ 31: "name.keyword",
+ 32: "name.keyword",
+ 33: "created_unix.keyword",
+ 34: "created_unix.keyword",
+ 40: "default",
+ 41: "name.keyword",
+ 42: "name.keyword",
+ 43: "created_unix.keyword",
+ 44: "created_unix.keyword",
+ 50: "default",
+ 51: "download_times",
+ 60: "default",
+ 61: "updated_unix.keyword",
};
var sortAscending = {
- "10": "false",
- "11": "false",
- "12": "false",
- "13": "false",
- "14": "false",
- "20": "false",
- "21": "false",
- "30": "false",
- "31": "true",
- "32": "false",
- "33": "false",
- "34": "true",
- "40": "false",
- "41": "true",
- "42": "false",
- "43": "false",
- "44": "true",
- "50": "false",
- "51": "false",
- "60": "false",
- "61": "false"
+ 10: "false",
+ 11: "false",
+ 12: "false",
+ 13: "false",
+ 14: "false",
+ 20: "false",
+ 21: "false",
+ 30: "false",
+ 31: "true",
+ 32: "false",
+ 33: "false",
+ 34: "true",
+ 40: "false",
+ 41: "true",
+ 42: "false",
+ 43: "false",
+ 44: "true",
+ 50: "false",
+ 51: "false",
+ 60: "false",
+ 61: "false",
};
var currentPage = 1;
@@ -91,1245 +91,1634 @@ var totalNum = 0;
var privateTotal = 0;
function initPageInfo() {
- currentPage = 1;
- startIndex = 1;
- endIndex = 5;
+ currentPage = 1;
+ startIndex = 1;
+ endIndex = 5;
}
function searchItem(type, sortType) {
- if (OnlySearchLabel) {
- doSearchLabel(currentSearchTableName, currentSearchKeyword, sortBy[sortType], sortAscending[sortType])
+ if (OnlySearchLabel) {
+ doSearchLabel(
+ currentSearchTableName,
+ currentSearchKeyword,
+ sortBy[sortType],
+ sortAscending[sortType]
+ );
+ } else {
+ currentSearchKeyword = document.getElementById("keyword_input").value;
+ if (!isEmpty(currentSearchKeyword)) {
+ initPageInfo();
+ currentSearchTableName = itemType[type];
+ currentSearchSortBy = sortBy[sortType];
+ currentSearchAscending = sortAscending[sortType];
+ OnlySearchLabel = false;
+ page(currentPage);
} else {
- currentSearchKeyword = document.getElementById("keyword_input").value;
- if (!isEmpty(currentSearchKeyword)) {
- initPageInfo();
- currentSearchTableName = itemType[type];
- currentSearchSortBy = sortBy[sortType];
- currentSearchAscending = sortAscending[sortType];
- OnlySearchLabel = false;
- page(currentPage);
- } else {
- emptySearch();
- }
+ emptySearch();
}
+ }
}
-
-
function search() {
- currentSearchKeyword = document.getElementById("keyword_input").value;
- if (!isEmpty(currentSearchKeyword)) {
- currentSearchKeyword = currentSearchKeyword.trim();
- }
- if (!isEmpty(currentSearchKeyword)) {
- doSpcifySearch(currentSearchTableName, currentSearchKeyword, sortBy[10], "false");
- } else {
- emptySearch();
- }
+ currentSearchKeyword = document.getElementById("keyword_input").value;
+ if (!isEmpty(currentSearchKeyword)) {
+ currentSearchKeyword = currentSearchKeyword.trim();
+ }
+ if (!isEmpty(currentSearchKeyword)) {
+ doSpcifySearch(
+ currentSearchTableName,
+ currentSearchKeyword,
+ sortBy[10],
+ "false"
+ );
+ } else {
+ emptySearch();
+ }
}
function emptySearch() {
- initDiv(false);
- initPageInfo();
- $('#searchForm').addClass("hiddenSearch");
- document.getElementById("find_id").innerHTML = getLabel(isZh, "search_empty");
- $('#find_title').html("");
- document.getElementById("sort_type").innerHTML = "";
- document.getElementById("child_search_item").innerHTML = "";
- document.getElementById("page_menu").innerHTML = "";
- $('#repo_total').text("");
- $('#pr_total').text("");
- $('#issue_total').text("");
- $('#dataset_total').text("");
- $('#user_total').text("");
- $('#org_total').text("");
- setActivate(null);
+ initDiv(false);
+ initPageInfo();
+ $("#searchForm").addClass("hiddenSearch");
+ document.getElementById("find_id").innerHTML = getLabel(isZh, "search_empty");
+ $("#find_title").html("");
+ document.getElementById("sort_type").innerHTML = "";
+ document.getElementById("child_search_item").innerHTML = "";
+ document.getElementById("page_menu").innerHTML = "";
+ $("#repo_total").text("");
+ $("#pr_total").text("");
+ $("#issue_total").text("");
+ $("#dataset_total").text("");
+ $("#user_total").text("");
+ $("#org_total").text("");
+ setActivate(null);
}
function initDiv(isSearchLabel = false) {
- if (isSearchLabel) {
- document.getElementById("search_div").style.display = "none";
- document.getElementById("search_label_div").style.display = "block";
- document.getElementById("dataset_item").style.display = "none";
- document.getElementById("issue_item").style.display = "none";
- document.getElementById("pr_item").style.display = "none";
- document.getElementById("user_item").style.display = "none";
- document.getElementById("org_item").style.display = "none";
- document.getElementById("find_id").innerHTML = "";
- } else {
- document.getElementById("search_div").style.display = "block";
- document.getElementById("search_label_div").style.display = "none";
- document.getElementById("dataset_item").style.display = "block";
- document.getElementById("issue_item").style.display = "block";
- document.getElementById("pr_item").style.display = "block";
- document.getElementById("user_item").style.display = "block";
- document.getElementById("org_item").style.display = "block";
- document.getElementById("find_id").innerHTML = getLabel(isZh, "search_finded");
- }
+ if (isSearchLabel) {
+ document.getElementById("search_div").style.display = "none";
+ document.getElementById("search_label_div").style.display = "block";
+ document.getElementById("dataset_item").style.display = "none";
+ document.getElementById("issue_item").style.display = "none";
+ document.getElementById("pr_item").style.display = "none";
+ document.getElementById("user_item").style.display = "none";
+ document.getElementById("org_item").style.display = "none";
+ document.getElementById("find_id").innerHTML = "";
+ } else {
+ document.getElementById("search_div").style.display = "block";
+ document.getElementById("search_label_div").style.display = "none";
+ document.getElementById("dataset_item").style.display = "block";
+ document.getElementById("issue_item").style.display = "block";
+ document.getElementById("pr_item").style.display = "block";
+ document.getElementById("user_item").style.display = "block";
+ document.getElementById("org_item").style.display = "block";
+ document.getElementById("find_id").innerHTML = getLabel(
+ isZh,
+ "search_finded"
+ );
+ }
}
function doSpcifySearch(tableName, keyword, sortBy = "", ascending = "false") {
- initDiv(false);
- $('#searchForm').addClass("hiddenSearch");
- document.getElementById("find_id").innerHTML = getLabel(isZh, "search_finded");
- currentSearchKeyword = keyword;
- initPageInfo();
- currentSearchTableName = tableName;
- currentSearchSortBy = sortBy;
- currentSearchAscending = ascending;
- OnlySearchLabel = false;
-
- page(currentPage);
-
- if (currentSearchTableName != "repository") {
- doSearch("repository", currentSearchKeyword, 1, pageSize, true, "", false);
- }
- if (currentSearchTableName != "issue") {
- doSearch("issue", currentSearchKeyword, 1, pageSize, true, "", false);
- }
- if (currentSearchTableName != "user") {
- doSearch("user", currentSearchKeyword, 1, pageSize, true, "", false);
- }
- if (currentSearchTableName != "org") {
- doSearch("org", currentSearchKeyword, 1, pageSize, true, "", false);
- }
- if (currentSearchTableName != "dataset") {
- doSearch("dataset", currentSearchKeyword, 1, pageSize, true, "", false);
- }
- if (currentSearchTableName != "pr") {
- doSearch("pr", currentSearchKeyword, 1, pageSize, true, "", false);
- }
+ initDiv(false);
+ $("#searchForm").addClass("hiddenSearch");
+ document.getElementById("find_id").innerHTML = getLabel(
+ isZh,
+ "search_finded"
+ );
+ currentSearchKeyword = keyword;
+ initPageInfo();
+ currentSearchTableName = tableName;
+ currentSearchSortBy = sortBy;
+ currentSearchAscending = ascending;
+ OnlySearchLabel = false;
+
+ page(currentPage);
+
+ if (currentSearchTableName != "repository") {
+ doSearch("repository", currentSearchKeyword, 1, pageSize, true, "", false);
+ }
+ if (currentSearchTableName != "issue") {
+ doSearch("issue", currentSearchKeyword, 1, pageSize, true, "", false);
+ }
+ if (currentSearchTableName != "user") {
+ doSearch("user", currentSearchKeyword, 1, pageSize, true, "", false);
+ }
+ if (currentSearchTableName != "org") {
+ doSearch("org", currentSearchKeyword, 1, pageSize, true, "", false);
+ }
+ if (currentSearchTableName != "dataset") {
+ doSearch("dataset", currentSearchKeyword, 1, pageSize, true, "", false);
+ }
+ if (currentSearchTableName != "pr") {
+ doSearch("pr", currentSearchKeyword, 1, pageSize, true, "", false);
+ }
}
function doSearchLabel(tableName, keyword, sortBy = "", ascending = "false") {
- initDiv(true);
- //document.getElementById("search_div").style.display="none";
- //document.getElementById("search_label_div").style.display="block";
- document.getElementById("search_label_div").innerHTML = "#" + keyword + "
";
-
- currentSearchKeyword = keyword;
- initPageInfo();
- currentSearchTableName = tableName;
- currentSearchSortBy = sortBy;
- currentSearchAscending = ascending;
- OnlySearchLabel = true;
-
- page(currentPage);
+ initDiv(true);
+ //document.getElementById("search_div").style.display="none";
+ //document.getElementById("search_label_div").style.display="block";
+ document.getElementById("search_label_div").innerHTML =
+ '#' + keyword + "
";
+
+ currentSearchKeyword = keyword;
+ initPageInfo();
+ currentSearchTableName = tableName;
+ currentSearchSortBy = sortBy;
+ currentSearchAscending = ascending;
+ OnlySearchLabel = true;
+
+ page(currentPage);
}
function searchLabel(tableName, keyword, sortBy = "", ascending = "false") {
-
- sessionStorage.setItem("keyword", keyword);
- sessionStorage.setItem("tableName", tableName);
- sessionStorage.setItem("searchLabel", true);
- sessionStorage.setItem("sortBy", sortBy);
- sessionStorage.setItem("ascending", ascending);
- window.open("/all/search/");
+ sessionStorage.setItem("keyword", keyword);
+ sessionStorage.setItem("tableName", tableName);
+ sessionStorage.setItem("searchLabel", true);
+ sessionStorage.setItem("sortBy", sortBy);
+ sessionStorage.setItem("ascending", ascending);
+ window.open("/all/search/");
}
-function doSearch(tableName, keyword, page, pageSize = 15, onlyReturnNum = true, sortBy = "", OnlySearchLabel = false) {
- var language = "zh-CN";
- if (!isZh) {
- language = "en-US";
- }
- $.ajax({
- type: "GET",
- url: "/all/dosearch/",
- headers: {
- authorization: token,
- },
- dataType: "json",
- data: {
- 'TableName': tableName,
- 'Key': keyword,
- 'Page': page,
- 'PageSize': pageSize,
- 'OnlyReturnNum': onlyReturnNum,
- 'SortBy': sortBy,
- 'OnlySearchLabel': OnlySearchLabel,
- 'Ascending': currentSearchAscending,
- 'WebTotal': totalNum,
- 'PrivateTotal': privateTotal,
- 'language': language
- },
- async: true,
- success: function (json) {
- displayResult(tableName, page, json, onlyReturnNum, keyword);
- },
- error: function (response) {
- }
- });
+function doSearch(
+ tableName,
+ keyword,
+ page,
+ pageSize = 15,
+ onlyReturnNum = true,
+ sortBy = "",
+ OnlySearchLabel = false
+) {
+ var language = "zh-CN";
+ if (!isZh) {
+ language = "en-US";
+ }
+ $.ajax({
+ type: "GET",
+ url: "/all/dosearch/",
+ headers: {
+ authorization: token,
+ },
+ dataType: "json",
+ data: {
+ TableName: tableName,
+ Key: keyword,
+ Page: page,
+ PageSize: pageSize,
+ OnlyReturnNum: onlyReturnNum,
+ SortBy: sortBy,
+ OnlySearchLabel: OnlySearchLabel,
+ Ascending: currentSearchAscending,
+ WebTotal: totalNum,
+ PrivateTotal: privateTotal,
+ language: language,
+ },
+ async: true,
+ success: function (json) {
+ displayResult(tableName, page, json, onlyReturnNum, keyword);
+ },
+ error: function (response) {},
+ });
}
function displayResult(tableName, page, jsonResult, onlyReturnNum, keyword) {
- if (tableName == "repository") {
- displayRepoResult(page, jsonResult, onlyReturnNum, keyword);
- } else if (tableName == "issue") {
- displayIssueResult(page, jsonResult, onlyReturnNum, keyword);
- } else if (tableName == "user") {
- displayUserResult(page, jsonResult, onlyReturnNum, keyword);
- } else if (tableName == "org") {
- displayOrgResult(page, jsonResult, onlyReturnNum, keyword);
- } else if (tableName == "dataset") {
- displayDataSetResult(page, jsonResult, onlyReturnNum, keyword);
- } else if (tableName == "pr") {
- displayPrResult(page, jsonResult, onlyReturnNum, keyword);
- }
- if (!onlyReturnNum) {
- totalPage = Math.ceil(jsonResult.Total / pageSize);
- totalNum = jsonResult.Total;
- privateTotal = jsonResult.PrivateTotal;
- setPage(page);
- }
-
+ if (tableName == "repository") {
+ displayRepoResult(page, jsonResult, onlyReturnNum, keyword);
+ } else if (tableName == "issue") {
+ displayIssueResult(page, jsonResult, onlyReturnNum, keyword);
+ } else if (tableName == "user") {
+ displayUserResult(page, jsonResult, onlyReturnNum, keyword);
+ } else if (tableName == "org") {
+ displayOrgResult(page, jsonResult, onlyReturnNum, keyword);
+ } else if (tableName == "dataset") {
+ displayDataSetResult(page, jsonResult, onlyReturnNum, keyword);
+ } else if (tableName == "pr") {
+ displayPrResult(page, jsonResult, onlyReturnNum, keyword);
+ }
+ if (!onlyReturnNum) {
+ totalPage = Math.ceil(jsonResult.Total / pageSize);
+ totalNum = jsonResult.Total;
+ privateTotal = jsonResult.PrivateTotal;
+ setPage(page);
+ }
}
function displayPrResult(page, jsonResult, onlyReturnNum, keyword) {
- var data = jsonResult.Result;
- var total = jsonResult.Total;
- $('#pr_total').text(total);
- if (!onlyReturnNum) {
- setActivate("pr_item");
- //$('#keyword_desc').text(keyword);
- //$('#obj_desc').text(getLabel(isZh,"search_pr"));
- //$('#child_total').text(total);
- $('#find_title').html(getLabel(isZh, "find_title").replace('{keyword}', keyword).replace('{tablename}', getLabel(isZh, "search_pr")).replace('{total}', total));
-
- setIssueOrPrInnerHtml(data, "pulls");
- }
+ var data = jsonResult.Result;
+ var total = jsonResult.Total;
+ $("#pr_total").text(total);
+ if (!onlyReturnNum) {
+ setActivate("pr_item");
+ //$('#keyword_desc').text(keyword);
+ //$('#obj_desc').text(getLabel(isZh,"search_pr"));
+ //$('#child_total').text(total);
+ $("#find_title").html(
+ getLabel(isZh, "find_title")
+ .replace("{keyword}", keyword)
+ .replace("{tablename}", getLabel(isZh, "search_pr"))
+ .replace("{total}", total)
+ );
+
+ setIssueOrPrInnerHtml(data, "pulls");
+ }
}
var categoryDesc = {
- "computer_vision": "计算机视觉",
- "natural_language_processing": "自然语言处理",
- "speech_processing": "语音处理",
- "computer_vision_natural_language_processing": "计算机视觉、自然语言处理"
+ computer_vision: "计算机视觉",
+ natural_language_processing: "自然语言处理",
+ speech_processing: "语音处理",
+ computer_vision_natural_language_processing: "计算机视觉、自然语言处理",
};
var categoryENDesc = {
- "computer_vision": "computer vision",
- "natural_language_processing": "natural language processing",
- "speech_processing": "speech processing",
- "computer_vision_natural_language_processing": "computer vision and natural language processing"
+ computer_vision: "computer vision",
+ natural_language_processing: "natural language processing",
+ speech_processing: "speech processing",
+ computer_vision_natural_language_processing:
+ "computer vision and natural language processing",
};
var taskDesc = {
- "machine_translation": "机器翻译",
- "question_answering_system": "问答系统",
- "information_retrieval": "信息检索",
- "knowledge_graph": "知识图谱",
- "text_annotation": "文本标注",
- "text_categorization": "文本分类",
- "emotion_analysis": "情感分析",
- "language_modeling": "语言建模",
- "speech_recognition": "语音识别",
- "automatic_digest": "自动文摘",
- "information_extraction": "信息抽取",
- "description_generation": "说明生成",
- "image_classification": "图像分类",
- "face_recognition": "人脸识别",
- "image_search": "图像搜索",
- "target_detection": "目标检测",
- "image_description_generation": "图像描述生成",
- "vehicle_license_plate_recognition": "车辆车牌识别",
- "medical_image_analysis": "医学图像分析",
- "unmanned": "无人驾驶",
- "unmanned_security": "无人安防",
- "drone": "无人机",
- "vr_ar": "VR/AR",
- "2_d_vision": "2-D视觉",
- "2_5_d_vision": "2.5-D视觉",
- "3_d_reconstruction": "3D重构",
- "image_processing": "图像处理",
- "video_processing": "视频处理",
- "visual_input_system": "视觉输入系统",
- "speech_coding": "语音编码",
- "speech_enhancement": "语音增强",
- "speech_recognition": "语音识别",
- "speech_synthesis": "语音合成"
+ machine_translation: "机器翻译",
+ question_answering_system: "问答系统",
+ information_retrieval: "信息检索",
+ knowledge_graph: "知识图谱",
+ text_annotation: "文本标注",
+ text_categorization: "文本分类",
+ emotion_analysis: "情感分析",
+ language_modeling: "语言建模",
+ speech_recognition: "语音识别",
+ automatic_digest: "自动文摘",
+ information_extraction: "信息抽取",
+ description_generation: "说明生成",
+ image_classification: "图像分类",
+ face_recognition: "人脸识别",
+ image_search: "图像搜索",
+ target_detection: "目标检测",
+ image_description_generation: "图像描述生成",
+ vehicle_license_plate_recognition: "车辆车牌识别",
+ medical_image_analysis: "医学图像分析",
+ unmanned: "无人驾驶",
+ unmanned_security: "无人安防",
+ drone: "无人机",
+ vr_ar: "VR/AR",
+ "2_d_vision": "2-D视觉",
+ "2_5_d_vision": "2.5-D视觉",
+ "3_d_reconstruction": "3D重构",
+ image_processing: "图像处理",
+ video_processing: "视频处理",
+ visual_input_system: "视觉输入系统",
+ speech_coding: "语音编码",
+ speech_enhancement: "语音增强",
+ speech_recognition: "语音识别",
+ speech_synthesis: "语音合成",
};
var taskENDesc = {
- "machine_translation": "machine translation",
- "question_answering_system": "question answering system",
- "information_retrieval": "information retrieval",
- "knowledge_graph": "knowledge graph",
- "text_annotation": "text annotation",
- "text_categorization": "text categorization",
- "emotion_analysis": "emotion analysis",
- "language_modeling": "language modeling",
- "speech_recognition": "speech recognition",
- "automatic_digest": "automatic digest",
- "information_extraction": "information extraction",
- "description_generation": "description generation",
- "image_classification": "image classification",
- "face_recognition": "face recognition",
- "image_search": "image search",
- "target_detection": "target detection",
- "image_description_generation": "image description generation",
- "vehicle_license_plate_recognition": "vehicle license plate recognition",
- "medical_image_analysis": "medical image analysis",
- "unmanned": "unmanned",
- "unmanned_security": "unmanned security",
- "drone": "drone",
- "vr_ar": "VR/AR",
- "2_d_vision": "2.D vision",
- "2.5_d_vision": "2.5D vision",
- "3_d_reconstruction": "3Dreconstruction",
- "image_processing": "image processing",
- "video_processing": "video processing",
- "visual_input_system": "visual input system",
- "speech_coding": "speech coding",
- "speech_enhancement": "speech enhancement",
- "speech_recognition": "speech recognition",
- "speech_synthesis": "speech synthesis"
+ machine_translation: "machine translation",
+ question_answering_system: "question answering system",
+ information_retrieval: "information retrieval",
+ knowledge_graph: "knowledge graph",
+ text_annotation: "text annotation",
+ text_categorization: "text categorization",
+ emotion_analysis: "emotion analysis",
+ language_modeling: "language modeling",
+ speech_recognition: "speech recognition",
+ automatic_digest: "automatic digest",
+ information_extraction: "information extraction",
+ description_generation: "description generation",
+ image_classification: "image classification",
+ face_recognition: "face recognition",
+ image_search: "image search",
+ target_detection: "target detection",
+ image_description_generation: "image description generation",
+ vehicle_license_plate_recognition: "vehicle license plate recognition",
+ medical_image_analysis: "medical image analysis",
+ unmanned: "unmanned",
+ unmanned_security: "unmanned security",
+ drone: "drone",
+ vr_ar: "VR/AR",
+ "2_d_vision": "2.D vision",
+ "2.5_d_vision": "2.5D vision",
+ "3_d_reconstruction": "3Dreconstruction",
+ image_processing: "image processing",
+ video_processing: "video processing",
+ visual_input_system: "visual input system",
+ speech_coding: "speech coding",
+ speech_enhancement: "speech enhancement",
+ speech_recognition: "speech recognition",
+ speech_synthesis: "speech synthesis",
};
function getCategoryDesc(isZh, key) {
- var re = key;
- if (isZh) {
- re = categoryDesc[key];
- } else {
- re = categoryENDesc[key];
- }
- if (isEmpty(re)) {
- return key;
- }
- return re;
+ var re = key;
+ if (isZh) {
+ re = categoryDesc[key];
+ } else {
+ re = categoryENDesc[key];
+ }
+ if (isEmpty(re)) {
+ return key;
+ }
+ return re;
}
function getTaskDesc(isZh, key) {
- var re = key;
- if (isZh) {
- re = taskDesc[key];
- } else {
- re = taskENDesc[key];
- }
- if (isEmpty(re)) {
- return key;
- }
- return re;
+ var re = key;
+ if (isZh) {
+ re = taskDesc[key];
+ } else {
+ re = taskENDesc[key];
+ }
+ if (isEmpty(re)) {
+ return key;
+ }
+ return re;
}
function getActiveItem(sort_type) {
- if (currentSearchSortBy == sortBy[sort_type] && currentSearchAscending == sortAscending[sort_type]) {
- return "active ";
- } else {
- return "";
- }
+ if (
+ currentSearchSortBy == sortBy[sort_type] &&
+ currentSearchAscending == sortAscending[sort_type]
+ ) {
+ return "active ";
+ } else {
+ return "";
+ }
}
function displayDataSetResult(page, jsonResult, onlyReturnNum, keyword) {
- var data = jsonResult.Result;
- var total = jsonResult.Total;
- $('#dataset_total').text(total);
- if (!onlyReturnNum) {
- setActivate("dataset_item");
- //$('#keyword_desc').text(keyword);
- //$('#obj_desc').text(getLabel(isZh,"search_dataset"));
- //$('#child_total').text(total);
- $('#find_title').html(getLabel(isZh, "find_title").replace('{keyword}', keyword).replace('{tablename}', getLabel(isZh, "search_dataset")).replace('{total}', total));
-
- var sortHtml = "";
- sortHtml += "";
- sortHtml += "";
- document.getElementById("sort_type").innerHTML = sortHtml;
-
- var html = "";
- var currentTime = new Date().getTime();
- for (var i = 0; i < data.length; i++) {
- var recordMap = data[i];
- html += "";
- html += "
";
- html += "
";
- if (!isEmpty(recordMap["category"])) {
- html += " " + getCategoryDesc(isZh, recordMap["category"]) + "";
- }
- if (!isEmpty(recordMap["task"])) {
- html += " " + getTaskDesc(isZh, recordMap["task"]) + "";
- }
- html += " " + recordMap["download_times"] + " ";
- html += "
";
- html += "
";
- html += "
";
- html += "
" + recordMap["description"] + "
";
- if (!isEmpty(recordMap["file_name"])) {
- html += "
" + recordMap["file_name"] + "
";
- }
- html += "
";
- html += " " + getLabel(isZh, "search_lasted_update") + " " + recordMap["updated_html"];
- html += "
";
- html += "
";
- html += "
";
- html += "
";
- }
- document.getElementById("child_search_item").innerHTML = html;
+ var data = jsonResult.Result;
+ var total = jsonResult.Total;
+ $("#dataset_total").text(total);
+ if (!onlyReturnNum) {
+ setActivate("dataset_item");
+ //$('#keyword_desc').text(keyword);
+ //$('#obj_desc').text(getLabel(isZh,"search_dataset"));
+ //$('#child_total').text(total);
+ $("#find_title").html(
+ getLabel(isZh, "find_title")
+ .replace("{keyword}", keyword)
+ .replace("{tablename}", getLabel(isZh, "search_dataset"))
+ .replace("{total}", total)
+ );
+
+ var sortHtml = "";
+ sortHtml +=
+ '";
+ sortHtml +=
+ '";
+ document.getElementById("sort_type").innerHTML = sortHtml;
+
+ var html = "";
+ var currentTime = new Date().getTime();
+ for (var i = 0; i < data.length; i++) {
+ var recordMap = data[i];
+ html += '';
+ html += '
';
+ html += '
';
+ if (!isEmpty(recordMap["category"])) {
+ html +=
+ ' ' +
+ getCategoryDesc(isZh, recordMap["category"]) +
+ "";
+ }
+ if (!isEmpty(recordMap["task"])) {
+ html +=
+ ' ' +
+ getTaskDesc(isZh, recordMap["task"]) +
+ "";
+ }
+ html +=
+ ' ' +
+ recordMap["download_times"] +
+ " ";
+ html += "
";
+ html += ' ";
+ html += '
';
+ html +=
+ '
' + recordMap["description"] + "
";
+ if (!isEmpty(recordMap["file_name"])) {
+ html +=
+ '
' + recordMap["file_name"] + "
";
+ }
+ html += '
';
+ html +=
+ ' ' +
+ getLabel(isZh, "search_lasted_update") +
+ " " +
+ recordMap["updated_html"];
+ html += "
";
+ html += "
";
+ html += "
";
+ html += "
";
}
+ document.getElementById("child_search_item").innerHTML = html;
+ }
}
function displayOrgResult(page, jsonResult, onlyReturnNum, keyword) {
- var data = jsonResult.Result;
- var total = jsonResult.Total;
- $('#org_total').text(total);
- if (!onlyReturnNum) {
- setActivate("org_item");
- //$('#keyword_desc').text(keyword);
- //$('#obj_desc').text(getLabel(isZh,"search_org"));
- //$('#child_total').text(total);
- $('#find_title').html(getLabel(isZh, "find_title").replace('{keyword}', keyword).replace('{tablename}', getLabel(isZh, "search_org")).replace('{total}', total));
-
- var sortHtml = "";
- sortHtml += "";
- sortHtml += "";
- sortHtml += "";
- sortHtml += "";
- sortHtml += "";
- document.getElementById("sort_type").innerHTML = sortHtml;
-
- var html = "";
- var currentTime = new Date().getTime();
- for (var i = 0; i < data.length; i++) {
- var recordMap = data[i];
- html += "";
- html += "

";
- html += "
";
- html += "
";
- html += "
";
- html += "
" + recordMap["description"] + "
";
- html += "
";
- if (!isEmpty(recordMap["location"]) && recordMap["location"] != "null") {
- html += " " + recordMap["location"];
- }
- html += " ";
- if (!isEmpty(recordMap["website"]) && recordMap["website"] != "null") {
- html += " " + "" + recordMap["website"] + "";
- }
- html += " " + getLabel(isZh, "search_add_by") + " ";
- html += recordMap["add_time"]
- html += "
";
- html += "
";
- html += "
";
- html += "
";
- }
- document.getElementById("child_search_item").innerHTML = html;
- }
-}
-var monthDisplay = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Spt", "Oct", "Nov", "Dec");
-function displayUserResult(page, jsonResult, onlyReturnNum, keyword) {
- var data = jsonResult.Result;
- var total = jsonResult.Total;
- $('#user_total').text(total);
- if (!onlyReturnNum) {
- setActivate("user_item");
- //$('#keyword_desc').text(keyword);
- //$('#obj_desc').text(getLabel(isZh,"search_user"));
- //$('#child_total').text(total);
-
- $('#find_title').html(getLabel(isZh, "find_title").replace('{keyword}', keyword).replace('{tablename}', getLabel(isZh, "search_user")).replace('{total}', total));
-
- var sortHtml = "";//equal user sort by
- sortHtml += "";
- sortHtml += "";
- sortHtml += "";
- sortHtml += "";
- sortHtml += "";
-
- document.getElementById("sort_type").innerHTML = sortHtml;
-
- var html = "";
- var currentTime = new Date().getTime();
- for (var i = 0; i < data.length; i++) {
- var recordMap = data[i];
- html += "";
- html += "

";
- html += "
";
- html += "
";
- html += "
";
- html += "
" + recordMap["description"] + "
";
- html += "
";
- if (!isEmpty(recordMap["email"]) && recordMap["email"] != "null") {
- html += " " + recordMap["email"] + "";
- }
- html += " " + getLabel(isZh, "search_add_by") + " ";
- html += recordMap["add_time"]
- html += "
";
- html += "
";
- html += "
";
- html += "
";
- }
- document.getElementById("child_search_item").innerHTML = html;
- }
-}
+ var data = jsonResult.Result;
+ var total = jsonResult.Total;
+ $("#org_total").text(total);
+ if (!onlyReturnNum) {
+ setActivate("org_item");
+ //$('#keyword_desc').text(keyword);
+ //$('#obj_desc').text(getLabel(isZh,"search_org"));
+ //$('#child_total').text(total);
+ $("#find_title").html(
+ getLabel(isZh, "find_title")
+ .replace("{keyword}", keyword)
+ .replace("{tablename}", getLabel(isZh, "search_org"))
+ .replace("{total}", total)
+ );
-function setIssueOrPrInnerHtml(data, path) {
var sortHtml = "";
- if (path == "issues") {
- sortHtml += "";
- sortHtml += "";
- } else {
- sortHtml += "";
- sortHtml += "";
- }
-
+ sortHtml +=
+ '";
+ sortHtml +=
+ '";
+ sortHtml +=
+ '";
+ sortHtml +=
+ '";
+ sortHtml +=
+ '";
document.getElementById("sort_type").innerHTML = sortHtml;
var html = "";
var currentTime = new Date().getTime();
for (var i = 0; i < data.length; i++) {
- var recordMap = data[i];
- html += "";
- html += "
";
- html += "
";
- html += "
";
- html += "
" + recordMap["content"] + "
";
- html += "
";
- html += " ";
- html += " " + addBlank(recordMap["repoUrl"]) + " #" + recordMap["index"] + " ";
- html += " ";
- if (recordMap["is_closed"] != null && (!(recordMap["is_closed"]) || recordMap["is_closed"] == "f")) {
- html += getLabel(isZh, "search_open");
- } else {
- html += getLabel(isZh, "search_closed");
- }
- html += " " + recordMap["num_comments"];
+ var recordMap = data[i];
+ html += '
';
+ html +=
+ '

';
+ html += '
';
+ html += ' ";
+ html += '
';
+ html +=
+ '
' + recordMap["description"] + "
";
+ html += '
';
+ if (!isEmpty(recordMap["location"]) && recordMap["location"] != "null") {
+ html +=
+ ' ' +
+ recordMap["location"];
+ }
+ html += ' ';
+ if (!isEmpty(recordMap["website"]) && recordMap["website"] != "null") {
+ html +=
+ ' ' +
+ '' +
+ recordMap["website"] +
+ "";
+ }
+ html +=
+ ' ' +
+ getLabel(isZh, "search_add_by") +
+ " ";
+ html += recordMap["add_time"];
+ html += "
";
+ html += "
";
+ html += "
";
+ html += "
";
+ }
+ document.getElementById("child_search_item").innerHTML = html;
+ }
+}
+var monthDisplay = new Array(
+ "Jan",
+ "Feb",
+ "Mar",
+ "Apr",
+ "May",
+ "Jun",
+ "Jul",
+ "Aug",
+ "Spt",
+ "Oct",
+ "Nov",
+ "Dec"
+);
+function displayUserResult(page, jsonResult, onlyReturnNum, keyword) {
+ var data = jsonResult.Result;
+ var total = jsonResult.Total;
+ $("#user_total").text(total);
+ if (!onlyReturnNum) {
+ setActivate("user_item");
+ //$('#keyword_desc').text(keyword);
+ //$('#obj_desc').text(getLabel(isZh,"search_user"));
+ //$('#child_total').text(total);
+
+ $("#find_title").html(
+ getLabel(isZh, "find_title")
+ .replace("{keyword}", keyword)
+ .replace("{tablename}", getLabel(isZh, "search_user"))
+ .replace("{total}", total)
+ );
+
+ var sortHtml = ""; //equal user sort by
+ sortHtml +=
+ '";
+ sortHtml +=
+ '";
+ sortHtml +=
+ '";
+ sortHtml +=
+ '";
+ sortHtml +=
+ '";
- html += "
" + getLabel(isZh, "search_lasted_update") + " " + recordMap["updated_html"];
+ document.getElementById("sort_type").innerHTML = sortHtml;
- html += " ";
- html += "
";
- html += "
";
- html += "
";
+ var html = "";
+ var currentTime = new Date().getTime();
+ for (var i = 0; i < data.length; i++) {
+ var recordMap = data[i];
+ html += '';
+ html +=
+ '

';
+ html += '
';
+ html += ' ";
+ html += '
';
+ html +=
+ '
' + recordMap["description"] + "
";
+ html += '
';
+ if (!isEmpty(recordMap["email"]) && recordMap["email"] != "null") {
+ html +=
+ ' ' +
+ recordMap["email"] +
+ "";
+ }
+ html +=
+ ' ' +
+ getLabel(isZh, "search_add_by") +
+ " ";
+ html += recordMap["add_time"];
+ html += "
";
+ html += "
";
+ html += "
";
+ html += "
";
}
document.getElementById("child_search_item").innerHTML = html;
+ }
}
-function addBlank(url) {
- if (url == null) {
- return url;
- }
- var tmps = url.split("/");
- if (tmps.length == 2) {
- return tmps[0] + " / " + tmps[1];
+function setIssueOrPrInnerHtml(data, path) {
+ var sortHtml = "";
+ if (path == "issues") {
+ sortHtml +=
+ '";
+ sortHtml +=
+ '";
+ } else {
+ sortHtml +=
+ '";
+ sortHtml +=
+ '";
+ }
+
+ document.getElementById("sort_type").innerHTML = sortHtml;
+
+ var html = "";
+ var currentTime = new Date().getTime();
+ for (var i = 0; i < data.length; i++) {
+ var recordMap = data[i];
+ html += '';
+ html += '
';
+ html += ' ";
+ html += '
';
+ html += '
' + recordMap["content"] + "
";
+ html += '
';
+ html += ' ';
+ html +=
+ ' ' +
+ addBlank(recordMap["repoUrl"]) +
+ " #" +
+ recordMap["index"] +
+ " ";
+ html += ' ';
+ if (
+ recordMap["is_closed"] != null &&
+ (!recordMap["is_closed"] || recordMap["is_closed"] == "f")
+ ) {
+ html += getLabel(isZh, "search_open");
+ } else {
+ html += getLabel(isZh, "search_closed");
}
+ html +=
+ ' ' +
+ recordMap["num_comments"];
+
+ html +=
+ ' ' +
+ getLabel(isZh, "search_lasted_update") +
+ " " +
+ recordMap["updated_html"];
+
+ html += "
";
+ html += "
";
+ html += "
";
+ html += "
";
+ }
+ document.getElementById("child_search_item").innerHTML = html;
+}
+
+function addBlank(url) {
+ if (url == null) {
return url;
+ }
+ var tmps = url.split("/");
+ if (tmps.length == 2) {
+ return tmps[0] + " / " + tmps[1];
+ }
+ return url;
}
function displayIssueResult(page, jsonResult, onlyReturnNum, keyword) {
- var data = jsonResult.Result;
- var total = jsonResult.Total;
- $('#issue_total').text(total);
- if (!onlyReturnNum) {
- setActivate("issue_item");
- //$('#keyword_desc').text(keyword);
- //$('#obj_desc').text(getLabel(isZh,"search_issue"));
- //$('#child_total').text(total);
- $('#find_title').html(getLabel(isZh, "find_title").replace('{keyword}', keyword).replace('{tablename}', getLabel(isZh, "search_issue")).replace('{total}', total));
-
- setIssueOrPrInnerHtml(data, "issues");
- }
+ var data = jsonResult.Result;
+ var total = jsonResult.Total;
+ $("#issue_total").text(total);
+ if (!onlyReturnNum) {
+ setActivate("issue_item");
+ //$('#keyword_desc').text(keyword);
+ //$('#obj_desc').text(getLabel(isZh,"search_issue"));
+ //$('#child_total').text(total);
+ $("#find_title").html(
+ getLabel(isZh, "find_title")
+ .replace("{keyword}", keyword)
+ .replace("{tablename}", getLabel(isZh, "search_issue"))
+ .replace("{total}", total)
+ );
+
+ setIssueOrPrInnerHtml(data, "issues");
+ }
}
function setActivate(name) {
- $('#repo_item').removeClass("active");
- $('#user_item').removeClass("active");
- $('#issue_item').removeClass("active");
- $('#dataset_item').removeClass("active");
- $('#org_item').removeClass("active");
- $('#pr_item').removeClass("active");
- if (name == null) {
- return;
- }
- var tmp = "#" + name;
- $(tmp).addClass("active");
+ $("#repo_item").removeClass("active");
+ $("#user_item").removeClass("active");
+ $("#issue_item").removeClass("active");
+ $("#dataset_item").removeClass("active");
+ $("#org_item").removeClass("active");
+ $("#pr_item").removeClass("active");
+ if (name == null) {
+ return;
+ }
+ var tmp = "#" + name;
+ $(tmp).addClass("active");
}
-
function LetterAvatar(name, size, color) {
- name = name || '';
- size = size || 60;
- var colours = [
- "#1abc9c", "#2ecc71", "#3498db", "#9b59b6", "#34495e", "#16a085", "#27ae60", "#2980b9", "#8e44ad", "#2c3e50",
- "#f1c40f", "#e67e22", "#e74c3c", "#00bcd4", "#95a5a6", "#f39c12", "#d35400", "#c0392b", "#bdc3c7", "#7f8c8d"
+ name = name || "";
+ size = size || 60;
+ var colours = [
+ "#1abc9c",
+ "#2ecc71",
+ "#3498db",
+ "#9b59b6",
+ "#34495e",
+ "#16a085",
+ "#27ae60",
+ "#2980b9",
+ "#8e44ad",
+ "#2c3e50",
+ "#f1c40f",
+ "#e67e22",
+ "#e74c3c",
+ "#00bcd4",
+ "#95a5a6",
+ "#f39c12",
+ "#d35400",
+ "#c0392b",
+ "#bdc3c7",
+ "#7f8c8d",
],
- nameSplit = String(name).split(' '),
- initials, charIndex, colourIndex, canvas, context, dataURI;
- if (nameSplit.length == 1) {
- initials = nameSplit[0] ? nameSplit[0].charAt(0) : '?';
- } else {
- initials = nameSplit[0].charAt(0) + nameSplit[1].charAt(0);
- }
- if (w.devicePixelRatio) {
- size = (size * w.devicePixelRatio);
- }
-
- charIndex = (initials == '?' ? 72 : initials.charCodeAt(0)) - 64;
- colourIndex = charIndex % 20;
- canvas = d.createElement('canvas');
- canvas.width = size;
- canvas.height = size;
- context = canvas.getContext("2d");
-
- context.fillStyle = color ? color : colours[colourIndex - 1];
- context.fillRect(0, 0, canvas.width, canvas.height);
- context.font = Math.round(canvas.width / 2) + "px 'Microsoft Yahei'";
- context.textAlign = "center";
- context.fillStyle = "#FFF";
- context.fillText(initials, size / 2, size / 1.5);
- dataURI = canvas.toDataURL();
- canvas = null;
- return dataURI;
+ nameSplit = String(name).split(" "),
+ initials,
+ charIndex,
+ colourIndex,
+ canvas,
+ context,
+ dataURI;
+ if (nameSplit.length == 1) {
+ initials = nameSplit[0] ? nameSplit[0].charAt(0) : "?";
+ } else {
+ initials = nameSplit[0].charAt(0) + nameSplit[1].charAt(0);
+ }
+ let initials1 = initials.toUpperCase();
+ initials.toUpperCase();
+ if (w.devicePixelRatio) {
+ size = size * w.devicePixelRatio;
+ }
+
+ charIndex = (initials == "?" ? 72 : initials.charCodeAt(0)) - 64;
+ colourIndex = charIndex % 20;
+ canvas = d.createElement("canvas");
+ canvas.width = size;
+ canvas.height = size;
+ context = canvas.getContext("2d");
+
+ context.fillStyle = color ? color : colours[colourIndex - 1];
+ context.fillRect(0, 0, canvas.width, canvas.height);
+ context.font = Math.round(canvas.width / 2) + "px 'Microsoft Yahei'";
+ context.textAlign = "center";
+ context.fillStyle = "#FFF";
+ context.fillText(initials1, size / 2, size / 1.5);
+ dataURI = canvas.toDataURL();
+ canvas = null;
+ return dataURI;
}
LetterAvatar.transform = function () {
- Array.prototype.forEach.call(d.querySelectorAll('img[avatar]'), function (img, name, color) {
- name = img.getAttribute('avatar');
- color = img.getAttribute('color');
- img.src = LetterAvatar(name, img.getAttribute('width'), color);
- img.removeAttribute('avatar');
- img.setAttribute('alt', name);
- });
+ Array.prototype.forEach.call(
+ d.querySelectorAll("img[avatar]"),
+ function (img, name, color) {
+ name = img.getAttribute("avatar");
+ color = img.getAttribute("color");
+ img.src = LetterAvatar(name, img.getAttribute("width"), color);
+ img.removeAttribute("avatar");
+ img.setAttribute("alt", name);
+ }
+ );
};
function displayRepoResult(page, jsonResult, onlyReturnNum, keyword) {
- var data = jsonResult.Result;
- var total = jsonResult.Total;
- $('#repo_total').text(total);
-
- if (!onlyReturnNum) {
- setActivate("repo_item");
- // $('#keyword_desc').text(keyword);
- //$('#obj_desc').text(getLabel(isZh,"search_repo"));
- //$('#child_total').text(total);
- $('#find_title').html(getLabel(isZh, "find_title").replace('{keyword}', keyword).replace('{tablename}', getLabel(isZh, "search_repo")).replace('{total}', total));
-
- var sortHtml = "";
- sortHtml += "";
- sortHtml += "";
- sortHtml += "";
- sortHtml += "";
- sortHtml += "";
-
- document.getElementById("sort_type").innerHTML = sortHtml;
-
- var html = "";
- var currentTime = new Date().getTime();
- for (var i = 0; i < data.length; i++) {
- var recordMap = data[i];
- html += "";
- if (recordMap['avatar']) {
- html += `

`
- } else {
- html += `
![]()
`
- }
-
- html += "
";
- html += "
";
- html += "
";
- html += "
" + recordMap["description"] + "
";
- html += "
";
- if (!isEmpty(recordMap["topics"]) && recordMap["topics"] != "null") {
- for (var j = 0; j < recordMap["topics"].length; j++) {
- //function searchLabel(tableName,keyword,sortBy="",ascending=false)
- html += "
" + recordMap["hightTopics"][j] + "
";
- }
- }
- html += "
";
- html += "
";
- html += " " + recordMap["num_watches"] + " " + recordMap["num_stars"] + " " + recordMap["num_forks"] + " ";
- html += " " + getLabel(isZh, "search_lasted_update") + " " + recordMap["updated_html"];
- if (!isEmpty(recordMap["lang"])) {
- var lang = recordMap["lang"]
- var tmpLang = recordMap["lang"].split(",");
- if (tmpLang.length > 0) {
- lang = tmpLang[0]
- }
- var backColor = "#3572A5";
- if (LanguagesColor[lang] != null) {
- backColor = LanguagesColor[lang];
- }
- html += " " + lang + "";
- }
- html += "
";
- html += "
";
- html += "
";
- html += "
";
- }
+ var data = jsonResult.Result;
+ var total = jsonResult.Total;
+ $("#repo_total").text(total);
+
+ if (!onlyReturnNum) {
+ setActivate("repo_item");
+ // $('#keyword_desc').text(keyword);
+ //$('#obj_desc').text(getLabel(isZh,"search_repo"));
+ //$('#child_total').text(total);
+ $("#find_title").html(
+ getLabel(isZh, "find_title")
+ .replace("{keyword}", keyword)
+ .replace("{tablename}", getLabel(isZh, "search_repo"))
+ .replace("{total}", total)
+ );
- document.getElementById("child_search_item").innerHTML = html;
- LetterAvatar.transform()
- }
-}
+ var sortHtml = "";
+ sortHtml +=
+ '";
+ sortHtml +=
+ '";
+ sortHtml +=
+ '";
+ sortHtml +=
+ '";
+ sortHtml +=
+ '";
-function getTime(UpdatedUnix, currentTime) {
- UpdatedUnix = UpdatedUnix;
- currentTime = currentTime / 1000;
- var timeEscSecond = currentTime - UpdatedUnix;
- if (timeEscSecond < 0) {
- timeEscSecond = 1;
- }
+ document.getElementById("sort_type").innerHTML = sortHtml;
- var hours = Math.floor(timeEscSecond / 3600);
- //计算相差分钟数
- var leave2 = Math.floor(timeEscSecond % (3600)); //计算小时数后剩余的秒数
- var minutes = Math.floor(leave2 / 60);//计算相差分钟数
+ var html = "";
+ var currentTime = new Date().getTime();
+ for (var i = 0; i < data.length; i++) {
+ var recordMap = data[i];
+ html += '';
+ if (recordMap["avatar"]) {
+ html += `

`;
+ } else {
+ html += `
![]()
`;
+ }
+
+ html += '
';
+ html += ' ";
+ html += '
';
+ html +=
+ '
' + recordMap["description"] + "
";
+ html += '
";
+ html += '
';
+ html +=
+ ' ' +
+ recordMap["num_watches"] +
+ ' ' +
+ recordMap["num_stars"] +
+ ' ' +
+ recordMap["num_forks"] +
+ " ";
+ html +=
+ " " +
+ getLabel(isZh, "search_lasted_update") +
+ " " +
+ recordMap["updated_html"];
+ if (!isEmpty(recordMap["lang"])) {
+ var lang = recordMap["lang"];
+ var tmpLang = recordMap["lang"].split(",");
+ if (tmpLang.length > 0) {
+ lang = tmpLang[0];
+ }
+ var backColor = "#3572A5";
+ if (LanguagesColor[lang] != null) {
+ backColor = LanguagesColor[lang];
+ }
+ html +=
+ ' ' +
+ lang +
+ "";
+ }
+ html += "
";
+ html += "
";
+ html += "
";
+ html += "
";
+ }
- var leave3 = Math.floor(leave2 % 60); //计算分钟数后剩余的秒数
- var seconds = leave3;
+ document.getElementById("child_search_item").innerHTML = html;
+ LetterAvatar.transform();
+ }
+}
- if (hours == 0 && minutes == 0) {
- return seconds + getRepoOrOrg(6, isZh);
- } else {
- if (hours > 0) {
- if (hours >= 24) {
- var days = Math.ceil(hours / 24)
- if (days >= 30 && days < 365) {
- return Math.ceil(days / 30) + getRepoOrOrg(8, isZh);
- } else if (days >= 365) {
- return Math.ceil(days / 365) + getRepoOrOrg(9, isZh);
- }
- return Math.ceil(hours / 24) + getRepoOrOrg(7, isZh);
- } else {
- return hours + getRepoOrOrg(4, isZh);
- }
- } else {
- return minutes + getRepoOrOrg(5, isZh);
+function getTime(UpdatedUnix, currentTime) {
+ UpdatedUnix = UpdatedUnix;
+ currentTime = currentTime / 1000;
+ var timeEscSecond = currentTime - UpdatedUnix;
+ if (timeEscSecond < 0) {
+ timeEscSecond = 1;
+ }
+
+ var hours = Math.floor(timeEscSecond / 3600);
+ //计算相差分钟数
+ var leave2 = Math.floor(timeEscSecond % 3600); //计算小时数后剩余的秒数
+ var minutes = Math.floor(leave2 / 60); //计算相差分钟数
+
+ var leave3 = Math.floor(leave2 % 60); //计算分钟数后剩余的秒数
+ var seconds = leave3;
+
+ if (hours == 0 && minutes == 0) {
+ return seconds + getRepoOrOrg(6, isZh);
+ } else {
+ if (hours > 0) {
+ if (hours >= 24) {
+ var days = Math.ceil(hours / 24);
+ if (days >= 30 && days < 365) {
+ return Math.ceil(days / 30) + getRepoOrOrg(8, isZh);
+ } else if (days >= 365) {
+ return Math.ceil(days / 365) + getRepoOrOrg(9, isZh);
}
+ return Math.ceil(hours / 24) + getRepoOrOrg(7, isZh);
+ } else {
+ return hours + getRepoOrOrg(4, isZh);
+ }
+ } else {
+ return minutes + getRepoOrOrg(5, isZh);
}
+ }
}
function getRepoOrOrg(key, isZhLang) {
- if (isZhLang) {
- return repoAndOrgZH[key];
- } else {
- return repoAndOrgEN[key];
- }
+ if (isZhLang) {
+ return repoAndOrgZH[key];
+ } else {
+ return repoAndOrgEN[key];
+ }
}
var repoAndOrgZH = {
- "1": "项目",
- "2": "成员",
- "3": "团队",
- "4": "小时前",
- "5": "分钟前",
- "6": "秒前",
- "7": "天前",
- "8": "个月前",
- "9": "年前"
+ 1: "项目",
+ 2: "成员",
+ 3: "团队",
+ 4: "小时前",
+ 5: "分钟前",
+ 6: "秒前",
+ 7: "天前",
+ 8: "个月前",
+ 9: "年前",
};
var repoAndOrgEN = {
- "1": "repository",
- "2": "Members ",
- "3": "Teams",
- "4": " hours ago",
- "5": " minutes ago",
- "6": " seconds ago",
- "7": " day ago",
- "8": " month ago",
- "9": " year ago"
+ 1: "repository",
+ 2: "Members ",
+ 3: "Teams",
+ 4: " hours ago",
+ 5: " minutes ago",
+ 6: " seconds ago",
+ 7: " day ago",
+ 8: " month ago",
+ 9: " year ago",
};
-
-
-
function page(current) {
-
- currentPage = current;
-
- doSearch(currentSearchTableName, currentSearchKeyword, current, pageSize, false, currentSearchSortBy, OnlySearchLabel);
+ currentPage = current;
+
+ doSearch(
+ currentSearchTableName,
+ currentSearchKeyword,
+ current,
+ pageSize,
+ false,
+ currentSearchSortBy,
+ OnlySearchLabel
+ );
}
function nextPage() {
- currentPage = currentPage + 1;
- page(currentPage);
+ currentPage = currentPage + 1;
+ page(currentPage);
}
function prePage() {
- if (currentPage > 1) {
- currentPage = currentPage - 1;
- page(currentPage);
- }
+ if (currentPage > 1) {
+ currentPage = currentPage - 1;
+ page(currentPage);
+ }
}
function getXPosition(e) {
- var x = e.offsetLeft;
- while (e = e.offsetParent) {
- x += e.offsetLeft;
- }
- return x + 20;//-260防止屏幕超出
+ var x = e.offsetLeft;
+ while ((e = e.offsetParent)) {
+ x += e.offsetLeft;
+ }
+ return x + 20; //-260防止屏幕超出
}
//获取y坐标
function getYPosition(e) {
- var y = e.offsetTop;
- while (e = e.offsetParent) {
- y += e.offsetTop;
- }
- return y + 20;//80为input高度
+ var y = e.offsetTop;
+ while ((e = e.offsetParent)) {
+ y += e.offsetTop;
+ }
+ return y + 20; //80为input高度
}
-
function goPage(event) {
-
- var inputpage = document.getElementById("inputpage_div")
- var left = getXPosition(event.target);
- var top = getYPosition(event.target);
- var goNum = $('#inputpage').val();
- if (goNum <= 0) {
- showTip(getLabel(isZh, "search_input_large_0"), "warning", left + 5, top);
- }
- else if (goNum <= totalPage) {
- page(parseInt(goNum, 10));
- }
- else {
- showTip(getLabel(isZh, "search_input_maxed"), "warning", left + 5, top);
- }
+ var inputpage = document.getElementById("inputpage_div");
+ var left = getXPosition(event.target);
+ var top = getYPosition(event.target);
+ var goNum = $("#inputpage").val();
+ if (goNum <= 0) {
+ showTip(getLabel(isZh, "search_input_large_0"), "warning", left + 5, top);
+ } else if (goNum <= totalPage) {
+ page(parseInt(goNum, 10));
+ } else {
+ showTip(getLabel(isZh, "search_input_maxed"), "warning", left + 5, top);
+ }
}
function showTip(tip, type, left, top) {
- var $tip = $('#tipmsg');
- var tipmsg = document.getElementById("tipmsg")
- var style = "z-index:10024;top:" + top + "px;left:" + left + "px;position:absolute;width:200px;height:60px;vertical-align:middle;";
- tipmsg.style = style;
- var html = "" + tip + "
"
- $tip.stop(true).prop('class', 'alert alert-' + type).html(html).fadeIn(500).delay(2000).fadeOut(500);
+ var $tip = $("#tipmsg");
+ var tipmsg = document.getElementById("tipmsg");
+ var style =
+ "z-index:10024;top:" +
+ top +
+ "px;left:" +
+ left +
+ "px;position:absolute;width:200px;height:60px;vertical-align:middle;";
+ tipmsg.style = style;
+ var html = "" + tip + "
";
+ $tip
+ .stop(true)
+ .prop("class", "alert alert-" + type)
+ .html(html)
+ .fadeIn(500)
+ .delay(2000)
+ .fadeOut(500);
}
function setPage(currentPage) {
- var html = "";
- startIndex = currentPage - 1;
- if (startIndex < 1) {
- startIndex = 1;
- }
- endIndex = currentPage + 2;
- if (endIndex >= totalPage) {
- endIndex = totalPage;
+ var html = "";
+ startIndex = currentPage - 1;
+ if (startIndex < 1) {
+ startIndex = 1;
+ }
+ endIndex = currentPage + 2;
+ if (endIndex >= totalPage) {
+ endIndex = totalPage;
+ }
+ html +=
+ '' +
+ getLabel(isZh, "search_input_total") +
+ " " +
+ totalNum +
+ " " +
+ getLabel(isZh, "search_srtip") +
+ "";
+ if (currentPage > 1) {
+ html +=
+ '' +
+ getLabel(isZh, "search_home_page") +
+ "";
+ html +=
+ '';
+ } else {
+ html +=
+ '' +
+ getLabel(isZh, "search_home_page") +
+ "";
+ html +=
+ '';
+ }
+
+ for (var i = startIndex; i <= endIndex; i++) {
+ var page_i = i;
+ if (page_i > totalPage) {
+ break;
}
- html += "" + getLabel(isZh, "search_input_total") + " " + totalNum + " " + getLabel(isZh, "search_srtip") + ""
- if (currentPage > 1) {
- html += "" + getLabel(isZh, "search_home_page") + "";
- html += "";
+ if (page_i == currentPage) {
+ html +=
+ '' +
+ page_i +
+ "";
} else {
- html += "" + getLabel(isZh, "search_home_page") + "";
- html += "";
- }
-
- for (var i = startIndex; i <= endIndex; i++) {
- var page_i = i;
- if (page_i > totalPage) {
- break;
- }
- if (page_i == currentPage) {
- html += "" + page_i + "";
- } else {
- html += "" + page_i + "";
- }
- }
-
- if (endIndex < totalPage - 1) {
- html += "...";
- html += "" + totalPage + "";
+ html +=
+ '' +
+ page_i +
+ "";
}
-
- if (currentPage >= totalPage) {
- html += "";
- html += "" + getLabel(isZh, "search_last_page") + "";
- } else {
- html += "";
- html += "" + getLabel(isZh, "search_last_page") + "";
+ }
+
+ if (endIndex < totalPage - 1) {
+ html += "...";
+ html +=
+ '' +
+ totalPage +
+ "";
+ }
+
+ if (currentPage >= totalPage) {
+ html +=
+ '';
+ html +=
+ '' +
+ getLabel(isZh, "search_last_page") +
+ "";
+ } else {
+ html +=
+ '';
+ html +=
+ '' +
+ getLabel(isZh, "search_last_page") +
+ "";
+ }
+
+ html +=
+ ' ' +
+ getLabel(isZh, "search_go_to") +
+ '
' +
+ getLabel(isZh, "search_go_page") +
+ "
";
+ document.getElementById("page_menu").innerHTML = html;
+ $("#inputpage").on("keypress", function (event) {
+ if (event.keyCode == 13) {
+ goPage(event);
}
-
- html += " " + getLabel(isZh, "search_go_to") + "
" + getLabel(isZh, "search_go_page") + "
";
- document.getElementById("page_menu").innerHTML = html;
- $('#inputpage').on('keypress', function (event) {
- if (event.keyCode == 13) {
- goPage(event);
- }
- });
+ });
}
-$('#keyword_input').on('keypress', function (event) {
- if (event.keyCode == 13) {
- search();
- }
+$("#keyword_input").on("keypress", function (event) {
+ if (event.keyCode == 13) {
+ search();
+ }
});
-
-
-
-
var LanguagesColor = {
- "1C Enterprise": "#814CCC",
- "ABAP": "#E8274B",
- "AGS Script": "#B9D9FF",
- "AMPL": "#E6EFBB",
- "ANTLR": "#9DC3FF",
- "API Blueprint": "#2ACCA8",
- "APL": "#5A8164",
- "ASP": "#6a40fd",
- "ATS": "#1ac620",
- "ActionScript": "#882B0F",
- "Ada": "#02f88c",
- "Agda": "#315665",
- "Alloy": "#64C800",
- "AngelScript": "#C7D7DC",
- "AppleScript": "#101F1F",
- "Arc": "#aa2afe",
- "AspectJ": "#a957b0",
- "Assembly": "#6E4C13",
- "Asymptote": "#4a0c0c",
- "AutoHotkey": "#6594b9",
- "AutoIt": "#1C3552",
- "Ballerina": "#FF5000",
- "Batchfile": "#C1F12E",
- "BlitzMax": "#cd6400",
- "Boo": "#d4bec1",
- "Brainfuck": "#2F2530",
- "C": "#555555",
- "C#": "#178600",
- "C++": "#f34b7d",
- "CSS": "#563d7c",
- "Ceylon": "#dfa535",
- "Chapel": "#8dc63f",
- "Cirru": "#ccccff",
- "Clarion": "#db901e",
- "Clean": "#3F85AF",
- "Click": "#E4E6F3",
- "Clojure": "#db5855",
- "CoffeeScript": "#244776",
- "ColdFusion": "#ed2cd6",
- "Common Lisp": "#3fb68b",
- "Common Workflow Language": "#B5314C",
- "Component Pascal": "#B0CE4E",
- "Crystal": "#000100",
- "Cuda": "#3A4E3A",
- "D": "#ba595e",
- "DM": "#447265",
- "Dart": "#00B4AB",
- "DataWeave": "#003a52",
- "Dhall": "#dfafff",
- "Dockerfile": "#384d54",
- "Dogescript": "#cca760",
- "Dylan": "#6c616e",
- "E": "#ccce35",
- "ECL": "#8a1267",
- "EQ": "#a78649",
- "Eiffel": "#946d57",
- "Elixir": "#6e4a7e",
- "Elm": "#60B5CC",
- "Emacs Lisp": "#c065db",
- "EmberScript": "#FFF4F3",
- "Erlang": "#B83998",
- "F#": "#b845fc",
- "F*": "#572e30",
- "FLUX": "#88ccff",
- "Factor": "#636746",
- "Fancy": "#7b9db4",
- "Fantom": "#14253c",
- "Faust": "#c37240",
- "Forth": "#341708",
- "Fortran": "#4d41b1",
- "FreeMarker": "#0050b2",
- "Frege": "#00cafe",
- "G-code": "#D08CF2",
- "GAML": "#FFC766",
- "GDScript": "#355570",
- "Game Maker Language": "#71b417",
- "Genie": "#fb855d",
- "Gherkin": "#5B2063",
- "Glyph": "#c1ac7f",
- "Gnuplot": "#f0a9f0",
- "Go": "#00ADD8",
- "Golo": "#88562A",
- "Gosu": "#82937f",
- "Grammatical Framework": "#79aa7a",
- "Groovy": "#e69f56",
- "HTML": "#e34c26",
- "Hack": "#878787",
- "Harbour": "#0e60e3",
- "Haskell": "#5e5086",
- "Haxe": "#df7900",
- "HiveQL": "#dce200",
- "HolyC": "#ffefaf",
- "Hy": "#7790B2",
- "IDL": "#a3522f",
- "IGOR Pro": "#0000cc",
- "Idris": "#b30000",
- "Io": "#a9188d",
- "Ioke": "#078193",
- "Isabelle": "#FEFE00",
- "J": "#9EEDFF",
- "JSONiq": "#40d47e",
- "Java": "#b07219",
- "JavaScript": "#f1e05a",
- "Jolie": "#843179",
- "Jsonnet": "#0064bd",
- "Julia": "#a270ba",
- "Jupyter Notebook": "#DA5B0B",
- "KRL": "#28430A",
- "Kotlin": "#F18E33",
- "LFE": "#4C3023",
- "LLVM": "#185619",
- "LOLCODE": "#cc9900",
- "LSL": "#3d9970",
- "Lasso": "#999999",
- "Lex": "#DBCA00",
- "LiveScript": "#499886",
- "LookML": "#652B81",
- "Lua": "#000080",
- "MATLAB": "#e16737",
- "MAXScript": "#00a6a6",
- "MLIR": "#5EC8DB",
- "MQL4": "#62A8D6",
- "MQL5": "#4A76B8",
- "MTML": "#b7e1f4",
- "Makefile": "#427819",
- "Mask": "#f97732",
- "Max": "#c4a79c",
- "Mercury": "#ff2b2b",
- "Meson": "#007800",
- "Metal": "#8f14e9",
- "Mirah": "#c7a938",
- "Modula-3": "#223388",
- "NCL": "#28431f",
- "Nearley": "#990000",
- "Nemerle": "#3d3c6e",
- "NetLinx": "#0aa0ff",
- "NetLinx+ERB": "#747faa",
- "NetLogo": "#ff6375",
- "NewLisp": "#87AED7",
- "Nextflow": "#3ac486",
- "Nim": "#37775b",
- "Nit": "#009917",
- "Nix": "#7e7eff",
- "Nu": "#c9df40",
- "OCaml": "#3be133",
- "ObjectScript": "#424893",
- "Objective-C": "#438eff",
- "Objective-C++": "#6866fb",
- "Objective-J": "#ff0c5a",
- "Odin": "#60AFFE",
- "Omgrofl": "#cabbff",
- "Opal": "#f7ede0",
- "OpenQASM": "#AA70FF",
- "Oxygene": "#cdd0e3",
- "Oz": "#fab738",
- "P4": "#7055b5",
- "PHP": "#4F5D95",
- "PLSQL": "#dad8d8",
- "Pan": "#cc0000",
- "Papyrus": "#6600cc",
- "Parrot": "#f3ca0a",
- "Pascal": "#E3F171",
- "Pawn": "#dbb284",
- "Pep8": "#C76F5B",
- "Perl": "#0298c3",
- "PigLatin": "#fcd7de",
- "Pike": "#005390",
- "PogoScript": "#d80074",
- "PostScript": "#da291c",
- "PowerBuilder": "#8f0f8d",
- "PowerShell": "#012456",
- "Processing": "#0096D8",
- "Prolog": "#74283c",
- "Propeller Spin": "#7fa2a7",
- "Puppet": "#302B6D",
- "PureBasic": "#5a6986",
- "PureScript": "#1D222D",
- "Python": "#3572A5",
- "QML": "#44a51c",
- "Quake": "#882233",
- "R": "#198CE7",
- "RAML": "#77d9fb",
- "RUNOFF": "#665a4e",
- "Racket": "#3c5caa",
- "Ragel": "#9d5200",
- "Raku": "#0000fb",
- "Rascal": "#fffaa0",
- "Reason": "#ff5847",
- "Rebol": "#358a5b",
- "Red": "#f50000",
- "Ren'Py": "#ff7f7f",
- "Ring": "#2D54CB",
- "Riot": "#A71E49",
- "Roff": "#ecdebe",
- "Rouge": "#cc0088",
- "Ruby": "#701516",
- "Rust": "#dea584",
- "SAS": "#B34936",
- "SQF": "#3F3F3F",
- "SRecode Template": "#348a34",
- "SaltStack": "#646464",
- "Scala": "#c22d40",
- "Scheme": "#1e4aec",
- "Self": "#0579aa",
- "Shell": "#89e051",
- "Shen": "#120F14",
- "Slash": "#007eff",
- "Slice": "#003fa2",
- "SmPL": "#c94949",
- "Smalltalk": "#596706",
- "Solidity": "#AA6746",
- "SourcePawn": "#5c7611",
- "Squirrel": "#800000",
- "Stan": "#b2011d",
- "Standard ML": "#dc566d",
- "Starlark": "#76d275",
- "SuperCollider": "#46390b",
- "Swift": "#ffac45",
- "SystemVerilog": "#DAE1C2",
- "TI Program": "#A0AA87",
- "Tcl": "#e4cc98",
- "TeX": "#3D6117",
- "Terra": "#00004c",
- "Turing": "#cf142b",
- "TypeScript": "#2b7489",
- "UnrealScript": "#a54c4d",
- "V": "#5d87bd",
- "VBA": "#867db1",
- "VBScript": "#15dcdc",
- "VCL": "#148AA8",
- "VHDL": "#adb2cb",
- "Vala": "#fbe5cd",
- "Verilog": "#b2b7f8",
- "Vim script": "#199f4b",
- "Visual Basic .NET": "#945db7",
- "Volt": "#1F1F1F",
- "Vue": "#2c3e50",
- "WebAssembly": "#04133b",
- "Wollok": "#a23738",
- "X10": "#4B6BEF",
- "XC": "#99DA07",
- "XQuery": "#5232e7",
- "XSLT": "#EB8CEB",
- "YARA": "#220000",
- "YASnippet": "#32AB90",
- "Yacc": "#4B6C4B",
- "ZAP": "#0d665e",
- "ZIL": "#dc75e5",
- "ZenScript": "#00BCD1",
- "Zephir": "#118f9e",
- "Zig": "#ec915c",
- "eC": "#913960",
- "mIRC Script": "#926059",
- "mcfunction": "#E22837",
- "nesC": "#94B0C7",
- "ooc": "#b0b77e",
- "q": "#0040cd",
- "sed": "#64b970",
- "wdl": "#42f1f4",
- "wisp": "#7582D1",
- "xBase": "#403a40",
-}
+ "1C Enterprise": "#814CCC",
+ ABAP: "#E8274B",
+ "AGS Script": "#B9D9FF",
+ AMPL: "#E6EFBB",
+ ANTLR: "#9DC3FF",
+ "API Blueprint": "#2ACCA8",
+ APL: "#5A8164",
+ ASP: "#6a40fd",
+ ATS: "#1ac620",
+ ActionScript: "#882B0F",
+ Ada: "#02f88c",
+ Agda: "#315665",
+ Alloy: "#64C800",
+ AngelScript: "#C7D7DC",
+ AppleScript: "#101F1F",
+ Arc: "#aa2afe",
+ AspectJ: "#a957b0",
+ Assembly: "#6E4C13",
+ Asymptote: "#4a0c0c",
+ AutoHotkey: "#6594b9",
+ AutoIt: "#1C3552",
+ Ballerina: "#FF5000",
+ Batchfile: "#C1F12E",
+ BlitzMax: "#cd6400",
+ Boo: "#d4bec1",
+ Brainfuck: "#2F2530",
+ C: "#555555",
+ "C#": "#178600",
+ "C++": "#f34b7d",
+ CSS: "#563d7c",
+ Ceylon: "#dfa535",
+ Chapel: "#8dc63f",
+ Cirru: "#ccccff",
+ Clarion: "#db901e",
+ Clean: "#3F85AF",
+ Click: "#E4E6F3",
+ Clojure: "#db5855",
+ CoffeeScript: "#244776",
+ ColdFusion: "#ed2cd6",
+ "Common Lisp": "#3fb68b",
+ "Common Workflow Language": "#B5314C",
+ "Component Pascal": "#B0CE4E",
+ Crystal: "#000100",
+ Cuda: "#3A4E3A",
+ D: "#ba595e",
+ DM: "#447265",
+ Dart: "#00B4AB",
+ DataWeave: "#003a52",
+ Dhall: "#dfafff",
+ Dockerfile: "#384d54",
+ Dogescript: "#cca760",
+ Dylan: "#6c616e",
+ E: "#ccce35",
+ ECL: "#8a1267",
+ EQ: "#a78649",
+ Eiffel: "#946d57",
+ Elixir: "#6e4a7e",
+ Elm: "#60B5CC",
+ "Emacs Lisp": "#c065db",
+ EmberScript: "#FFF4F3",
+ Erlang: "#B83998",
+ "F#": "#b845fc",
+ "F*": "#572e30",
+ FLUX: "#88ccff",
+ Factor: "#636746",
+ Fancy: "#7b9db4",
+ Fantom: "#14253c",
+ Faust: "#c37240",
+ Forth: "#341708",
+ Fortran: "#4d41b1",
+ FreeMarker: "#0050b2",
+ Frege: "#00cafe",
+ "G-code": "#D08CF2",
+ GAML: "#FFC766",
+ GDScript: "#355570",
+ "Game Maker Language": "#71b417",
+ Genie: "#fb855d",
+ Gherkin: "#5B2063",
+ Glyph: "#c1ac7f",
+ Gnuplot: "#f0a9f0",
+ Go: "#00ADD8",
+ Golo: "#88562A",
+ Gosu: "#82937f",
+ "Grammatical Framework": "#79aa7a",
+ Groovy: "#e69f56",
+ HTML: "#e34c26",
+ Hack: "#878787",
+ Harbour: "#0e60e3",
+ Haskell: "#5e5086",
+ Haxe: "#df7900",
+ HiveQL: "#dce200",
+ HolyC: "#ffefaf",
+ Hy: "#7790B2",
+ IDL: "#a3522f",
+ "IGOR Pro": "#0000cc",
+ Idris: "#b30000",
+ Io: "#a9188d",
+ Ioke: "#078193",
+ Isabelle: "#FEFE00",
+ J: "#9EEDFF",
+ JSONiq: "#40d47e",
+ Java: "#b07219",
+ JavaScript: "#f1e05a",
+ Jolie: "#843179",
+ Jsonnet: "#0064bd",
+ Julia: "#a270ba",
+ "Jupyter Notebook": "#DA5B0B",
+ KRL: "#28430A",
+ Kotlin: "#F18E33",
+ LFE: "#4C3023",
+ LLVM: "#185619",
+ LOLCODE: "#cc9900",
+ LSL: "#3d9970",
+ Lasso: "#999999",
+ Lex: "#DBCA00",
+ LiveScript: "#499886",
+ LookML: "#652B81",
+ Lua: "#000080",
+ MATLAB: "#e16737",
+ MAXScript: "#00a6a6",
+ MLIR: "#5EC8DB",
+ MQL4: "#62A8D6",
+ MQL5: "#4A76B8",
+ MTML: "#b7e1f4",
+ Makefile: "#427819",
+ Mask: "#f97732",
+ Max: "#c4a79c",
+ Mercury: "#ff2b2b",
+ Meson: "#007800",
+ Metal: "#8f14e9",
+ Mirah: "#c7a938",
+ "Modula-3": "#223388",
+ NCL: "#28431f",
+ Nearley: "#990000",
+ Nemerle: "#3d3c6e",
+ NetLinx: "#0aa0ff",
+ "NetLinx+ERB": "#747faa",
+ NetLogo: "#ff6375",
+ NewLisp: "#87AED7",
+ Nextflow: "#3ac486",
+ Nim: "#37775b",
+ Nit: "#009917",
+ Nix: "#7e7eff",
+ Nu: "#c9df40",
+ OCaml: "#3be133",
+ ObjectScript: "#424893",
+ "Objective-C": "#438eff",
+ "Objective-C++": "#6866fb",
+ "Objective-J": "#ff0c5a",
+ Odin: "#60AFFE",
+ Omgrofl: "#cabbff",
+ Opal: "#f7ede0",
+ OpenQASM: "#AA70FF",
+ Oxygene: "#cdd0e3",
+ Oz: "#fab738",
+ P4: "#7055b5",
+ PHP: "#4F5D95",
+ PLSQL: "#dad8d8",
+ Pan: "#cc0000",
+ Papyrus: "#6600cc",
+ Parrot: "#f3ca0a",
+ Pascal: "#E3F171",
+ Pawn: "#dbb284",
+ Pep8: "#C76F5B",
+ Perl: "#0298c3",
+ PigLatin: "#fcd7de",
+ Pike: "#005390",
+ PogoScript: "#d80074",
+ PostScript: "#da291c",
+ PowerBuilder: "#8f0f8d",
+ PowerShell: "#012456",
+ Processing: "#0096D8",
+ Prolog: "#74283c",
+ "Propeller Spin": "#7fa2a7",
+ Puppet: "#302B6D",
+ PureBasic: "#5a6986",
+ PureScript: "#1D222D",
+ Python: "#3572A5",
+ QML: "#44a51c",
+ Quake: "#882233",
+ R: "#198CE7",
+ RAML: "#77d9fb",
+ RUNOFF: "#665a4e",
+ Racket: "#3c5caa",
+ Ragel: "#9d5200",
+ Raku: "#0000fb",
+ Rascal: "#fffaa0",
+ Reason: "#ff5847",
+ Rebol: "#358a5b",
+ Red: "#f50000",
+ "Ren'Py": "#ff7f7f",
+ Ring: "#2D54CB",
+ Riot: "#A71E49",
+ Roff: "#ecdebe",
+ Rouge: "#cc0088",
+ Ruby: "#701516",
+ Rust: "#dea584",
+ SAS: "#B34936",
+ SQF: "#3F3F3F",
+ "SRecode Template": "#348a34",
+ SaltStack: "#646464",
+ Scala: "#c22d40",
+ Scheme: "#1e4aec",
+ Self: "#0579aa",
+ Shell: "#89e051",
+ Shen: "#120F14",
+ Slash: "#007eff",
+ Slice: "#003fa2",
+ SmPL: "#c94949",
+ Smalltalk: "#596706",
+ Solidity: "#AA6746",
+ SourcePawn: "#5c7611",
+ Squirrel: "#800000",
+ Stan: "#b2011d",
+ "Standard ML": "#dc566d",
+ Starlark: "#76d275",
+ SuperCollider: "#46390b",
+ Swift: "#ffac45",
+ SystemVerilog: "#DAE1C2",
+ "TI Program": "#A0AA87",
+ Tcl: "#e4cc98",
+ TeX: "#3D6117",
+ Terra: "#00004c",
+ Turing: "#cf142b",
+ TypeScript: "#2b7489",
+ UnrealScript: "#a54c4d",
+ V: "#5d87bd",
+ VBA: "#867db1",
+ VBScript: "#15dcdc",
+ VCL: "#148AA8",
+ VHDL: "#adb2cb",
+ Vala: "#fbe5cd",
+ Verilog: "#b2b7f8",
+ "Vim script": "#199f4b",
+ "Visual Basic .NET": "#945db7",
+ Volt: "#1F1F1F",
+ Vue: "#2c3e50",
+ WebAssembly: "#04133b",
+ Wollok: "#a23738",
+ X10: "#4B6BEF",
+ XC: "#99DA07",
+ XQuery: "#5232e7",
+ XSLT: "#EB8CEB",
+ YARA: "#220000",
+ YASnippet: "#32AB90",
+ Yacc: "#4B6C4B",
+ ZAP: "#0d665e",
+ ZIL: "#dc75e5",
+ ZenScript: "#00BCD1",
+ Zephir: "#118f9e",
+ Zig: "#ec915c",
+ eC: "#913960",
+ "mIRC Script": "#926059",
+ mcfunction: "#E22837",
+ nesC: "#94B0C7",
+ ooc: "#b0b77e",
+ q: "#0040cd",
+ sed: "#64b970",
+ wdl: "#42f1f4",
+ wisp: "#7582D1",
+ xBase: "#403a40",
+};
function getLabel(isZh, key) {
- if (isZh) {
- return zhCN[key]
- } else {
- return esUN[key]
- }
+ if (isZh) {
+ return zhCN[key];
+ } else {
+ return esUN[key];
+ }
}
var zhCN = {
- "search": "搜索",
- "search_repo": "项目",
- "search_dataset": "数据集",
- "search_issue": "任务",
- "search_pr": "合并请求",
- "search_user": "用户",
- "search_org": "组织",
- "search_finded": "找到",
- "search_matched": "最佳匹配",
- "search_matched_download": "下载次数",
- "search_lasted_update": "最后更新于",
- "search_letter_asc": "字母顺序排序",
- "search_letter_desc": "字母逆序排序",
- "search_lasted_create": "最近创建",
- "search_early_create": "最早创建",
- "search_add_by": "加入于",
- "search_lasted": "最近更新",
- "search_open": "开启中",
- "search_closed": "已关闭",
- "search_watched": "关注数",
- "search_star": "点赞数",
- "search_fork": "Fork数",
- "search_input_large_0": "请输入大于0的数值。",
- "search_input_maxed": "不能超出总页数。",
- "search_input_total": "共",
- "search_srtip": "条",
- "search_home_page": "首页",
- "search_last_page": "末页",
- "search_go_to": "前往",
- "search_go_page": "页",
- "find_title": "“{keyword}”相关{tablename}约为{total}个",
- "search_empty": "请输入任意关键字开始搜索。"
-}
+ search: "搜索",
+ search_repo: "项目",
+ search_dataset: "数据集",
+ search_issue: "任务",
+ search_pr: "合并请求",
+ search_user: "用户",
+ search_org: "组织",
+ search_finded: "找到",
+ search_matched: "最佳匹配",
+ search_matched_download: "下载次数",
+ search_lasted_update: "最后更新于",
+ search_letter_asc: "字母顺序排序",
+ search_letter_desc: "字母逆序排序",
+ search_lasted_create: "最近创建",
+ search_early_create: "最早创建",
+ search_add_by: "加入于",
+ search_lasted: "最近更新",
+ search_open: "开启中",
+ search_closed: "已关闭",
+ search_watched: "关注数",
+ search_star: "点赞数",
+ search_fork: "Fork数",
+ search_input_large_0: "请输入大于0的数值。",
+ search_input_maxed: "不能超出总页数。",
+ search_input_total: "共",
+ search_srtip: "条",
+ search_home_page: "首页",
+ search_last_page: "末页",
+ search_go_to: "前往",
+ search_go_page: "页",
+ find_title:
+ '“{keyword}”相关{tablename}约为{total}个',
+ search_empty: "请输入任意关键字开始搜索。",
+};
var esUN = {
- "search": "Search",
- "search_repo": "Repository",
- "search_dataset": "DataSet",
- "search_issue": "Issue",
- "search_pr": "Pull Request",
- "search_user": "User",
- "search_org": "Organization",
- "search_finded": "Find",
- "search_matched": "Best Match",
- "search_matched_download": "Most downloads",
- "search_lasted_update": "Updated ",
- "search_letter_asc": "Alphabetically",
- "search_letter_desc": "Reverse alphabetically",
- "search_lasted_create": "Recently created",
- "search_early_create": "First created",
- "search_add_by": "Joined on",
- "search_lasted": "Recently updated",
- "search_open": "Open",
- "search_closed": "Closed",
- "search_watched": "Watches",
- "search_star": "Stars",
- "search_fork": "Forks",
- "search_input_large_0": "Please enter a value greater than 0.",
- "search_input_maxed": "Cannot exceed total pages.",
- "search_input_total": "Total",
- "search_srtip": "",
- "search_home_page": "First",
- "search_last_page": "Last",
- "search_go_to": "Go",
- "search_go_page": "Page",
- "find_title": " {total} \"{keyword}\" related {tablename}",
- "search_empty": "Please enter any keyword to start the search."
-}
+ search: "Search",
+ search_repo: "Repository",
+ search_dataset: "DataSet",
+ search_issue: "Issue",
+ search_pr: "Pull Request",
+ search_user: "User",
+ search_org: "Organization",
+ search_finded: "Find",
+ search_matched: "Best Match",
+ search_matched_download: "Most downloads",
+ search_lasted_update: "Updated ",
+ search_letter_asc: "Alphabetically",
+ search_letter_desc: "Reverse alphabetically",
+ search_lasted_create: "Recently created",
+ search_early_create: "First created",
+ search_add_by: "Joined on",
+ search_lasted: "Recently updated",
+ search_open: "Open",
+ search_closed: "Closed",
+ search_watched: "Watches",
+ search_star: "Stars",
+ search_fork: "Forks",
+ search_input_large_0: "Please enter a value greater than 0.",
+ search_input_maxed: "Cannot exceed total pages.",
+ search_input_total: "Total",
+ search_srtip: "",
+ search_home_page: "First",
+ search_last_page: "Last",
+ search_go_to: "Go",
+ search_go_page: "Page",
+ find_title:
+ ' {total} "{keyword}" related {tablename}',
+ search_empty:
+ "Please enter any keyword to start the search.",
+};
initDiv(false);
document.onreadystatechange = function () {
- if (document.readyState === "complete") {
- var tmpSearchLabel = sessionStorage.getItem("searchLabel");
- if (tmpSearchLabel) {
- sessionStorage.removeItem("searchLabel");
- doSearchLabel(sessionStorage.getItem("tableName"), sessionStorage.getItem("keyword"), sessionStorage.getItem("sortBy"), sessionStorage.getItem("ascending"));
- } else {
- var specifySearch = sessionStorage.getItem("specifySearch");
- if (specifySearch) {
- sessionStorage.removeItem("specifySearch");
- document.getElementById("keyword_input").value = sessionStorage.getItem("keyword");
- doSpcifySearch(sessionStorage.getItem("tableName"), sessionStorage.getItem("keyword"), sessionStorage.getItem("sortBy"), sessionStorage.getItem("ascending"));
- } else {
- search();
- }
-
- }
+ if (document.readyState === "complete") {
+ var tmpSearchLabel = sessionStorage.getItem("searchLabel");
+ if (tmpSearchLabel) {
+ sessionStorage.removeItem("searchLabel");
+ doSearchLabel(
+ sessionStorage.getItem("tableName"),
+ sessionStorage.getItem("keyword"),
+ sessionStorage.getItem("sortBy"),
+ sessionStorage.getItem("ascending")
+ );
+ } else {
+ var specifySearch = sessionStorage.getItem("specifySearch");
+ if (specifySearch) {
+ sessionStorage.removeItem("specifySearch");
+ document.getElementById("keyword_input").value =
+ sessionStorage.getItem("keyword");
+ doSpcifySearch(
+ sessionStorage.getItem("tableName"),
+ sessionStorage.getItem("keyword"),
+ sessionStorage.getItem("sortBy"),
+ sessionStorage.getItem("ascending")
+ );
+ } else {
+ search();
+ }
}
-}
-
-
+ }
+};
diff --git a/routers/admin/cloudbrains.go b/routers/admin/cloudbrains.go
index 0481e6743..8cfe10795 100755
--- a/routers/admin/cloudbrains.go
+++ b/routers/admin/cloudbrains.go
@@ -43,12 +43,6 @@ func CloudBrains(ctx *context.Context) {
if page <= 0 {
page = 1
}
- debugType := models.TypeCloudBrainAll
- if listType == models.GPUResource {
- debugType = models.TypeCloudBrainOne
- } else if listType == models.NPUResource {
- debugType = models.TypeCloudBrainTwo
- }
var jobTypes []string
jobTypeNot := false
@@ -77,13 +71,14 @@ func CloudBrains(ctx *context.Context) {
PageSize: setting.UI.IssuePagingNum,
},
Keyword: keyword,
- Type: debugType,
JobTypeNot: jobTypeNot,
JobStatusNot: jobStatusNot,
JobStatus: jobStatuses,
JobTypes: jobTypes,
NeedRepoInfo: true,
IsLatestVersion: modelarts.IsLatestVersion,
+ ComputeResource: listType,
+ Type: models.TypeCloudBrainAll,
})
if err != nil {
ctx.ServerError("Get job failed:", err)
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index a37d23158..e6c572e73 100755
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -1055,6 +1055,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("/prd/event", authentication.ValidEventSource)
m.Post("/prd/event", authentication.AcceptWechatEvent)
})
+ m.Get("/wechat/material", authentication.GetMaterial)
}, securityHeaders(), context.APIContexter(), sudo())
}
diff --git a/routers/authentication/wechat.go b/routers/authentication/wechat.go
index 72871afb3..f4a31ea0c 100644
--- a/routers/authentication/wechat.go
+++ b/routers/authentication/wechat.go
@@ -8,9 +8,11 @@ import (
"code.gitea.io/gitea/modules/redis/redis_client"
"code.gitea.io/gitea/modules/redis/redis_key"
"code.gitea.io/gitea/modules/setting"
+ "code.gitea.io/gitea/routers/response"
"encoding/json"
"errors"
gouuid "github.com/satori/go.uuid"
+ "strconv"
"time"
)
@@ -124,3 +126,23 @@ func createQRCode4Bind(userId int64) (*QRCodeResponse, error) {
}
return result, nil
}
+
+// GetMaterial
+func GetMaterial(ctx *context.Context) {
+ mType := ctx.Query("type")
+ offsetStr := ctx.Query("offset")
+ countStr := ctx.Query("count")
+ var offset, count int
+ if offsetStr == "" {
+ offset = 0
+ } else {
+ offset, _ = strconv.Atoi(offsetStr)
+ }
+ if countStr == "" {
+ count = 20
+ } else {
+ count, _ = strconv.Atoi(countStr)
+ }
+ r := wechat.GetWechatMaterial(mType, offset, count)
+ ctx.JSON(200, response.SuccessWithData(r))
+}
diff --git a/routers/authentication/wechat_event.go b/routers/authentication/wechat_event.go
index 9b1cebec6..887bfba0d 100644
--- a/routers/authentication/wechat_event.go
+++ b/routers/authentication/wechat_event.go
@@ -14,24 +14,48 @@ import (
// https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Passive_user_reply_message.html
func AcceptWechatEvent(ctx *context.Context) {
b, _ := ioutil.ReadAll(ctx.Req.Request.Body)
- we := wechat.WechatEvent{}
+ we := wechat.WechatMsg{}
xml.Unmarshal(b, &we)
-
+ switch we.MsgType {
+ case wechat.WECHAT_MSG_TYPE_EVENT:
+ HandleEventMsg(ctx, we)
+ case wechat.WECHAT_MSG_TYPE_TEXT:
+ HandleTextMsg(ctx, we)
+ }
log.Info("accept wechat event= %+v", we)
- var replyStr string
- switch we.Event {
- case wechat.WECHAT_EVENT_SUBSCRIBE, wechat.WECHAT_EVENT_SCAN:
- replyStr = wechat.HandleSubscribeEvent(we)
- break
+
+}
+
+// ValidEventSource
+func ValidEventSource(ctx *context.Context) {
+ echostr := ctx.Query("echostr")
+ ctx.Write([]byte(echostr))
+ return
+}
+
+func HandleEventMsg(ctx *context.Context, msg wechat.WechatMsg) {
+ switch msg.Event {
+ case wechat.WECHAT_EVENT_SCAN:
+ HandleEventScan(ctx, msg)
+ case wechat.WECHAT_EVENT_SUBSCRIBE:
+ if msg.EventKey != "" {
+ HandleEventScan(ctx, msg)
+ } else {
+ HandleEventSubscribe(ctx, msg)
+ }
+
}
+}
+func HandleEventScan(ctx *context.Context, msg wechat.WechatMsg) {
+ replyStr := wechat.HandleScanEvent(msg)
if replyStr == "" {
log.Info("reply str is empty")
return
}
- reply := &wechat.EventReply{
- ToUserName: we.FromUserName,
- FromUserName: we.ToUserName,
+ reply := &wechat.MsgReply{
+ ToUserName: msg.FromUserName,
+ FromUserName: msg.ToUserName,
CreateTime: time.Now().Unix(),
MsgType: wechat.WECHAT_MSG_TYPE_TEXT,
Content: replyStr,
@@ -39,9 +63,99 @@ func AcceptWechatEvent(ctx *context.Context) {
ctx.XML(200, reply)
}
-// ValidEventSource
-func ValidEventSource(ctx *context.Context) {
- echostr := ctx.Query("echostr")
- ctx.Write([]byte(echostr))
- return
+func HandleEventSubscribe(ctx *context.Context, msg wechat.WechatMsg) {
+ r := wechat.HandleSubscribeEvent(msg)
+ if r == nil {
+ return
+ }
+ reply := buildReplyContent(msg, r)
+ ctx.XML(200, reply)
+}
+
+func HandleTextMsg(ctx *context.Context, msg wechat.WechatMsg) {
+ r := wechat.GetAutomaticReply(msg.Content)
+ if r == nil {
+ log.Info("TextMsg reply is empty")
+ return
+ }
+ reply := buildReplyContent(msg, r)
+ ctx.XML(200, reply)
+}
+
+func buildReplyContent(msg wechat.WechatMsg, r *wechat.WechatReplyContent) interface{} {
+ reply := &wechat.MsgReply{
+ ToUserName: msg.FromUserName,
+ FromUserName: msg.ToUserName,
+ CreateTime: time.Now().Unix(),
+ MsgType: r.ReplyType,
+ }
+ switch r.ReplyType {
+ case wechat.ReplyTypeText:
+ return &wechat.TextMsgReply{
+ ToUserName: msg.FromUserName,
+ FromUserName: msg.ToUserName,
+ CreateTime: time.Now().Unix(),
+ MsgType: r.ReplyType,
+ Content: r.Reply.Content,
+ }
+
+ case wechat.ReplyTypeImage:
+ return &wechat.ImageMsgReply{
+ ToUserName: msg.FromUserName,
+ FromUserName: msg.ToUserName,
+ CreateTime: time.Now().Unix(),
+ MsgType: r.ReplyType,
+ Image: wechat.ImageContent{
+ MediaId: r.Reply.MediaId,
+ },
+ }
+ case wechat.ReplyTypeVoice:
+ return &wechat.VoiceMsgReply{
+ ToUserName: msg.FromUserName,
+ FromUserName: msg.ToUserName,
+ CreateTime: time.Now().Unix(),
+ MsgType: r.ReplyType,
+ Voice: wechat.VoiceContent{
+ MediaId: r.Reply.MediaId,
+ },
+ }
+ case wechat.ReplyTypeVideo:
+ return &wechat.VideoMsgReply{
+ ToUserName: msg.FromUserName,
+ FromUserName: msg.ToUserName,
+ CreateTime: time.Now().Unix(),
+ MsgType: r.ReplyType,
+ Video: wechat.VideoContent{
+ MediaId: r.Reply.MediaId,
+ Title: r.Reply.Title,
+ Description: r.Reply.Description,
+ },
+ }
+ case wechat.ReplyTypeMusic:
+ return &wechat.MusicMsgReply{
+ ToUserName: msg.FromUserName,
+ FromUserName: msg.ToUserName,
+ CreateTime: time.Now().Unix(),
+ MsgType: r.ReplyType,
+ Music: wechat.MusicContent{
+ Title: r.Reply.Title,
+ Description: r.Reply.Description,
+ MusicUrl: r.Reply.MusicUrl,
+ HQMusicUrl: r.Reply.HQMusicUrl,
+ ThumbMediaId: r.Reply.ThumbMediaId,
+ },
+ }
+ case wechat.ReplyTypeNews:
+ return &wechat.NewsMsgReply{
+ ToUserName: msg.FromUserName,
+ FromUserName: msg.ToUserName,
+ CreateTime: time.Now().Unix(),
+ MsgType: r.ReplyType,
+ ArticleCount: len(r.Reply.Articles),
+ Articles: wechat.ArticleItem{
+ Item: r.Reply.Articles},
+ }
+
+ }
+ return reply
}
diff --git a/routers/home.go b/routers/home.go
index 1ed5faaa8..8829e26f4 100755
--- a/routers/home.go
+++ b/routers/home.go
@@ -345,7 +345,9 @@ func ExploreDatasets(ctx *context.Context) {
var datasetsIds []int64
if ownerID > 0 {
- datasetsIds = models.GetCollaboratorDatasetIdsByUserID(ownerID)
+ collaboratorDatasetsIds := models.GetCollaboratorDatasetIdsByUserID(ownerID)
+ teamDatasetsIds := models.GetTeamDatasetIdsByUserID(ownerID)
+ datasetsIds = append(collaboratorDatasetsIds, teamDatasetsIds...)
}
opts := &models.SearchDatasetOptions{
diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go
index 133262bf3..19cd6e6dc 100755
--- a/routers/repo/dataset.go
+++ b/routers/repo/dataset.go
@@ -172,8 +172,8 @@ func DatasetIndex(ctx *context.Context) {
for _, attachment := range pageAttachments {
uploader, _ := models.GetUserByID(attachment.UploaderID)
attachment.Uploader = uploader
- if !strings.HasSuffix(attachment.Name, ".zip") {
- attachment.DecompressState = -1 //非zip文件
+ if !strings.HasSuffix(attachment.Name, ".zip") && !strings.HasSuffix(attachment.Name, ".tar.gz") {
+ attachment.DecompressState = -1 //非压缩文件
}
}
@@ -616,8 +616,14 @@ func DatasetIsCollaborator(ctx *context.Context, dataset *models.Dataset) bool {
repo.GetOwner()
if ctx.User != nil {
if repo.Owner.IsOrganization() {
- if repo.Owner.IsUserPartOfOrg(ctx.User.ID) {
- for _, t := range repo.Owner.Teams {
+ org := repo.Owner
+ org.Teams, err = org.GetUserTeams(ctx.User.ID)
+ if err != nil {
+ log.Error("GetUserTeams error:", err.Error())
+ return false
+ }
+ if org.IsUserPartOfOrg(ctx.User.ID) {
+ for _, t := range org.Teams {
if t.IsMember(ctx.User.ID) && t.HasRepository(repo.ID) {
return true
}
diff --git a/routers/repo/grampus.go b/routers/repo/grampus.go
index 48957387f..52f803d1d 100755
--- a/routers/repo/grampus.go
+++ b/routers/repo/grampus.go
@@ -71,6 +71,25 @@ func grampusTrainJobNewDataPrepare(ctx *context.Context, processType string) err
ctx.Data["images"] = images.Infos
}
+ grampus.InitSpecialPool()
+
+ ctx.Data["GPUEnabled"] = true
+ ctx.Data["NPUEnabled"] = true
+
+ if grampus.SpecialPools != nil {
+ for _, pool := range grampus.SpecialPools.Pools {
+ if pool.IsExclusive {
+ org, _ := models.GetOrgByName(pool.Org)
+ if org != nil {
+ isOrgMember, _ := models.IsOrganizationMember(org.ID, ctx.User.ID)
+ if !isOrgMember {
+ ctx.Data[pool.Type+"Enabled"] = false
+ }
+ }
+ }
+ }
+ }
+
//get valid resource specs
specs, err := grampus.GetResourceSpecs(processType)
if err != nil {
@@ -128,10 +147,18 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain
image := strings.TrimSpace(form.Image)
if !jobNamePattern.MatchString(displayJobName) {
+ grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU)
ctx.RenderWithErr(ctx.Tr("repo.cloudbrain_jobname_err"), tplGrampusTrainJobGPUNew, &form)
return
}
+ errStr := checkSpecialPool(ctx, "GPU")
+ if errStr != "" {
+ grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU)
+ ctx.RenderWithErr(errStr, tplGrampusTrainJobGPUNew, &form)
+ return
+ }
+
//check count limit
count, err := models.GetGrampusCountByUserID(ctx.User.ID, string(models.JobTypeTrain), models.GPUResource)
if err != nil {
@@ -263,6 +290,28 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/modelarts/train-job")
}
+func checkSpecialPool(ctx *context.Context, resourceType string) string {
+ grampus.InitSpecialPool()
+ if grampus.SpecialPools != nil {
+ for _, pool := range grampus.SpecialPools.Pools {
+
+ if pool.IsExclusive && pool.Type == resourceType {
+
+ org, _ := models.GetOrgByName(pool.Org)
+ if org != nil {
+ isOrgMember, _ := models.IsOrganizationMember(org.ID, ctx.User.ID)
+ if !isOrgMember {
+ return ctx.Tr("repo.grampus.no_operate_right")
+ }
+ }
+ }
+
+ }
+
+ }
+ return ""
+}
+
func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrainJobForm) {
displayJobName := form.DisplayJobName
jobName := util.ConvertDisplayJobNameToJobName(displayJobName)
@@ -281,10 +330,18 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain
engineName := form.EngineName
if !jobNamePattern.MatchString(displayJobName) {
+ grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU)
ctx.RenderWithErr(ctx.Tr("repo.cloudbrain_jobname_err"), tplGrampusTrainJobNPUNew, &form)
return
}
+ errStr := checkSpecialPool(ctx, "NPU")
+ if errStr != "" {
+ grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU)
+ ctx.RenderWithErr(errStr, tplGrampusTrainJobGPUNew, &form)
+ return
+ }
+
//check count limit
count, err := models.GetGrampusCountByUserID(ctx.User.ID, string(models.JobTypeTrain), models.NPUResource)
if err != nil {
@@ -607,7 +664,12 @@ func GrampusGetLog(ctx *context.Context) {
func generateCommand(repoName, processorType, codeRemotePath, dataRemotePath, bootFile, paramSrc, outputRemotePath, datasetName string) (string, error) {
var command string
- command += grampus.CommandPrepareScript
+ workDir := grampus.NpuWorkDir
+ if processorType == grampus.ProcessorTypeGPU {
+ workDir = grampus.GpuWorkDir
+ }
+
+ command += "pwd;cd " + workDir + grampus.CommandPrepareScript
//download code & dataset
if processorType == grampus.ProcessorTypeNPU {
commandDownload := "./downloader_for_obs " + setting.Bucket + " " + codeRemotePath + " " + grampus.CodeArchiveName + " " + dataRemotePath + " " + datasetName + ";"
@@ -626,7 +688,7 @@ func generateCommand(repoName, processorType, codeRemotePath, dataRemotePath, bo
if strings.HasSuffix(datasetName, ".tar.gz") {
toolUnzip = "tar -zxvf "
}
- commandUnzip := "cd /cache/code;unzip -q master.zip;echo \"start to unzip dataset\";cd /cache/dataset;" + toolUnzip + datasetName + ";"
+ commandUnzip := "cd " + workDir + "code;unzip -q master.zip;echo \"start to unzip dataset\";cd " + workDir + "dataset;" + toolUnzip + datasetName + ";"
command += commandUnzip
//check unzip result
@@ -655,7 +717,7 @@ func generateCommand(repoName, processorType, codeRemotePath, dataRemotePath, bo
}
}
- commandCode := "cd /cache/code/" + strings.ToLower(repoName) + ";python " + bootFile + paramCode + ";"
+ commandCode := "cd " + workDir + "code/" + strings.ToLower(repoName) + ";python " + bootFile + paramCode + ";"
command += commandCode
//get exec result
@@ -664,10 +726,10 @@ func generateCommand(repoName, processorType, codeRemotePath, dataRemotePath, bo
//upload models
if processorType == grampus.ProcessorTypeNPU {
- commandUpload := "cd /cache/script_for_grampus/;./uploader_for_obs " + setting.Bucket + " " + outputRemotePath + " " + "/cache/output/;"
+ commandUpload := "cd " + workDir + "script_for_grampus/;./uploader_for_obs " + setting.Bucket + " " + outputRemotePath + " " + workDir + "output/;"
command += commandUpload
} else if processorType == grampus.ProcessorTypeGPU {
- commandUpload := "cd /cache/script_for_grampus/;./uploader_for_minio " + setting.Grampus.Env + " " + outputRemotePath + " " + "/cache/output/;"
+ commandUpload := "cd " + workDir + "script_for_grampus/;./uploader_for_minio " + setting.Grampus.Env + " " + outputRemotePath + " " + workDir + "output/;"
command += commandUpload
}
diff --git a/services/socketwrap/clientManager.go b/services/socketwrap/clientManager.go
index 6ffa96933..98bcc8a85 100755
--- a/services/socketwrap/clientManager.go
+++ b/services/socketwrap/clientManager.go
@@ -10,7 +10,7 @@ import (
"github.com/elliotchance/orderedmap"
)
-var opTypes = []int{1, 2, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}
+var opTypes = []int{1, 2, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33}
type ClientsManager struct {
Clients *orderedmap.OrderedMap
diff --git a/templates/admin/cloudbrain/list.tmpl b/templates/admin/cloudbrain/list.tmpl
index 4c63b167a..347b5658d 100755
--- a/templates/admin/cloudbrain/list.tmpl
+++ b/templates/admin/cloudbrain/list.tmpl
@@ -102,7 +102,7 @@
{{else if eq .JobType "TRAIN"}}
{{.DisplayJobName}}
@@ -204,7 +204,7 @@
{{else}}
{{$.i18n.Tr "repo.stop"}}
@@ -212,7 +212,7 @@