Commit b420a18c authored by Jure's avatar Jure

Readme and polish.

parent cf14b659
.DS_Store
node_modules/
api/db/*
public/assets/*
# Science Blogger
Powered by PubSweet.
# Preconditions
Node.js, version above or equal to 4.0.0, is a requirement, read about how to install it here: [https://nodejs.org/en/](https://nodejs.org/en/)
Warning about `npm`: Because the newly released npm 3 changed the way npm installs nested dependencies (it flattens them), and we rely on previous behaviour (https://github.com/npm/npm/issues/9809) please use npm 2.x while we work on resolving this.
# Install
```bash
$ git clone git@gitlab.coko.foundation:pubsweet/science-blogger.git
$ cd science-blogger
$ npm install
```
# Start the server
First, initialize your blog by running and going through the setup process:
```bash
$ NODE_ENV=dev npm run setup
```
To start the JS compilation and webserver, run:
```bash
$ npm run dev
```
Point your browser to: http://localhost:3000/manage/posts and login with the chosen admin username and password and all should be well. Visit http://localhost:3000 for the blog landing page.
# Themes
Themes are a PubSweet component. If you want to write a custom theme, set your theme component in `config.js`. When you require a style from a component, using e.g. `import './Signup.scss'` in `app/components/Signup/Signup.jsx`, we'll automatically find the right themed style (e.g. `app/components/PepperTheme/Signup/Signup.scss` if theme is set to `PepperTheme`). You can then continue working on your themed styles as usual, and the page will hot-reload when you change anything.
# How to look into the database for debugging purposes
Run a PouchDB server (comes with the app):
```bash
$ npm run pouchdb
```
And navigate to [http://localhost:5984/_utils/](http://localhost:5984/_utils/). Click "Add New Database" and enter "dev", to connect to the development database. You should now be able to run queries on your development database.
# Production installation
These are instructions for Ubuntu 15.10, exact steps may vary from OS to OS so if you're using another system, please take this as general guidance only.
First [install node 4.x](https://github.com/nodesource/distributions#debinstall)
```bash
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
```
Then clone the repository:
```bash
git clone https://gitlab.coko.foundation/pubsweet/science-blogger.git
```
Install the required npm modules:
```bash
npm install
```
Build the production JS:
```bash
npm run build
```
Configure your initial admin account:
```bash
NODE_ENV=production npm run setup
```
Start the server:
```bash
npm run start
```
The application should now be accessible through port 80 on your server.
import React, { Component, PropTypes } from 'react'
import { ReduxRouter } from 'redux-router'
import { Provider } from 'react-redux'
export default class Root extends Component {
render () {
const { store } = this.props
return (
<Provider store={store}>
<div>
<ReduxRouter />
</div>
</Provider>
)
}
}
Root.propTypes = {
store: PropTypes.object.isRequired
}
import React from 'pubsweet-core/node_modules/react'
import { render } from 'pubsweet-core/node_modules/react-dom'
import ReactDOM from 'pubsweet-core/node_modules/react-dom'
import configureStore from 'pubsweet-core/app/store/configureStore'
import Root from 'pubsweet-core/app/components/Root'
import { AppContainer } from 'react-hot-loader'
import { AppContainer } from 'pubsweet-core/node_modules/react-hot-loader'
import { browserHistory } from 'pubsweet-core/node_modules/react-router'
import { syncHistoryWithStore } from 'pubsweet-core/node_modules/react-router-redux'
let store = configureStore()
let store = configureStore(browserHistory, {})
let history = syncHistoryWithStore(browserHistory, store)
render(
const rootEl = document.getElementById('root')
ReactDOM.render(
<AppContainer>
<Root store={store}/>
<Root store={store} history={history}/>
</AppContainer>,
document.getElementById('root')
rootEl
)
if (module.hot) {
module.hot.accept('pubsweet-core/app/components/Root', () => {
const NextRoot = require('pubsweet-core/app/components/Root').default
render(
ReactDOM.render(
<AppContainer>
<NextRoot store={store}/>
<NextRoot store={store} history={history}/>
</AppContainer>,
document.getElementById('root')
rootEl
)
})
}
......@@ -27,16 +27,13 @@ export default class Navigation extends React.Component {
</Navbar.Header>
<Nav eventKey={0}>
<LinkContainer to='/manage/posts'>
<NavItem>Science Postss</NavItem>
<NavItem>Science Posts</NavItem>
</LinkContainer>
{ AuthHelper.showForUser(auth, 'users') &&
<LinkContainer to='/manage/users'>
<NavItem>Users</NavItem>
</LinkContainer>
}
<LinkContainer to='/manage/users'>
<NavItem>She's alive!</NavItem>
</LinkContainer>
</Nav>
{ logoutButtonIfAuthenticated }
</Navbar>
......
......@@ -4,7 +4,7 @@ import { Route } from 'pubsweet-core/node_modules/react-router'
import { requireAuthentication } from 'pubsweet-core/app/components/AuthenticatedComponent'
// Manage
import Manage from 'pubsweet-core/app/components/Manage'
import Manage from 'pubsweet-core/app/components/Manage/Manage'
import PostsManager from 'pubsweet-core/app/components/PostsManager/PostsManager'
import ScienceWriter from 'pubsweet-core/app/components/ScienceWriter/ScienceWriter'
import UsersManager from 'pubsweet-core/app/components/UsersManager/UsersManager'
......
module.exports = {
secret: 'EXAMPLEDONTUSE',
API_ENDPOINT: '/api',
theme: 'pepper',
theme: 'PepperTheme',
routes: 'app/routes.jsx',
navigation: 'app/components/Navigation/Navigation.jsx'
}
......@@ -3,9 +3,9 @@
"version": "1.0.0-alpha.2",
"private": true,
"scripts": {
"setup": "node node_modules/core/api/setup.js",
"setup": "node node_modules/pubsweet-core/api/setup.js",
"build": "webpack --colors --config ./webpack/webpack.prod.config.js",
"start": "PORT=80 NODE_ENV=production node bin/www",
"start": "PORT=3333 NODE_ENV=production node bin/www",
"dev": "NODE_ENV=dev LOADER=hot node bin/www",
"pouchdb": "./node_modules/pouchdb-server/bin/pouchdb-server --level-prefix=./api/db/ -d ./api/db/",
"test": "NODE_ENV=test ./node_modules/.bin/mocha --harmony api/test/*.js -R nyan",
......@@ -20,6 +20,7 @@
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-2": "^6.5.0",
"eslint": "^1.10.3",
"eslint-config-standard": "^4.4.0",
"eslint-config-standard-react": "^1.2.1",
......
......@@ -12,7 +12,7 @@ var commonLoaders = [
test: /\.js$|\.jsx$/,
loader: 'babel',
query: {
presets: ['react', 'es2015'],
presets: ['es2015', 'react', 'stage-2'],
plugins: ['react-hot-loader/babel']
},
include: [
......@@ -39,8 +39,6 @@ var commonLoaders = [
]
console.log(commonLoaders[0])
module.exports = [
{
// The configuration for the client
......@@ -49,8 +47,8 @@ module.exports = [
context: path.join(__dirname, '..', 'app'),
entry: {
app: [
'webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000&reload=true',
'react-hot-loader/patch',
'webpack-hot-middleware/client',
'./app'
]
},
......
var path = require('path')
var webpack = require('webpack')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var ThemeResolver = require('../node_modules/core/webpack/ThemeResolver')
var config = require('../config')
var ExtractTextPlugin = require('pubsweet-core/node_modules/extract-text-webpack-plugin')
var HtmlWebpackPlugin = require('pubsweet-core/node_modules/html-webpack-plugin')
var ThemeResolver = require('pubsweet-core/webpack/ThemeResolver')
var assetsPath = path.join(__dirname, '..', 'public', 'assets')
var publicPath = '/assets/'
......@@ -12,20 +11,17 @@ var publicPath = '/assets/'
// but excluding its node_modules.
var commonLoaders = [
{
/*
* TC39 categorises proposals for babel in 4 stages
* Read more http://babeljs.io/docs/usage/experimental/
*/
test: /\.js$|\.jsx$/,
loader: 'babel',
// Reason why we put this here instead of babelrc
// https://github.com/gaearon/react-transform-hmr/issues/5#issuecomment-142313637
query: {
'presets': ['es2015', 'react'],
'cacheDirectory': true
presets: ['es2015', 'react', 'stage-2'],
plugins: ['react-hot-loader/babel']
},
include: path.join(__dirname, '..', 'app'),
exclude: path.join(__dirname, '/node_modules/')
include: [
new RegExp(path.join(__dirname, '../node_modules/core/app')),
new RegExp(path.join(__dirname, '../app')),
new RegExp(path.join(__dirname, '../../core/app')) // TODO: Temp while linked.
]
},
{ test: /\.png$/, loader: 'url-loader' },
{
......@@ -42,6 +38,7 @@ var commonLoaders = [
include: /\.local\.s?css/, // Local styles
loader: 'style-loader!css-loader?modules&importLoaders=1!sass-loader'
}
]
module.exports = [
......@@ -51,31 +48,35 @@ module.exports = [
target: 'web',
context: path.join(__dirname, '..', 'app'),
entry: {
app: [ './app' ]
app: [
'./app'
]
},
output: {
// The output directory as absolute path
path: assetsPath,
// The filename of the entry chunk as relative path inside the output.path directory
filename: '[name]-[hash].js',
// The output path from the view of the Javascript
publicPath: publicPath
},
module: {
preLoaders: [{
test: /\.js$|\.jsx$/,
exclude: [/node_modules/, /\/lens/, /\/substance/],
exclude: [/\/node_modules/, /\/lens/, /\/substance/],
loaders: ['eslint-loader']
}],
loaders: commonLoaders
},
resolve: {
root: path.resolve(__dirname, '..'),
extensions: ['', '.js', '.jsx', '.json', '.scss'],
alias: {
'routes$': config.routes,
'navigation$': config.navigation
}
},
plugins: [
new webpack.ResolverPlugin([ThemeResolver], ['normal', 'context', 'loader']),
new HtmlWebpackPlugin({
title: 'PubSweet',
title: 'PubSweet Science Blogger',
template: '../app/index.ejs', // Load a custom template
inject: 'body' // Inject all scripts into the body
}),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment