diff --git a/client/homebrew/navbar/issue.navitem.jsx b/client/homebrew/navbar/issue.navitem.jsx index b78ca831f..ffa235a94 100644 --- a/client/homebrew/navbar/issue.navitem.jsx +++ b/client/homebrew/navbar/issue.navitem.jsx @@ -1,51 +1,8 @@ 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 : { - title : '', - sharedId : '', - text : '' - } - }; - }, - - getText : function(){ - - }, - - - handleClick : function(){ - var url = [ - MAIN_URL, - 'title=' + encodeURIComponent(this.props.brew.title ? this.props.brew.title : 'Check out my brew!'), - - 'text=' + encodeURIComponent(this.props.brew.text) - - - ].join('&'); - - window.open(url, '_blank'); - }, - - - render : function(){ - return - share on reddit - - }, - -}); - -module.exports = RedditShare; \ No newline at end of file +module.exports = function(props){ + return + report issue + +}; \ No newline at end of file diff --git a/client/homebrew/navbar/navbar.less b/client/homebrew/navbar/navbar.less index d95678c45..38902b2e9 100644 --- a/client/homebrew/navbar/navbar.less +++ b/client/homebrew/navbar/navbar.less @@ -19,7 +19,7 @@ margin : 0; padding : 2px; width : 250px; - background-color : #333; + background-color : #444; font-family : 'Open Sans', sans-serif; font-size : 12px; font-weight : 800; diff --git a/client/homebrew/navbar/print.navitem.jsx b/client/homebrew/navbar/print.navitem.jsx index b78ca831f..f4c081e10 100644 --- a/client/homebrew/navbar/print.navitem.jsx +++ b/client/homebrew/navbar/print.navitem.jsx @@ -1,51 +1,8 @@ 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 : { - title : '', - sharedId : '', - text : '' - } - }; - }, - - getText : function(){ - - }, - - - handleClick : function(){ - var url = [ - MAIN_URL, - 'title=' + encodeURIComponent(this.props.brew.title ? this.props.brew.title : 'Check out my brew!'), - - 'text=' + encodeURIComponent(this.props.brew.text) - - - ].join('&'); - - window.open(url, '_blank'); - }, - - - render : function(){ - return - share on reddit - - }, - -}); - -module.exports = RedditShare; \ No newline at end of file +module.exports = function(props){ + return + print + +}; \ No newline at end of file diff --git a/client/homebrew/navbar/source.navitem.jsx b/client/homebrew/navbar/source.navitem.jsx deleted file mode 100644 index b78ca831f..000000000 --- a/client/homebrew/navbar/source.navitem.jsx +++ /dev/null @@ -1,51 +0,0 @@ -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 : { - title : '', - sharedId : '', - text : '' - } - }; - }, - - getText : function(){ - - }, - - - handleClick : function(){ - var url = [ - MAIN_URL, - 'title=' + encodeURIComponent(this.props.brew.title ? this.props.brew.title : 'Check out my brew!'), - - 'text=' + encodeURIComponent(this.props.brew.text) - - - ].join('&'); - - window.open(url, '_blank'); - }, - - - render : function(){ - return - share on reddit - - }, - -}); - -module.exports = RedditShare; \ No newline at end of file diff --git a/client/homebrew/pages/editPage/editPage.jsx b/client/homebrew/pages/editPage/editPage.jsx index 22f51ba9d..8c9c48444 100644 --- a/client/homebrew/pages/editPage/editPage.jsx +++ b/client/homebrew/pages/editPage/editPage.jsx @@ -8,6 +8,8 @@ var Nav = require('naturalcrit/nav/nav.jsx'); var Navbar = require('../../navbar/navbar.jsx'); var EditTitle = require('../../navbar/editTitle.navitem.jsx'); +var ReportIssue = require('../../navbar/issue.navitem.jsx'); +var PrintLink = require('../../navbar/print.navitem.jsx'); var SplitPane = require('naturalcrit/splitPane/splitPane.jsx'); @@ -49,19 +51,27 @@ var EditPage = React.createClass({ return { title : this.props.brew.title, text: this.props.brew.text, + isSaving : false, + + isPending : false, + errors : null, - pending : false, lastUpdated : this.props.brew.updatedAt }; }, - componentDidMount: function() { - var self = this; - window.onbeforeunload = function(){ - if(!self.state.pending) return; - return "You have unsaved changes!"; + savedBrew : null, + + + componentDidMount: function(){ + this.debounceSave = _.debounce(this.save, SAVE_TIMEOUT); + + window.onbeforeunload = ()=>{ + //do state checks + + //return "You have unsaved changes!"; } }, componentWillUnmount: function() { @@ -77,7 +87,8 @@ var EditPage = React.createClass({ title : title, pending : true }); - this.save(); + + (this.hasChanges() ? this.debounceSave() : this.debounceSave.cancel()); }, handleTextChange : function(text){ @@ -85,7 +96,8 @@ var EditPage = React.createClass({ text : text, pending : true }); - this.save(); + + (this.hasChanges() ? this.debounceSave() : this.debounceSave.cancel()); }, handleDelete : function(){ @@ -99,17 +111,43 @@ var EditPage = React.createClass({ }); }, - save : _.debounce(function(){ + hasChanges : function(){ + if(this.savedBrew){ + if(this.state.text !== this.savedBrew.text) return true; + if(this.state.title !== this.savedBrew.title) return true; + }else{ + if(this.state.text !== this.props.brew.text) return true; + if(this.state.title !== this.props.brew.title) return true; + } + return false; + }, + + save : function(){ + console.log('saving!'); + this.debounceSave.cancel(); request - .put('/homebrew/api/update/' + this.props.id) + .put('/homebrew/api/update/' + this.props.brew.editId) .send({text : this.state.text}) .end((err, res) => { + console.log('done', res.body); + this.savedBrew = res.body; this.setState({ pending : false, lastUpdated : res.body.updatedAt }) }) - }, SAVE_TIMEOUT), + }, + + renderSaveButton : function(){ + if(!this.state.isPending && !this.state.isSaving){ + //saved + }else if(this.state.isPending && this.hasChanges()){ + //save now + }else if(this.state.isSaving){ + //saving + } + + }, @@ -120,22 +158,13 @@ var EditPage = React.createClass({ - - report issue - - Share - - - print - - - + + Delete - }, diff --git a/todo.md b/todo.md index e936161de..67824c0fb 100644 --- a/todo.md +++ b/todo.md @@ -14,23 +14,18 @@ X Update the admin page with pagnition and a query box X Test the old/small brew filtering for deleteion X Partial rendering kills style tags on unrendered pages. Detect if pages have style tags and render them. - Add in the link of Pateron? -- Add in brew title, use for metadata? -- Add in specific entry point rendering in server.js -- Add in a tutorial page? + X Add in a localstorage fallback on the `/new` page, clear it when they save X Rename `/client/naturalCrit` -> `/client/main` - Move snippets into their new groups - Replace pseudo-elements with encoded images ## v1.6 +- Add in brew title, use for metadata? - Add error handling to the saving wdiget in the status bar - Should provide error dump to copy and a link to github issues page -- Add in the pane splitter -- Add in CodeMIrror of markdown -- Code Editor should display errors at bottom -- Add in Descriptive name box for a brew - Look into improving the metadata on pages for linking - +- Add in a tutorial page? ## v1.7 - User accounts!