30 | Some of the best content on Hacker News are the 31 | links to up-and coming projects on GitHub. 32 | Get a list of these awesome projects without the distraction of the rest 33 | of Hacker News. 34 |
35 |├── .gitignore ├── Procfile ├── update-db.js ├── migrations ├── 20160123121933_🌟stars🌟.js └── 20141229012503_00.js ├── clock.js ├── knexfile.js ├── README.md ├── app.js ├── LICENSE.txt ├── package.json ├── views ├── base.hjs └── index.hjs ├── routes.js ├── static └── style.css └── backend.js /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | node_modules 3 | dev.sqlite3 4 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: node app.js 2 | worker: npm run worker 3 | -------------------------------------------------------------------------------- /update-db.js: -------------------------------------------------------------------------------- 1 | var clock = require('./clock'); 2 | clock.forceUpdate(); 3 | -------------------------------------------------------------------------------- /migrations/20160123121933_🌟stars🌟.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | exports.up = function(knex, Promise) { 4 | return knex.schema.table('ghprojects', function (table) { 5 | table.integer('gh_stars'); 6 | }); 7 | }; 8 | 9 | exports.down = function(knex, Promise) { 10 | }; 11 | -------------------------------------------------------------------------------- /clock.js: -------------------------------------------------------------------------------- 1 | var schedule = require('node-schedule'); 2 | var backend = require('./backend'); 3 | 4 | // every ten minutes from 8:00-20:00 5 | var job = schedule.scheduleJob('*/10 8-20 * * *', function () { 6 | runJob(); 7 | }); 8 | 9 | function runJob() { 10 | console.log("Starting job."); 11 | backend.httpGet( 12 | backend.hn_api_host, 13 | '/v0/topstories.json', 14 | backend.processHNPosts); 15 | backend.clearOldPosts(); 16 | } 17 | 18 | module.exports.forceUpdate = runJob; 19 | -------------------------------------------------------------------------------- /knexfile.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 3 | development: { 4 | client: 'sqlite3', 5 | connection: { 6 | filename: './dev.sqlite3' 7 | } 8 | }, 9 | 10 | staging: { 11 | client: 'postgresql', 12 | connection: process.env.DATABASE_URL, 13 | pool: { 14 | min: 2, 15 | max: 10 16 | }, 17 | migrations: { 18 | tableName: 'knex_migrations' 19 | } 20 | }, 21 | 22 | production: { 23 | client: 'postgresql', 24 | connection: process.env.DATABASE_URL, 25 | pool: { 26 | min: 2, 27 | max: 10 28 | }, 29 | migrations: { 30 | tableName: 'knex_migrations' 31 | } 32 | } 33 | 34 | }; 35 | -------------------------------------------------------------------------------- /migrations/20141229012503_00.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | exports.up = function(knex, Promise) { 4 | return knex.schema.createTable('ghprojects', function (table) { 5 | table.string('gh_url').primary(); 6 | table.string('gh_name'); 7 | table.string('gh_description'); 8 | table.string('gh_language'); 9 | }).createTable('hnposts', function (table) { 10 | table.integer('id').primary(); 11 | table.string('gh_url').references('gh_url').inTable('ghprojects'); 12 | table.timestamp('retrievedAt'); 13 | table.string('hn_url'); 14 | table.string('hn_time'); 15 | }); 16 | }; 17 | 18 | exports.down = function(knex, Promise) { 19 | return knex.schema.dropTable('hnposts') 20 | .dropTable('ghprojects'); 21 | }; 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Y-Cloninator 2 | ============ 3 | 4 | Get the best parts of Y-Combinator's Hacker News - the links to awesome github 5 | projects 6 | 7 | Getting started 8 | --------------- 9 | * Install node.js on your system 10 | * Install dependencies 11 | * Run migrations 12 | * Run the app 13 | ```shell 14 | $ npm install 15 | $ npm run migrate 16 | $ npm start 17 | ``` 18 | 19 | Testing 20 | ------- 21 | Tests are run using mocha. 22 | ```shell 23 | $ npm test 24 | ``` 25 | You can also run the jshint linter quite easily: 26 | ```shell 27 | $ npm run lint 28 | ``` 29 | 30 | Configuration 31 | ------------- 32 | Configuration is done using environment variables. Sane defaults are provided 33 | for a dev environment, but require dev dependencies to be installed. 34 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true */ 2 | 'use strict'; 3 | 4 | var express = require('express'); 5 | var nunjucks = require('nunjucks'); 6 | var bodyParser = require('body-parser'); 7 | var knex = require('knex')({ 8 | client: process.env.CLIENT || 'sqlite3', 9 | connection: process.env.DATABASE_URL || { filename: 'dev.sqlite3' } 10 | }); 11 | 12 | var app = express(); 13 | app.use(express.static(__dirname + '/static')); 14 | app.use(bodyParser.json()); 15 | app.use(bodyParser.urlencoded({ extended: true })); 16 | app.set('knex', knex); 17 | 18 | nunjucks.configure('views', { 19 | autoescape: true, 20 | express: app 21 | }); 22 | 23 | var routes = require('./routes')(app); 24 | 25 | app.listen(process.env.PORT || 8000, function () { 26 | console.log('App now listening on %s', process.env.Port || 8000); 27 | }); 28 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Ian Kronquist 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 13 | all 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 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "y-cloninator", 3 | "version": "1.0.0", 4 | "description": "Scrapes HN for github projects", 5 | "main": "app.js", 6 | "scripts": { 7 | "start": "node app.js", 8 | "migrate": "knex migrate:latest", 9 | "worker": "node clock.js", 10 | "lint": "jshint **.js", 11 | "update": "node update-db.js" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/iankronquist/y-cloninator" 16 | }, 17 | "keywords": [ 18 | "hacker", 19 | "news", 20 | "scraper", 21 | "github" 22 | ], 23 | "author": "Ian Kronquist and Evan Tschuy", 24 | "license": "MIT", 25 | "bugs": { 26 | "url": "https://github.com/iankronquist/y-cloninator/issues" 27 | }, 28 | "homepage": "https://github.com/iankronquist/y-cloninator", 29 | "dependencies": { 30 | "body-parser": "^1.10.0", 31 | "express": "^4.10.6", 32 | "follow-redirects": "0.0.3", 33 | "knex": "^0.7.3", 34 | "node-schedule": "^0.1.15", 35 | "nunjucks": "^1.1.0", 36 | "pg": "^4.1.1" 37 | }, 38 | "devDependencies": { 39 | "mocha": "^1.21.3", 40 | "sqlite3": "^3.0.4", 41 | "jshint": "^2.5.11" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /views/base.hjs: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |30 | Some of the best content on Hacker News are the 31 | links to up-and coming projects on GitHub. 32 | Get a list of these awesome projects without the distraction of the rest 33 | of Hacker News. 34 |
35 |22 | Only showing results for the language {{ filter_lang }}. 23 |
24 || 29 | Project Name 30 | | 31 |32 | Description 33 | | 34 |35 | Language 36 | | 37 |38 | Stars 39 | | 40 |41 | Hacker News 42 | | 43 |44 | | 45 |||
| 49 | {{ project.gh_name }} 50 | | 51 |
52 |
53 | {{ project.gh_description }}
54 | |
55 | 56 | {{ project.gh_language }} 57 | | 58 |59 | 🌟 {{project.gh_stars}} 60 | | 61 | {% if project.hn_first_mention_timestamp == project.hn_last_mention_timestamp %} 62 |63 | 64 | Read on HN 65 | 66 | | 67 |68 | | 69 | {% else %} 70 |71 | 72 | Oldest 73 | 74 | | 75 |76 | 77 | Newest 78 | 79 | | 80 | {% endif %} 81 |