Commit e6fd7c9a authored by Jure's avatar Jure

Move initial-app from pubsweet-cli

parent 30d3353c
api
logs
node_modules
.env.*
_build
{
"description": "A new pubsweet app",
"files": [
"app",
"config",
"static",
"webpack"
],
"dependencies": {
"pubsweet": "1.0.0-alpha.3",
"pubsweet-server": "1.0.0-alpha.2",
"pubsweet-client": "1.0.0-alpha.3",
"pubsweet-component-blog": "^0.2.0",
"pubsweet-component-login": "^0.3.0",
"pubsweet-component-manage": "^0.1.8",
"pubsweet-component-signup": "^0.2.0",
"pubsweet-component-pepper-theme": "^0.0.3",
"pubsweet-component-posts-manager": "^0.3.0",
"pubsweet-theme-plugin": "^0.0.1",
"pubsweet-component-teams-manager": "^0.1.7",
"pubsweet-component-users-manager": "^0.1.6",
"pubsweet-component-html": "^0.0.1",
"pubsweet-component-medium-draft": "^0.0.3"
},
"devDependencies": {
"app-module-path": "^2.2.0",
"autobind-decorator": "^1.3.4",
"babel-core": "^6.14.0",
"babel-loader": "^7.0.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-babili": "0.0.12",
"babel-preset-es2015": "^6.14.0",
"babel-preset-es2015-native-modules": "^6.9.4",
"babel-preset-react": "^6.11.1",
"babel-preset-stage-2": "^6.13.0",
"babili-webpack-plugin": "^0.0.11",
"bootstrap-sass": "^3.3.7",
"compression-webpack-plugin": "^0.3.1",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.28.1",
"standard": "^10.0.1",
"extract-text-webpack-plugin": "^2.0.0-beta.4",
"file-loader": "^0.11.1",
"html-webpack-plugin": "^2.24.0",
"joi-browser": "^10.0.6",
"json-loader": "^0.5.4",
"node-sass": "^4.5.2",
"pouchdb-adapter-memory": "^6.1.1",
"react-hot-loader": "^3.0.0-beta.6",
"sass-loader": "^6.0.3",
"script-loader": "^0.7.0",
"string-replace-loader": "^1.2.0",
"style-loader": "^0.17.0",
"url-loader": "^0.5.8",
"webpack": "^2.4.1",
"webpack-dev-middleware": "^1.10.2",
"webpack-hot-middleware": "^2.18.0"
},
"scripts": {
"start": "pubsweet run",
"setupdb": "pubsweet setupdb .",
"pubsweet": "pubsweet"
},
"repository": "put your repo here",
"license": "UNLICENSED"
}
// Use this file as a starting point for your project's .eslintrc.
// Copy this file, and add rule overrides as needed.
{
"extends": ["standard", "standard-react"]
}
import React from 'react'
import ReactDOM from 'react-dom'
import { configureStore, Root } from 'pubsweet-client'
import { AppContainer } from 'react-hot-loader'
import { browserHistory } from 'react-router'
import { syncHistoryWithStore } from 'react-router-redux'
let store = configureStore(browserHistory, {})
let history = syncHistoryWithStore(browserHistory, store)
const rootEl = document.getElementById('root')
ReactDOM.render(
<AppContainer>
<Root store={store} history={history} />
</AppContainer>,
rootEl
)
if (module.hot) {
module.hot.accept('pubsweet-client/src/components/Root', () => {
const NextRoot = require('pubsweet-client/src/components/Root').default
ReactDOM.render(
<AppContainer>
<NextRoot store={store} history={history} />
</AppContainer>,
rootEl
)
})
}
import React from 'react'
import { LinkContainer } from 'react-router-bootstrap'
import { Navbar, Nav, NavItem, NavbarBrand } from 'react-bootstrap'
import Authorize from 'pubsweet-client/src/helpers/Authorize'
import NavbarUser from 'pubsweet-component-navigation/NavbarUser'
export default class Navigation extends React.Component {
render () {
const { actions, currentUser } = this.props
let logoutButtonIfAuthenticated
if (currentUser.isAuthenticated) {
logoutButtonIfAuthenticated = <NavbarUser
user={currentUser.user}
onLogoutClick={actions.logoutUser}
/>
}
return (
<Navbar fluid>
<Navbar.Header>
<NavbarBrand>
<a href='#'><img src='/assets/pubsweet.jpg' alt='pubsweet' /></a>
</NavbarBrand>
</Navbar.Header>
<Nav>
<LinkContainer to='/manage/posts'>
<NavItem>Posts</NavItem>
</LinkContainer>
<Authorize operation='read' object='users'>
<LinkContainer to='/manage/users'>
<NavItem>Users</NavItem>
</LinkContainer>
</Authorize>
<Authorize operation='read' object='teams'>
<LinkContainer to='/manage/teams'>
<NavItem>Teams</NavItem>
</LinkContainer>
</Authorize>
</Nav>
{ logoutButtonIfAuthenticated }
</Navbar>
)
}
}
Navigation.propTypes = {
actions: React.PropTypes.object.isRequired,
currentUser: React.PropTypes.object
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<div id="root"></div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<div id="root"></div>
<script type="text/javascript" charset="utf-8" src="/assets/app.js"></script>
</body>
</html>
import React from 'react'
import { Route } from 'react-router'
import { requireAuthentication } from 'pubsweet-client/src/components/AuthenticatedComponent'
// Manage
import Manage from 'pubsweet-component-manage/Manage'
import PostsManager from 'pubsweet-component-posts-manager/PostsManager'
import UsersManager from 'pubsweet-component-users-manager/UsersManager'
import TeamsManager from 'pubsweet-component-teams-manager/TeamsManager'
// Editor
import MediumDraft from 'pubsweet-component-medium-draft/MediumDraft'
// Public
import Blog from 'pubsweet-component-blog/Blog'
import HTML from 'pubsweet-component-html/HTML'
// Authentication
import Login from 'pubsweet-component-login/Login'
import Signup from 'pubsweet-component-signup/Signup'
const AuthenticatedManage = requireAuthentication(
Manage, 'create', (state) => state.collections[0]
)
export default (
<Route>
<Route path='/' component={Blog} />
<Route path='/manage' component={AuthenticatedManage}>
<Route path='posts' component={PostsManager} />
<Route path='users' component={UsersManager} />
<Route path='teams' component={TeamsManager} />
<Route path='sciencewriter/:id' component={MediumDraft} />
</Route>
<Route path='/login' component={Login} />
<Route path='/signup' component={Signup} />
<Route path='/:id' component={HTML} />
</Route>
)
[
"pubsweet-component-blog",
"pubsweet-component-login",
"pubsweet-component-manage",
"pubsweet-component-pepper-theme",
"pubsweet-component-posts-manager",
"pubsweet-component-signup"
]
const config = require('./shared.js')
module.exports = config
const config = require('./shared.js')
module.exports = config
const path = require('path')
const blogmode = require('authsome/src/modes/blog')
const Joi = require('joi')
module.exports = {
'pubsweet-server': {
dbPath: process.env.PUBSWEET_DB || path.join(__dirname, '..', 'api', 'db'),
API_ENDPOINT: '/api',
sse: process.env.PUBSWEET_SSE
},
'pubsweet-client': {
theme: 'PepperTheme',
'login-redirect': '/manage/posts'
},
authsome: {
mode: blogmode,
teams: {
teamContributors: {
name: 'Contributors',
permissions: 'create'
},
teamCoauthors: {
name: 'Coauthors',
permissions: 'update'
}
},
'fail-redirect': '/login'
},
pubsweet: {
components: require('./components.json')
},
validations: {
fragment: {
kind: Joi.string(),
published: Joi.bool(),
published_at: Joi.string(),
source: Joi.any(),
presentation: Joi.string()
}
}
}
const config = require('./shared.js')
module.exports = config
const path = require('path')
module.exports = [
new RegExp(path.join(__dirname, '..', 'node_modules', 'pubsweet-client', 'src')),
new RegExp(path.join(__dirname, '..', 'app')),
new RegExp(path.join(__dirname, '..', 'node_modules', 'pubsweet-[^/\\\\]*(?!.*/node_modules)'))
]
const path = require('path')
const config = require(`../config/${process.env.NODE_ENV}.js`)
const babelIncludes = require('./babel-includes')
const resolve = (type, entry) => {
if (typeof entry === 'string') {
return require.resolve(`babel-${type}-${entry}`)
} else {
return [require.resolve(`babel-${type}-${entry[0]}`), entry[1]]
}
}
const resolvePreset = entry => resolve('preset', entry)
const resolvePlugin = entry => resolve('plugin', entry)
const clientComponents = config.pubsweet.components.filter(name => {
let component = require(name)
// Backwards compatibility - old name was 'frontend', new name is 'client'
return component.client || component.frontend
})
module.exports = [
{
test: /\.js$|\.jsx$/,
loader: 'babel-loader',
query: {
presets: [
['es2015', { 'modules': false }],
'react',
'stage-2'
].map(resolvePreset),
plugins: [
'react-hot-loader/babel',
resolvePlugin('transform-decorators-legacy')
],
env: {
production: {
presets: ['babili']
}
}
},
include: babelIncludes
},
{ test: /\.png$/, loader: 'url-loader' },
{
test: /\.woff|\.woff2|\.svg|.eot|\.ttf/,
loader: [
{
loader: 'url-loader',
options: {
prefix: 'font',
limit: 1000
}
}
]
},
{ test: /\.html$/, loader: 'html-loader' },
{ test: /\.json$/, loader: 'json-loader' },
{ test: /\.css$|\.scss$/,
exclude: /\.local\.s?css$/, // Exclude local styles from global
loader: [
{
loader: 'style-loader'
},
{
loader: 'css-loader'
},
{
loader: 'sass-loader',
options: {
includePaths: [path.join(__dirname, '..', 'node_modules')]
}
}
]
},
{ test: /\.css$|\.scss$/,
include: /\.local\.s?css/, // Local styles
loader: [
{
loader: 'style-loader'
},
{
loader: 'css-loader',
options: {
modules: true,
importLoaders: 1
}
},
{
loader: 'sass-loader',
options: {
includePaths: [path.join(__dirname, '..', 'node_modules')]
}
}
]
},
{
test: /\.js$|\.jsx$/,
loader: 'string-replace-loader',
query: {
search: 'PUBSWEET_COMPONENTS',
replace: '[' + clientComponents.map(component => `require('${component}')`).join(', ') + ']'
},
include: babelIncludes
}
]
const path = require('path')
const webpack = require('webpack')
const ThemePlugin = require('pubsweet-theme-plugin')
const config = require('../config/dev')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const CompressionPlugin = require('compression-webpack-plugin')
module.exports = [
{
// The configuration for the client
name: 'app',
target: 'web',
context: path.join(__dirname, '..', 'app'),
entry: {
app: [
'react-hot-loader/patch',
'webpack-hot-middleware/client',
'./app'
]
},
output: {
path: path.join(__dirname, '..', '_build', 'assets'),
filename: '[name].js',
publicPath: '/assets/'
},
devtool: 'cheap-module-source-map',
module: {
rules: require('./common-rules')
},
resolve: {
symlinks: false,
modules: [
path.resolve(__dirname, '..'),
path.resolve(__dirname, '..', 'node_modules'),
'node_modules'
],
alias: {
joi: 'joi-browser'
},
plugins: [new ThemePlugin(config['pubsweet-client'].theme)],
extensions: ['.js', '.jsx', '.json', '.scss'],
enforceExtension: false
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('dev'),
'REDUXLOG_OFF': process.env.REDUXLOG_OFF
}
}),
new webpack.ProvidePlugin({
'CONFIG': path.resolve(__dirname, '..', 'config', 'dev.js')
}),
new CopyWebpackPlugin([
{ from: '../static' }
]),
new webpack.optimize.AggressiveMergingPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new CompressionPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: /\.js$|\.css$|\.html$/
})
],
node: {
fs: 'empty',
__dirname: true
}
}
]
const path = require('path')
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ThemePlugin = require('pubsweet-theme-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const CompressionPlugin = require('compression-webpack-plugin')
const config = require('../config/production')
module.exports = [
{
// The configuration for the client
name: 'app',
target: 'web',
context: path.join(__dirname, '..', 'app'),
entry: {
app: ['./app']
},
output: {
path: path.join(__dirname, '..', '_build', 'assets'),
filename: '[name].[hash].js',
publicPath: '/assets/'
},
module: {
rules: require('./common-rules')
},
resolve: {
symlinks: false,
modules: [
path.resolve(__dirname, '..'),
path.join(__dirname, '..', 'node_modules'),
'node_modules'
],
alias: {
joi: 'joi-browser'
},
extensions: ['.js', '.jsx', '.json', '.scss'],
plugins: [new ThemePlugin(config['pubsweet-client'].theme)]
},
plugins: [
new HtmlWebpackPlugin({
title: 'PubSweet app',
template: '../app/index.ejs', // Load a custom template
inject: 'body' // Inject all scripts into the body
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new webpack.ProvidePlugin({
'CONFIG': path.resolve(__dirname, '..', 'config', 'production.js')
}),
new ExtractTextPlugin('styles/main.css'),
new CopyWebpackPlugin([
{ from: '../static' }
]),
new webpack.optimize.AggressiveMergingPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new CompressionPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: /\.js$|\.css$|\.html$/
})
],
node: {
fs: 'empty',
__dirname: true
}
}
]
const path = require('path')
const webpack = require('webpack')
const ThemePlugin = require('pubsweet-theme-plugin')
const config = require('../config/test')
const CompressionPlugin = require('compression-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
module.exports = [
{
// The configuration for the client
name: 'app',
target: 'web',
context: path.join(__dirname, '..', 'app'),
entry: {
app: [
'react-hot-loader/patch',
'webpack-hot-middleware/client',
'./app'
]
},
output: {
path: path.join(__dirname, '..', '_build', 'assets'),
filename: '[name].js',
publicPath: '/assets/'
},
module: {
rules: require('./common-rules')
},
resolve: {
symlinks: false,
modules: [
path.resolve(__dirname, '..'),
path.resolve(__dirname, '..', 'node_modules'),
'node_modules'
],
alias: {
joi: 'joi-browser'
},
plugins: [new ThemePlugin(config['pubsweet-client'].theme)],
extensions: ['.js', '.jsx', '.json', '.scss'],
enforceExtension: false
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('test'),
'REDUXLOG_OFF': process.env.REDUXLOG_OFF
}
}),
new webpack.ProvidePlugin({
'CONFIG': path.resolve(__dirname, '..', 'config', 'test.js')
}),
new CopyWebpackPlugin([
{ from: '../static' }
]),
new webpack.optimize.AggressiveMergingPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new CompressionPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: /\.js$|\.css$|\.html$/,
threshold: 10240,
minRatio: 0.8
})
],
node: {
fs: 'empty',
__dirname: true
}
}
]
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