From 0cb23c89e1bbe757baff1cbd46f74af2ffbb639a Mon Sep 17 00:00:00 2001 From: Jack Lenox Date: Wed, 30 Sep 2015 20:42:48 +0800 Subject: [PATCH 01/10] Non-working beginnings of server-side render --- components/content/content.jsx | 10 ++++--- .../hentry/entry-content/entry-content.jsx | 5 ++-- components/content/loop/hentry/hentry.jsx | 26 ++++++++++++------- components/content/loop/loop.jsx | 9 +++---- .../loop/navigation/post-navigation.jsx | 4 +-- package.json | 2 ++ sample.json | 12 +++++++++ webpack.config.js | 21 +++++++++++++++ 8 files changed, 67 insertions(+), 22 deletions(-) create mode 100644 sample.json create mode 100644 webpack.config.js diff --git a/components/content/content.jsx b/components/content/content.jsx index b6b015e..513e0fe 100644 --- a/components/content/content.jsx +++ b/components/content/content.jsx @@ -12,7 +12,7 @@ var Loop = require( './loop/loop.jsx' ), /** * Handles getting of posts from the server */ -Content = React.createClass({ +var Content = React.createClass({ componentDidMount: function() { @@ -32,14 +32,16 @@ Content = React.createClass({ entry_thumbnail(); // Scroll to top of page so user can see page transition - window.scroll(0,0); + //window.scroll(0,0); }, render: function() { + var singlePostID; + // Check if we're just viewing one post, if so, pass the ID down if ( this.props.data.length === 1 ) { - singlePostID = this.props.data[0].ID; + singlePostID = this.props.data[0].id; } else { singlePostID = 0; } @@ -51,4 +53,4 @@ Content = React.createClass({ } }); -module.exports = Content; \ No newline at end of file +module.exports = Content; diff --git a/components/content/loop/hentry/entry-content/entry-content.jsx b/components/content/loop/hentry/entry-content/entry-content.jsx index 9349c65..4ea8040 100644 --- a/components/content/loop/hentry/entry-content/entry-content.jsx +++ b/components/content/loop/hentry/entry-content/entry-content.jsx @@ -9,11 +9,12 @@ var React = require( 'react' ); var EntryContent = React.createClass({ render: function() { + console.log( this.props.content ); return ( -
+
); } }); -module.exports = EntryContent; \ No newline at end of file +module.exports = EntryContent; diff --git a/components/content/loop/hentry/hentry.jsx b/components/content/loop/hentry/hentry.jsx index f734b60..2fc8174 100644 --- a/components/content/loop/hentry/hentry.jsx +++ b/components/content/loop/hentry/hentry.jsx @@ -1,8 +1,7 @@ /** * External dependencies */ -var React = require( 'react/addons' ), - page = require( 'page' ); +var React = require( 'react/addons' ); /** * Internal dependencies @@ -18,21 +17,30 @@ var ReactCSSTransitionGroup = React.addons.CSSTransitionGroup; /** * Renders post */ -Hentry = React.createClass({ +var Hentry = React.createClass({ handleAdd: function( e ) { e.preventDefault(); url = this.props.link; url = url.replace(/^.*\/\/[^\/]+/, ''); - page( url ); + //page( url ); }, render: function() { - var d = new Date( this.props.date ), + var entryContent, + d = new Date( this.props.date ), formattedDate = d.toDateString(); + if ( 'the_date' !== this.props.date ) { + d = new Date( this.props.date ); + formattedDate = d.toDateString(); + } else { + formattedDate = this.props.date; + } + // Decide whether or not to render comments and entry-content var comments, content; - if ( this.props.context !== 'index' && this.props.showExtra === true ) { + console.log( this.props ); + if ( ( this.props.context !== 'index' && this.props.showExtra === true ) || this.props.loop ) { comments = ; entryContent = ; } else { @@ -50,7 +58,7 @@ Hentry = React.createClass({ entryHeader =

- + {this.props.title}

@@ -79,7 +87,7 @@ Hentry = React.createClass({
{ entryHeader } - + { entryContent }
@@ -89,4 +97,4 @@ Hentry = React.createClass({ } }); -module.exports = Hentry; \ No newline at end of file +module.exports = Hentry; diff --git a/components/content/loop/loop.jsx b/components/content/loop/loop.jsx index a10e97d..5ebf4d5 100644 --- a/components/content/loop/loop.jsx +++ b/components/content/loop/loop.jsx @@ -1,8 +1,7 @@ /** * External dependencies */ -var React = require( 'react/addons' ), - page = require( 'page' ); +var React = require( 'react/addons' ); /** * Internal dependencies @@ -15,7 +14,7 @@ var ReactCSSTransitionGroup = React.addons.CSSTransitionGroup; /** * Renders list of posts */ -Loop = React.createClass({ +var Loop = React.createClass({ render: function() { var context = this.props.context, @@ -42,7 +41,7 @@ Loop = React.createClass({ return (
- + { postNodes } { navigationNodes } @@ -51,4 +50,4 @@ Loop = React.createClass({ } }); -module.exports = Loop; \ No newline at end of file +module.exports = Loop; diff --git a/components/content/loop/navigation/post-navigation.jsx b/components/content/loop/navigation/post-navigation.jsx index 93a84f3..822c4ba 100644 --- a/components/content/loop/navigation/post-navigation.jsx +++ b/components/content/loop/navigation/post-navigation.jsx @@ -6,7 +6,7 @@ var React = require( 'react/addons' ); /** * Renders links to the next and previous posts. */ -PostNavigation = React.createClass({ +var PostNavigation = React.createClass({ render: function() { var previousPostLink; @@ -38,4 +38,4 @@ PostNavigation = React.createClass({ } }); -module.exports = PostNavigation; \ No newline at end of file +module.exports = PostNavigation; diff --git a/package.json b/package.json index d506e3e..65adb1c 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,8 @@ }, "homepage": "https://github.com/Automattic/Picard", "devDependencies": { + "babel": "^5.8.23", + "babel-runtime": "^5.8.25", "browserify": "~7.0.3", "gulp": "~3.8.10", "gulp-autoprefixer": "^2.0.0", diff --git a/sample.json b/sample.json new file mode 100644 index 0000000..2c56ba1 --- /dev/null +++ b/sample.json @@ -0,0 +1,12 @@ +[{ + "id": "the_id", + "date": "the_date", + "link": "the_link", + "title": { + "rendered": "the_title" + }, + "content": { + "rendered": "the_content" + }, + "loop": "the_loop" +}] diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..696fe35 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,21 @@ +var fs = require( 'fs' ), + data = require( './sample.json' ), + React = require( 'react' ), + babel = require( 'babel/register' ), + //posts = require( './components/content/content.jsx' ); + posts = React.createFactory( require( './components/content/content.jsx' ) ); + +//data = JSON.parse( data ); + +//var markup = ""; +markup = React.renderToStaticMarkup( posts({ data: data }) ); +//markup += ""; + +console.log( markup ); + +//var replacedMarkup = markup.replace( /the_title/gi, '' ); +//replacedMarkup = markup.replace( /the_content/gi, '' ); +//replacedMarkup = markup.replace( /the_loop/gi, ''); +//replacedMarkup = markup.replace( /end_loop/gi, '' ); + +//fs.writeFileSync( 'page.php', replacedMarkup ); From 78e1d519eebb8b568521b704e6d490fd53b2566c Mon Sep 17 00:00:00 2001 From: Jack Lenox Date: Thu, 1 Oct 2015 15:06:31 +0800 Subject: [PATCH 02/10] Update components for server-side rendering --- components/content/loop/loop.jsx | 7 ++++++- webpack.config.js | 7 +++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/components/content/loop/loop.jsx b/components/content/loop/loop.jsx index 5ebf4d5..6400bc0 100644 --- a/components/content/loop/loop.jsx +++ b/components/content/loop/loop.jsx @@ -25,9 +25,12 @@ var Loop = React.createClass({ showExtra = true; } + var loop; + var postNodes = this.props.data.map( function ( post ) { + loop = post.loop; return ( - + ); }); @@ -41,10 +44,12 @@ var Loop = React.createClass({ return (
+ { loop ? 'the_loop' : null } { postNodes } { navigationNodes } + { loop ? 'end_loop' : null }
); } diff --git a/webpack.config.js b/webpack.config.js index 696fe35..95550ca 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,14 +2,13 @@ var fs = require( 'fs' ), data = require( './sample.json' ), React = require( 'react' ), babel = require( 'babel/register' ), - //posts = require( './components/content/content.jsx' ); posts = React.createFactory( require( './components/content/content.jsx' ) ); //data = JSON.parse( data ); -//var markup = ""; -markup = React.renderToStaticMarkup( posts({ data: data }) ); -//markup += ""; +var markup = ""; +markup += React.renderToStaticMarkup( posts({ data: data }) ); +markup += ""; console.log( markup ); From 52caf3e843cab80ad4714bd0a03481d854204e2c Mon Sep 17 00:00:00 2001 From: Jack Lenox Date: Tue, 29 Sep 2015 17:26:49 +0800 Subject: [PATCH 03/10] Compatibility updates for Picard_API_Comments --- functions.php | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/functions.php b/functions.php index 53a8d2a..cf48f29 100644 --- a/functions.php +++ b/functions.php @@ -160,13 +160,25 @@ function picard_api_init() { } add_action( 'wp_json_server_before_serve', 'picard_api_init' ); -class Picard_API_Comments extends WP_JSON_Comments { - public function register_routes( $routes ) { - $routes['/picard/comments'] = array( - array( array( $this, 'new_post' ), WP_JSON_Server::CREATABLE ), - ); +class Picard_API_Comments extends WP_REST_Comments_Controller { + //public function register_routes( $routes ) { + //$routes['/picard/comments'] = array( + //array( array( $this, 'new_post' ), WP_JSON_Server::CREATABLE ), + //); + + //return $routes; + //} + + public function register_routes() { + + register_rest_route( 'wp/v2', '/picard/comments', array( + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'new_post' ), + ), + + ) ); - return $routes; } public function new_post() { @@ -184,7 +196,7 @@ public function new_post() { $new_comment = get_comment( $comment_id ); - $prepared_comment = $this->prepare_comment( $new_comment ); + $prepared_comment = $this->prepare_item_for_response( $new_comment ); return ( $comment_id ) ? $prepared_comment : array(); } From bb9a45f9a4f357711d772cc025f560b11005d0fd Mon Sep 17 00:00:00 2001 From: Jack Lenox Date: Tue, 29 Sep 2015 18:07:19 +0800 Subject: [PATCH 04/10] Compatibility updates for routes and properties --- .../loop/comments/comment-list/comment/comment.jsx | 8 ++++---- components/content/loop/comments/comments.jsx | 2 +- components/router/router.jsx | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/components/content/loop/comments/comment-list/comment/comment.jsx b/components/content/loop/comments/comment-list/comment/comment.jsx index 5abf80e..9d9b0de 100644 --- a/components/content/loop/comments/comment-list/comment/comment.jsx +++ b/components/content/loop/comments/comment-list/comment/comment.jsx @@ -23,16 +23,16 @@ var Comment = React.createClass({
-
+
@@ -43,4 +43,4 @@ var Comment = React.createClass({ }); -module.exports = Comment; \ No newline at end of file +module.exports = Comment; diff --git a/components/content/loop/comments/comments.jsx b/components/content/loop/comments/comments.jsx index 506565b..755dc60 100644 --- a/components/content/loop/comments/comments.jsx +++ b/components/content/loop/comments/comments.jsx @@ -16,7 +16,7 @@ var CommentList = require( './comment-list/comment-list.jsx' ), var Comments = React.createClass({ loadCommentsFromServer: function() { - var repliesLink = '/wp-json/posts/' + this.props.postID + '/comments/'; + var repliesLink = '/wp-json/wp/v2/comments?post=' + this.props.postID; var self = this; diff --git a/components/router/router.jsx b/components/router/router.jsx index 306fa93..cded214 100644 --- a/components/router/router.jsx +++ b/components/router/router.jsx @@ -19,7 +19,7 @@ var Router = React.createClass({ page( '/', function ( ctx ) { var data, slug = ctx.params.slug, - url = "/wp-json/posts"; + url = "/wp-json/wp/v2/posts"; request .get( url ) .end( function( err, res ) { @@ -31,7 +31,7 @@ var Router = React.createClass({ page( '/:year/:month/:day/:slug', function ( ctx ) { var data, slug = ctx.params.slug, - url = "/wp-json/posts/?filter[name]=" + slug; + url = "/wp-json/wp/v2/posts/?filter[name]=" + slug; request .get( url ) .end( function( err, res ) { @@ -56,7 +56,7 @@ var Router = React.createClass({ slug = slug.substr(0, slug.length - 1); } var part = slug.substring(slug.lastIndexOf('/') + 1); - var url = "/wp-json/posts/?type[]=page&filter[name]=" + part; + var url = "/wp-json/wp/v2/pages/?filter[name]=" + part; request .get( url ) .end( function( err, res ) { @@ -82,4 +82,4 @@ var Router = React.createClass({ }); -module.exports = Router; \ No newline at end of file +module.exports = Router; From ec37323e0a01fd799105e837c82098430221900f Mon Sep 17 00:00:00 2001 From: Jack Lenox Date: Tue, 29 Sep 2015 18:51:50 +0800 Subject: [PATCH 05/10] Compatiblity updates - Remove Picard's comment handling as WP-API is now capable of taking care of this. - Fix URLs where need be - Fix properties where need be --- .../comments/comment-form/comment-form.jsx | 4 +- components/content/loop/comments/comments.jsx | 6 +-- components/content/loop/loop.jsx | 2 +- functions.php | 50 ------------------- 4 files changed, 6 insertions(+), 56 deletions(-) diff --git a/components/content/loop/comments/comment-form/comment-form.jsx b/components/content/loop/comments/comment-form/comment-form.jsx index 4fb4660..3badc21 100644 --- a/components/content/loop/comments/comment-form/comment-form.jsx +++ b/components/content/loop/comments/comment-form/comment-form.jsx @@ -16,7 +16,7 @@ var commentForm = React.createClass({ if ( !text || !author ) { return; } - this.props.onCommentSubmit({comment_author: author, comment_author_email: emailAddress, comment_author_url: website, content: text }); + this.props.onCommentSubmit({author_name: author, author_email: emailAddress, author_url: website, content: text }); this.refs.author.getDOMNode().value = ''; this.refs.emailAddress.getDOMNode().value = ''; this.refs.website.getDOMNode().value = ''; @@ -48,4 +48,4 @@ var commentForm = React.createClass({ }); -module.exports = commentForm; \ No newline at end of file +module.exports = commentForm; diff --git a/components/content/loop/comments/comments.jsx b/components/content/loop/comments/comments.jsx index 755dc60..0875a18 100644 --- a/components/content/loop/comments/comments.jsx +++ b/components/content/loop/comments/comments.jsx @@ -34,7 +34,7 @@ var Comments = React.createClass({ var newComment, self = this, - url = '/wp-json/picard/comments'; + url = '/wp-json/wp/v2/comments?post=' + this.props.postID; request .post( url ) .type( 'form' ) @@ -44,7 +44,7 @@ var Comments = React.createClass({ newComment = JSON.parse( res.text ); self.setState( { data: self.state.data.concat( [ newComment ] ) } ); } else { - console.error( '/wp-json/picard/comments', err.toString() ); + console.error( '/wp-json/wp/v2/comments?post=' + self.props.postID, err.toString() ); } }); @@ -70,4 +70,4 @@ var Comments = React.createClass({ }); -module.exports = Comments; \ No newline at end of file +module.exports = Comments; diff --git a/components/content/loop/loop.jsx b/components/content/loop/loop.jsx index 6400bc0..1be80ef 100644 --- a/components/content/loop/loop.jsx +++ b/components/content/loop/loop.jsx @@ -30,7 +30,7 @@ var Loop = React.createClass({ var postNodes = this.props.data.map( function ( post ) { loop = post.loop; return ( - + ); }); diff --git a/functions.php b/functions.php index cf48f29..9afdd18 100644 --- a/functions.php +++ b/functions.php @@ -151,53 +151,3 @@ function picard_get_json( $_post ) { } add_filter( 'json_prepare_post', 'picard_get_json' ); - -function picard_api_init() { - global $picard_api_comments; - - $picard_api_comments = new Picard_API_Comments(); - add_filter( 'json_endpoints', array( $picard_api_comments, 'register_routes' ) ); -} -add_action( 'wp_json_server_before_serve', 'picard_api_init' ); - -class Picard_API_Comments extends WP_REST_Comments_Controller { - //public function register_routes( $routes ) { - //$routes['/picard/comments'] = array( - //array( array( $this, 'new_post' ), WP_JSON_Server::CREATABLE ), - //); - - //return $routes; - //} - - public function register_routes() { - - register_rest_route( 'wp/v2', '/picard/comments', array( - array( - 'methods' => WP_REST_Server::CREATABLE, - 'callback' => array( $this, 'new_post' ), - ), - - ) ); - - } - - public function new_post() { - - $commentdata = array( - 'comment_post_ID' => $_POST['comment_post_ID'], - 'comment_author' => $_POST['comment_author'], - 'comment_author_email' => $_POST['comment_author_email'], - 'comment_author_url' => $_POST['comment_author_url'], - 'comment_content' => $_POST['content'], - 'comment_author_IP' => $_SERVER['REMOTE_ADDR'], - 'comment_type' => '', - ); - $comment_id = wp_new_comment( $commentdata ); - - $new_comment = get_comment( $comment_id ); - - $prepared_comment = $this->prepare_item_for_response( $new_comment ); - - return ( $comment_id ) ? $prepared_comment : array(); - } -} From 8bc30130c3a5d96aa456dc89eddc50a42a85eaa2 Mon Sep 17 00:00:00 2001 From: Jack Lenox Date: Wed, 30 Sep 2015 19:20:38 +0800 Subject: [PATCH 06/10] Remove whitespace --- components/content/loop/comments/comments.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/content/loop/comments/comments.jsx b/components/content/loop/comments/comments.jsx index 0875a18..71498ce 100644 --- a/components/content/loop/comments/comments.jsx +++ b/components/content/loop/comments/comments.jsx @@ -57,7 +57,7 @@ var Comments = React.createClass({ componentDidMount: function() { this.loadCommentsFromServer(); }, - + render: function() { return (
From 0a074f435a03c3eef7980295f7db0a2786079461 Mon Sep 17 00:00:00 2001 From: Jack Lenox Date: Wed, 30 Sep 2015 20:42:48 +0800 Subject: [PATCH 07/10] Non-working beginnings of server-side render --- webpack.config.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/webpack.config.js b/webpack.config.js index 95550ca..b931e28 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,13 +2,23 @@ var fs = require( 'fs' ), data = require( './sample.json' ), React = require( 'react' ), babel = require( 'babel/register' ), +<<<<<<< HEAD +======= + //posts = require( './components/content/content.jsx' ); +>>>>>>> Non-working beginnings of server-side render posts = React.createFactory( require( './components/content/content.jsx' ) ); //data = JSON.parse( data ); +<<<<<<< HEAD var markup = ""; markup += React.renderToStaticMarkup( posts({ data: data }) ); markup += ""; +======= +//var markup = ""; +markup = React.renderToStaticMarkup( posts({ data: data }) ); +//markup += ""; +>>>>>>> Non-working beginnings of server-side render console.log( markup ); From 690d4756807aadcf5d76e30ffe279d726bf7469f Mon Sep 17 00:00:00 2001 From: Jack Lenox Date: Thu, 1 Oct 2015 15:06:31 +0800 Subject: [PATCH 08/10] Update components for server-side rendering --- components/content/loop/loop.jsx | 2 +- webpack.config.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/components/content/loop/loop.jsx b/components/content/loop/loop.jsx index 1be80ef..d44ee5f 100644 --- a/components/content/loop/loop.jsx +++ b/components/content/loop/loop.jsx @@ -30,7 +30,7 @@ var Loop = React.createClass({ var postNodes = this.props.data.map( function ( post ) { loop = post.loop; return ( - + ); }); diff --git a/webpack.config.js b/webpack.config.js index b931e28..5177af8 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -3,13 +3,17 @@ var fs = require( 'fs' ), React = require( 'react' ), babel = require( 'babel/register' ), <<<<<<< HEAD +<<<<<<< HEAD ======= //posts = require( './components/content/content.jsx' ); >>>>>>> Non-working beginnings of server-side render +======= +>>>>>>> Update components for server-side rendering posts = React.createFactory( require( './components/content/content.jsx' ) ); //data = JSON.parse( data ); +<<<<<<< HEAD <<<<<<< HEAD var markup = ""; markup += React.renderToStaticMarkup( posts({ data: data }) ); @@ -19,6 +23,11 @@ markup += ""; markup = React.renderToStaticMarkup( posts({ data: data }) ); //markup += ""; >>>>>>> Non-working beginnings of server-side render +======= +var markup = ""; +markup += React.renderToStaticMarkup( posts({ data: data }) ); +markup += ""; +>>>>>>> Update components for server-side rendering console.log( markup ); From 001e539ea3f01bd8e141d6bbf4c48c477c203de2 Mon Sep 17 00:00:00 2001 From: Jack Lenox Date: Thu, 1 Oct 2015 16:23:29 +0800 Subject: [PATCH 09/10] More server side render additions --- components/content/loop/hentry/hentry.jsx | 4 +- components/content/loop/loop.jsx | 2 +- footer.php | 17 ++++++ header.php | 30 +++++++++++ index.php | 66 +---------------------- page.php | 1 + single.php | 1 + webpack.config.js | 48 ++++++++++++++--- 8 files changed, 95 insertions(+), 74 deletions(-) create mode 100644 footer.php create mode 100644 header.php create mode 100644 page.php create mode 100644 single.php diff --git a/components/content/loop/hentry/hentry.jsx b/components/content/loop/hentry/hentry.jsx index 2fc8174..1c0bb17 100644 --- a/components/content/loop/hentry/hentry.jsx +++ b/components/content/loop/hentry/hentry.jsx @@ -40,7 +40,7 @@ var Hentry = React.createClass({ var comments, content; console.log( this.props ); - if ( ( this.props.context !== 'index' && this.props.showExtra === true ) || this.props.loop ) { + if ( this.props.context !== 'index' && this.props.showExtra === true ) { comments = ; entryContent = ; } else { @@ -71,7 +71,7 @@ var Hentry = React.createClass({ } else { entryHeader =

- + {this.props.title}

diff --git a/components/content/loop/loop.jsx b/components/content/loop/loop.jsx index d44ee5f..0eaf3ca 100644 --- a/components/content/loop/loop.jsx +++ b/components/content/loop/loop.jsx @@ -21,7 +21,7 @@ var Loop = React.createClass({ showExtra = false, next, previous; - if ( this.props.postID !== 0 && this.props.postID === this.props.data[0].ID ) { + if ( this.props.postID !== 0 && this.props.postID === this.props.data[0].id ) { showExtra = true; } diff --git a/footer.php b/footer.php new file mode 100644 index 0000000..94ae05e --- /dev/null +++ b/footer.php @@ -0,0 +1,17 @@ + +
+
+ +
+
+ + | + Automattic' ); ?> +
+
+
+ + + + + diff --git a/header.php b/header.php new file mode 100644 index 0000000..6548957 --- /dev/null +++ b/header.php @@ -0,0 +1,30 @@ + +> + + + + + + + + +> +
+ + + + +
+
+
diff --git a/index.php b/index.php index 1afc74a..d8d756a 100644 --- a/index.php +++ b/index.php @@ -1,65 +1 @@ - -> - - - - - - - - -> -
- - - - -
-
-
- - - - - - - - - - - - - - - - - - -
-
-
- -
-
- - | - Automattic' ); ?> -
-
-
- - - - - \ No newline at end of file +

\ No newline at end of file diff --git a/page.php b/page.php new file mode 100644 index 0000000..c427a95 --- /dev/null +++ b/page.php @@ -0,0 +1 @@ +

Comments

    Leave a reply

    Your email address will not be published. Required fields are marked *

    \ No newline at end of file diff --git a/single.php b/single.php new file mode 100644 index 0000000..ca0f2cc --- /dev/null +++ b/single.php @@ -0,0 +1 @@ +

    Comments

      Leave a reply

      Your email address will not be published. Required fields are marked *

      \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index 5177af8..5c41797 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -16,7 +16,7 @@ var fs = require( 'fs' ), <<<<<<< HEAD <<<<<<< HEAD var markup = ""; -markup += React.renderToStaticMarkup( posts({ data: data }) ); +markup += React.renderToStaticMarkup( posts({ data: data, bodyClass: 'index' }) ); markup += ""; ======= //var markup = ""; @@ -29,11 +29,47 @@ markup += React.renderToStaticMarkup( posts({ data: data }) ); markup += ""; >>>>>>> Update components for server-side rendering +markup = markup.replace( /the_title/gi, '' ); +markup = markup.replace( /the_link/gi, '' ); +markup = markup.replace( /the_date/gi, '' ); +markup = markup.replace( /the_content/gi, '' ); +markup = markup.replace( /the_loop/gi, ''); +markup = markup.replace( /end_loop/gi, '' ); + console.log( markup ); -//var replacedMarkup = markup.replace( /the_title/gi, '' ); -//replacedMarkup = markup.replace( /the_content/gi, '' ); -//replacedMarkup = markup.replace( /the_loop/gi, ''); -//replacedMarkup = markup.replace( /end_loop/gi, '' ); +fs.writeFileSync( 'index.php', markup ); + + + +markup = ""; +markup += React.renderToStaticMarkup( posts({ data: data, bodyClass: 'page' }) ); +markup += ""; + +markup = markup.replace( /the_title/gi, '' ); +markup = markup.replace( /the_link/gi, '' ); +markup = markup.replace( /the_date/gi, '' ); +markup = markup.replace( /the_content/gi, '' ); +markup = markup.replace( /the_loop/gi, ''); +markup = markup.replace( /end_loop/gi, '' ); + +console.log( markup ); + +fs.writeFileSync( 'page.php', markup ); + + + +markup = ""; +markup += React.renderToStaticMarkup( posts({ data: data, bodyClass: 'single' }) ); +markup += ""; + +markup = markup.replace( /the_title/gi, '' ); +markup = markup.replace( /the_link/gi, '' ); +markup = markup.replace( /the_date/gi, '' ); +markup = markup.replace( /the_content/gi, '' ); +markup = markup.replace( /the_loop/gi, ''); +markup = markup.replace( /end_loop/gi, '' ); + +console.log( markup ); -//fs.writeFileSync( 'page.php', replacedMarkup ); +fs.writeFileSync( 'single.php', markup ); From 8a5defdb6d04c44e0efbe9f5d17ceee99c006d61 Mon Sep 17 00:00:00 2001 From: Jack Lenox Date: Thu, 1 Oct 2015 16:23:29 +0800 Subject: [PATCH 10/10] More server side render additions --- webpack.config.js | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 5c41797..8e0ccaa 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,32 +2,14 @@ var fs = require( 'fs' ), data = require( './sample.json' ), React = require( 'react' ), babel = require( 'babel/register' ), -<<<<<<< HEAD -<<<<<<< HEAD -======= //posts = require( './components/content/content.jsx' ); ->>>>>>> Non-working beginnings of server-side render -======= ->>>>>>> Update components for server-side rendering posts = React.createFactory( require( './components/content/content.jsx' ) ); //data = JSON.parse( data ); -<<<<<<< HEAD -<<<<<<< HEAD var markup = ""; markup += React.renderToStaticMarkup( posts({ data: data, bodyClass: 'index' }) ); markup += ""; -======= -//var markup = ""; -markup = React.renderToStaticMarkup( posts({ data: data }) ); -//markup += ""; ->>>>>>> Non-working beginnings of server-side render -======= -var markup = ""; -markup += React.renderToStaticMarkup( posts({ data: data }) ); -markup += ""; ->>>>>>> Update components for server-side rendering markup = markup.replace( /the_title/gi, '' ); markup = markup.replace( /the_link/gi, '' );