This repository has been archived by the owner on May 29, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add: ver 1.6 parse GitHub user info via JSONP.
- Loading branch information
Showing
5 changed files
with
217 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?> | ||
<?php | ||
/** | ||
* 开源页面 | ||
* | ||
* @author innei | ||
* @package custom | ||
*/ | ||
$this->need('header.php'); | ||
require_once 'pages.php'; | ||
?> | ||
<main style="overflow:hidden"> | ||
<nav class="navigation"> | ||
<a href="<?php echo $GLOBALS['project'] ?>">精选</a> | ||
<a href="<?php echo $GLOBALS['opensource'] ?>" class="active">开源</a> | ||
</nav> | ||
<div id="loading" class="jsonp-loading"> | ||
<div class="box"></div> | ||
</div> | ||
<div id="opensource-wrap" style="opacity: 0"> | ||
<section class="me github"> | ||
<div class="my-avatar"> | ||
<img src=""> | ||
</div> | ||
<div class="my-info"> | ||
<h1><span></span> | ||
<svg width="100%" height="3.5rem"> | ||
<text text-anchor="start" x="0" y="2.2rem" class="text text-1"> | ||
</text> | ||
<text text-anchor="start" x="0" y="2.2rem" class="text text-2"> | ||
</text> | ||
<text text-anchor="start" x="0" y="2.2rem" class="text text-3"> | ||
</text> | ||
<text text-anchor="start" x="0" y="2.2rem" class="text text-4"> | ||
</text> | ||
</svg> | ||
</h1> | ||
<p></p> | ||
<div class="social-icons"> | ||
</div> | ||
</section> | ||
<section class="repos" style="overflow:hidden"> | ||
<div class="repo-wrap"> | ||
<ul id="repo-list"> | ||
<li></li> | ||
</ul> | ||
</div> | ||
</section> | ||
</div> | ||
<?php if ($this->options->github_username): ?> | ||
<script> | ||
window.githubID = "<?php $this->options->github_username(); ?>" | ||
</script> | ||
<script src="<?php $this->options->themeUrl("src/github.js") ?>"></script> | ||
<?php endif;?> | ||
</main> | ||
|
||
<?php $this->need('footer.php') ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
var githubInfo = document.createElement("script"); | ||
var githubRepos = document.createElement("script"); | ||
function select(dom) { | ||
return document.querySelectorAll(dom).length == 1 | ||
? document.querySelector(dom) | ||
: document.querySelectorAll(dom); | ||
} | ||
|
||
function userInfo(res) { | ||
select(".my-avatar > img").setAttribute("src", res.data.avatar_url); | ||
select(".my-info span").innerText = res.data.login; | ||
[...select(".my-info text")].forEach( | ||
item => (item.innerHTML = res.data.login) | ||
); | ||
select(".my-info p").innerText = res.data.bio; | ||
select(".social-icons").innerHTML = `<a href="https://github.com/${ | ||
res.data.login | ||
}" target="_blank" | ||
ks-tag="bottom" | ||
ks-text="GitHub"><i | ||
class="fa fa-github" style="color: #44006f"></i></a>`; | ||
} | ||
|
||
function userRepos(res) { | ||
let content = ""; | ||
for (let item of res.data) { | ||
content += `<li> <a href="${item.html_url}" target | ||
="_blank"><div class="repo-name">${ | ||
item.full_name | ||
}</div> </a><div class="repo-des">${ | ||
item.description ? item.description : "" | ||
}</div></li>`; | ||
} | ||
select("#repo-list").innerHTML = content; | ||
loadingComplete(); | ||
} | ||
function loadingComplete() { | ||
select("#loading.jsonp-loading").remove(); | ||
select("#opensource-wrap").removeAttribute("style"); | ||
} | ||
|
||
githubInfo.src = `https://api.github.com/users/${ | ||
window.githubID | ||
}?callback=userInfo`; | ||
|
||
document.head.appendChild(githubInfo); | ||
|
||
githubRepos.src = `https://api.github.com/users/${ | ||
window.githubID | ||
}/repos?sort=updated&callback=userRepos`; | ||
document.head.appendChild(githubRepos); |
Oops, something went wrong.