Skip to content

Commit 8ab32f7

Browse files
committed
🎉 fist blood
0 parents  commit 8ab32f7

12 files changed

+3328
-0
lines changed

.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
lib-cov
2+
*.seed
3+
*.log
4+
*.csv
5+
*.dat
6+
*.out
7+
*.pid
8+
*.gz
9+
*.swp
10+
11+
pids
12+
logs
13+
results
14+
tmp
15+
16+
#Build
17+
18+
19+
# API keys and secrets
20+
.env
21+
22+
# Dependency directory
23+
node_modules
24+
bower_components
25+
26+
# Editors
27+
.idea
28+
29+
# OS metadata
30+
.DS_Store
31+
Thumbs.db
32+
33+
2lib/

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
# iGitIssue
3+
4+
『iGitIssue』 is a Google Chrome extension for [GitIssue](https://gitissue.com).
5+
6+
GitIssue user can subscribe or unsubscribe Github repository easily with this extension when visiting Github.
7+
8+
9+
『iGitIssue』 是 [GitIssue](https://gitissue.com) 的 Chrome 浏览器插件, 主要帮助用户浏览 Github 时,关注订阅 Github Issue 博客仓库到 GitIssue 网站,方便用户及时订阅阅读。
10+
11+
12+
<p align="center">
13+
<img src="https://gitissue.com/public/iGitIssue.png" alt="GitIssue" width="600">
14+
</p>

gitissue.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#gitIssue {
2+
position: relative;
3+
}
4+
5+
#gitIssue img {
6+
position: relative;
7+
top: 2px;
8+
left: 0;
9+
margin-right: 5px;
10+
width: 16px;
11+
}

gitissue.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
$(function () {
2+
var tplBegin = '<li id="gitIssue">' +
3+
'<a href="javascript:void(0)" aria-label="subscribe or unsubscribe the repo to GitIssue" class="btn btn-sm">' +
4+
'<img src="https://gitissue.com/public/logo/apple-icon.png" >';
5+
var tplEnd = '</a></li>';
6+
var loginUserName = $('meta[name="user-login"]').attr('content');
7+
var nameWithOwner = $('meta[name="octolytics-dimension-repository_nwo"]').attr('content');
8+
var isSubscribedUrl = 'https://gitissue.com/api/isSubscribed?loginUserName=' + loginUserName + '&nameWithOwner=' + encodeURIComponent(nameWithOwner);
9+
var subscribeUrl = 'https://gitissue.com/api/subscribe';
10+
11+
var pageScript = document.createElement('script');
12+
pageScript.innerHTML = 'document.addEventListener("pjax:success", function () { var evt = new Event("PJAX_PUSH_STATE_GIT_ISSUE"); document.dispatchEvent(evt); });';
13+
document.querySelector('body').appendChild(pageScript);
14+
15+
render();
16+
17+
document.addEventListener('PJAX_PUSH_STATE_GIT_ISSUE', render);
18+
19+
function render() {
20+
// TODO 私有仓库不能 watch,
21+
// (暂时不处理,有用户提了再修复,这会导致所有的业务逻辑都要修改下,因为现在关注的仓库都应该是 public)?
22+
if (!$('.pagehead-actions').length) {
23+
return;
24+
}
25+
$.get(isSubscribedUrl, function (data) {
26+
if ($('#gitIssue').length) return;
27+
var tplMiddle = '';
28+
if (data.isSubscribed) {
29+
tplMiddle = '<span class="subscribe">Unsubscribe</span>';
30+
} else {
31+
tplMiddle = '<span class="subscribe">Subscribe</span>';
32+
}
33+
var tpl = tplBegin + tplMiddle + tplEnd;
34+
$('.pagehead-actions').prepend(tpl);
35+
// if (!data.success) {
36+
// $('#gitIssue').tooltipster({
37+
// content: data.message + '<a href="https://gitissue.com" target="_blank">GitIssue</a>',
38+
// trigger: 'click',
39+
// side: ['bottom'],
40+
// maxWidth: 250,
41+
// interactive: true,
42+
// contentAsHTML: true
43+
// });
44+
// }
45+
});
46+
}
47+
48+
49+
$(document).on('click', '#gitIssue', function (e) {
50+
$.post(subscribeUrl, {
51+
loginUserName: loginUserName,
52+
nameWithOwner: nameWithOwner
53+
}, function (data) {
54+
if (data.success) {
55+
if (data.isSubscribed) {
56+
$('#gitIssue .subscribe').text('Unsubscribe');
57+
} else {
58+
$('#gitIssue .subscribe').text('Subscribe');
59+
}
60+
} else {
61+
$('#gitIssue').tooltipster({
62+
content: data.message ,
63+
side: ['bottom'],
64+
maxWidth: 250,
65+
interactive: true,
66+
contentAsHTML: true,
67+
debug: false
68+
}).tooltipster('open');;
69+
}
70+
})
71+
})
72+
});

gitissue.svg

Lines changed: 65 additions & 0 deletions
Loading

icon16x16.png

1.34 KB
Loading

icon48x48.png

2.67 KB
Loading

jquery-3.2.1.min.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifest.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"manifest_version": 2,
3+
"name": "iGitIssue",
4+
"version": "0.4",
5+
"description": "GitIssue user can subscribe or unsubscribe Github repository easily with this extension when visiting Github.",
6+
"icons": {
7+
"16": "icon16x16.png",
8+
"48": "icon48x48.png"
9+
},
10+
"browser_action": {
11+
"default_icon": "icon48x48.png",
12+
"default_popup": "popup.html",
13+
"default_title": "Hello, GitIssuer"
14+
},
15+
"content_scripts": [
16+
{
17+
"matches": ["https://github.com/*/*"],
18+
"js": ["jquery-3.2.1.min.js", "tooltipster.js","gitissue.js"],
19+
"css": ["tooltipster.css", "gitissue.css"]
20+
}
21+
],
22+
"author": "GitIssue",
23+
"homepage_url": "https://gitissue.com",
24+
"permissions": [
25+
"tabs",
26+
"https://gitissue.com/api/*",
27+
"https://github.com/*"
28+
],
29+
"web_accessible_resources": [
30+
"icon48x48.png"
31+
]
32+
}

popup.html

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>GitIssue</title>
8+
<style>
9+
body {
10+
width: 400px;
11+
text-align: center;
12+
}
13+
14+
h1 {
15+
margin-top: 25px;
16+
font-size: 18px;
17+
}
18+
19+
h2 {
20+
font-size: 16px;
21+
font-weight: 400
22+
}
23+
24+
button,a {
25+
display: inline-block;
26+
padding: 0px 20px;
27+
margin: 0 13px;
28+
border: 1px solid #d9d9d9;
29+
border-radius: 25px;
30+
text-decoration: none;
31+
color: rgba(0,0,0,.65);
32+
background-color: #fff;
33+
transition: all .3s cubic-bezier(.645,.045,.355,1);
34+
font-weight: 500;
35+
-ms-touch-action: manipulation;
36+
touch-action: manipulation;
37+
cursor: pointer;
38+
white-space: nowrap;
39+
line-height: 28px;
40+
font-size: 12px;
41+
border-radius: 4px;
42+
height: 28px;
43+
}
44+
a:hover {
45+
color: #108ee9;
46+
background-color: #fff;
47+
border-color: #108ee9;
48+
}
49+
a:focus {
50+
border: none;
51+
}
52+
.logo {
53+
border: none;
54+
outline: none;
55+
}
56+
</style>
57+
<script src="zepto.min.js"></script>
58+
<script src="app.js"></script>
59+
</head>
60+
<body>
61+
<a href="https://gitissue.com" target="_blank" class="logo">
62+
<img src="https://gitissue.com/dist/GitIssue.png" alt="GitIssue" width="200"></a>
63+
<h1>Github Issue Blog Reader</h1>
64+
<h2>Monkey see, monkey read.</h2>
65+
<!-- <button id="login"></button> -->
66+
<a href="https://gitissue.com/login" target="_blank">登录</a>
67+
<!-- <button id="logout">退出</button> -->
68+
</body>
69+
</html>

0 commit comments

Comments
 (0)