Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Home Landing Page #462

Merged
merged 6 commits into from
Aug 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.DS_Store
node_modules
npm-debug.log
package-lock.json
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: node_js
node_js:
- "node"
4 changes: 2 additions & 2 deletions careers.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<li class="ph4 di-l pv2 tl pv0-l"><a href="/team" class="white link">Team</a></li>
<li class="ph4 dib-l pv2 tl pv0-l"><a href="/time-app" class="white link">App
<span class="dwyl-bg-gold pa1 br2 f7">BETA</span></a></li>
<li class="ph4 di-l pv2 tl pv0-l"><a href="/blog" class="white link">Blog</a></li>
<!-- <li class="ph4 di-l pv2 tl pv0-l"><a href="/blog" class="white link">Blog</a></li> -->
<li class="ph4 di-l pt2 pb3 tl pv0-l"><a href="#contact" id="contact-link" class="white link">Contact</a></li>
</ul>
</nav>
Expand Down Expand Up @@ -184,7 +184,7 @@ <h2>We will get back to you soon!</h2>
<li class="ph4 fw3 f6 dib-ns pv2"><a href="/careers" class="white link">Careers</a></li>
<div class="dib">
<li class="ph4 fw3 f6 dib-ns pv2"><a href="/community" class="white link">Community</a></li>
<li class="ph4 fw3 f6 dib-ns pv2"><a href="/blog" class="dwyl-mint link">Blog</a></li>
<!-- <li class="ph4 fw3 f6 dib-ns pv2"><a href="/blog" class="dwyl-mint link">Blog</a></li> -->
</div>
</ul>
<a href="https://twitter.com/dwyl" class="link f0" >
Expand Down
4 changes: 2 additions & 2 deletions community.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<li class="ph4 di-l pv2 tl pv0-l"><a href="/team" class="dwyl-dark-gray link">Team</a></li>
<li class="ph4 dib-l pv2 tl pv0-l"><a href="/time-app" class="dwyl-dark-gray link">App
<span class="dwyl-bg-yellow fw3 pa1 br2 f7 shadow-6">BETA</span></a></li>
<li class="ph4 di-l pv2 tl pv0-l"><a href="/blog" class="dwyl-dark-gray link">Blog</a></li>
<!-- <li class="ph4 di-l pv2 tl pv0-l"><a href="/blog" class="dwyl-dark-gray link">Blog</a></li> -->
<li class="ph4 di-l pt2 pb3 tl pv0-l"><a href="#contact" id="contact-link" class="dwyl-dark-gray link">Contact</a></li>
</ul>
</nav>
Expand Down Expand Up @@ -149,7 +149,7 @@ <h2>We will get back to you soon!</h2>
<li class="ph4 fw3 f6 dib-ns pv2"><a href="/careers" class="white link">Careers</a></li>
<div class="dib">
<li class="ph4 fw3 f6 dib-ns pv2"><a href="/community" class="white link">Community</a></li>
<li class="ph4 fw3 f6 dib-ns pv2"><a href="/blog" class="dwyl-mint link">Blog</a></li>
<!-- <li class="ph4 fw3 f6 dib-ns pv2"><a href="/blog" class="dwyl-mint link">Blog</a></li> -->
</div>
</ul>
<a href="https://twitter.com/dwyl" class="link f0" >
Expand Down
Empty file added home.html
Empty file.
26 changes: 26 additions & 0 deletions home/compile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
var fs = require('fs');
var http_request = require('./http_request');
var cheerio = require('cheerio');

// Adding Colors to Terminal *Without* a Library/Module
var bgRedBlack = '\x1b[41m\x1b[30m';
var bgGreenBlack = '\x1b[42m\x1b[30m';
var RESET = '\x1b[0m'; // see: https://stackoverflow.com/a/41407246/1148249
var URL = 'https://github.com/nelsonic/home/blob/master/README.md';

http_request(URL, function (status, html) {
if (status !== 200 || !html) {
console.log(bgRedBlack,
" - - - GitHub Scraper FAIL >> " + URL + " - - - ", RESET);
process.exit();
}
else {
var $ = cheerio.load(html);
var body = $('#readme').html()
var css = fs.readFileSync('./style.css', 'utf8');
var template = fs.readFileSync('./template.html', 'utf8');
var out = template.replace('{css}', css).replace('{content}', body);
fs.writeFileSync('./index.html', out, 'utf8');
console.log(bgGreenBlack, 'done.', RESET);
}
});
48 changes: 48 additions & 0 deletions home/http_request.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use strict';

var http = require('https'); // ALWAYS use TLS over the internets!
var bgRedBlack = '\x1b[41m\x1b[30m';
var RESET = '\x1b[0m'; // see: https://stackoverflow.com/a/41407246/1148249
/**
* simple_http_request is a bare-bones http request using node.js core http
* see: https://nodejs.org/api/http.html#http_http_request_options_callback
* the NPM request module is 3.6 Megabytes and offers v. little benefit ...
* This code achieves the same in less than 1kb. less code = faster response.
* @param {Object} path - the path (on GitHub) we want to "view"
* @param {Function} callback - a standard callback with error & response args
* response is a JSON Object unless there is an error.
*/

module.exports = function simple_http_request (path, callback) {

var options = {
headers: {
'Accept': 'text/html',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36'
},
hostname: 'github.com',
port: '443',
path: path
}

http.request(options, function (res) {
var resStr = '';
var response;
// console.log(res.statusCode);
if (res.statusCode !== 200) {
console.log(bgRedBlack, ' GOT ', res.statusCode, ' for ', options, RESET);
return callback(res.statusCode);
}

res.setEncoding('utf8');
res.on('data', function (chunk) {
// console.log(chunk);
resStr += chunk;
}).on('end', function () {
return callback(res.statusCode, resStr); // return response as HTML!
});

return true;
}).end();

};
Loading