diff --git a/Gruntfile.js b/Gruntfile.js index b5979a5..b98b0df 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -70,7 +70,7 @@ module.exports = function (grunt) { '<%= config.app %>/images/{,*/}*', '.tmp/scripts/{,*/}*.js' ], - port: 9000, + port: 8000, server: { baseDir: ['.tmp', config.app], routes: { diff --git a/README.md b/README.md new file mode 100644 index 0000000..0e98bd3 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +### Installation: + +* Install [Homebrew](http://brew.sh/): ```ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"``` you may need to run ```ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"``` and make certain that your user has administrative rights for the file system + - Make sure everything is running smoothly with ```brew doctor``` +* Install [Node](http://nodejs.org/): ```brew install node``` +* Install [Grunt-Cli](http://gruntjs.com/): ```npm install -g grunt-cli``` +* Install [Bower](http://bower.io/): ```npm install -g bower``` +* Install packages by running ```npm install && bower install``` + +#### Grunt Commands + +* `grunt serve` - This will give you a local development instance to work from and open the site in a local server. +* `grunt build` - This will build a deployable version of the app. diff --git a/app/index.html b/app/index.html index e945475..38ac497 100644 --- a/app/index.html +++ b/app/index.html @@ -18,18 +18,15 @@ - - - -
+
+
+ +
+
+
+
+ + + - -

GOOGLE TRENDS

- - - +
+
+ - - - - -
-

Twitter Results

- -
- - - - - - - -<<<<<<< HEAD - - - - - - - - - - + + + @@ -205,7 +185,6 @@

Twitter Results

- diff --git a/app/scripts/main.js b/app/scripts/main.js index 9521a1e..b5a4567 100644 --- a/app/scripts/main.js +++ b/app/scripts/main.js @@ -1,7 +1,146 @@ -// jshint devel:true -console.log('\'Allo \'Allo!'); - // load nytimes: $(document).ready(function() { - nyt('obamacare'); + nyt('digital privacy'); +}); + +// React app +function get( src, query ) { + return new Promise( (res, rej) => { + const request = new XMLHttpRequest(); + let url; + + if ( src === 'sunlight') { + url = 'https://congress.api.sunlightfoundation.com/documents/search?' + + 'query=' + query + '&apikey=18a4e7908bc444e8a506f970d12f1a5a'; + } + + request.open('GET', url, true); + //TODO: Figure out why API key isn't passing and getting 200 response. + // request.setRequestHeader('X-APIKEY', '18a4e7908bc444e8a506f970d12f1a5a'); + + request.onload = ()=> { + if (request.status >= 200 && request.status < 400) { + // Success! + var data = JSON.parse(request.response); + res( data ); + } else { + // We reached our target server, but it returned an error + rej( console.warn(request.statusText) ); + } + }; + + request.onerror = ()=> { + // There was a connection error of some sort + rej( console.error('Failed Network Connection') ); + }; + + request.send(); + }); +} + +const Loader = React.createClass({ + propTypes: { + showContentWhen: React.PropTypes.bool.isRequired + }, + render () { + if ( this.props.showContentWhen ) { + return
{ this.props.children }
; + } else { + return
Loading...
; + }; + } }); + +const SearchForm = React.createClass({ + getInitialState () { + return { + submitted: false, + search: '' + }; + }, + handleClick: function(event) { + this.setState({ + submitted: true, + search: '' + }); + }, + getFormData: function() { + let data = { + search: this.refs.search_terms.getDOMNode().value + // , geoLocation: this.refs.location.getDOMNode().value + } + + return data + }, + render () { + // TODO: Add location based searches + //
+ // + //
+ return ( +
+
+ +
+ +
+ ) + } +}); + +const SunlightWidget = React.createClass({ + getInitialState () { + return { + noData: true, + loading: true, + results: [] + }; + }, + componentDidMount () { + new Promise( ( resolve, reject )=> { + get( 'sunlight', 'Digital Privacy' ).then( + ( data )=> { + if ( !data ) { return; } + + return resolve( data.results ); + }, + ( err ) => { + return reject( console.error( 'Failed!', err ) ); + } + ); + }).then( ( results )=> { + this.setState({ + noData: false, + loading: false, + results: results.map( + (item, i)=> { + return
  • { item.title }
  • + } + ) + }); + }); + }, + render () { + let defaultText = 'This widget searchs documents including the Government Accountability Office (GAO) Reports' + + ' and Inspector General Reports. These government oversight documents investigate misconduct,' + + ' waste and programs.' + return ( +
    +
    GAO Documents (provided by the Sunlight Foundation)
    +

    { defaultText }

    + + { this.state.noData ?

    No Results

    + : } +
    +
    + ); + } +}); + +// React.render( +// , document.getElementById('form-search') +// ); + +React.render( + , document.getElementById('sl-widget') +); diff --git a/bower.json b/bower.json index bbc868d..cbbc0db 100644 --- a/bower.json +++ b/bower.json @@ -4,7 +4,8 @@ "dependencies": { "bootstrap-sass": "~3.3.5", "underscore": "1.8.3", - "moment": "2.10.3" + "moment": "2.10.3", + "react": "~0.13.3" }, "overrides": { "bootstrap-sass": { diff --git a/package.json b/package.json index f25bca1..e334fba 100644 --- a/package.json +++ b/package.json @@ -45,5 +45,9 @@ "single" ] } + }, + "dependencies": { + "babel-core": "^5.6.18", + "react": "^0.13.3" } }