From 97598ba7e88c73af1018869855a8ab3f59a3e20c Mon Sep 17 00:00:00 2001 From: mgerb42 Date: Tue, 30 Aug 2016 02:45:56 +0000 Subject: [PATCH] changes --- client/assets/scss/Content.scss | 1 + client/js/components/Preview.js | 4 +++- client/js/pages/Index.js | 2 +- client/js/redux/actions.js | 6 ++++++ client/js/redux/constants.js | 3 ++- client/js/redux/reducers.js | 14 ++++++-------- package.json | 5 +++-- server.go | 10 +++++++--- 8 files changed, 29 insertions(+), 16 deletions(-) diff --git a/client/assets/scss/Content.scss b/client/assets/scss/Content.scss index 1d23a1c..55c9552 100644 --- a/client/assets/scss/Content.scss +++ b/client/assets/scss/Content.scss @@ -1,6 +1,7 @@ .Content { flex: 1; flex-wrap: wrap; + min-width: 0; .post + .post { margin-top: 2em; } diff --git a/client/js/components/Preview.js b/client/js/components/Preview.js index 59069a3..db6f688 100644 --- a/client/js/components/Preview.js +++ b/client/js/components/Preview.js @@ -22,6 +22,8 @@ export default class Preview extends React.Component{

); + + if(i >= this.props.postLimit) break; } return elements; @@ -32,7 +34,7 @@ export default class Preview extends React.Component{ return (
- {posts.length > 0 ? this.insertPosts(posts): ""} + {posts.length > 0 ? this.insertPosts(posts): null}
); } diff --git a/client/js/pages/Index.js b/client/js/pages/Index.js index 51f19f4..3c21c8d 100644 --- a/client/js/pages/Index.js +++ b/client/js/pages/Index.js @@ -43,7 +43,7 @@ export default class Index extends React.Component {
- {typeof this.page === 'undefined' && !fetching ? : null} + {typeof this.page === 'undefined' && !fetching ? : null} {this.page === 'post' && !fetching ? : null} {fetching ? loadingElement : null} diff --git a/client/js/redux/actions.js b/client/js/redux/actions.js index 47adfdd..a191abd 100644 --- a/client/js/redux/actions.js +++ b/client/js/redux/actions.js @@ -2,6 +2,12 @@ import * as types from "./constants"; import marked from 'marked'; import 'whatwg-fetch'; +export function increasePostLimit(){ + return { + type: types.INCREASE_POST_LIMIT + } +} + function initPreview(posts) { return { type: types.INIT_PREVIEW, diff --git a/client/js/redux/constants.js b/client/js/redux/constants.js index d9cc693..6d21a68 100644 --- a/client/js/redux/constants.js +++ b/client/js/redux/constants.js @@ -2,4 +2,5 @@ export const INIT_PREVIEW = 'INIT_PREVIEW'; export const FILTER_PREVIEW = 'FILTER_PREVIEW'; export const LOAD_POST = 'LOAD_POST'; -export const FETCHING = 'FETCHING'; \ No newline at end of file +export const FETCHING = 'FETCHING'; +export const INCREASE_POST_LIMIT = 'INCREASE_POST_LIMIT'; \ No newline at end of file diff --git a/client/js/redux/reducers.js b/client/js/redux/reducers.js index 37bfec8..ebf0d11 100644 --- a/client/js/redux/reducers.js +++ b/client/js/redux/reducers.js @@ -14,12 +14,10 @@ const defaultState = { preview: { posts: [] }, - filteredPreview: { - posts: [] - }, post: "", fetched: false, - fetching: false + fetching: false, + postLimit: 10 }; //default reducer @@ -32,10 +30,6 @@ function reducer(state = defaultState, action) { fetched: true, fetching: false }); - case types.FILTER_PREVIEW: - return Object.assign({}, state, { - filteredPreview: Object.assign({}, state.filteredPreview, action.posts) - }); case types.LOAD_POST: return Object.assign({}, state, { post: action.post, @@ -47,6 +41,10 @@ function reducer(state = defaultState, action) { fetched : false, fetching: true }); + case types.INCREASE_POST_LIMIT: + return Object.assign({}, state, { + postLimit : state.postLimit + 10 + }); } //return present state if no actions get called diff --git a/package.json b/package.json index b0cfce2..e744041 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,9 @@ "build": "webpack && babel-node metadata.js", "c9": "webpack-dev-server --port $PORT --host $IP --hot --content-base dist --history-api-fallback", "dev": "webpack-dev-server --content-base public --inline --hot --history-api-fallback", - "prod": "export NODE_ENV=production && webpack -p && babel-node metadata.js", - "prod-win": "set NODE_ENV=production && webpack -p && babel-node metadata.js" + "prod": "export NODE_ENV=production && webpack -p && babel-node metadata.js && go build", + "prod-win": "set NODE_ENV=production && webpack -p && babel-node metadata.js && go build", + "deploy" : "npm run prod && ./mywebsite" }, "repository": { "type": "git", diff --git a/server.go b/server.go index 9377d20..6199475 100644 --- a/server.go +++ b/server.go @@ -4,7 +4,8 @@ import ( "log" "net/http" "strconv" - + "github.com/NYTimes/gziphandler" + //local import paths relative to app.yaml file "mywebsite/server/controller/api" "mywebsite/server/db" @@ -34,7 +35,10 @@ func main(){ api.Configure(configurations.Api) db.Mongo.Connect() - + + //register middleware + handle := gziphandler.GzipHandler(route.Routes()) + log.Println("Starting Server...") - log.Println(http.ListenAndServe(":"+strconv.Itoa(configurations.Port), route.Routes())) + log.Println(http.ListenAndServe(":"+strconv.Itoa(configurations.Port), handle)) }