diff --git a/changelog.md b/changelog.md index fd5400322..386f1a340 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,21 @@ # changelog +### Wednesday, 23/11/2016 - v2.5.0 +- Metadata can now be added to brews +- Added a metadata editor onto the edit and new pages +- Moved deleting a brew into the metadata editor +- Added in account middleware +- Can now search for brews by a specific author +- Editing a brew in anyway while logged in will now add you to the list of authors +- Added a new user page to see others published brews, as well as all of your own brews. +- Added a new nav item for accessing your profile and logging in + + +### Monday, 14/11/2016 +- Updated snippet bar style +- You can now print from a new page without saving +- Added the ability to use ctrl+p and ctrl+s to print and save respectively. + ### Monday, 07/11/2016 - Added final touches to the html validator and updating the rest of the branch - If anyone finds issues with the new HTML validator, please let me know. I hope this will bring a more consistent feel to Homebrewery rendering. diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index d79ef4a98..e02f2451b 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -1,25 +1,31 @@ -var React = require('react'); -var _ = require('lodash'); -var cx = require('classnames'); +const React = require('react'); +const _ = require('lodash'); +const cx = require('classnames'); -var CodeEditor = require('naturalcrit/codeEditor/codeEditor.jsx'); -var Snippets = require('./snippets/snippets.js'); +const CodeEditor = require('naturalcrit/codeEditor/codeEditor.jsx'); +const SnippetBar = require('./snippetbar/snippetbar.jsx'); +const MetadataEditor = require('./MetadataEditor/MetadataEditor.jsx'); -var splice = function(str, index, inject){ +const splice = function(str, index, inject){ return str.slice(0, index) + inject + str.slice(index); }; -var execute = function(val){ - if(_.isFunction(val)) return val(); - return val; -} +const SNIPPETBAR_HEIGHT = 25; -var Editor = React.createClass({ +const Editor = React.createClass({ getDefaultProps: function() { return { - value : "", - onChange : function(){} + value : '', + onChange : ()=>{}, + + metadata : {}, + onMetadataChange : ()=>{}, + }; + }, + getInitialState: function() { + return { + showMetadataEditor: false }; }, cursorPosition : { @@ -27,7 +33,6 @@ var Editor = React.createClass({ ch : 0 }, - componentDidMount: function() { this.updateEditorSize(); window.addEventListener("resize", this.updateEditorSize); @@ -37,8 +42,8 @@ var Editor = React.createClass({ }, updateEditorSize : function() { - var paneHeight = this.refs.main.parentNode.clientHeight; - paneHeight -= this.refs.snippetBar.clientHeight + 1; + let paneHeight = this.refs.main.parentNode.clientHeight; + paneHeight -= SNIPPETBAR_HEIGHT + 1; this.refs.codeEditor.codeMirror.setSize(null, paneHeight); }, @@ -48,38 +53,37 @@ var Editor = React.createClass({ handleCursorActivty : function(curpos){ this.cursorPosition = curpos; }, - - handleSnippetClick : function(injectText){ - var lines = this.props.value.split('\n'); + handleInject : function(injectText){ + const lines = this.props.value.split('\n'); lines[this.cursorPosition.line] = splice(lines[this.cursorPosition.line], this.cursorPosition.ch, injectText); this.handleTextChange(lines.join('\n')); this.refs.codeEditor.setCursorPosition(this.cursorPosition.line, this.cursorPosition.ch + injectText.length); }, + handgleToggle : function(){ + this.setState({ + showMetadataEditor : !this.state.showMetadataEditor + }) + }, //Called when there are changes to the editor's dimensions update : function(){ this.refs.codeEditor.updateSize(); }, - renderSnippetGroups : function(){ - return _.map(Snippets, (snippetGroup)=>{ - return - }) + renderMetadataEditor : function(){ + if(!this.state.showMetadataEditor) return; + return }, render : function(){ return(
-
- {this.renderSnippetGroups()} -
+ + {this.renderMetadataEditor()} { - return
- - {snippet.name} -
- }) - }, - - render : function(){ - return
-
- - {this.props.groupName} -
-
- {this.renderSnippets()} -
-
- }, - -}); \ No newline at end of file diff --git a/client/homebrew/editor/editor.less b/client/homebrew/editor/editor.less index 377c71607..8678fd189 100644 --- a/client/homebrew/editor/editor.less +++ b/client/homebrew/editor/editor.less @@ -2,55 +2,10 @@ .editor{ position : relative; width : 100%; - .snippetBar{ - display : flex; - padding : 5px; - background-color : #ddd; - align-items : center; - .snippetGroup{ - .animate(background-color); - margin : 0px 8px; - padding : 3px; - font-size : 13px; - border-radius : 5px; - &:hover, &.selected{ - background-color : #999; - } - .text{ - line-height : 20px; - .groupName{ - margin-left : 6px; - font-size : 10px; - } - } - &:hover{ - .dropdown{ - visibility : visible; - } - } - .dropdown{ - position : absolute; - visibility : hidden; - z-index : 1000; - padding : 5px; - background-color : #ddd; - .snippet{ - .animate(background-color); - padding : 10px; - cursor : pointer; - font-size : 10px; - i{ - margin-right: 8px; - font-size : 13px; - } - &:hover{ - background-color : #999; - } - } - } - } - } + .codeEditor{ height : 100%; } + + } \ No newline at end of file diff --git a/client/homebrew/editor/metadataEditor/metadataEditor.jsx b/client/homebrew/editor/metadataEditor/metadataEditor.jsx new file mode 100644 index 000000000..baf74f40d --- /dev/null +++ b/client/homebrew/editor/metadataEditor/metadataEditor.jsx @@ -0,0 +1,148 @@ +const React = require('react'); +const _ = require('lodash'); +const cx = require('classnames'); +const request = require("superagent"); + +const SYSTEMS = ['5e', '4e', '3.5e', 'Pathfinder'] + +const MetadataEditor = React.createClass({ + getDefaultProps: function() { + return { + metadata: { + editId : null, + title : '', + description : '', + tags : '', + published : false, + authors : [], + systems : [] + }, + onChange : ()=>{} + }; + }, + + handleFieldChange : function(name, e){ + this.props.onChange(_.merge({}, this.props.metadata, { + [name] : e.target.value + })) + }, + handleSystem : function(system, e){ + if(e.target.checked){ + this.props.metadata.systems.push(system); + }else{ + this.props.metadata.systems = _.without(this.props.metadata.systems, system); + } + this.props.onChange(this.props.metadata); + }, + handlePublish : function(val){ + this.props.onChange(_.merge({}, this.props.metadata, { + published : val + })); + }, + + handleDelete : function(){ + if(!confirm("are you sure you want to delete this brew?")) return; + if(!confirm("are you REALLY sure? You will not be able to recover it")) return; + + request.get('/api/remove/' + this.props.metadata.editId) + .send() + .end(function(err, res){ + window.location.href = '/'; + }); + }, + + renderSystems : function(){ + return _.map(SYSTEMS, (val)=>{ + return + }); + }, + + renderPublish : function(){ + if(this.props.metadata.published){ + return + }else{ + return + } + }, + + renderDelete : function(){ + if(!this.props.metadata.editId) return; + + return
+ +
+ +
+
+ }, + + renderAuthors : function(){ + let text = 'None.'; + if(this.props.metadata.authors.length){ + text = this.props.metadata.authors.join(', '); + } + return
+ +
+ {text} +
+
+ }, + + render : function(){ + return
+
+ + +
+
+ +