mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-19 18:32:39 +00:00
Trying out a reddit share button, looks promising
This commit is contained in:
@@ -11,6 +11,8 @@ var PageContainer = require('../pageContainer/pageContainer.jsx');
|
|||||||
var Nav = require('naturalCrit/nav/nav.jsx');
|
var Nav = require('naturalCrit/nav/nav.jsx');
|
||||||
var Navbar = require('../navbar/navbar.jsx');
|
var Navbar = require('../navbar/navbar.jsx');
|
||||||
|
|
||||||
|
var RedditShare = require('../navbar/redditShare.navitem.jsx');
|
||||||
|
|
||||||
var SplitPane = require('../splitPane/splitPane.jsx');
|
var SplitPane = require('../splitPane/splitPane.jsx');
|
||||||
|
|
||||||
|
|
||||||
@@ -59,6 +61,8 @@ var HomePage = React.createClass({
|
|||||||
return(
|
return(
|
||||||
<div className='homePage page'>
|
<div className='homePage page'>
|
||||||
<Navbar>
|
<Navbar>
|
||||||
|
<RedditShare brew={{text : this.state.text}}/>
|
||||||
|
|
||||||
<Nav.item
|
<Nav.item
|
||||||
newTab={true}
|
newTab={true}
|
||||||
href='https://github.com/stolksdorf/naturalcrit/issues'
|
href='https://github.com/stolksdorf/naturalcrit/issues'
|
||||||
@@ -82,7 +86,7 @@ var HomePage = React.createClass({
|
|||||||
|
|
||||||
<div className='content'>
|
<div className='content'>
|
||||||
<SplitPane>
|
<SplitPane>
|
||||||
<CodeEditor language='gfm' value={this.state.text} onChange={this.handleTextChange} />
|
<CodeEditor wrap={true} language='gfm' value={this.state.text} onChange={this.handleTextChange} />
|
||||||
<div>{this.state.text}</div>
|
<div>{this.state.text}</div>
|
||||||
</SplitPane>
|
</SplitPane>
|
||||||
|
|
||||||
|
|||||||
52
client/homebrew/navbar/redditShare.navitem.jsx
Normal file
52
client/homebrew/navbar/redditShare.navitem.jsx
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
var React = require('react');
|
||||||
|
var _ = require('lodash');
|
||||||
|
var cx = require('classnames');
|
||||||
|
|
||||||
|
var striptags = require('striptags');
|
||||||
|
|
||||||
|
var Nav = require('naturalCrit/nav/nav.jsx');
|
||||||
|
|
||||||
|
const MAX_URL_SIZE = 2083;
|
||||||
|
const MAIN_URL = "https://www.reddit.com/r/UnearthedArcana/submit?selftext=true"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var RedditShare = React.createClass({
|
||||||
|
getDefaultProps: function() {
|
||||||
|
return {
|
||||||
|
brew : {
|
||||||
|
desc : '',
|
||||||
|
sharedId : '',
|
||||||
|
text : ''
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
getText : function(){
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
handleClick : function(){
|
||||||
|
var url = [
|
||||||
|
MAIN_URL,
|
||||||
|
'title=' + encodeURIComponent(this.props.brew.desc ? this.props.brew.desc : 'Check out my brew!'),
|
||||||
|
|
||||||
|
'text=' + encodeURIComponent(this.props.brew.text)
|
||||||
|
|
||||||
|
|
||||||
|
].join('&');
|
||||||
|
|
||||||
|
window.open(url, '_blank');
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
render : function(){
|
||||||
|
return <Nav.item icon='fa-reddit' color='red' onClick={this.handleClick}>
|
||||||
|
share on reddit
|
||||||
|
</Nav.item>
|
||||||
|
},
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = RedditShare;
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
"react": "^15.0.2",
|
"react": "^15.0.2",
|
||||||
"react-dom": "^15.0.2",
|
"react-dom": "^15.0.2",
|
||||||
"shortid": "^2.2.4",
|
"shortid": "^2.2.4",
|
||||||
|
"striptags": "^2.1.1",
|
||||||
"superagent": "^1.6.1",
|
"superagent": "^1.6.1",
|
||||||
"vitreum": "^3.2.1"
|
"vitreum": "^3.2.1"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,20 +15,6 @@ var HomebrewSchema = mongoose.Schema({
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
HomebrewSchema.options.toJSON.transform = function (doc, ret, options) {
|
|
||||||
delete ret._id;
|
|
||||||
delete ret.__t;
|
|
||||||
delete ret.__v;
|
|
||||||
}
|
|
||||||
HomebrewSchema.options.toObject.transform = function (doc, ret, options) {
|
|
||||||
delete ret._id;
|
|
||||||
delete ret.__t;
|
|
||||||
delete ret.__v;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
var Homebrew = mongoose.model('Homebrew', HomebrewSchema);
|
var Homebrew = mongoose.model('Homebrew', HomebrewSchema);
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ var CodeEditor = React.createClass({
|
|||||||
return {
|
return {
|
||||||
language : '',
|
language : '',
|
||||||
value : '',
|
value : '',
|
||||||
|
wrap : false,
|
||||||
onChange : function(){},
|
onChange : function(){},
|
||||||
onCursorActivity : function(){},
|
onCursorActivity : function(){},
|
||||||
};
|
};
|
||||||
@@ -27,6 +28,7 @@ var CodeEditor = React.createClass({
|
|||||||
this.codeMirror = CodeMirror(this.refs.editor,{
|
this.codeMirror = CodeMirror(this.refs.editor,{
|
||||||
value : this.props.value,
|
value : this.props.value,
|
||||||
lineNumbers: true,
|
lineNumbers: true,
|
||||||
|
lineWrapping : this.props.wrap,
|
||||||
mode : this.props.language
|
mode : this.props.language
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -34,7 +36,7 @@ var CodeEditor = React.createClass({
|
|||||||
this.codeMirror.on('cursorActivity', this.handleCursorActivity);
|
this.codeMirror.on('cursorActivity', this.handleCursorActivity);
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillReceiveProps: _.debounce((nextProps)=>{
|
componentWillReceiveProps: _.debounce(function(nextProps){
|
||||||
if(this.codeMirror && nextProps.value !== undefined && this.codeMirror.getValue() != nextProps.value) {
|
if(this.codeMirror && nextProps.value !== undefined && this.codeMirror.getValue() != nextProps.value) {
|
||||||
this.codeMirror.setValue(nextProps.value);
|
this.codeMirror.setValue(nextProps.value);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user