ghrepo
This commit is contained in:
parent
159d275a82
commit
54b605a46e
|
@ -27,8 +27,8 @@ sidebar:
|
||||||
widgets:
|
widgets:
|
||||||
index: [welcome, recent] # for home/wiki/categories/tags/archives/404 pages
|
index: [welcome, recent] # for home/wiki/categories/tags/archives/404 pages
|
||||||
page: [welcome, toc] # for pages using 'layout:page'
|
page: [welcome, toc] # for pages using 'layout:page'
|
||||||
post: [toc, repo_info] # for pages using 'layout:post'
|
post: [toc, ghrepo] # for pages using 'layout:post'
|
||||||
wiki: [toc, repo_info, wiki_more] # for pages using 'layout:wiki'
|
wiki: [ghrepo, toc, wiki_more] # for pages using 'layout:wiki'
|
||||||
|
|
||||||
|
|
||||||
######## Main ########
|
######## Main ########
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
# - markdown: 渲染 md 文本
|
# - markdown: 渲染 md 文本
|
||||||
#
|
#
|
||||||
|
|
||||||
# ---- 内置组件,请勿覆盖 ----
|
# ---- 内置组件,暂时不支持覆盖 ----
|
||||||
repo_info:
|
ghrepo:
|
||||||
layout: repo_info
|
layout: ghrepo
|
||||||
wiki_more:
|
wiki_more:
|
||||||
layout: wiki_more
|
layout: wiki_more
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ meta:
|
||||||
updated: 'Updated on'
|
updated: 'Updated on'
|
||||||
license: License
|
license: License
|
||||||
share: Share
|
share: Share
|
||||||
repo_info: Repo Info
|
|
||||||
date_suffix:
|
date_suffix:
|
||||||
just: Just
|
just: Just
|
||||||
min: minutes ago
|
min: minutes ago
|
||||||
|
|
|
@ -28,7 +28,6 @@ meta:
|
||||||
updated: 更新于
|
updated: 更新于
|
||||||
license: 许可协议
|
license: 许可协议
|
||||||
share: 分享文章
|
share: 分享文章
|
||||||
repo_info: 项目仓库
|
|
||||||
date_suffix:
|
date_suffix:
|
||||||
just: 刚刚
|
just: 刚刚
|
||||||
min: 分钟前
|
min: 分钟前
|
||||||
|
|
|
@ -28,7 +28,6 @@ meta:
|
||||||
updated: 更新於
|
updated: 更新於
|
||||||
license: 授權條款
|
license: 授權條款
|
||||||
share: 分享文章
|
share: 分享文章
|
||||||
repo_info: 專案儲存庫
|
|
||||||
date_suffix:
|
date_suffix:
|
||||||
just: 剛剛
|
just: 剛剛
|
||||||
min: 分鐘前
|
min: 分鐘前
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
<%
|
||||||
|
function layoutDiv() {
|
||||||
|
var el = '';
|
||||||
|
var repo;
|
||||||
|
var branch = 'main';
|
||||||
|
if (page.layout === 'wiki' && page.wiki) {
|
||||||
|
let proj = theme.wiki.projects[page.wiki];
|
||||||
|
if (proj && proj.repo) {
|
||||||
|
repo = proj.repo;
|
||||||
|
if (proj.branch != undefined) {
|
||||||
|
branch = proj.branch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 其它的如果有设置 repo 也可以
|
||||||
|
repo = page.repo;
|
||||||
|
}
|
||||||
|
if (repo == undefined) {
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
// 布局
|
||||||
|
el += '<div class="widget-wrap" id="repo-info">';
|
||||||
|
// body
|
||||||
|
el += '<div class="widget-body">';
|
||||||
|
el += '<div class="items stellar-ghinfo-api" api="https://api.github.xaoxuu.com/repos/' + repo + '">';
|
||||||
|
el += '<a class="repo" href="https://github.com/' + repo + '" target="_blank" rel="external nofollow noopener noreferrer">';
|
||||||
|
el += '<div class="repo-name flex-row">';
|
||||||
|
el += '<svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1em" height="1em" fill="currentColor" style="user-select:none;overflow:visible"><path fill-rule="evenodd" d="M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8zM5 12.25v3.25a.25.25 0 00.4.2l1.45-1.087a.25.25 0 01.3 0L8.6 15.7a.25.25 0 00.4-.2v-3.25a.25.25 0 00-.25-.25h-3.5a.25.25 0 00-.25.25z"></path></svg>';
|
||||||
|
el += '<span>' + repo + '</span>';
|
||||||
|
el += '</div>';
|
||||||
|
el += '<div class="repo-desc"><span type="text" id="description"> </span></div>';
|
||||||
|
el += '<div class="grid">';
|
||||||
|
el += '<div class="flex-row">';
|
||||||
|
el += '<svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1em" height="1em" fill="currentColor" style="user-select:none;overflow:visible"><path fill-rule="evenodd" d="M8 .25a.75.75 0 01.673.418l1.882 3.815 4.21.612a.75.75 0 01.416 1.279l-3.046 2.97.719 4.192a.75.75 0 01-1.088.791L8 12.347l-3.766 1.98a.75.75 0 01-1.088-.79l.72-4.194L.818 6.374a.75.75 0 01.416-1.28l4.21-.611L7.327.668A.75.75 0 018 .25zm0 2.445L6.615 5.5a.75.75 0 01-.564.41l-3.097.45 2.24 2.184a.75.75 0 01.216.664l-.528 3.084 2.769-1.456a.75.75 0 01.698 0l2.77 1.456-.53-3.084a.75.75 0 01.216-.664l2.24-2.183-3.096-.45a.75.75 0 01-.564-.41L8 2.694v.001z"></path></svg>';
|
||||||
|
el += '<span type="text" id="stargazers_count"></span>';
|
||||||
|
el += '</div>';
|
||||||
|
el += '<div class="flex-row">';
|
||||||
|
el += '<svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1em" height="1em" fill="currentColor" style="user-select:none;overflow:visible"><path fill-rule="evenodd" d="M5 3.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm0 2.122a2.25 2.25 0 10-1.5 0v.878A2.25 2.25 0 005.75 8.5h1.5v2.128a2.251 2.251 0 101.5 0V8.5h1.5a2.25 2.25 0 002.25-2.25v-.878a2.25 2.25 0 10-1.5 0v.878a.75.75 0 01-.75.75h-4.5A.75.75 0 015 6.25v-.878zm3.75 7.378a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm3-8.75a.75.75 0 100-1.5.75.75 0 000 1.5z"></path></svg>';
|
||||||
|
el += '<span type="text" id="forks_count"></span>';
|
||||||
|
el += '</div>';
|
||||||
|
el += '<div class="flex-row stellar-ghinfo-api" api="https://api.github.xaoxuu.com/repos/' + repo + '/releases/latest">';
|
||||||
|
el += '<svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1em" height="1em" fill="currentColor" style="user-select:none;overflow:visible"><path fill-rule="evenodd" d="M2.5 7.775V2.75a.25.25 0 01.25-.25h5.025a.25.25 0 01.177.073l6.25 6.25a.25.25 0 010 .354l-5.025 5.025a.25.25 0 01-.354 0l-6.25-6.25a.25.25 0 01-.073-.177zm-1.5 0V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 010 2.474l-5.026 5.026a1.75 1.75 0 01-2.474 0l-6.25-6.25A1.75 1.75 0 011 7.775zM6 5a1 1 0 100 2 1 1 0 000-2z"></path></svg>';
|
||||||
|
el += '<span type="text" id="tag_name"></span>';
|
||||||
|
el += '</div>';
|
||||||
|
el += '</div>';
|
||||||
|
el += '</a>';
|
||||||
|
el += '</div>';
|
||||||
|
el += '</div>';
|
||||||
|
el += '</div>';
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
<%- layoutDiv() %>
|
|
@ -1,91 +0,0 @@
|
||||||
<%
|
|
||||||
function layoutDiv() {
|
|
||||||
var el = '';
|
|
||||||
var repo;
|
|
||||||
var branch = 'main';
|
|
||||||
if (page.layout === 'wiki' && page.wiki) {
|
|
||||||
let proj = theme.wiki.projects[page.wiki];
|
|
||||||
if (proj && proj.repo) {
|
|
||||||
repo = proj.repo;
|
|
||||||
if (proj.branch != undefined) {
|
|
||||||
branch = proj.branch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 其它的如果有设置 repo 也可以
|
|
||||||
repo = page.repo;
|
|
||||||
}
|
|
||||||
if (repo == undefined) {
|
|
||||||
return el;
|
|
||||||
}
|
|
||||||
// 布局
|
|
||||||
el += '<div class="widget-wrap" id="repo-info">';
|
|
||||||
// header
|
|
||||||
el += '<div class="widget-header cap dis-select">';
|
|
||||||
el += '<span class="name">' + __("meta.repo_info") + '</span>';
|
|
||||||
el += '</div>';
|
|
||||||
// body
|
|
||||||
el += '<div class="widget-body fs14">';
|
|
||||||
el += '<div class="items stellar-ghinfo-api" api="https://api.github.xaoxuu.com/repos/' + repo + '">';
|
|
||||||
var items = [];
|
|
||||||
// GitHub
|
|
||||||
items.push({
|
|
||||||
icon: '<svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1rem" height="1rem" fill="currentColor" style="display:inline-block;user-select:none;vertical-align:text-bottom;overflow:visible"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path></svg>',
|
|
||||||
text: 'GitHub',
|
|
||||||
href: 'https://github.com/' + repo
|
|
||||||
});
|
|
||||||
// Stars
|
|
||||||
items.push({
|
|
||||||
icon: '<svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1rem" height="1rem" fill="currentColor" style="display:inline-block;user-select:none;vertical-align:text-bottom;overflow:visible"><path fill-rule="evenodd" d="M8 .25a.75.75 0 01.673.418l1.882 3.815 4.21.612a.75.75 0 01.416 1.279l-3.046 2.97.719 4.192a.75.75 0 01-1.088.791L8 12.347l-3.766 1.98a.75.75 0 01-1.088-.79l.72-4.194L.818 6.374a.75.75 0 01.416-1.28l4.21-.611L7.327.668A.75.75 0 018 .25zm0 2.445L6.615 5.5a.75.75 0 01-.564.41l-3.097.45 2.24 2.184a.75.75 0 01.216.664l-.528 3.084 2.769-1.456a.75.75 0 01.698 0l2.77 1.456-.53-3.084a.75.75 0 01.216-.664l2.24-2.183-3.096-.45a.75.75 0 01-.564-.41L8 2.694v.001z"></path></svg>',
|
|
||||||
text: 'Stars',
|
|
||||||
apiKey: 'stargazers_count',
|
|
||||||
href: 'https://github.com/' + repo + '/stargazers'
|
|
||||||
});
|
|
||||||
// Forks
|
|
||||||
items.push({
|
|
||||||
icon: '<svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1rem" height="1rem" fill="currentColor" style="display:inline-block;user-select:none;vertical-align:text-bottom;overflow:visible"><path fill-rule="evenodd" d="M5 3.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm0 2.122a2.25 2.25 0 10-1.5 0v.878A2.25 2.25 0 005.75 8.5h1.5v2.128a2.251 2.251 0 101.5 0V8.5h1.5a2.25 2.25 0 002.25-2.25v-.878a2.25 2.25 0 10-1.5 0v.878a.75.75 0 01-.75.75h-4.5A.75.75 0 015 6.25v-.878zm3.75 7.378a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm3-8.75a.75.75 0 100-1.5.75.75 0 000 1.5z"></path></svg>',
|
|
||||||
text: 'Forks',
|
|
||||||
apiKey: 'forks_count',
|
|
||||||
href: 'https://github.com/' + repo + '/network/members'
|
|
||||||
});
|
|
||||||
// Releases
|
|
||||||
items.push({
|
|
||||||
icon: '<svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1rem" height="1rem" fill="currentColor" style="display:inline-block;user-select:none;vertical-align:text-bottom;overflow:visible"><path fill-rule="evenodd" d="M2.5 7.775V2.75a.25.25 0 01.25-.25h5.025a.25.25 0 01.177.073l6.25 6.25a.25.25 0 010 .354l-5.025 5.025a.25.25 0 01-.354 0l-6.25-6.25a.25.25 0 01-.073-.177zm-1.5 0V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 010 2.474l-5.026 5.026a1.75 1.75 0 01-2.474 0l-6.25-6.25A1.75 1.75 0 011 7.775zM6 5a1 1 0 100 2 1 1 0 000-2z"></path></svg>',
|
|
||||||
text: 'Releases',
|
|
||||||
href: 'https://github.com/' + repo + '/releases'
|
|
||||||
});
|
|
||||||
// Download
|
|
||||||
items.push({
|
|
||||||
icon: '<svg aria-hidden="true" role="img" class="color-icon-primary" viewBox="0 0 16 16" width="1rem" height="1rem" fill="currentColor" style="display:inline-block;user-select:none;vertical-align:text-bottom;overflow:visible"><path fill-rule="evenodd" d="M7.47 10.78a.75.75 0 001.06 0l3.75-3.75a.75.75 0 00-1.06-1.06L8.75 8.44V1.75a.75.75 0 00-1.5 0v6.69L4.78 5.97a.75.75 0 00-1.06 1.06l3.75 3.75zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z"></path></svg>',
|
|
||||||
text: 'Download Zip',
|
|
||||||
href: 'https://github.com/' + repo + '/archive/refs/heads/' + branch + '.zip'
|
|
||||||
});
|
|
||||||
items.forEach((item, i) => {
|
|
||||||
el += '<div class="line"></div>';
|
|
||||||
el += '<a class="item-link"';
|
|
||||||
el += ' title="' + item.href + '"';
|
|
||||||
el += ' href="' + url_for(item.href) + '"';
|
|
||||||
el += ' target="_blank" rel="external nofollow noopener noreferrer"';
|
|
||||||
el += '>';
|
|
||||||
// left
|
|
||||||
el += '<div class="left">';
|
|
||||||
el += '<span>' + item.text + '</span>';
|
|
||||||
el += '</div>';
|
|
||||||
// right
|
|
||||||
el += '<div class="right">';
|
|
||||||
if (item.apiKey) {
|
|
||||||
el += '<span type="text" id="' + item.apiKey + '"></span>';
|
|
||||||
}
|
|
||||||
if (item.icon) {
|
|
||||||
el += item.icon;
|
|
||||||
}
|
|
||||||
el += '</div>';
|
|
||||||
el += '</a>';
|
|
||||||
});
|
|
||||||
el += '</div>';
|
|
||||||
el += '</div>';
|
|
||||||
el += '</div>';
|
|
||||||
return el;
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%- layoutDiv() %>
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
.widget-wrap#repo-info
|
||||||
|
.widget-body
|
||||||
|
a.repo
|
||||||
|
display: block
|
||||||
|
border: 1px solid var(--block-border)
|
||||||
|
color: var(--text-p2)
|
||||||
|
background: var(--block)
|
||||||
|
border-radius: $border-block
|
||||||
|
>div
|
||||||
|
margin: 0.75rem 0.5rem
|
||||||
|
span
|
||||||
|
color: var(--text-p2)
|
||||||
|
&:hover
|
||||||
|
background: var(--block-hover)
|
||||||
|
a.repo
|
||||||
|
svg
|
||||||
|
margin-right: 4px
|
||||||
|
.flex-row
|
||||||
|
display: flex
|
||||||
|
align-items: center
|
||||||
|
.repo-name
|
||||||
|
font-size: $fs-14
|
||||||
|
font-weight: 700
|
||||||
|
.repo-desc
|
||||||
|
font-size: $fs-13
|
||||||
|
.grid
|
||||||
|
font-size: $fs-13
|
||||||
|
display: grid
|
||||||
|
grid-gap: 2px
|
||||||
|
grid-template-columns: repeat(auto-fill, "calc((100% - 2 * %s) / 3)" % 2px)
|
|
@ -1,31 +0,0 @@
|
||||||
.widget-wrap#repo-info
|
|
||||||
.widget-body
|
|
||||||
>.items
|
|
||||||
margin: 4px 0
|
|
||||||
border: 1px solid var(--block-border)
|
|
||||||
border-radius: $border-block
|
|
||||||
background: var(--block)
|
|
||||||
overflow: hidden
|
|
||||||
.line
|
|
||||||
margin: 0
|
|
||||||
height: 1px
|
|
||||||
background: var(--block-border)
|
|
||||||
&+.line,&:first-child,&:last-child
|
|
||||||
display: none
|
|
||||||
a.item-link
|
|
||||||
color: var(--text-p2)
|
|
||||||
font-weight: 500
|
|
||||||
display: flex
|
|
||||||
align-items: center
|
|
||||||
padding: 0.5rem .5rem
|
|
||||||
font-size: $fs-13
|
|
||||||
justify-content: space-between
|
|
||||||
svg
|
|
||||||
width: 1em
|
|
||||||
height: 1em
|
|
||||||
margin-left: 4px
|
|
||||||
div
|
|
||||||
display: flex
|
|
||||||
align-items: center
|
|
||||||
a:hover
|
|
||||||
background: var(--block-hover)
|
|
Loading…
Reference in New Issue