Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Administrator
committed
Dec 16, 2014
1 parent
5a19c4e
commit be96fa2
Showing
101 changed files
with
9,149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1. Please make sure you maintain current code style |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: ./node_modules/.bin/forever -m 5 server.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
var cache = require('memory-cache'); | ||
var request = require('request'); | ||
var CronJob = require('cron').CronJob; | ||
var _ = require('lodash'); | ||
var utils = require('../../lib/utils'); | ||
var awes = utils.awes(); | ||
|
||
|
||
exports.index = function (req, res){ | ||
var aweCookie = req.cookies.awec; | ||
var recents = aweCookie? JSON.parse(aweCookie) : []; | ||
res.render('index', { | ||
title: 'Home', | ||
recents: recents | ||
}); | ||
}; | ||
|
||
function processCookie(req, res) { | ||
var awe = req.param('awe'); | ||
var aweCookie = req.cookies.awec; | ||
var maxAge = 7*24*60*60*1000; | ||
|
||
if (!aweCookie) { | ||
var arr = []; | ||
arr.push(awe); | ||
res.cookie('awec', JSON.stringify(arr), { maxAge: maxAge, httpOnly: true }); | ||
} else { | ||
var existings = JSON.parse(aweCookie); | ||
if (!_.contains(existings, awe)) { | ||
if (existings.length < 3) { | ||
existings.push(awe); | ||
res.cookie('awec', JSON.stringify(existings), { maxAge: maxAge, httpOnly: true }); | ||
} else { | ||
var arr = []; | ||
arr.push(existings[1]); | ||
arr.push(existings[2]); | ||
arr.push(awe); | ||
res.cookie('awec', JSON.stringify(arr), { maxAge: maxAge, httpOnly: true }); | ||
} | ||
} | ||
} | ||
} | ||
|
||
exports.get = function (req, res){ | ||
var awe = req.param('awe'); | ||
var post = cache.get(awe); | ||
|
||
if (!awes[awe]) return res.render('404'); | ||
|
||
processCookie(req, res); | ||
var aweCookie = req.cookies.awec; | ||
var recents = aweCookie? JSON.parse(aweCookie) : []; | ||
|
||
if (!post) { | ||
var elem = awes[awe]; | ||
return cacheGit(elem.url, elem.start, elem.end, awe, function(content){ | ||
if (content) { | ||
new CronJob('* * 1 * * *', function(){ | ||
cacheGit(elem.url, elem.start, elem.end, awe, null); | ||
}, null, true, null); | ||
res.render('get', { | ||
title: awe, | ||
article: content, | ||
recents: recents, | ||
awe: awe | ||
}); | ||
} | ||
}) | ||
} | ||
|
||
res.render('get', { | ||
title: awe, | ||
article: post, | ||
recents: recents, | ||
awe: awe | ||
}); | ||
}; | ||
|
||
function cacheGit (url, start, end, key, done) { | ||
request(url, function (error, response, body) { | ||
var content; | ||
if (!error && response.statusCode == 200) { | ||
var arr = body.split('\n'); | ||
// remove github toc. | ||
arr.splice(start, end); | ||
content = arr.join('\n'); | ||
cache.put(key, content ); | ||
} | ||
done(content); | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% extends 'layouts/default.html' %} | ||
|
||
{% block content %} | ||
<h2>404 - Not found</h2> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{% extends 'layouts/default.html' %} | ||
|
||
{% block content %} | ||
<h2>500 - Oops! Internal server error occured</h2> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
{% if (env == 'development') %} | ||
<pre> | ||
{{ error }} | ||
</pre> | ||
{% endif %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{% extends 'layouts/default.html' %} | ||
|
||
{% block content %} | ||
<div class="row"> | ||
<div class="col-md-2"> | ||
{% include 'includes/left.html' %} | ||
</div> | ||
<div class="col-md-7"> | ||
<article> | ||
{{ md(article) }} | ||
</article> | ||
</div> | ||
<div class="col-md-3"> | ||
<div id="sidebar" class="toc"></div> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
<title>{{ title }} | {{ pkg.name }}</title> | ||
<meta name="keywords" content="{{ pkg.keywords.join(',') }}"> | ||
<meta name="description" content="{{ pkg.description }}"> | ||
{% block head %} | ||
{# Styles #} | ||
{{ css('styles') }} | ||
{% endblock %} | ||
</head> | ||
|
||
{# HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries #} | ||
<!--[if lt IE 9]> | ||
<script src='https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js'></script> | ||
<script src='https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js'></script> | ||
<![endif]--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<nav role="navigation" class="navbar navbar-default navbar-fixed-top"> | ||
<div class="container"> | ||
<div class="navbar-header"> | ||
<button type="button" data-toggle="collapse" data-target=".navbar-collapse" class="navbar-toggle"> | ||
<span class="sr-only">Toggle navigation</span> | ||
<span class="icon-bar"></span> | ||
<span class="icon-bar"></span> | ||
<span class="icon-bar"></span> | ||
</button> | ||
<a href="/" class="navbar-brand">getAwesomeness()</a> | ||
</div> | ||
<div class="collapse navbar-collapse"> | ||
{% if (recents.length) %} | ||
<ul class="nav navbar-nav"> | ||
{% for r in recents %} | ||
<li class="{% if (r == awe) %}active{% endif %}"><a href="{{ '/get/' + r }}">{{ getAwesomeName(r) }}</a></li> | ||
{% endfor %} | ||
</ul> | ||
{% endif %} | ||
<ul class="nav navbar-nav navbar-right"> | ||
<li> | ||
<a href="https://www.gratipay.com/panzhangwang/"><img src="https://img.shields.io/gratipay/panzhangwang.svg?style=flat" alt="Gittip" data-canonical-src="https://img.shields.io/gratipay/panzhangwang.svg?style=flat" style="max-width:100%;"></a> | ||
</li> | ||
<li> | ||
<iframe src="http://ghbtns.com/github-btn.html?user=panzhangwang&repo=getawesomeness&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110" height="45" style="padding: 15px 0 0 15px;"></iframe> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</nav> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<div id="leftbar"> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">General</div> | ||
<div class="list-group"> | ||
<a class="list-group-item {% if (awe == 'go') %}active{% endif %}" href="/get/go">Go</a> | ||
<a class="list-group-item" href="#">Link</a> | ||
<a class="list-group-item" href="#">Link</a> | ||
</div> | ||
</div> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Scripting</div> | ||
<div class="list-group"> | ||
<a class="list-group-item" href="#">Link</a> | ||
<a class="list-group-item" href="#">Link</a> | ||
<a class="list-group-item" href="#">Link</a> | ||
</div> | ||
</div> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">JVM</div> | ||
<div class="list-group"> | ||
<a class="list-group-item" href="#">Link</a> | ||
<a class="list-group-item" href="#">Link</a> | ||
</div> | ||
</div> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Domain Specific</div> | ||
<div class="list-group"> | ||
<a class="list-group-item" href="#">Link</a> | ||
<a class="list-group-item" href="#">Link</a> | ||
</div> | ||
</div> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Functional</div> | ||
<div class="list-group"> | ||
<a class="list-group-item" href="#">Link</a> | ||
<a class="list-group-item" href="#">Link</a> | ||
</div> | ||
</div> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Web</div> | ||
<div class="list-group"> | ||
<a class="list-group-item {% if (awe == 'php') %}active{% endif %}" href="/get/php">PHP</a> | ||
<a class="list-group-item" href="#">Link</a> | ||
</div> | ||
</div> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Mobile</div> | ||
<div class="list-group"> | ||
<a class="list-group-item" href="#">Link</a> | ||
<a class="list-group-item" href="#">Link</a> | ||
</div> | ||
</div> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Frontend</div> | ||
<div class="list-group"> | ||
<a class="list-group-item" href="#">Link</a> | ||
<a class="list-group-item" href="#">Link</a> | ||
</div> | ||
</div> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Backend</div> | ||
<div class="list-group"> | ||
<a class="list-group-item" href="#">Link</a> | ||
<a class="list-group-item" href="#">Link</a> | ||
</div> | ||
</div> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Dynamic</div> | ||
<div class="list-group"> | ||
<a class="list-group-item" href="#">Link</a> | ||
<a class="list-group-item" href="#">Link</a> | ||
</div> | ||
</div> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Editors</div> | ||
<div class="list-group"> | ||
<a class="list-group-item" href="#">Link</a> | ||
<a class="list-group-item" href="#">Link</a> | ||
</div> | ||
</div> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Self-education</div> | ||
<div class="list-group"> | ||
<a class="list-group-item" href="#">Link</a> | ||
<a class="list-group-item" href="#">Link</a> | ||
</div> | ||
</div> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Data</div> | ||
<div class="list-group"> | ||
<a class="list-group-item" href="#">Link</a> | ||
<a class="list-group-item" href="#">Link</a> | ||
</div> | ||
</div> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Dev Tools</div> | ||
<div class="list-group"> | ||
<a class="list-group-item" href="#">Link</a> | ||
<a class="list-group-item" href="#">Link</a> | ||
</div> | ||
</div> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Another</div> | ||
<div class="list-group"> | ||
<a class="list-group-item" href="#">Link</a> | ||
<a class="list-group-item" href="#">Link</a> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{% extends 'layouts/default.html' %} | ||
|
||
{% block content %} | ||
<div class="row"> | ||
<div class="col-md-2"> | ||
{% include 'includes/left.html' %} | ||
</div> | ||
<div class="col-md-10"> | ||
<div class="jumbotron"> | ||
<h1>Use getAwesomeness()</h1> | ||
<p>To retrieve all amazing awesomeness on Github in one shot!</p> | ||
</div> | ||
<div class="row"> | ||
<div class="col-sm-6"> | ||
<h2>Features</h2> | ||
<ul> | ||
<li>Designed for all developers.</li> | ||
<li>All awesomeness in a single place, simple layout.</li> | ||
<li>Better organization on awesomeness category.</li> | ||
<li>Easier navigation between categories or table of contents.</li> | ||
<li>Content automaticly synchronized with github.</li> | ||
<li>No hassle! No login! No database!</li> | ||
<li>Open source and use for free.</li> | ||
</ul> | ||
|
||
<h2>Honors</h2> | ||
<ul> | ||
<li>bayandin, <a href="https://github.com/bayandin/awesome-awesomeness">awesome-awesomeness</a></li> | ||
<li>avelino, <a href="https://github.com/avelino/awesome-go">awesome-go</a> </li> | ||
<li>ziadoz, <a href="https://github.com/ziadoz/awesome-php">awesome-php</a> </li> | ||
</ul> | ||
|
||
<h2>Guide</h2> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{% include '../includes/head.html' %} | ||
|
||
<body> | ||
{% include '../includes/header.html' %} | ||
<div class="container"> | ||
{% block content %}{% endblock %} | ||
</div> | ||
{{ js('application') }} | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var path = require('path'); | ||
var extend = require('util')._extend; | ||
|
||
var development = require('./env/development'); | ||
var test = require('./env/test'); | ||
var production = require('./env/production'); | ||
|
||
var defaults = { | ||
root: path.normalize(__dirname + '/..') | ||
}; | ||
|
||
/** | ||
* Expose | ||
*/ | ||
|
||
module.exports = { | ||
development: extend(development, defaults), | ||
test: extend(test, defaults), | ||
production: extend(production, defaults) | ||
}[process.env.NODE_ENV || 'development']; |
Oops, something went wrong.