Tip: You can customize your feed by adding filters on GitHub.
14 |
Your feed address:
15 |
16 |
21 |
22 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Shiquan Sun
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | gh-feed
2 | =======
3 |
4 | Generate RSS feed from GitHub Issues.
5 |
6 | Check out [gh-feed.imsun.net](http://gh-feed.imsun.net)
7 |
8 | [中文简介](http://imsun.net/posts/gh-feed)
9 |
10 | ## Why
11 |
12 | Some engineers take GitHub Issues as blogs. It's easy to use, supporting Markdown, Git, code highlighting, comments, notifications, and lots of fancy features. But there isn't a feed address for it. So I write this project.
13 |
14 | ## Usage
15 |
16 | 1. Open project's issues page on GitHub.
17 | 1. Paste its URL to the input field on gh-feed's index page, or just replace `https://github.com` with `http://gh-feed.imsun.net`
18 | 1. Get your feed address.
19 |
20 | To customize your feed, you can add filters on issues page.
21 |
22 | ## To Run
23 |
24 | ### 1. Set Your GitHub Token (optional)
25 |
26 | By default gh-feed uses GitHub API, but rate of requests is [limited by GitHub](https://developer.github.com/v3/#rate-limiting).
27 |
28 | > For requests using Basic Authentication or OAuth, you can make up to 5,000 requests per hour. For unauthenticated requests, the rate limit allows you to make up to 60 requests per hour. Unauthenticated requests are associated with your IP address, and not the user making requests.
29 |
30 | For higher rate, you need to create `config.js` as follows:
31 |
32 | ```
33 | module.exports = {
34 | token: 'Your GitHub token'
35 | }
36 | ```
37 |
38 | You can use [personal access token](https://github.com/settings/tokens) or [register an application](https://github.com/settings/developers) and [generate a token](https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization) for it.
39 |
40 | Once you runs out your requests, gh-feed will **load the full issues page** to generate feed, which costs much more than using GitHub API.
41 |
42 | ### 2. Run It
43 |
44 | ```
45 | npm install && npm start
46 | ```
47 |
48 | ## License
49 |
50 | MIT
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | const app = require('koa')()
2 | const router = require('koa-router')()
3 | const compress = require('koa-compress')
4 |
5 | const request = require('co-request')
6 | const { readFile } = require('co-fs')
7 | const S = require('string')
8 | const marked = require('marked')
9 | const RSS = require('rss')
10 | const { DOMParser, XMLSerializer } = require('xmldom')
11 | const parser = new DOMParser({
12 | errorHandler: {}
13 | })
14 | const serlializer = new XMLSerializer()
15 |
16 | const config = { token: '' }
17 | try {
18 | Object.assign(config, require('./config'))
19 | } catch (e) {}
20 | if (process.env.GH_TOKEN) {
21 | Object.assign(config, {
22 | token: process.env.GH_TOKEN
23 | })
24 | }
25 |
26 | const headers = {
27 | 'User-Agent': 'gh-feed',
28 | 'Accept': 'application/vnd.github.v3+json'
29 | }
30 | if (config.token) {
31 | headers.Authorization = `token ${config.token}`
32 | }
33 |
34 | const hotFeeds = {}
35 |
36 | router
37 | .get('/', function *() {
38 | const page = yield readFile('./index.html', 'utf8')
39 | this.set('Content-Type', 'text/html; charset=utf-8')
40 | this.body = page
41 | })
42 | .get('/hot', function *() {
43 | this.set('Content-Type', 'text/html; charset=utf-8')
44 | this.body = `