diff --git a/.gitignore b/.gitignore index 572212e0e..9f34fea2a 100644 --- a/.gitignore +++ b/.gitignore @@ -95,3 +95,6 @@ prime/ # Make evidence files /.make_evidence + +/templates/home_bak.tmpl +/==bak \ No newline at end of file diff --git a/custom/public/css/git.openi.css b/custom/public/css/git.openi.css new file mode 100644 index 000000000..052e4c94d --- /dev/null +++ b/custom/public/css/git.openi.css @@ -0,0 +1,178 @@ +.bg-gray{ background-color:#F8F8F8!important;} +.am-mb-0{ margin-bottom: 0 !important;} +.am-mb-05{ margin-bottom: 0.5rem !important;} +.am-mb-10{ margin-bottom: 1.0rem !important;} +.am-mb-15{ margin-bottom: 1.5rem !important;} +.am-mb-20{ margin-bottom: 2.0rem !important;} +.am-mb-30{ margin-bottom: 3.0rem !important;} +.am-mt-0{ margin-top: 0 !important;} +.am-mt-05{ margin-top: 0.5rem !important;} +.am-mt-10{ margin-top: 1.0rem !important;} +.am-mt-15{ margin-top: 1.5rem !important;} +.am-mt-20{ margin-top: 2.0rem !important;} +.am-mt-30{ margin-top: 3.0rem !important;} +.am-pb-0{ padding-bottom: 0 !important;} +.am-pb-05{ padding-bottom: 0.5rem !important;} +.am-pb-10{ padding-bottom: 1.0rem !important;} +.am-pb-15{ padding-bottom: 1.5rem !important;} +.am-pb-20{ padding-bottom: 2.0rem !important;} +.am-pb-30{ padding-bottom: 3.0rem !important;} +.am-pt-0{ padding-top: 0 !important;} +.am-pt-05{ padding-top: 0.5rem !important;} +.am-pt-10{ padding-top: 1.0rem !important;} +.am-pt-15{ padding-top: 1.5rem !important;} +.am-pt-20{ padding-top: 2.0rem !important;} +.am-pt-30{ padding-top: 3.0rem !important;} +.am-pl-30{ padding-left: 3.0rem !important;} +.am-ml-30{ margin-left: 3.0rem !important;} +.am-pr-30{ padding-right: 3.0rem !important;} +.am-mr-30{ margin-right: 3.0rem !important;} +.am-lh-18{ line-height: 1.8em;} + +.opacity5{ opacity:0.5;} +.radius15{ border-radius:1.5rem !important; } +.radius10{ border-radius:1.0rem !important; } +.radius5{ border-radius:0.5rem !important; } +.am-shadow-1{ + -webkit-box-shadow: 0 1px 2px 0 rgba(34,36,38,.15); + box-shadow: 0 1px 2px 0 rgba(34,36,38,.15); +} +.am-shadow-2{ + -webkit-box-shadow: 0 2px 4px 0 rgba(34,36,38,.3); + box-shadow: 0 2px 4px 0 rgba(34,36,38,.3); +} + + +.ui.secondary.hometop.segment{ + background: #DFE9F0; + padding-top: 0; + border: none; + margin-bottom: 90px; +} +.ui.secondary.hometop.segment #navbar{ + z-index: 10; +} + +.hometop .ui.secondary.menu .active.item{ + color: #000; + background:none; + border-bottom: 1px solid #000; +} + +.homebanner{ + position: relative; + padding: 100px 32px 80px; + z-index: 9; +} +.homebanner .ui.header .sub.header{ + color: #3291F8; +} +.bannerpic{ + position: absolute; + right: 50px; + bottom: -64px; + width: 560px; +} +.ui[class*="very padded"].segment.i-code{ + padding-left: 6.0rem; +} +.i-code > .ui.blue.header{ + color: #1678c2!important; +} +.i-code h2{ + position: relative; +} +.i-code h2::before { + content: ""; + position: absolute; + left: calc(-4.0rem + 6px); + top: 0.8rem; + width: 18px; + height: 18px; + border: 2px solid #505559; + border-radius: 50%; + background: #1b1c1d; + z-index: 9; +} +.i-code h2.am-bw::before{ + background: #FFF; +} +.i-code-pic{ + position: relative; +} +.i-code-pic > img{ + margin-bottom: -3.0rem; +} +.i-env .ui.cards>.card>.image{ + background: none; +} +.i-env .ui.cards>.card>.content{ + border-top: none; +} +.leftline01{ + position: absolute; + left: 3.0rem; + top: 0; + bottom: 0; + border-left: 2px solid #505559; + border-bottom: 2px solid #505559; + border-radius: 0 0 0 2.0rem; + width: 17.5rem; +} +.leftline02{ + position: absolute; + left: 20.5rem; + top: calc(-5.0rem - 2px); + border-top: 2px solid #505559; + border-right: 2px solid #505559; + border-radius: 0 2.0rem 0 0; + width: 2.0rem; + height: 6.0rem; +} + +@media only screen and (max-width: 767px) { + .am-mt-30{ margin-top: 1.5rem !important;} + .ui.secondary.hometop.segment{ + margin-bottom: 2.0rem; + } + .bannerpic, .i-code-pic{ + display: none; + } + .i-code h2::before { + left: calc(-5.0rem + 6px); + } + .i-code h2.am-bw::before{ + left: calc(-4.0rem + 6px); + } + .leftline01{ + width: calc(50% - 4.0rem); + } + .leftline02{ + left: calc(50% - 1.0rem); + top: calc(-3.5rem - 2px); + } +} + +@media only screen and (min-width: 768px) and (max-width: 991px) { + .bannerpic, .i-code-pic{ + display: none; + } + .i-code h2::before { + left: calc(-5.0rem + 6px); + } + .i-code h2.am-bw::before{ + left: calc(-4.0rem + 6px); + } +} + +@media only screen and (min-width: 992px) and (max-width: 1199px) { + +} + +@media only screen and (min-width: 1200px) and (max-width: 1919px) { + +} + +@media only screen and (min-width: 1920px) { + +} \ No newline at end of file diff --git a/custom/public/img/develop.svg b/custom/public/img/develop.svg new file mode 100644 index 000000000..954f054af --- /dev/null +++ b/custom/public/img/develop.svg @@ -0,0 +1,282 @@ + + \ No newline at end of file diff --git a/custom/public/img/gitopeni-index-01.svg b/custom/public/img/gitopeni-index-01.svg new file mode 100644 index 000000000..18401747f --- /dev/null +++ b/custom/public/img/gitopeni-index-01.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/custom/public/img/gitopeni-index-02.svg b/custom/public/img/gitopeni-index-02.svg new file mode 100644 index 000000000..4b47fe632 --- /dev/null +++ b/custom/public/img/gitopeni-index-02.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/custom/public/img/i-code-pic.jpg b/custom/public/img/i-code-pic.jpg new file mode 100644 index 000000000..cba627b73 Binary files /dev/null and b/custom/public/img/i-code-pic.jpg differ diff --git a/custom/public/img/i-data-pic.jpg b/custom/public/img/i-data-pic.jpg new file mode 100644 index 000000000..2e5dbfb1f Binary files /dev/null and b/custom/public/img/i-data-pic.jpg differ diff --git a/custom/public/img/i-pic-01.svg b/custom/public/img/i-pic-01.svg new file mode 100644 index 000000000..97d8e4165 --- /dev/null +++ b/custom/public/img/i-pic-01.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/custom/public/img/i-pic-02.svg b/custom/public/img/i-pic-02.svg new file mode 100644 index 000000000..ef8606b5e --- /dev/null +++ b/custom/public/img/i-pic-02.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/custom/public/img/i-pic-03.svg b/custom/public/img/i-pic-03.svg new file mode 100644 index 000000000..779a28d5f --- /dev/null +++ b/custom/public/img/i-pic-03.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/custom/public/img/i-pic-04.svg b/custom/public/img/i-pic-04.svg new file mode 100644 index 000000000..96bb3e455 --- /dev/null +++ b/custom/public/img/i-pic-04.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/custom/public/img/i-yunnao.svg b/custom/public/img/i-yunnao.svg new file mode 100644 index 000000000..aeb1e9435 --- /dev/null +++ b/custom/public/img/i-yunnao.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/modules/git/repo.go b/modules/git/repo.go index 644ff0928..a2a4d28af 100644 --- a/modules/git/repo.go +++ b/modules/git/repo.go @@ -434,3 +434,38 @@ func GetDivergingCommits(repoPath string, baseBranch string, targetBranch string return DivergeObject{ahead, behind}, nil } + +type Contributor struct { + CommitCnt int + Committer string + Email string +} + +func GetContributors(repoPath string) ([]Contributor, error){ + cmd := NewCommand("shortlog", "-sne", "--all") + stdout, err := cmd.RunInDir(repoPath) + if err != nil { + return nil, err + } + stdout = strings.Trim(stdout, "\n") + contributorRows := strings.Split(stdout, "\n") + if len(contributorRows) > 0 { + contributorsInfo := make([]Contributor, len(contributorRows)) + for i := 0; i < len(contributorRows); i++ { + var oneCount string = strings.Trim(contributorRows[i], " ") + if strings.Index(oneCount, "\t") < 0 { + continue + } + number := oneCount[0:strings.Index(oneCount, "\t")] + commitCnt, _ := strconv.Atoi(number) + committer := oneCount[strings.Index(oneCount, "\t")+1:strings.LastIndex(oneCount, " ")] + committer = strings.Trim(committer, " ") + email := oneCount[strings.Index(oneCount, "<")+1:strings.Index(oneCount, ">")] + contributorsInfo[i] = Contributor{ + commitCnt, committer, email, + } + } + return contributorsInfo, nil + } + return nil, nil +} diff --git a/routers/repo/view.go b/routers/repo/view.go index 9c9cdc06b..76593ecc7 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -7,6 +7,7 @@ package repo import ( "bytes" + "code.gitea.io/gitea/modules/options" "encoding/base64" "fmt" gotemplate "html/template" @@ -567,9 +568,32 @@ func safeURL(address string) string { return u.String() } +type ContributorInfo struct { + UserInfo *models.User + Email string // for contributor who is not a registered user +} + // Home render repository home page func Home(ctx *context.Context) { if len(ctx.Repo.Units) > 0 { + //get repo contributors info + contributors, err := git.GetContributors(ctx.Repo.Repository.RepoPath()) + if err == nil && contributors != nil { + var contributorInfos []*ContributorInfo + for _, c := range contributors { + user, err := models.GetUserByEmail(c.Email) + if err == nil { + contributorInfos = append(contributorInfos, &ContributorInfo{ + user, c.Email, + }) + } else { + contributorInfos = append(contributorInfos, &ContributorInfo{ + nil, c.Email, + }) + } + } + ctx.Data["ContributorInfo"] = contributorInfos + } if ctx.Repo.Repository.IsBeingCreated() { task, err := models.GetMigratingTask(ctx.Repo.Repository.ID) if err != nil { @@ -611,6 +635,39 @@ func Home(ctx *context.Context) { ctx.NotFound("Home", fmt.Errorf(ctx.Tr("units.error.no_unit_allowed_repo"))) } +func renderLicense(ctx *context.Context) { + entry, err := ctx.Repo.Commit.GetTreeEntryByPath("LICENSE") + if err != nil { + log.Error(err.Error()) + return + } + blob := entry.Blob() + dataRc, err := blob.DataAsync() + if err != nil { + log.Error("DataAsync", err) + return + } + defer dataRc.Close() + buf, err := ioutil.ReadAll(dataRc) + if err != nil { + log.Error("DataAsync", err) + return + } + for _, f := range models.Licenses { + license, err := options.License(f) + if err != nil { + log.Error("failed to get license content: %v, err:%v", f, err) + continue + } + if bytes.Compare(buf,license) == 0 { + log.Info("got matched license:%v",f) + ctx.Data["LICENSE"] = f + return + } + } + log.Info("not found matched license,repo:%v",ctx.Repo.Repository.Name) +} + func renderLanguageStats(ctx *context.Context) { langs, err := ctx.Repo.Repository.GetTopLanguageStats(5) if err != nil { @@ -657,6 +714,8 @@ func renderCode(ctx *context.Context) { // Get Topics of this repo renderRepoTopics(ctx) + // Get license of this repo + renderLicense(ctx) if ctx.Written() { return } diff --git a/templates/base/head_home.tmpl b/templates/base/head_home.tmpl new file mode 100644 index 000000000..0311caa31 --- /dev/null +++ b/templates/base/head_home.tmpl @@ -0,0 +1,210 @@ + + +
+ + + +Open Intelligence,Open Source,Open Community,Open Ecosystem
- -
在这里为你和你的团队创建项目,基于Git工具,提交记录或者回滚代码修改。
+ 不论是公开或者私有仓库,都可免费使用所有功能。
+ 尽情将你喜欢的代码都放在这里,仓库数量、存储容量不受限
鼓励通过创建合并请求(PR)的方式,更好的进行团队协作
+ 代码评审让每一次的代码修改得以二次确认,提高代码质量
+ 创建并指派任务(Issue),让每一个任务的进展有迹可循,规范管理
+ 被合并的PR,可获得奖励积分;积分总额可以显示出你在项目中的贡献度,也许有一天会有人愿意为此付费
+
+ 数据是重要的生产要素,AI开发更是离不开数据;
+ - 数据与模型代码的协同,可在项目中上传关联的数据集;
+ - 数据存储免费,不限制文件大小;
+ - 数据可共享,标注清洗过的公开数据集,用户可设置为公有数据,供社区用户下载;
+
+ 数据集可以直接用于训练或者推理任务中
+ 创建任务时选择对应的数据集,启动任务执行环境(Docker)后,即可在Docker内访问到你的代码和数据,就像在你本地执行一样
+
-
-
- - OpenI社区旨在促进人工智能领域的开源开放协同创新,构建OpenI的技术链、创新链和生态链、推动人工智能产业健康快速发展及其在社会经济各领域的广泛应用。围绕重大产业创新,汇聚创新资源,促进众创共享,形成产业生态的目标,让"一体两翼"构想下的以技术专家为主体组成的多个工作组(标准工作组、知识产权工作组、投融资工作组、开源治理工作组等)、和以企业为主体的多个应用推进组(智能交通推进组、智能医疗推进组、智能金融推进组、智能教育推进组等)作为一个整体进行工作。以"完全开源、完全开放、完全免费、尊重创新"为准则,汇聚学术机构、商业实体、自然人或任何其他法人,共建共享开源软件、开源硬件和开源数据的超级社区;以众智、赛智、创智、有智等工作方法,努力建设成具有国际影响力的人工智能开源开放平台。 -
- 申请贡献项目到OpenI - 加入OpenI社区 - + + ++ {{if .Repository.DescriptionHTML}}{{.Repository.DescriptionHTML}}{{else if .IsRepositoryAdmin}}{{.i18n.Tr "repo.no_desc"}}{{end}} + {{.Repository.Website}} +
++ + {{range .Topics}}{{.Name}}{{end}} + {{if and .Permission.IsAdmin (not .Repository.IsArchived)}}{{.i18n.Tr "repo.topic.manage_topics"}}{{end}} +
+ + ++ + {{range .LanguageStats}} + {{.Language}} + {{end}} +
+ ++ + {{if .LICENSE}} + {{.LICENSE}} + {{end}} +
+ + + +