|
1 | 1 | --- |
| 2 | +layout: page |
| 3 | +type: list |
2 | 4 | --- |
3 | | -<!DOCTYPE html> |
4 | | -<html> |
5 | | -<head> |
6 | | -<meta charset="UTF-8" /> |
7 | | -<title>Yncoder</title> |
8 | | -<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" /> |
9 | | -<link rel="icon" href="/favicon.png" type="image/x-icon" /> |
10 | | -<link rel="shortcut icon" href="/favicon.png" type="image/x-icon" /> |
11 | | -<link rel="stylesheet" href="/assets/css/common.css" /> |
12 | | -<style type="text/css"> |
13 | | -.holder{ |
14 | | - min-height: 100%; |
15 | | - margin-bottom: -60px; |
16 | | -} |
17 | | -.holder:after{ |
18 | | - content: ""; |
19 | | - display: block; |
20 | | - height: 60px; |
21 | | -} |
22 | | - |
23 | | -nav .logo{ |
24 | | - display: none; |
25 | | -} |
26 | | - |
27 | | -header{ |
28 | | - text-align: center; |
29 | | -} |
30 | | -header h1{ |
31 | | - margin: 10px 0; |
32 | | - font: normal 250%/1 Consolas, Arial; |
33 | | -} |
34 | | -header hgroup{ |
35 | | - margin: 50px 0; |
36 | | -} |
37 | | -header h2{ |
38 | | - margin: 0; |
39 | | - font-size: 2em; |
40 | | - font-weight: normal; |
41 | | -} |
42 | | -header blockquote{ |
43 | | - margin: 1.5em 0; |
44 | | - font-size: 110%; |
45 | | - line-height: 1.5em; |
46 | | -} |
47 | | - |
48 | | -main{ |
49 | | - text-align: center; |
50 | | -} |
51 | | -main ul{ |
52 | | - margin: 1em 0; |
53 | | -} |
54 | | -main li{ |
55 | | - list-style: none; |
56 | | - display: inline-block; |
57 | | - margin-right: 20px; |
58 | | - line-height: 1.5em; |
59 | | -} |
60 | | -main li.upcoming span{ |
61 | | - margin-left: .5em; |
62 | | - color: #999; |
63 | | -} |
64 | | - |
65 | | -footer{ |
66 | | - height: 60px; |
67 | | - padding: 20px 0; |
68 | | -} |
69 | | -footer .copyright{ |
70 | | - line-height: 20px; |
71 | | - text-align: center; |
72 | | - color: #999; |
73 | | - font-size: 80%; |
74 | | -} |
75 | | - |
76 | | -@media (min-width: 1024px) { |
77 | | - header.container{ |
78 | | - margin-top: 50px; |
79 | | - } |
80 | | -} |
81 | 5 |
|
82 | | -@media (max-width: 640px) { |
83 | | - header h1{ |
84 | | - font-size: 2em; |
| 6 | +<div class="container"> |
| 7 | + <main> |
| 8 | + <ul id="label-list"></ul> |
| 9 | + <ul id="issue-list"></ul> |
| 10 | + </main> |
| 11 | + <aside> |
| 12 | + |
| 13 | + </aside> |
| 14 | +</div> |
| 15 | + |
| 16 | +<script> |
| 17 | +(function () { |
| 18 | + function ajax (url, options, callback) { |
| 19 | + options = options || {}; |
| 20 | + |
| 21 | + var query = Object.keys(options.query || {}).map(function (key) { |
| 22 | + return key + '=' + encodeURIComponent(options.query[key]); |
| 23 | + }).join('&'); |
| 24 | + |
| 25 | + var request = new XMLHttpRequest(); |
| 26 | + request.responseType = options.responseType || 'json'; |
| 27 | + request.open(options.method || 'GET', url + (query ? '?' + query : ''), true); |
| 28 | + |
| 29 | + request.onreadystatechange = function () { |
| 30 | + if (this.readyState != 4) { |
| 31 | + return; |
| 32 | + } |
| 33 | + |
| 34 | + if (this.status >= 200 && this.status < 300) { |
| 35 | + callback(this.response); |
| 36 | + } |
| 37 | + }; |
| 38 | + |
| 39 | + request.send(options.data || null); |
85 | 40 | } |
86 | | - header h2{ |
87 | | - font-size: 1.2em; |
| 41 | + |
| 42 | + function escapeHTML (str) { |
| 43 | + return str.replace(/([&<>'"])/g, function (matcher, symbol) { |
| 44 | + return '&#' + symbol.charCodeAt(0) + ';'; |
| 45 | + }); |
88 | 46 | } |
89 | 47 |
|
90 | | - footer p{ |
91 | | - width: 100%; |
| 48 | + function format (template, data) { |
| 49 | + return template.replace(/\{(\s*\w+\s*)\}/g, function (matcher, name) { |
| 50 | + var value = data[name.trim()]; |
| 51 | + return typeof value != 'undefined' ? value : ''; |
| 52 | + }); |
92 | 53 | } |
93 | | -} |
94 | | -</style> |
95 | | -</head> |
96 | | - |
97 | | -<body> |
98 | | - |
99 | | -<div class="holder"> |
100 | | - |
101 | | -{% include nav.html %} |
102 | | - |
103 | | -<header class="container"> |
104 | | - <figure> |
105 | | - <img src="assets/img/logo-160.png" width="160" height="160" alt="<yn/>" /> |
106 | | - <h1>Yncoder</h1> |
107 | | - </figure> |
108 | | - <hgroup> |
109 | | - <h2>分享 · 交流 · 共创</h2> |
110 | | - <blockquote>我们相信,每个开发者都是富有创造力的个体,即使在这块IT欠发达的土地上,我们也并不孤独。</blockquote> |
111 | | - </hgroup> |
112 | | -</header> |
113 | | - |
114 | | -<main class="container"> |
115 | | - <h3>社区活动</h3> |
116 | | - <ul> |
117 | | - {% assign list = site.posts | sort:"date" %} |
118 | | - {% for item in list %} |
119 | | - {% if item.public %} |
120 | | - <li class="status-{{ item.status }}"><a href="{{ item.url }}">{{ item.title }}</a></li> |
121 | | - {% endif %} |
122 | | - {% endfor %} |
123 | | - </ul> |
124 | | -</main> |
125 | 54 |
|
126 | | -</div> |
| 55 | + ajax('//api.github.com/repos/yncoder/yncoder.github.io/issues', { |
| 56 | + query: { |
| 57 | + state: 'open' |
| 58 | + } |
| 59 | + }, function (data) { |
| 60 | + var template = '<li class="{labelClasses} {statusClass}">' + |
| 61 | + '<figure><img src="{authorAvatarUrl}" /></figure>' + |
| 62 | + '<h4><a href="{link}">{title}</h4>' + |
| 63 | + '<p>{labelElements} <a href="{authorLink}" target="_blank">{authorName}</a></p>' + |
| 64 | + '<i>{comments}</i>'; |
| 65 | + |
| 66 | + var labelTemplate = '<a href="{url}" class="label" style="backbround-color: #{color}">{name}</a>'; |
| 67 | + |
| 68 | + function renderLabelItem (label) { |
| 69 | + return format(labelTemplate, label); |
| 70 | + } |
| 71 | + |
| 72 | + function renderLabelClass (label) { |
| 73 | + return 'label-' + label.name; |
| 74 | + } |
| 75 | + |
| 76 | + var html = data.map(function (item) { |
| 77 | + return format(template, { |
| 78 | + labelClasses: item.labels.map(renderLabelClass).join(''), |
| 79 | + labelElements: item.labels.map(renderLabelItem).join(''), |
| 80 | + title: escapeHTML(item.title), |
| 81 | + link: item.html_url, |
| 82 | + authorAvatarUrl: item.user.avatar_url, |
| 83 | + authorName: item.user.login, |
| 84 | + authorLink: item.user.html_url, |
| 85 | + comments: item.comments |
| 86 | + }); |
| 87 | + }).join(''); |
| 88 | + |
| 89 | + document.getElementById('issue-list').innerHTML = html; |
| 90 | + }); |
127 | 91 |
|
128 | | -<footer class="container"> |
129 | | - <p class="copyright">© Since 2014. 官方 QQ 群:39615502</p> |
130 | | -</footer> |
| 92 | + ajax('//api.github.com/repos/yncoder/yncoder.github.io/labels', null, function (data) { |
131 | 93 |
|
132 | | -</body> |
133 | | -</html> |
| 94 | + }); |
| 95 | +})(); |
| 96 | +</script> |
0 commit comments