├── .gitignore
├── LICENSE
├── Makefile
├── README.md
├── generate.py
├── index.html
├── jsdelivr
├── cards
│ ├── default.html
│ └── medium.html
└── widget.js
├── package.json
├── site.css
├── site.js
├── src
├── card.js
└── widget.js
└── theme
├── default.css
├── default.html
├── medium.css
└── medium.html
/.gitignore:
--------------------------------------------------------------------------------
1 | widget.js
2 | _site
3 | cards
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 - 2014, Hsiaoming Yang
2 |
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 |
9 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10 |
11 | * Neither the name of the creator nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12 |
13 |
14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | generate:
2 | @mkdir -p cards
3 | @./generate.py
4 |
5 | jsdelivr:
6 | @cp -r cards jsdelivr
7 |
8 | site: generate
9 | @rm -fr _site
10 | @mkdir -p _site
11 | @uglifyjs src/widget.js -m -o _site/widget.js
12 | @cp index.html site.js site.css _site/
13 | @cp cards/default.html _site/card.html
14 | @mv cards _site/
15 |
16 | publish: _site
17 | @ghp-import _site -p -n
18 |
19 | build: generate jsdelivr site
20 |
21 | .PHONY: build jsdelivr generate publish site
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Unofficial GitHub Cards
2 |
3 | Card for your GitHub profile, card for your GitHub repositories.
4 |
5 | [](https://typlog.com/donate?amount=10&reason=lepture%2Fgithub-cards)
6 |
7 | 
8 |
9 | **New theme available**
10 |
11 | 
12 |
13 |
14 | ## Usage
15 |
16 | The cards are hosted via GitHub Pages.
17 |
18 | Visit card generator: http://lab.lepture.com/github-cards/
19 |
20 | ### widget.js
21 |
22 | You can include the `widget.js` script, it will create the embed iframes
23 | for you.
24 |
25 | Example of user card:
26 |
27 | ```html
28 |
29 |
30 | ```
31 |
32 | Example of repo card:
33 |
34 | ```html
35 |
36 |
37 | ```
38 |
39 | Data parameters:
40 |
41 | - user: GitHub username
42 | - repo: GitHub repository name
43 | - width: Embed width you want, default is 400
44 | - height: Embed height you want, default is 200
45 | - theme: GitHub card theme, default is `default`
46 | - target: If you want to open links in new tab, set it to `blank`
47 | - client_id: Your app client_id, optional
48 | - client_secret: Your app client_secret, optional
49 |
50 | You can also define in meta tags:
51 |
52 | ```html
53 |
54 |
55 |
56 |
57 | ```
58 |
59 | ## Limitation
60 |
61 | There are some limitations for github cards.
62 |
63 | 1. GitHub API rate limitation
64 | 2. No interaction. You can't actually follow someone
65 |
66 | ## SSL support
67 |
68 | GitHub Cards is available on jsdelivr now. Use widget hosted on jsdelivr:
69 |
70 | ```html
71 |
72 |
73 | ```
74 |
75 | ## Contribution
76 |
77 | This project is under the BSD License.
78 |
--------------------------------------------------------------------------------
/generate.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | import re
4 | import os
5 | import json
6 | from subprocess import Popen, PIPE
7 |
8 | GA = '''
9 | (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
10 | (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
11 | m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
12 | })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
13 | ga('create', '%s', 'auto');
14 | var t = qs.user;
15 | if (qs.repo) t += '/' + qs.repo;
16 | ga('send', 'pageview', {'title': t});
17 | '''
18 |
19 |
20 | def tinyhtml(text):
21 | lines = re.split('(<[^>]+>)', text)
22 | rv = []
23 | for line in lines:
24 | line = line.strip()
25 | rv.append(line)
26 | return ''.join(rv)
27 |
28 |
29 | def shell(cmd, data=None):
30 | p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
31 | stdout, stderr = p.communicate(input=data)
32 | if not stdout:
33 | raise RuntimeError(stderr)
34 | return stdout
35 |
36 |
37 | def create_card(theme):
38 | with open('theme/%s.html' % theme) as f:
39 | template = f.read()
40 |
41 | html = (
42 | ''
43 | '%s'
44 | ''
45 | ''
46 | )
47 |
48 | css = shell(['cleancss', 'theme/%s.css' % theme])
49 |
50 | with open('src/card.js', 'rb') as f:
51 | content = f.read()
52 | content += GA % 'UA-21475122-2'
53 |
54 | js = shell(['uglifyjs', '-m'], content)
55 |
56 | out = html % (css, tinyhtml(template), js)
57 | with open('cards/%s.html' % theme, 'wb') as f:
58 | f.write(out)
59 |
60 |
61 | def create_widget():
62 | with open('package.json') as f:
63 | pkg = json.load(f)
64 |
65 | url = '//cdn.jsdelivr.net/gh/lepture/github-cards@%s/' % pkg['version']
66 |
67 | with open('src/widget.js') as f:
68 | content = f.read()
69 | content = content.replace(
70 | 'var base = "//lab.lepture.com/github-cards/";',
71 | 'var base = "%s";' % url
72 | )
73 |
74 | js = shell(['uglifyjs', '-m'], content)
75 | with open('jsdelivr/widget.js', 'wb') as f:
76 | f.write(js)
77 |
78 |
79 | create_widget()
80 |
81 | if not os.path.isdir('cards'):
82 | os.makedirs('cards')
83 |
84 | create_card('default')
85 | create_card('medium')
86 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | GitHub Cards
5 |
6 |
7 |
8 |
9 |
23 |
24 |
25 |
26 |
27 |
The unofficial
28 |
GitHub Cards
29 |
Card for your GitHub profile, card for your GitHub repositories.