Skip to content

Commit

Permalink
Merge branch 'master' into addUserInfo-naturalcrit#1908
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Ambatte committed Apr 13, 2022
2 parents 001224b + daa0832 commit e491036
Show file tree
Hide file tree
Showing 14 changed files with 714 additions and 473 deletions.
34 changes: 33 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,43 @@ pre {
.page p + pre {
margin-top : 0.1cm;
}

.page .openSans {
font-family: 'Open Sans';
font-size: 0.9em;
}
```

## changelog
For a full record of development, visit our [Github Page](https://github.com/naturalcrit/homebrewery).

### Wednesday 27/03/2022 - v3.0.8
{{taskList
* [x] Style updates to user page.

* [x] Added a logout button (finally)! You can find it under {{openSans **USERNAME {{fa,fa-user}} → LOGOUT {{fas,fa-power-off}}**}}

Fixes issues: [#303](https://github.com/naturalcrit/homebrewery/issues/303)

* [x] Clarified the default text when submitting an issue via Reddit post.

* [x] Fixed broken Table of Contents links in PDFs. (Thanks lucastucious!)

Fixes issues: [#1749](https://github.com/naturalcrit/homebrewery/issues/1749)

* [x] Fixed window resizing causing the edit page divider to get lost off of the edge of the page.

Fixes issues: [#2053](https://github.com/naturalcrit/homebrewery/issues/2053)

* [x] Fixed Class Table decorations overlapping main text.

Fixes issues: [#1985](https://github.com/naturalcrit/homebrewery/issues/1985)

* [x] Updated {{openSans **STYLE EDITOR {{fa,fa-pencil-alt}} → REMOVE DROP CAP {{fas,fa-remove-format}}**}} snippet to also remove small-caps first line font.

* [x] Background work in preparation for brew themes.
}}

### Wednesday 02/02/2022 - v3.0.7
{{taskList
* [x] Revert active line highlighting.
Expand All @@ -50,7 +82,7 @@ For a full record of development, visit our [Github Page](https://github.com/nat

Fixes issues: [#1943](https://github.com/naturalcrit/homebrewery/issues/1943)

* [x] Added a Legacy to V3 migration guide under **NEED HELP? {{fa,fa-question-circle}} → MIGRATE {{fas,fa-file-import}}**
* [x] Added a Legacy to V3 migration guide under {{openSans **NEED HELP? {{fa,fa-question-circle}} → MIGRATE {{fas,fa-file-import}}**}}

* [x] Background refactoring and unit tests.
}}
Expand Down
2 changes: 1 addition & 1 deletion client/homebrew/editor/metadataEditor/metadataEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const MetadataEditor = createClass({
if(!confirm('Are you REALLY sure? You will lose editor access to this document.')) return;
}

request.delete(`/api/${this.props.metadata.editId}`)
request.delete(`/api/${this.props.metadata.googleId ?? ''}${this.props.metadata.editId}`)
.send()
.end(function(err, res){
window.location.href = '/';
Expand Down
6 changes: 5 additions & 1 deletion client/homebrew/editor/snippetbar/snippets/snippets.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ module.exports = [
gen : dedent`/* Removes Drop Caps */
.page h1+p:first-letter {
all: unset;
}\n\n`
}\n\n
/* Removes Small-Caps in first line */
.page h1+p:first-line {
all: unset;
}`
},
{
name : 'Tweak Drop Cap',
Expand Down
2 changes: 1 addition & 1 deletion client/homebrew/homebrew.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const Homebrew = createClass({
<Route path='/share/:id' component={(routeProps)=><SharePage id={routeProps.match.params.id} brew={this.props.brew} />}/>
<Route path='/new/:id' component={(routeProps)=><NewPage id={routeProps.match.params.id} brew={this.props.brew} />}/>
<Route path='/new' exact component={(routeProps)=><NewPage />}/>
<Route path='/user/:username' component={(routeProps)=><UserPage username={routeProps.match.params.username} brews={this.props.brews} />}/>
<Route path='/user/:username' component={(routeProps)=><UserPage username={routeProps.match.params.username} brews={this.props.brews} query={queryString.parse(routeProps.location.search)}/>}/>
<Route path='/print/:id' component={(routeProps)=><PrintPage brew={this.props.brew} query={queryString.parse(routeProps.location.search)} />}/>
<Route path='/print' exact component={(routeProps)=><PrintPage query={queryString.parse(routeProps.location.search)} />}/>
<Route path='/changelog' exact component={()=><SharePage brew={this.props.brew} />}/>
Expand Down
12 changes: 10 additions & 2 deletions client/homebrew/navbar/account.navitem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@ const Account = createClass({
// Reset divider position
window.localStorage.removeItem('naturalcrit-pane-split');
// Clear login cookie
document.cookie = `nc_session=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/;samesite=lax;${window.domain ? `domain=${window.domain}` : ''}`;
let domain = '';
if(window.location?.hostname) {
let domainArray = window.location.hostname.split('.');
if(domainArray.length > 2){
domainArray = [''].concat(domainArray.slice(-2));
}
domain = domainArray.join('.');
}
document.cookie = `nc_session=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/;samesite=lax;${domain ? `domain=${domain}` : ''}`;
window.location = '/';
};
}
},

render : function(){
Expand Down
18 changes: 5 additions & 13 deletions client/homebrew/pages/basePages/listPage/brewItem/brewItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,11 @@ const BrewItem = createClass({
if(!confirm('Are you REALLY sure? You will lose editor access to this document.')) return;
}

if(this.props.brew.googleId) {
request.get(`/api/removeGoogle/${this.props.brew.googleId}${this.props.brew.editId}`)
.send()
.end(function(err, res){
location.reload();
});
} else {
request.delete(`/api/${this.props.brew.editId}`)
.send()
.end(function(err, res){
location.reload();
});
}
request.delete(`/api/${this.props.brew.googleId ?? ''}${this.props.brew.editId}`)
.send()
.end(function(err, res){
location.reload();
});
},

renderDeleteBrewLink : function(){
Expand Down
23 changes: 20 additions & 3 deletions client/homebrew/pages/basePages/listPage/listPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const ListPage = createClass({
return {
sortType : 'alpha',
sortDir : 'asc',
filterString : ''
filterString : this.props.query?.filter || '',
query : this.props.query
};
},

Expand Down Expand Up @@ -74,19 +75,35 @@ const ListPage = createClass({

handleFilterTextChange : function(e){
this.setState({
filterString : e.target.value
filterString : e.target.value,
});
this.updateUrl(e.target.value);
return;
},

updateUrl : function(filterTerm){
const url = new URL(window.location.href);
const urlParams = new URLSearchParams(url.search);
if(urlParams.get('filter') == filterTerm)
return;
if(!filterTerm)
urlParams.delete('filter');
else
urlParams.set('filter', filterTerm);
url.search = urlParams;
window.history.replaceState(null, null, url);
},

renderFilterOption : function(){
return <td>
<label>
<i className='fas fa-search'></i>
<input
type='search'
placeholder='search title/description'
autoFocus={true}
placeholder='filter title/description'
onChange={this.handleFilterTextChange}
value={this.state.filterString}
/>
</label>
</td>;
Expand Down
119 changes: 32 additions & 87 deletions client/homebrew/pages/editPage/editPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,73 +200,18 @@ const EditPage = createClass({
const brew = this.state.brew;
brew.pageCount = ((brew.renderer=='legacy' ? brew.text.match(/\\page/g) : brew.text.match(/^\\page$/gm)) || []).length + 1;

if(this.state.saveGoogle) {
if(transfer) {
const res = await request
.post('/api/newGoogle/')
.send(brew)
.catch((err)=>{
console.log(err.status === 401
? 'Not signed in!'
: 'Error Transferring to Google!');
this.setState({ errors: err, saveGoogle: false });
});

if(!res) { return; }

console.log('Deleting Local Copy');
await request.delete(`/api/${brew.editId}`)
.send()
.catch((err)=>{
console.log('Error deleting Local Copy');
});

this.savedBrew = res.body;
history.replaceState(null, null, `/edit/${this.savedBrew.googleId}${this.savedBrew.editId}`); //update URL to match doc ID
} else {
const res = await request
.put(`/api/updateGoogle/${brew.editId}`)
.send(brew)
.catch((err)=>{
console.log(err.status === 401
? 'Not signed in!'
: 'Error Saving to Google!');
this.setState({ errors: err });
return;
});

this.savedBrew = res.body;
}
} else {
if(transfer) {
const res = await request.post('/api')
.send(brew)
.catch((err)=>{
console.log('Error creating Local Copy');
this.setState({ errors: err });
return;
});

await request.get(`/api/removeGoogle/${brew.googleId}${brew.editId}`)
.send()
.catch((err)=>{
console.log('Error Deleting Google Brew');
});

this.savedBrew = res.body;
history.replaceState(null, null, `/edit/${this.savedBrew.editId}`); //update URL to match doc ID
} else {
const res = await request
.put(`/api/update/${brew.editId}`)
.send(brew)
.catch((err)=>{
console.log('Error Updating Local Brew');
this.setState({ errors: err });
return;
});

this.savedBrew = res.body;
}
const params = `${transfer ? `?transfer${this.state.saveGoogle ? 'To' : 'From'}Google=true` : ''}`;
const res = await request
.put(`/api/update/${brew.editId}${params}`)
.send(brew)
.catch((err)=>{
console.log('Error Updating Local Brew');
this.setState({ errors: err });
});

this.savedBrew = res.body;
if(transfer) {
history.replaceState(null, null, `/edit/${this.savedBrew.googleId ?? ''}${this.savedBrew.editId}`);
}

this.setState((prevState)=>({
Expand Down Expand Up @@ -331,26 +276,26 @@ const EditPage = createClass({
console.log(errMsg);
} catch (e){}

if(this.state.errors.status == '401'){
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
Oops!
<div className='errorContainer' onClick={this.clearErrors}>
You must be signed in to a Google account
to save this to<br />Google Drive!<br />
<a target='_blank' rel='noopener noreferrer'
href={`https://www.naturalcrit.com/login?redirect=${this.state.url}`}>
<div className='confirm'>
Sign In
</div>
</a>
<div className='deny'>
Not Now
</div>
</div>
</Nav.item>;
}

if(this.state.errors.response.req.url.match(/^\/api\/.*Google.*$/m)){
// if(this.state.errors.status == '401'){
// return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
// Oops!
// <div className='errorContainer' onClick={this.clearErrors}>
// You must be signed in to a Google account
// to save this to<br />Google Drive!<br />
// <a target='_blank' rel='noopener noreferrer'
// href={`https://www.naturalcrit.com/login?redirect=${this.state.url}`}>
// <div className='confirm'>
// Sign In
// </div>
// </a>
// <div className='deny'>
// Not Now
// </div>
// </div>
// </Nav.item>;
// }

if(this.state.errors.response.req.url.match(/^\/api.*Google.*$/m)){
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
Oops!
<div className='errorContainer' onClick={this.clearErrors}>
Expand Down
Loading

0 comments on commit e491036

Please sign in to comment.