content: import React from 'react'
  import request from 'superagent'
  import $ from 'jquery'
  
  const AddLink = React.createClass({
  	getInitialState() {
  	    return {
  	      url: '',
  	      title: '',
  	      description: '',
  	      image: '',
  	      bookmarks: []
  	    };
  	},
  	handleSubmit(event) {
    		event.preventDefault()
    		const self = this
    		const link = this.refs.link.value
    		const re = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$/i
  		const url  = location.origin + '/api/scrape'
  		const data = { url: link }
  
  		if (!re.test(link)) { 
  		    alert("url error");
  		    return false;
  		}
    		else {
    			request.post(url)
    			       .send(data)
    			       .end(function(err, res){
    			       		const data = $.parseJSON(res.text);
  				       	self.setState({title: data.title, description: data.description, image: data.image});
  			     	});
    		}
    	},
  	render() {
  		
  		return (
  			<div className="modal-background">
  				<form onSubmit={this.handleSubmit}>
  					<div className="form-group">
  						<input ref="link" type="text" className="form-control" id="article-link" placeholder="Article URL" />
  					</div>
  					<div className="form-group">
  						<input type="submit" className="btn btn-success" value="Bookmark" />
  					</div>
  				</form>
  				<div>
  					<h1>{this.state.title}</h1>
  					<p>{this.state.description}</p>
  					<img src={this.state.image}/>
  				</div>
  			</div>
  		);
  	}
  })
  
  export default AddLink;