Skip to content

Commit

Permalink
done dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jackhutu committed Jan 5, 2016
1 parent 84c611c commit bc35b92
Show file tree
Hide file tree
Showing 41 changed files with 161 additions and 1,232 deletions.
21 changes: 21 additions & 0 deletions .gitignore
@@ -1 +1,22 @@
# Logs
*.log
npm-debug.log*

# Runtime data
*.pid
.tmp

###############
.DS_Store
node_modules
dist

##push server
#/*
#!/dist
#!server.js
#!/logs
#!package.json
#!process.json
#*.log
#*.pid
22 changes: 22 additions & 0 deletions LICENSE
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 Jack Hu

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.

1 change: 1 addition & 0 deletions README.md
@@ -0,0 +1 @@
# jackblog react redux
29 changes: 0 additions & 29 deletions dist/1373cc49.bundle.js

This file was deleted.

8 changes: 0 additions & 8 deletions dist/1373cc49.style.css

This file was deleted.

22 changes: 0 additions & 22 deletions dist/1373cc49.vendor.js

This file was deleted.

Binary file removed dist/assets/fonts/32400f4e.fontawesome-webfont.eot
Binary file not shown.
Binary file not shown.
288 changes: 0 additions & 288 deletions dist/assets/fonts/89889688.glyphicons-halflings-regular.svg

This file was deleted.

Binary file removed dist/assets/fonts/a35720c2.fontawesome-webfont.woff
Binary file not shown.
Binary file removed dist/assets/fonts/a3de2170.fontawesome-webfont.ttf
Binary file not shown.
Binary file removed dist/assets/fonts/db812d8a.fontawesome-webfont.woff2
Binary file not shown.
Binary file not shown.
Binary file not shown.
655 changes: 0 additions & 655 deletions dist/assets/fonts/f775f9cc.fontawesome-webfont.svg

This file was deleted.

Binary file not shown.
Binary file removed dist/assets/images/ee50bb63.shanghai.jpg
Binary file not shown.
4 changes: 2 additions & 2 deletions dist/index.html
@@ -1,3 +1,3 @@
<!doctype html><html><head><base href="/"><meta charset="utf-8"><title>Jack&#39;s blog for react-redux</title><base href="/"><meta name="description" content="This is Jack Hu's blog."><meta name="keyword" content="jackblog blog react node angular node angular 前端博客"><meta name="viewport" content="width=device-width"><link rel="shortcut icon" href="favicon.ico"><link href="1373cc49.style.css" rel="stylesheet"></head><body class="day-mode"><!--[if lt IE 10]>
<!doctype html><html><head><base href="/"><meta charset="utf-8"><title>JackHu&#39;s blog</title><base href="/"><meta name="description" content="This is Jack Hu's blog."><meta name="keyword" content="jackblog blog react node angular node angular 前端博客"><meta name="viewport" content="width=device-width"><link rel="shortcut icon" href="favicon.ico"><link href="05c78466.style.css" rel="stylesheet"></head><body class="day-mode"><!--[if lt IE 10]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]--><div class="top-box" id="root"></div><script src="1373cc49.vendor.js"></script><script src="1373cc49.bundle.js"></script></body></html>
<![endif]--><div class="top-box" id="root"></div><script src="05c78466.vendor.js"></script><script src="05c78466.bundle.js"></script></body></html>
143 changes: 19 additions & 124 deletions gulpfile.babel.js
Expand Up @@ -6,11 +6,13 @@ import webpack from "webpack"
import del from 'del'
import env from 'gulp-env'
import gulpSequence from 'gulp-sequence'
import nodemon from 'gulp-nodemon'
import open from 'open'

const DEV_PORT = 5000,PROD_PORT = 8300
gulp.task('serve', cb =>{
let webpackConfig = require('./webpack.config')
let myConfig = Object.create(webpackConfig)
myConfig.debug = true
new WebpackDevServer(webpack(myConfig), {
noInfo: true,
hot: true,
Expand All @@ -19,9 +21,10 @@ gulp.task('serve', cb =>{
stats: {
colors: true
}
}).listen(5000, "localhost", err => {
}).listen(DEV_PORT, "localhost", err => {
if(err) throw new gutil.PluginError("webpack-dev-server", err)
gutil.log("[webpack-dev-server]", "==> 🌎 http://localhost:5000/webpack-dev-server/index.html")
gutil.log("[webpack-dev-server]", "==> 🌎 http://localhost:" + DEV_PORT)
open('http://localhost:' + DEV_PORT)
});
})

Expand All @@ -37,7 +40,8 @@ gulp.task('set-env-prod', ()=>{

gulp.task('webpack', cb => {
let webpackConfig = require('./webpack.config')
webpack(webpackConfig, function(err, stats) {
let myConfig = Object.create(webpackConfig)
webpack(myConfig, function(err, stats) {
if(err) throw new gutil.PluginError("webpack", err)
gutil.log("[webpack]", stats.toString({
// output options
Expand All @@ -51,124 +55,15 @@ gulp.task('webpack:dist',gulpSequence('set-env-prod','webpack'))

gulp.task('build', gulpSequence('clean','webpack:dist'))

gulp.task('nodemon', ()=> {
nodemon({
script: path.join(__dirname,'/server.js'),
ext: 'js',
watch: [
path.join(__dirname,'/dist')
],
env: { 'NODE_ENV': 'production','PORT':PROD_PORT }
})
})




// gulp.task("webpack-dev-server", function(callback) {
// // modify some webpack config options
// var myConfig = Object.create(webpackConfig);
// myConfig.devtool = "eval";
// myConfig.debug = true;

// // Start a webpack-dev-server
// new WebpackDevServer(webpack(myConfig), {
// publicPath: "/" + myConfig.output.publicPath,
// stats: {
// colors: true
// }
// }).listen(8080, "localhost", function(err) {
// if(err) throw new gutil.PluginError("webpack-dev-server", err);
// gutil.log("[webpack-dev-server]", "http://localhost:8080/webpack-dev-server/index.html");
// });
// });




// import del from "del";
// import path from "path";
// import gulp from "gulp";
// import open from "open";
// import gulpLoadPlugins from "gulp-load-plugins";
// import packageJson from "./package.json";
// import runSequence from "run-sequence";
// import webpack from "webpack";
// import webpackConfig from "./webpack.config";
// import WebpackDevServer from "webpack-dev-server";


// const PORT = process.env.PORT || 3000;
// const $ = gulpLoadPlugins({camelize: true});


// // Main tasks
// gulp.task('serve', () => runSequence('serve:clean', 'serve:index', 'serve:start'));
// gulp.task('dist', () => runSequence('dist:clean', 'dist:build', 'dist:index'));
// gulp.task('clean', ['dist:clean', 'serve:clean']);
// gulp.task('open', () => open('http://localhost:3000'));

// // Remove all built files
// gulp.task('serve:clean', cb => del('build', {dot: true}, cb));
// gulp.task('dist:clean', cb => del(['dist', 'dist-intermediate'], {dot: true}, cb));

// // Copy static files across to our final directory
// gulp.task('serve:static', () =>
// gulp.src([
// 'src/static/**'
// ])
// .pipe($.changed('build'))
// .pipe(gulp.dest('build'))
// .pipe($.size({title: 'static'}))
// );

// gulp.task('dist:static', () =>
// gulp.src([
// 'src/static/**'
// ])
// .pipe(gulp.dest('dist'))
// .pipe($.size({title: 'static'}))
// );

// // Copy our index file and inject css/script imports for this build
// gulp.task('serve:index', () => {
// return gulp
// .src('src/index.html')
// .pipe($.injectString.after('<!-- inject:app:js -->', '<script src="generated/main.js"></script>'))
// .pipe(gulp.dest('build'));
// });

// // Copy our index file and inject css/script imports for this build
// gulp.task('dist:index', () => {
// const app = gulp
// .src(["*.{css,js}"], {cwd: 'dist-intermediate/generated'})
// .pipe(gulp.dest('dist'));

// // Build the index.html using the names of compiled files
// return gulp.src('src/index.html')
// .pipe($.inject(app, {
// ignorePath: 'dist',
// starttag: '<!-- inject:app:{{ext}} -->'
// }))
// .on("error", $.util.log)
// .pipe(gulp.dest('dist'));
// });

// // Start a livereloading development server
// gulp.task('serve:start', ['serve:static'], () => {
// const config = webpackConfig(true, 'build', PORT);

// return new WebpackDevServer(webpack(config), {
// contentBase: 'build',
// publicPath: config.output.publicPath,
// watchDelay: 100
// })
// .listen(PORT, '0.0.0.0', (err) => {
// if (err) throw new $.util.PluginError('webpack-dev-server', err);

// $.util.log(`[${packageJson.name} serve]`, `Listening at 0.0.0.0:${PORT}`);
// });
// });

// // Create a distributable package
// gulp.task('dist:build', ['dist:static'], cb => {
// const config = webpackConfig(false, 'dist-intermediate');

// webpack(config, (err, stats) => {
// if (err) throw new $.util.PluginError('dist', err);

// $.util.log(`[${packageJson.name} dist]`, stats.toString({colors: true}));

// cb();
// });
// });
gulp.task('serve:dist',gulpSequence('build','nodemon'))
40 changes: 17 additions & 23 deletions package.json
@@ -1,28 +1,28 @@
{
"name": "jackblog-react-redux",
"version": "1.0.0",
"description": "Jack Hu's Blog for redux",
"description": "Jackblog react redux 版",
"repository": "https://github.com/jackhutu/jackblog-react-redux",
"license": "MIT",
"scripts": {
"start": "node server.js",
"test": "NODE_ENV=test mocha --recursive --compilers js:babel-core/register --require ./test/setup.js",
"test:watch": "npm test -- --watch",
"build": "NODE_ENV=production webpack"
},
"repository": {
"type": "git",
"url": "https://github.com/rackt/redux.git"
"start": "gulp serve",
"build": "gulp build",
"pm2-start": "pm2 start process.json",
"pm2-restart": "pm2 restart process.json"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/rackt/redux/issues"
"url": "https://github.com/jackhutu/jackblog-react-redux/issues"
},
"homepage": "http://rackt.github.io/redux",
"homepage": "https://github.com/jackhutu/jackblog-react-redux",
"dependencies": {
"axios": "^0.8.0",
"express": "^4.13.3",
"pm2": "^0.15.10",
"serve-favicon": "^2.3.0"
},
"devDependencies": {
"bootstrap": "^3.3.5",
"bootstrap-sass": "^3.3.5",
"classnames": "^2.1.2",
"express": "^4.13.3",
"extract-text-webpack-plugin": "^0.9.1",
"font-awesome": "^4.5.0",
"history": "^1.13.1",
Expand All @@ -41,10 +41,6 @@
"redux": "^3.0.0",
"redux-router": "^1.0.0-beta5",
"redux-thunk": "^1.0.0",
"serve-favicon": "^2.3.0",
"whatwg-fetch": "^0.10.1"
},
"devDependencies": {
"babel-core": "^6.3.15",
"babel-loader": "^6.2.0",
"babel-plugin-react-transform": "^2.0.0-beta1",
Expand All @@ -58,14 +54,15 @@
"express": "^4.13.3",
"gulp": "^3.9.0",
"gulp-env": "^0.4.0",
"gulp-nodemon": "^2.0.6",
"gulp-sequence": "^0.4.4",
"gulp-util": "^3.0.7",
"image-webpack-loader": "^1.6.2",
"jsdom": "^5.6.1",
"mocha": "^2.2.5",
"node-libs-browser": "^0.5.2",
"node-sass": "^3.4.2",
"raw-loader": "^0.5.1",
"open": "0.0.5",
"react-addons-test-utils": "^0.14.0",
"react-transform-catch-errors": "^1.0.0",
"react-transform-hmr": "^1.0.1",
Expand All @@ -75,11 +72,8 @@
"redux-devtools-log-monitor": "^1.0.0-beta-3",
"sass-loader": "^3.1.2",
"style-loader": "^0.12.3",
"todomvc-app-css": "^2.0.1",
"url-loader": "^0.5.7",
"webpack": "^1.9.11",
"webpack-dev-middleware": "^1.2.0",
"webpack-dev-server": "^1.14.0",
"webpack-hot-middleware": "^2.2.0"
"webpack-dev-server": "^1.14.0"
}
}
18 changes: 18 additions & 0 deletions process.json
@@ -0,0 +1,18 @@
{
"apps" : [
{
"name" : "jackblog-react-redux",
"script" : "./server.js",
"log_date_format" : "YYYY-MM-DD HH:mm Z",
"out_file" : "./logs/pm2-out.log",
"error_file" : "./logs/pm2-err.log",
"pid_file" : "./logs/jackblog-react-redux.pid",
"ignoreWatch" : ["[\\/\\\\]\\./", "node_modules"],
"watch" : "false",
"exec_mode" : "fork_mode", //cluster_mode
"env": {
"NODE_ENV": "production"
}
}
]
}
4 changes: 1 addition & 3 deletions server.js
Expand Up @@ -3,13 +3,11 @@ var express = require('express');
var favicon = require('serve-favicon');

var app = new express();
var port = 8300;

var port = process.env.PORT || 8300;

app.use(express.static(path.join(__dirname, 'dist')));
app.use(favicon(path.join(__dirname, 'dist', 'favicon.ico')));


app.get("/*", function(req, res) {
return res.sendFile(__dirname + '/dist/index.html')
})
Expand Down
23 changes: 0 additions & 23 deletions server.webpack.js

This file was deleted.

5 changes: 2 additions & 3 deletions src/actions/auth.js
@@ -1,6 +1,5 @@
import {GET_CAPTCHAURL,LOGIN_SUCCESS,LOGIN_FAILURE,USERINFO_SUCCESS,LOGOUT_USER,USERINFO_FAILURE,UPDATE_USER_FAILURE,UPDATE_USER_SUCCESS} from './ActionTypes'
const LOGIN_API = 'http://localhost:9000/auth/'
const API_ROOT = 'http://localhost:9000/'
import {API_ROOT} from '../config'
import fetch from 'isomorphic-fetch'
import { pushState } from 'redux-router'
import cookie from 'react-cookie'
Expand All @@ -20,7 +19,7 @@ function loginFailure(err) {
}
export function localLogin(userInfo) {
return (dispatch,getState) =>{
return fetch(LOGIN_API + 'local',{
return fetch(API_ROOT + 'auth/local',{
method: 'post',
credentials: 'include',
headers: {
Expand Down
2 changes: 1 addition & 1 deletion src/actions/index.js
@@ -1,6 +1,6 @@
import {CHANGE_STYLE_MODE,GET_INDEX_IMG,TAG_LIST,ARTICLE_LIST,ARTICLE_DETAIL,COMMENT_LIST,PRENEXT_ARTICLE, CHANGE_OPTIONS,ADD_ARTICLE_LIST,REQUEST_ARTICLE_LIST,GET_CAPTCHAURL,TOGGLE_LIKE,FAILURE_ADD_COMMENT,SUCCESS_ADD_COMMENT,FAILURE_ADD_REPLY,SUCCESS_ADD_REPLY} from './ActionTypes'
import fetch from 'isomorphic-fetch'
const API_ROOT = 'http://localhost:9000/'
import {API_ROOT} from '../config'
import img from '../assets/images/shanghai.jpg'
import querystring from 'querystring'
import cookie from 'react-cookie'
Expand Down

0 comments on commit bc35b92

Please sign in to comment.