1
0
mirror of https://github.com/stolksdorf/homebrewery.git synced 2025-12-11 07:45:56 +00:00

vitreum 4 is looking stable

This commit is contained in:
Scott Tolksdorf
2016-12-25 21:44:27 -05:00
parent 1ec0b2fa91
commit 56048ab936
11 changed files with 121 additions and 712 deletions

6
.babelrc Normal file
View File

@@ -0,0 +1,6 @@
{
"presets": [
"env",
"react"
]
}

View File

@@ -1,30 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<script>global=window</script>
<link href="//netdna.bootstrapcdn.com/font-awesome/4.6.2/css/font-awesome.min.css" rel="stylesheet" />
<link href="//fonts.googleapis.com/css?family=Open+Sans:400,300,600,700" rel="stylesheet" type="text/css" />
<link rel="icon" href="/assets/homebrew/favicon.ico" type="image/x-icon" />
{{=vitreum.css}}
{{=vitreum.globals}}
<title>The Homebrewery - NaturalCrit</title>
</head>
<body>
<div id="reactContainer">{{=vitreum.component}}</div>
</body>
{{=vitreum.libs}}
{{=vitreum.js}}
{{=vitreum.reactRender}}
{{? vitreum.inProduction}}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','http://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-72212009-1', 'auto');
ga('send', 'pageview');
</script>
{{?}}
</html>

21
client/template.js Normal file
View File

@@ -0,0 +1,21 @@
module.exports = function(vitreum){
return `
<!DOCTYPE html>
<html>
<head>
<link href="//netdna.bootstrapcdn.com/font-awesome/4.6.2/css/font-awesome.min.css" rel="stylesheet" />
<link href="//fonts.googleapis.com/css?family=Open+Sans:400,300,600,700" rel="stylesheet" type="text/css" />
<link rel="icon" href="/assets/homebrew/favicon.ico" type="image/x-icon" />
<title>The Homebrewery - NaturalCrit</title>
${vitreum.head}
</head>
<body>
<main id="reactRoot">${vitreum.body}</main>
</body>
${vitreum.js}
</html>
`;
}

View File

@@ -1,26 +1,24 @@
{
"name": "homebrewery",
"description": "Create authentic looking D&D homebrews using only markdown",
"version": "2.6.2",
"version": "2.7.0",
"scripts": {
"build": "node_modules/.bin/gulp prod",
"watch": "node_modules/.bin/gulp",
"libs": "node_modules/.bin/gulp fresh",
"dev": "node scripts/dev.js",
"build": "node scripts/build.js",
"phb": "node scripts/phb.js",
"prod": "set NODE_ENV=production&& npm run build",
"postinstall": "npm run build",
"start": "node server.js"
},
"author": "stolksdorf",
"license": "MIT",
"dependencies": {
"app-module-path": "^1.0.4",
"basic-auth": "^1.0.3",
"body-parser": "^1.14.2",
"classnames": "^2.2.0",
"codemirror": "^5.22.0",
"cookie-parser": "^1.4.3",
"express": "^4.13.3",
"gulp": "^3.9.0",
"gulp-less": "^3.1.0",
"gulp-rename": "^1.2.2",
"jwt-simple": "^0.5.1",
"lodash": "^4.11.2",
"marked": "^0.3.5",
@@ -34,6 +32,6 @@
"shortid": "^2.2.4",
"striptags": "^2.1.1",
"superagent": "^1.6.1",
"vitreum": "^3.2.1"
"vitreum": "^4.0.5"
}
}

File diff suppressed because one or more lines are too long

20
scripts/build.js Normal file
View File

@@ -0,0 +1,20 @@
const label = 'build';
console.time(label);
const clean = require('vitreum/steps/clean.js');
const jsx = require('vitreum/steps/jsx.js').partial;
const lib = require('vitreum/steps/libs.js').partial;
const less = require('vitreum/steps/less.js').partial;
const asset = require('vitreum/steps/assets.js').partial;
const Proj = require('./project.json');
clean()
.then(lib(Proj.libs))
.then(jsx('homebrew', './client/homebrew/homebrew.jsx', Proj.libs, ['./shared']))
.then(less('homebrew', ['./shared']))
.then(jsx('admin', './client/admin/admin.jsx', Proj.libs, ['./shared']))
.then(less('admin', ['./shared']))
.then(asset(Proj.assets, ['./shared', './client']))
.then(console.timeEnd.bind(console, label))
.catch(console.error);

19
scripts/dev.js Normal file
View File

@@ -0,0 +1,19 @@
const label = 'dev';
console.time(label);
const jsx = require('vitreum/steps/jsx.watch.js').partial;
const less = require('vitreum/steps/less.watch.js').partial;
const assets = require('vitreum/steps/assets.watch.js').partial;
const server = require('vitreum/steps/server.watch.js').partial;
const livereload = require('vitreum/steps/livereload.js').partial;
const Proj = require('./project.json');
Promise.resolve()
.then(jsx('homebrew', './client/homebrew/homebrew.jsx', Proj.libs, ['shared']))
.then(less('homebrew', './shared'))
.then(assets(Proj.assets, ['./shared', './client']))
.then(livereload())
.then(server('./server.js', ['server']))
.then(console.timeEnd.bind(console, label))
.catch(console.error)

10
scripts/phb.js Normal file
View File

@@ -0,0 +1,10 @@
const less = require('less');
const fs = require('fs');
less.render(fs.readFileSync('./client/homebrew/phbStyle/phb.style.less', 'utf8'), {compress : true})
.then((output) => {
fs.writeFileSync('./phb.standalone.css', output.css);
console.log('phb.standalone.css created!');
}, (err) => {
console.error(err);
});

19
scripts/project.json Normal file
View File

@@ -0,0 +1,19 @@
{
"assets": ["*.png","*.otf", "*.ico"],
"shared":[
],
"libs" : [
"react",
"react-dom",
"lodash",
"classnames",
"codemirror",
"codemirror/mode/gfm/gfm.js",
"codemirror/mode/javascript/javascript.js",
"moment",
"superagent",
"marked",
"pico-router",
"pico-flux"
]
}

View File

@@ -1,10 +1,8 @@
require('app-module-path').addPath('./shared');
const _ = require('lodash');
const jwt = require('jwt-simple');
const vitreumRender = require('vitreum/render');
const express = require("express");
const app = express();
app.use(express.static(__dirname + '/build'));
app.use(require('body-parser').json({limit: '25mb'}));
app.use(require('cookie-parser')());
@@ -33,7 +31,7 @@ app.use((req, res, next) => {
app.use(require('./server/homebrew.api.js'));
app.use(require('./server/admin.api.js'));
//app.use(require('./server/admin.api.js'));
const HomebrewModel = require('./server/homebrew.model.js').model;
@@ -113,31 +111,28 @@ app.get('/print/:id', (req, res, next)=>{
//Render Page
const render = require('vitreum/steps/render');
const templateFn = require('./client/template.js');
app.use((req, res) => {
vitreumRender({
page: './build/homebrew/bundle.dot',
globals:{
version : require('./package.json').version
},
prerenderWith : './client/homebrew/homebrew.jsx',
initialProps: {
render('homebrew', templateFn, {
version : require('./package.json').version,
url: req.originalUrl,
welcomeText : welcomeText,
changelog : changelogText,
brew : req.brew,
brews : req.brews,
account : req.account
},
clearRequireCache : !process.env.PRODUCTION,
}, (err, page) => {
return res.send(page)
});
})
.then((page) => {
return res.send(page)
})
.catch((err) => {
console.log(err);
return res.sendStatus(500);
});
});
var port = process.env.PORT || 8000;
app.listen(port);
console.log('Listening on localhost:' + port);
const PORT = process.env.PORT || 8000;
app.listen(PORT);
console.log(`server on port:${PORT}`);

View File

@@ -12,7 +12,7 @@
font-family : CodeBold;
src : url('/assets/naturalcrit/styles/CODE Bold.otf');
}
html,body, #reactContainer{
html,body, #reactRoot{
height : 100vh;
min-height : 100vh;
margin : 0;