mirror of
https://github.com/stolksdorf/homebrewery.git
synced 2025-12-24 08:51:29 +00:00
'Share
This commit is contained in:
@@ -8,7 +8,7 @@ const Actions = require('homebrewery/brew.actions.js');
|
||||
const HomePage = require('./pages/homePage/homePage.jsx');
|
||||
const EditPage = require('./pages/editPage/editPage.jsx');
|
||||
//const UserPage = require('./pages/userPage/userPage.jsx');
|
||||
//const SharePage = require('./pages/sharePage/sharePage.jsx');
|
||||
const SharePage = require('./pages/sharePage/sharePage.jsx');
|
||||
const NewPage = require('./pages/newPage/newPage.jsx');
|
||||
//const ErrorPage = require('./pages/errorPage/errorPage.jsx');
|
||||
const PrintPage = require('./pages/printPage/printPage.jsx');
|
||||
@@ -43,11 +43,8 @@ const Homebrew = React.createClass({
|
||||
return <ErrorPage errorId={args.id}/>
|
||||
}
|
||||
|
||||
return <EditPage
|
||||
id={args.id}
|
||||
brew={this.props.brew} />
|
||||
return <EditPage />
|
||||
},
|
||||
/*
|
||||
|
||||
'/share/:id' : (args) => {
|
||||
if(!this.props.brew.shareId){
|
||||
@@ -58,6 +55,7 @@ const Homebrew = React.createClass({
|
||||
id={args.id}
|
||||
brew={this.props.brew} />
|
||||
},
|
||||
/*
|
||||
'/user/:username' : (args) => {
|
||||
return <UserPage
|
||||
username={args.username}
|
||||
|
||||
@@ -23,16 +23,16 @@ const ContinousSave = React.createClass({
|
||||
};
|
||||
},
|
||||
componentDidMount: function() {
|
||||
flux.actionEmitter.on('dispatch', this.brewUpdate);
|
||||
flux.actionEmitter.on('dispatch', this.actionHandler);
|
||||
window.onbeforeunload = ()=>{
|
||||
if(this.props.status !== 'ready') return 'You have unsaved changes!';
|
||||
};
|
||||
},
|
||||
componentWillUnmount: function() {
|
||||
flux.actionEmitter.removeListenr('dispatch', this.brewUpdate);
|
||||
flux.actionEmitter.removeListener('dispatch', this.actionHandler);
|
||||
window.onbeforeunload = function(){};
|
||||
},
|
||||
brewUpdate : function(actionType){
|
||||
actionHandler : function(actionType){
|
||||
if(actionType == 'UPDATE_BREW_TEXT' || actionType == 'UPDATE_META'){
|
||||
Actions.pendingSave();
|
||||
}
|
||||
|
||||
@@ -99,14 +99,12 @@
|
||||
text-align : center;
|
||||
}
|
||||
}
|
||||
|
||||
.staticSave.navItem{
|
||||
background-color: @orange;
|
||||
background-color : @orange;
|
||||
&:hover{
|
||||
background-color: @green;
|
||||
background-color : @green;
|
||||
}
|
||||
}
|
||||
|
||||
.continousSave.navItem{
|
||||
width : 105px;
|
||||
text-align : center;
|
||||
|
||||
@@ -8,40 +8,21 @@ const Account = require('../../navbar/account.navitem.jsx');
|
||||
const Issue = require('../../navbar/issue.navitem.jsx');
|
||||
const Save = require('../../navbar/staticSave.navitem.jsx');
|
||||
|
||||
|
||||
const Store = require('homebrewery/brew.store.js');
|
||||
const Actions = require('homebrewery/brew.actions.js');
|
||||
|
||||
const BrewInterface = require('homebrewery/brewInterface/brewInterface.jsx');
|
||||
|
||||
const Utils = require('homebrewery/utils.js');
|
||||
|
||||
|
||||
const KEY = 'homebrewery-new';
|
||||
|
||||
const NewPage = React.createClass({
|
||||
/*
|
||||
getInitialState: function() {
|
||||
return {
|
||||
metadata : {
|
||||
title : '',
|
||||
description : '',
|
||||
tags : '',
|
||||
published : false,
|
||||
authors : [],
|
||||
systems : []
|
||||
},
|
||||
|
||||
text: '',
|
||||
isSaving : false,
|
||||
errors : []
|
||||
};
|
||||
},
|
||||
*/
|
||||
componentDidMount: function() {
|
||||
const storage = localStorage.getItem(KEY);
|
||||
|
||||
//TODO: Add aciton to load from local?
|
||||
|
||||
//TODO: add a store listener for updates and dump to lcoal storage
|
||||
|
||||
|
||||
if(storage){
|
||||
@@ -59,77 +40,6 @@ const NewPage = React.createClass({
|
||||
p : Actions.localPrint
|
||||
}),
|
||||
|
||||
/*
|
||||
|
||||
handleControlKeys : function(e){
|
||||
console.log(e);
|
||||
if(!(e.ctrlKey || e.metaKey)) return;
|
||||
const S_KEY = 83;
|
||||
const P_KEY = 80;
|
||||
if(e.keyCode == S_KEY) this.save();
|
||||
if(e.keyCode == P_KEY) this.print();
|
||||
if(e.keyCode == P_KEY || e.keyCode == S_KEY){
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
save : function(){
|
||||
this.setState({
|
||||
isSaving : true
|
||||
});
|
||||
|
||||
request.post('/api')
|
||||
.send(_.merge({}, this.state.metadata, {
|
||||
text : this.state.text
|
||||
}))
|
||||
.end((err, res)=>{
|
||||
if(err){
|
||||
this.setState({
|
||||
isSaving : false
|
||||
});
|
||||
return;
|
||||
}
|
||||
window.onbeforeunload = function(){};
|
||||
const brew = res.body;
|
||||
localStorage.removeItem(KEY);
|
||||
window.location = '/edit/' + brew.editId;
|
||||
})
|
||||
},
|
||||
*/
|
||||
/*
|
||||
renderSaveButton : function(){
|
||||
if(this.state.isSaving){
|
||||
return <Nav.item icon='fa-spinner fa-spin' className='saveButton'>
|
||||
save...
|
||||
</Nav.item>
|
||||
}else{
|
||||
return <Nav.item icon='fa-save' className='saveButton' onClick={this.save}>
|
||||
save
|
||||
</Nav.item>
|
||||
}
|
||||
},
|
||||
*/
|
||||
/*
|
||||
print : function(){
|
||||
localStorage.setItem('print', this.state.text);
|
||||
window.open('/print?dialog=true&local=print','_blank');
|
||||
},
|
||||
*/
|
||||
|
||||
/*
|
||||
renderLocalPrintButton : function(){
|
||||
return <Nav.item color='purple' icon='fa-file-pdf-o' onClick={Actions.localPrint}>
|
||||
get PDF
|
||||
</Nav.item>
|
||||
},
|
||||
|
||||
renderNavbar : function(){
|
||||
return
|
||||
},
|
||||
|
||||
*/
|
||||
render : function(){
|
||||
return <div className='newPage page'>
|
||||
<Navbar>
|
||||
|
||||
@@ -9,9 +9,11 @@ const ReportIssue = require('../../navbar/issue.navitem.jsx');
|
||||
//const RecentlyViewed = require('../../navbar/recent.navitem.jsx').viewed;
|
||||
const Account = require('../../navbar/account.navitem.jsx');
|
||||
|
||||
const BrewRenderer = require('homebrewery/brewRenderer/brewRenderer.jsx');
|
||||
const Utils = require('homebrewery/utils.js');
|
||||
|
||||
const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
|
||||
|
||||
const Actions = require('homebrewery/brew.actions.js');
|
||||
const Store = require('homebrewery/brew.store.js');
|
||||
|
||||
const SharePage = React.createClass({
|
||||
getDefaultProps: function() {
|
||||
@@ -33,36 +35,29 @@ const SharePage = React.createClass({
|
||||
componentWillUnmount: function() {
|
||||
document.removeEventListener('keydown', this.handleControlKeys);
|
||||
},
|
||||
handleControlKeys : function(e){
|
||||
if(!(e.ctrlKey || e.metaKey)) return;
|
||||
const P_KEY = 80;
|
||||
if(e.keyCode == P_KEY){
|
||||
window.open(`/print/${this.props.brew.shareId}?dialog=true`, '_blank').focus();
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
handleControlKeys : Utils.controlKeys({
|
||||
p : Actions.print
|
||||
}),
|
||||
|
||||
render : function(){
|
||||
const brew = Store.getBrew();
|
||||
return <div className='sharePage page'>
|
||||
<Navbar>
|
||||
<Nav.section>
|
||||
<Nav.item className='brewTitle'>{this.props.brew.title}</Nav.item>
|
||||
<Nav.item className='brewTitle'>{brew.title}</Nav.item>
|
||||
</Nav.section>
|
||||
|
||||
<Nav.section>
|
||||
<ReportIssue />
|
||||
{/*<RecentlyViewed brew={this.props.brew} />*/}
|
||||
<PrintLink shareId={this.props.brew.shareId} />
|
||||
<Nav.item href={'/source/' + this.props.brew.shareId} color='teal' icon='fa-code'>
|
||||
<PrintLink shareId={brew.shareId} />
|
||||
<Nav.item href={'/source/' + brew.shareId} color='teal' icon='fa-code'>
|
||||
source
|
||||
</Nav.item>
|
||||
<Account />
|
||||
</Nav.section>
|
||||
</Navbar>
|
||||
|
||||
<div className='content'>
|
||||
<BrewRenderer text={this.props.brew.text} />
|
||||
<BrewRenderer brewText={brew.text} />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ const Actions = {
|
||||
updateMetaData : (meta) => {
|
||||
dispatch('UPDATE_META', meta);
|
||||
},
|
||||
|
||||
pendingSave : () => {
|
||||
clearTimeout(pendingTimer);
|
||||
pendingTimer = setTimeout(Actions.save, PENDING_TIMEOUT);
|
||||
@@ -38,7 +37,6 @@ const Actions = {
|
||||
dispatch('SET_STATUS', 'ready');
|
||||
});
|
||||
},
|
||||
|
||||
saveNew : () => {
|
||||
dispatch('SET_STATUS', 'saving');
|
||||
request.post('/api')
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
const _ = require('lodash');
|
||||
|
||||
|
||||
const Utils = {
|
||||
controlKeys : (mapping) => {
|
||||
return (e) => {
|
||||
@@ -13,8 +12,6 @@ const Utils = {
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
module.exports = Utils;
|
||||
Reference in New Issue
Block a user