0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-29 09:02:37 +00:00

Merge branch 'various'

This commit is contained in:
Scott Tolksdorf
2016-08-20 13:44:11 -04:00
24 changed files with 359 additions and 69 deletions

View File

@@ -31,3 +31,7 @@ You can use [Docker](https://docs.docker.com) to get up and running with Natural
### changelog
You can check out the changelog [here](https://github.com/stolksdorf/homebrewery/blob/master/changelog.md)
### license
This project licensed under [MIT](./license)

View File

@@ -1,5 +1,18 @@
# changelog
### Saturday, 20/08/2016 - v2.3.0
- Added in a license file
- Updated the welcome text
- Added in a much better Error page
- If you visit a deleted brew, it will now remove it from your recent list. (Thanks u/sIllverback!)
- Improved parsing of embedded html text in brews. (Thanks u/com-charizard!)
- Added in a new coverpage snippet
- Homebrewery will now try and onsert a good title for your brew if you don't provide one
- Homebrewery now re-renders properly when you zoom
- Fixed the noteblock overlapping into titles (thanks u/dsompura!)
- Fixed a bad search route in the admin panel (thanks u/SnappyTom!)
### Friday, 29/07/2016 - v2.2.7
- Adding in descriptive note blocks. (Thanks calculuschild!)

View File

@@ -28,7 +28,7 @@ var HomebrewAdmin = React.createClass({
fetchBrews : function(page){
request.get('/homebrew/api/search')
request.get('/api/search')
.query({
admin_key : this.props.admin_key,
count : this.state.count,

View File

@@ -23,11 +23,20 @@ var BrewRenderer = React.createClass({
height : 0,
componentDidMount: function() {
this.updateSize();
window.addEventListener("resize", this.updateSize);
},
componentWillUnmount: function() {
window.removeEventListener("resize", this.updateSize);
},
updateSize : function() {
this.setState({
height : this.refs.main.parentNode.clientHeight,
isMounted : true
});
},
handleScroll : function(e){
this.setState({
viewablePageNumber : Math.floor(e.target.scrollTop / PAGE_HEIGHT)

View File

@@ -27,7 +27,16 @@ var Editor = React.createClass({
ch : 0
},
componentDidMount: function() {
this.updateEditorSize();
window.addEventListener("resize", this.updateEditorSize);
},
componentWillUnmount: function() {
window.removeEventListener("resize", this.updateEditorSize);
},
updateEditorSize : function() {
var paneHeight = this.refs.main.parentNode.clientHeight;
paneHeight -= this.refs.snippetBar.clientHeight + 1;
this.refs.codeEditor.codeMirror.setSize(null, paneHeight);

View File

@@ -0,0 +1,117 @@
var _ = require('lodash');
var titles = [
"The Burning Gallows",
"The Ring of Nenlast",
"Below the Blind Tavern",
"Below the Hungering River",
"Before Bahamut's Land",
"The Cruel Grave from Within",
"The Strength of Trade Road",
"Through The Raven Queen's Worlds",
"Within the Settlement",
"The Crown from Within",
"The Merchant Within the Battlefield",
"Ioun's Fading Traveler",
"The Legion Ingredient",
"The Explorer Lure",
"Before the Charming Badlands",
"The Living Dead Above the Fearful Cage",
"Vecna's Hidden Sage",
"Bahamut's Demonspawn",
"Across Gruumsh's Elemental Chaos",
"The Blade of Orcus",
"Beyond Revenge",
"Brain of Insanity",
"Breed Battle!, A New Beginning",
"Evil Lake, A New Beginning",
"Invasion of the Gigantic Cat, Part II",
"Kraken War 2020",
"The Body Whisperers",
"The Diabolical Tales of the Ape-Women",
"The Doctor Immortal",
"The Doctor from Heaven",
"The Graveyard",
"Azure Core",
"Core Battle",
"Core of Heaven: The Guardian of Amazement",
"Deadly Amazement III",
"Dry Chaos IX",
"Gate Thunder",
"Guardian: Skies of the Dark Wizard",
"Lute of Eternity",
"Mercury's Planet: Brave Evolution",
"Ruby of Atlantis: The Quake of Peace",
"Sky of Zelda: The Thunder of Force",
"Vyse's Skies",
"White Greatness III",
"Yellow Divinity",
"Zidane's Ghost"
];
var subtitles = [
"In an ominous universe, a botanist opposes terrorism.",
"In a demon-haunted city, in an age of lies and hate, a physicist tries to find an ancient treasure and battles a mob of aliens.",
"In a land of corruption, two cyberneticists and a dungeon delver search for freedom.",
"In an evil empire of horror, two rangers battle the forces of hell.",
"In a lost city, in an age of sorcery, a librarian quests for revenge.",
"In a universe of illusions and danger, three time travellers and an adventurer search for justice.",
"In a forgotten universe of barbarism, in an era of terror and mysticism, a virtual reality programmer and a spy try to find vengance and battle crime.",
"In a universe of demons, in an era of insanity and ghosts, three bodyguards and a bodyguard try to find vengance.",
"In a kingdom of corruption and battle, seven artificial intelligences try to save the last living fertile woman.",
"In a universe of virutal reality and agony, in an age of ghosts and ghosts, a fortune-teller and a wanderer try to avert the apocalypse.",
"In a crime-infested kingdom, three martial artists quest for the truth and oppose evil.",
"In a terrifying universe of lost souls, in an era of lost souls, eight dancers fight evil.",
"In a galaxy of confusion and insanity, three martial artists and a duke battle a mob of psychics.",
"In an amazing kingdom, a wizard and a secretary hope to prevent the destruction of mankind.",
"In a kingdom of deception, a reporter searches for fame.",
"In a hellish empire, a swordswoman and a duke try to find the ultimate weapon and battle a conspiracy.",
"In an evil galaxy of illusion, in a time of technology and misery, seven psychiatrists battle crime.",
"In a dark city of confusion, three swordswomen and a singer battle lawlessness.",
"In an ominous empire, in an age of hate, two philosophers and a student try to find justice and battle a mob of mages intent on stealing the souls of the innocent.",
"In a kingdom of panic, six adventurers oppose lawlessness.",
"In a land of dreams and hopelessness, three hackers and a cyborg search for justice.",
"On a planet of mysticism, three travelers and a fire fighter quest for the ultimate weapon and oppose evil.",
"In a wicked universe, five seers fight lawlessness.",
"In a kingdom of death, in an era of illusion and blood, four colonists search for fame.",
"In an amazing kingdom, in an age of sorcery and lost souls, eight space pirates quest for freedom.",
"In a cursed empire, five inventors oppose terrorism.",
"On a crime-ridden planet of conspiracy, a watchman and an artificial intelligence try to find love and oppose lawlessness.",
"In a forgotten land, a reporter and a spy try to stop the apocalypse.",
"In a forbidden land of prophecy, a scientist and an archivist oppose a cabal of barbarians intent on stealing the souls of the innocent.",
"On an infernal world of illusion, a grave robber and a watchman try to find revenge and combat a syndicate of mages intent on stealing the source of all magic.",
"In a galaxy of dark magic, four fighters seek freedom.",
"In an empire of deception, six tomb-robbers quest for the ultimate weapon and combat an army of raiders.",
"In a kingdom of corruption and lost souls, in an age of panic, eight planetologists oppose evil.",
"In a galaxy of misery and hopelessness, in a time of agony and pain, five planetologists search for vengance.",
"In a universe of technology and insanity, in a time of sorcery, a computer techician quests for hope.",
"On a planet of dark magic and barbarism, in an age of horror and blasphemy, seven librarians search for fame.",
"In an empire of dark magic, in a time of blood and illusions, four monks try to find the ultimate weapon and combat terrorism.",
"In a forgotten empire of dark magic, six kings try to prevent the destruction of mankind.",
"In a galaxy of dark magic and horror, in an age of hopelessness, four marines and an outlaw combat evil.",
"In a mysterious city of illusion, in an age of computerization, a witch-hunter tries to find the ultimate weapon and opposes an evil corporation.",
"In a damned kingdom of technology, a virtual reality programmer and a fighter seek fame.",
"In a hellish kingdom, in an age of blasphemy and blasphemy, an astrologer searches for fame.",
"In a damned world of devils, an alien and a ranger quest for love and oppose a syndicate of demons.",
"In a cursed galaxy, in a time of pain, seven librarians hope to avert the apocalypse.",
"In a crime-infested galaxy, in an era of hopelessness and panic, three champions and a grave robber try to solve the ultimate crime."
];
module.exports = () => {
return `<style>
.phb#p1{ text-align:center; }
.phb#p1:after{ display:none; }
</style>
<div style='margin-top:450px;'></div>
# ${_.sample(titles)}
<div style='margin-top:25px'></div>
<div class='wide'>
##### ${_.sample(subtitles)}
</div>
\\page`
}

View File

@@ -3,6 +3,7 @@ var ClassTableGen = require('./classtable.gen.js');
var MonsterBlockGen = require('./monsterblock.gen.js');
var ClassFeatureGen = require('./classfeature.gen.js');
var FullClassGen = require('./fullclass.gen.js');
var CoverPageGen = require('./coverpage.gen.js');
module.exports = [
@@ -130,7 +131,12 @@ module.exports = [
name : 'Wide Monster Stat Block',
icon : 'fa-paw',
gen : MonsterBlockGen.full,
}
},
{
name : 'Cover Page',
icon : 'fa-file-word-o',
gen : CoverPageGen,
},
]
},

View File

@@ -8,14 +8,16 @@ var HomePage = require('./pages/homePage/homePage.jsx');
var EditPage = require('./pages/editPage/editPage.jsx');
var SharePage = require('./pages/sharePage/sharePage.jsx');
var NewPage = require('./pages/newPage/newPage.jsx');
var ErrorPage = require('./pages/errorPage/errorPage.jsx');
var Router;
var Homebrew = React.createClass({
getDefaultProps: function() {
return {
url : "",
welcomeText : "",
changelog : "",
url : '',
welcomeText : '',
changelog : '',
version : '0.0.0',
brew : {
title : '',
text : '',
@@ -29,27 +31,43 @@ var Homebrew = React.createClass({
componentWillMount: function() {
Router = CreateRouter({
'/edit/:id' : (args) => {
return <EditPage id={args.id} brew={this.props.brew} />
if(!this.props.brew.editId){
return <ErrorPage ver={this.props.version} errorId={args.id}/>
}
return <EditPage
ver={this.props.version}
id={args.id}
brew={this.props.brew} />
},
'/share/:id' : (args) => {
return <SharePage id={args.id} brew={this.props.brew} />
if(!this.props.brew.shareId){
return <ErrorPage ver={this.props.version} errorId={args.id}/>
}
return <SharePage
ver={this.props.version}
id={args.id}
brew={this.props.brew} />
},
'/changelog' : (args) => {
return <SharePage brew={{title : 'Changelog', text : this.props.changelog}} />
return <SharePage
ver={this.props.version}
brew={{title : 'Changelog', text : this.props.changelog}} />
},
'/new' : (args) => {
return <NewPage />
return <NewPage ver={this.props.version} />
},
'*' : <HomePage welcomeText={this.props.welcomeText} />,
'*' : <HomePage
ver={this.props.version}
welcomeText={this.props.welcomeText} />,
});
},
render : function(){
return(
<div className='homebrew'>
<Router initialUrl={this.props.url}/>
</div>
);
return <div className='homebrew'>
<Router initialUrl={this.props.url}/>
</div>
}
});

View File

@@ -6,7 +6,8 @@ var Nav = require('naturalcrit/nav/nav.jsx');
var Navbar = React.createClass({
getInitialState: function() {
return {
showNonChromeWarning : false
showNonChromeWarning : false,
ver : '0.0.0'
};
},
@@ -34,7 +35,7 @@ var Navbar = React.createClass({
<Nav.item href='/' className='homebrewLogo'>
<div>The Homebrewery</div>
</Nav.item>
<Nav.item>v2.2.8</Nav.item>
<Nav.item>{`v${this.props.ver}`}</Nav.item>
{this.renderChromeWarning()}
</Nav.section>

View File

@@ -122,6 +122,12 @@ module.exports = {
}),
both : React.createClass({
getDefaultProps: function() {
return {
errorId : null
};
},
getInitialState: function() {
return {
showDropdown: false,
@@ -131,9 +137,26 @@ module.exports = {
},
componentDidMount: function() {
var edited = JSON.parse(localStorage.getItem(EDIT_KEY) || '[]');
var viewed = JSON.parse(localStorage.getItem(VIEW_KEY) || '[]');
if(this.props.errorId){
edited = _.filter(edited, (edit) => {
return edit.id !== this.props.errorId;
});
viewed = _.filter(viewed, (view) => {
return view.id !== this.props.errorId;
});
localStorage.setItem(EDIT_KEY, JSON.stringify(edited));
localStorage.setItem(VIEW_KEY, JSON.stringify(viewed));
}
this.setState({
edit : JSON.parse(localStorage.getItem(EDIT_KEY) || '[]'),
view : JSON.parse(localStorage.getItem(VIEW_KEY) || '[]')
edit : edited,
view : viewed
});
},

View File

@@ -27,6 +27,7 @@ const SAVE_TIMEOUT = 3000;
var EditPage = React.createClass({
getDefaultProps: function() {
return {
ver : '0.0.0',
id : null,
brew : {
title : '',
@@ -170,7 +171,7 @@ var EditPage = React.createClass({
}
},
renderNavbar : function(){
return <Navbar>
return <Navbar ver={this.props.ver}>
<Nav.section>
<EditTitle title={this.state.title} onChange={this.handleTitleChange} />
</Nav.section>

View File

@@ -0,0 +1,46 @@
var React = require('react');
var _ = require('lodash');
var cx = require('classnames');
var Nav = require('naturalcrit/nav/nav.jsx');
var Navbar = require('../../navbar/navbar.jsx');
var PatreonNavItem = require('../../navbar/patreon.navitem.jsx');
var IssueNavItem = require('../../navbar/issue.navitem.jsx');
var RecentNavItem = require('../../navbar/recent.navitem.jsx');
var BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
var ErrorPage = React.createClass({
getDefaultProps: function() {
return {
ver : '0.0.0',
errorId: ''
};
},
text : '# Oops \n We could not find a brew with that id. **Sorry!**',
render : function(){
return <div className='errorPage page'>
<Navbar ver={this.props.ver}>
<Nav.section>
<Nav.item className='errorTitle'>
Crit Fail!
</Nav.item>
</Nav.section>
<Nav.section>
<PatreonNavItem />
<IssueNavItem />
<RecentNavItem.both errorId={this.props.errorId} />
</Nav.section>
</Navbar>
<div className='content'>
<BrewRenderer text={this.text} />
</div>
</div>
}
});
module.exports = ErrorPage;

View File

@@ -0,0 +1,5 @@
.errorPage{
.errorTitle{
background-color: @orange;
}
}

View File

@@ -19,7 +19,8 @@ var BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
var HomePage = React.createClass({
getDefaultProps: function() {
return {
welcomeText : ""
welcomeText : '',
ver : '0.0.0'
};
},
getInitialState: function() {
@@ -30,7 +31,6 @@ var HomePage = React.createClass({
handleSave : function(){
request.post('/api')
.send({
title : 'Change This',
text : this.state.text
})
.end((err, res)=>{
@@ -48,7 +48,7 @@ var HomePage = React.createClass({
});
},
renderNavbar : function(){
return <Navbar>
return <Navbar ver={this.props.ver}>
<Nav.section>
<PatreonNavItem />
<IssueNavItem />

View File

@@ -18,8 +18,6 @@ Like this tool? Want to buy me a beer? [Head here](https://www.patreon.com/stolk
This tool will **always** be free, never have ads, and I will never offer any "premium" features or whatever.
### Bugs, Issues, Suggestions?
Have an idea of how to make The Homebrewery better? Or did you find something that wasn't quite right? Head [here](https://github.com/stolksdorf/homebrewery/issues/new) and let me know!.
>##### PDF Exporting
@@ -38,25 +36,19 @@ Have an idea of how to make The Homebrewery better? Or did you find something th
```
```
## New Things in v2.2.0!
## New Things All The Time!
What's new in the latest update? Check out the full changelog [here](/changelog)
* **New Subdomain** I moved The Homebrewery to it's own subdomain. This will make it easier to build and deploy more tools in the future.
## V2 Overhaul
A lot of <i class='fa fa-heart'></i> has been put into version 2 of The Homebrewery. Here are the highlights:
* **A whole new look** The site has been re-built from the ground up!
* **Better editor and split pane** Syntax highlighting will make writing your brews even easier, and now you can customize how large your editor is.
* **More reliable rendering** Lots of work has been put into making the rendering more reliable, not just for web, but also for PDFs
* **PDF Printing on Chrome** You don't need to use Chrome Canary anymore!
* ** Performance Improvements** The site should load faster, save faster, and render large brews *much* faster.
* **Patreon page** If you like this tool and want to show some thanks you can [head here](https://www.patreon.com/stolksdorf).
### Bugs, Issues, Suggestions?
Have an idea of how to make The Homebrewery better? Or did you find something that wasn't quite right? Head [here](https://github.com/stolksdorf/homebrewery/issues/new) and let me know!.
### Legal Junk
The Homebrewery is licensed using the [MIT License](https://github.com/stolksdorf/homebrewery/blob/master/license). Which means you are free to use The Homebrewery is any way that you want, except for claiming that you made it yourself.
If you wish to sell or in some way gain profit for what's created on this site, it's your responsibility to ensure you have the proper licenses/rights for any images or resources used.
### More Resources
If you are looking for more 5e Homebrew resources check out [r/UnearthedArcana](https://www.reddit.com/r/UnearthedArcana/) and their list of useful resources [here](https://www.reddit.com/r/UnearthedArcana/comments/3uwxx9/resources_open_to_the_community/).
@@ -83,18 +75,17 @@ ___
```
```
### Images
Images can be included 'inline' with the text using Markdown-style images. However for background images more control is needed.
Background images should be included as HTML-style img tags. Using inline CSS you can precisely position your image where you'd like it to be. I have added both a inflow image snippet and a background image snippet to give you exmaples of how to do it.
```
```
### Legal Junk
You are free to use The Homebrewery is any way that you want, except for claiming that you made it yourself. If you wish to sell or in some way gain profit for what's created on this site, it's your responsibility to ensure you have the proper licenses/rights for any images or resources used.
### Crediting Me
If you'd like to credit The Homebrewery in your brew, I'd be flattered! Just reference that you made it with The Homebrewery.

View File

@@ -19,7 +19,8 @@ const KEY = 'homebrewery-new';
var NewPage = React.createClass({
getInitialState: function() {
return {
title : 'My Awesome Brew v99',
ver : '0.0.0',
title : '',
text: '',
isSaving : false
};
@@ -98,7 +99,7 @@ var NewPage = React.createClass({
},
renderNavbar : function(){
return <Navbar>
return <Navbar ver={this.props.ver}>
<Nav.section>
<EditTitle title={this.state.title} onChange={this.handleTitleChange} />
</Nav.section>

View File

@@ -14,6 +14,7 @@ var HijackPrint = require('../hijackPrint.js');
var SharePage = React.createClass({
getDefaultProps: function() {
return {
ver : '0.0.0',
brew : {
title : '',
text : '',
@@ -34,7 +35,7 @@ var SharePage = React.createClass({
render : function(){
return <div className='sharePage page'>
<Navbar>
<Navbar ver={this.props.ver}>
<Nav.section>
<Nav.item className='brewTitle'>{this.props.brew.title}</Nav.item>
</Nav.section>

View File

@@ -195,8 +195,8 @@ body {
}
}
//If a note starts a column, give it space at the top to render border
pre+blockquote{
margin-top : 11px;
pre+blockquote, h2+blockquote, h3+blockquote, h4+blockquote, h5+blockquote {
margin-top : 13px;
}
//*****************************
// * MONSTER STAT BLOCK

21
license Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2016 Scott Tolksdorf
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,7 +1,7 @@
{
"name": "homebrewery",
"description": "Create authentic looking D&D homebrews using only markdown",
"version": "2.2.8",
"version": "2.3.0",
"scripts": {
"postinstall": "gulp prod",
"start": "node server.js"

View File

@@ -375,8 +375,12 @@ body {
font-size: 0.352cm;
line-height: 1.1em;
}
.phb pre + blockquote {
margin-top: 11px;
.phb pre + blockquote,
.phb h2 + blockquote,
.phb h3 + blockquote,
.phb h4 + blockquote,
.phb h5 + blockquote {
margin-top: 13px;
}
.phb hr + blockquote {
position: relative;

View File

@@ -43,7 +43,7 @@ app.get('/admin', function(req, res){
//Populate homebrew routes
app = require('./server/homebrew.api.js')(app);
//app = require('./server/homebrew.server.js')(app);
var HomebrewModel = require('./server/homebrew.model.js').model;
@@ -53,14 +53,14 @@ var sanitizeBrew = function(brew){
return cleanBrew;
};
//Load project version
var projectVersion = require('./package.json').version;
//Edit Page
app.get('/edit/:id', function(req, res){
HomebrewModel.find({editId : req.params.id}, function(err, objs){
if(err || !objs.length) return res.status(404).send('Could not find Homebrew with that id');
var resObj = null;
var errObj = {text: "# oops\nCould not find the homebrew."}
if(objs.length){
resObj = objs[0].toJSON();
}
@@ -71,7 +71,8 @@ app.get('/edit/:id', function(req, res){
prerenderWith : './client/homebrew/homebrew.jsx',
initialProps: {
url: req.originalUrl,
brew : resObj || errObj
brew : resObj || {},
version : projectVersion
},
clearRequireCache : !process.env.PRODUCTION,
}, function (err, page) {
@@ -84,16 +85,15 @@ app.get('/edit/:id', function(req, res){
//Share Page
app.get('/share/:id', function(req, res){
HomebrewModel.find({shareId : req.params.id}, function(err, objs){
if(err || !objs.length) return res.status(404).send('Could not find Homebrew with that id');
var resObj = null;
var errObj = {text: "# oops\nCould not find the homebrew."}
var brew = {};
if(objs.length){
resObj = objs[0];
var resObj = objs[0];
resObj.lastViewed = new Date();
resObj.views = resObj.views + 1;
resObj.save();
brew = resObj.toJSON();
}
vitreumRender({
@@ -102,7 +102,8 @@ app.get('/share/:id', function(req, res){
prerenderWith : './client/homebrew/homebrew.jsx',
initialProps: {
url: req.originalUrl,
brew : sanitizeBrew(resObj.toJSON() || errObj)
brew : sanitizeBrew(brew || {}),
version : projectVersion
},
clearRequireCache : !process.env.PRODUCTION,
}, function (err, page) {
@@ -116,13 +117,15 @@ var Markdown = require('naturalcrit/markdown.js');
var PHBStyle = '<style>' + require('fs').readFileSync('./phb.standalone.css', 'utf8') + '</style>'
app.get('/print/:id', function(req, res){
HomebrewModel.find({shareId : req.params.id}, function(err, objs){
if(err || !objs.length) return res.status(404).send('Could not find Homebrew with that id');
var brew = null;
var brew = {};
if(objs.length){
brew = objs[0];
}
if(err || !objs.length){
brew.text = '# Oops \n We could not find a brew with that id. **Sorry!**';
}
var content = _.map(brew.text.split('\\page'), function(pageText, index){
return `<div class="phb print" id="p${index+1}">` + Markdown.render(pageText) + '</div>';
}).join('\n');
@@ -150,7 +153,7 @@ app.get('/source/:id', function(req, res){
});
//Home and 404, etc.
var welcomeText = require('fs').readFileSync('./client/homebrew/pages/homePage/welcome_msg.txt', 'utf8');
var welcomeText = require('fs').readFileSync('./client/homebrew/pages/homePage/welcome_msg.md', 'utf8');
var changelogText = require('fs').readFileSync('./changelog.md', 'utf8');
app.get('*', function (req, res) {
vitreumRender({
@@ -160,7 +163,8 @@ app.get('*', function (req, res) {
initialProps: {
url: req.originalUrl,
welcomeText : welcomeText,
changelog : changelogText
changelog : changelogText,
version : projectVersion
},
clearRequireCache : !process.env.PRODUCTION,
}, function (err, page) {

View File

@@ -27,11 +27,26 @@ var getTopBrews = function(cb){
});
}
var getGoodBrewTitle = (text) => {
var titlePos = text.indexOf('# ');
if(titlePos !== -1){
var ending = text.indexOf('\n', titlePos);
return text.substring(titlePos + 2, ending);
}else{
return _.find(text.split('\n'), (line)=>{
return line;
});
}
};
module.exports = function(app){
app.post('/api', function(req, res){
var newHomebrew = new HomebrewModel(req.body);
if(!newHomebrew.title){
newHomebrew.title = getGoodBrewTitle(newHomebrew.text);
}
newHomebrew.save(function(err, obj){
if(err){
console.error(err, err.toString(), err.stack);
@@ -92,6 +107,7 @@ module.exports = function(app){
app.get('/api/search', mw.adminOnly, function(req, res){
var page = req.query.page || 0;
var count = req.query.count || 20;

View File

@@ -4,7 +4,7 @@ var renderer = new Markdown.Renderer();
//Processes the markdown within an HTML block if it's just a class-wrapper
renderer.html = function (html) {
if(_.startsWith(_.trim(html), '<div class=') && _.endsWith(_.trim(html), '</div>')){
if(_.startsWith(_.trim(html), '<div') && _.endsWith(_.trim(html), '</div>')){
var openTag = html.substring(0, html.indexOf('>')+1);
html = html.substring(html.indexOf('>')+1);
html = html.substring(0, html.lastIndexOf('</div>'));