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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ node_modules

venv
*.pyc
.env
.env
static
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Quickipedia

When two web development students collaborate for a one day hackaton you get Quickipedia!
[quickipedia.herokuapp.com](quickipedia.herokuapp.com)

When two web development students collaborate for a one day hackathon you get Quickipedia!

Sometimes you don't have time to read through an entire Wikipedia article, or, let's be honest, even the summary. Quickipedia summarizes the summary!

Expand All @@ -16,6 +18,6 @@ Sometimes you don't have time to read through an entire Wikipedia article, or, l

## Up Next:

- Display random when search has no results
- ~~Display random when search has no results~~
- Use local storage to store summaries
- List related articles
2 changes: 0 additions & 2 deletions assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
<title>Quikipedia</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" media="screen" href="//netdna.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<!-- <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css"> -->
<!-- <link rel="stylesheet" type="text/css" href="//cdn.bootcss.com/animate.css/3.4.0/animate.min.css"> -->
<link href='https://fonts.googleapis.com/css?family=Josefin+Sans' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="css/styles.css">
</head>
Expand Down
22 changes: 11 additions & 11 deletions assets/js/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,43 @@ var SearchForm = require('./SearchForm');
var Header = require('./Header');
var SearchResult = require('./SearchResult');

var TuneSearch = React.createClass({
var Search = React.createClass({
getInitialState: function(){
return {
searchTerm:'',
results: {},
// Status tells what is happening
status: 'What can we learn about today...',
// Optional msg to indicate that something unexpected happened (no results, etc)
msg: ''
};
},
componentDidMount: function() {
this.wikiSearch(false);
},
// conducts search for article to summarize, either specific or random (no result reverts to random)
wikiSearch: function(value){
this.setState({searchTerm: value,status: 'Let me take a few seconds to summarize that for you...'});
console.log('value is', value);
console.log('message', this.state.msg);

console.log('search term is', this.state.searchTerm);

// finding a way to use "bind" here would be better, but for now, set "self" to store "this"
var self = this;
var ajax = new XMLHttpRequest();
// specifies what happens when data has loaded
ajax.addEventListener('load',function(){
try {
var data = JSON.parse(this.responseText);
console.log(data)
self.setState({results:data,status:data.msg,msg:''});
if (data.msg) {
console.log('logged');
// response when user enters text that does not match an exact Wikipedia result
self.setState({msg: "Sorry, we couldn't find a Wikipedia article matching your search. But maybe you'll find this interesting..."})
// restarts search, but for random article
self.wikiSearch(false);
}
} catch(e) {
// in case of any unexpected errors
self.setState({results:{},status:"Sorry, we couldn't find a Wikipedia article matching your search."});
}
});
// console.log('value is', value === true);

// determines whether to try to get random or specific article; api data from backend is delivered to these routes
var url = (typeof value === 'string') ? '/summary?q=' + value : '/random';
ajax.open('GET',url);
ajax.send();
Expand All @@ -59,5 +59,5 @@ var TuneSearch = React.createClass({
}
});

module.exports = TuneSearch;
module.exports = Search;

1 change: 1 addition & 0 deletions assets/js/components/Header.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var React = require('react');

// Basic header for page
module.exports = React.createClass({
render: function() {
return (
Expand Down
1 change: 1 addition & 0 deletions assets/js/components/RandomSearch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var React = require('react');

// Handles button to trigger random search
module.exports = React.createClass({
render: function() {
return (
Expand Down
9 changes: 5 additions & 4 deletions assets/js/components/SearchForm.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
var React = require('react');
var RandomSearch = require('./RandomSearch');

// handles search input, search button and random button (pulling in RandomSearch component)
module.exports = React.createClass({
propTypes:{
onUpdate: React.PropTypes.func.isRequired
},
update: function(e){
console.log('update')
e.preventDefault();
// gets search term through accessing the node affiliated with the ref "textInput"
var value = this.refs.textInput.getDOMNode().value;
// passes search term to onUpdate as "value"
this.props.onUpdate(value);
},
random: function(e){
console.log('random');
e.preventDefault();
var value = false;
this.props.onUpdate(value);
// Passes "false" instead of search term value, so that in App.js a "random" article is requested
this.props.onUpdate(false);
},
render: function(){
return (
Expand Down
3 changes: 2 additions & 1 deletion assets/js/components/SearchResult.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
var React = require('react');

// displays results
module.exports = React.createClass({
render: function() {
var hide = 'nothing'
var hide = 'nothing';
return (
<div className={"search-result " + hide}>
<h2><a target="_blank" title="Read the details on Wikipedia" href={this.props.data.link}>{this.props.data.title}</a></h2>
Expand Down
2 changes: 0 additions & 2 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
<title>Quikipedia</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" media="screen" href="//netdna.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<!-- <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css"> -->
<!-- <link rel="stylesheet" type="text/css" href="//cdn.bootcss.com/animate.css/3.4.0/animate.min.css"> -->
<link href='https://fonts.googleapis.com/css?family=Josefin+Sans' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="css/styles.css">
</head>
Expand Down
40 changes: 22 additions & 18 deletions static/js/main.js

Large diffs are not rendered by default.