Skip to content
Open
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 @@ -4,3 +4,4 @@ secrets
*.swp
*.swo
.env
dist
8 changes: 3 additions & 5 deletions client/js/.jshintrc → client/.jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@
"latedef": true,
"trailing": true,
"undef": true,
"strict": true,
"globalstrict": true,

// Relaxing options
"eqnull": true,
"laxcomma": true,
"lastsemic": true,

// Environment options
"node": false,
"browser": true,
"jquery": true
"node": true,
"browser": true
}

6 changes: 6 additions & 0 deletions client/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

var $ = require('jquery')
, handleFormSubmission = require('./form');

$(document).ready(handleFormSubmission);
12 changes: 6 additions & 6 deletions client/js/rhyme.js → client/form.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
(function() {
"use strict";
'use strict';

var $ = require('jquery');

module.exports = function() {
$('#rhyme-form').on('submit', function(e) {
e.preventDefault();
var rhymeLine = $('#rhyme-line').val();
$.post('/rhyme', {line: rhymeLine}, function(res) {
var poem = [{'text': rhymeLine}].concat(res);
for (var i = 0; i < res.length; i++) {
$('#tweets').append('<li>' + poem[i].text + '</li>');
}
});

return false;
});

}).call(this);
};
14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
"version": "2.0.0",
"private": true,
"scripts": {
"start": "node app.js"
"start": "npm run assets && npm run browserify && node server/app.js",
"assets": "mkdir -p dist && cp -r ./public/* dist/",
"browserify": "mkdir -p ./dist/js && ./node_modules/.bin/browserify -g uglifyify ./client/app.js --debug | ./node_modules/.bin/exorcist ./dist/js/bundle.js.map > ./dist/js/bundle.js"
},
"dependencies": {
"bluebird": "^1.1.0",
"browserify": "^8.1.1",
"dotenv": "^0.2.5",
"exorcist": "^0.1.6",
"express": "^3.4.8",
"jquery": "^2.1.3",
"mongodb": "^1.3.23",
"request": "^2.34.0",
"twitter": "^0.2.9",
"mongodb": "^1.3.23",
"bluebird": "^1.1.0",
"dotenv": "^0.2.5"
"uglifyify": "^3.0.1"
}
}
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
3 changes: 1 addition & 2 deletions client/index.html → public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<head>
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.4.2/pure-min.css">
<link rel="stylesheet" href="/css/style.css">
<script src="/js/bundle.js" async></script>
</head>
<body>
<div class='pure-g body-container'>
Expand Down Expand Up @@ -30,7 +31,5 @@ <h2>Automated poetry for tweets</h2>
<p>Give me a line, and I'll rhyme it for you.</p>
</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="/js/rhyme.js"></script>
</body>
</html>
11 changes: 5 additions & 6 deletions app.js → server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@ require('dotenv').load();
* Module dependencies
*/
var express = require('express')
, storage = require('./server/storage')
, dictionary = require('./server/dictionary')
, rhymes = require('./server/rhymes')
, twitter = require('./server/twitter')
, storage = require('./storage')
, dictionary = require('./dictionary')
, rhymes = require('./rhymes')
, twitter = require('./twitter')
, app = express();

/**
* Configure app
*/
app.set('views', __dirname + '/views');
app.use(express.favicon());
app.use(express.static(__dirname + '/client'));
app.use(express.static(__dirname + '/../dist'));
app.use(express.bodyParser());

/**
Expand Down
1 change: 1 addition & 0 deletions server/twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var twitter = new Twitter({

/**
* Create a prototype for Tweets
* @constructor
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be part of this commit in an ideal world, but whatever.

*/
function Tweet(id, text, user, avatar) {
this.id = id;
Expand Down