Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #845: Script to create Gutenberg test page #1018

Merged
merged 10 commits into from Mar 14, 2018

Conversation

@kienstra
Copy link
Contributor

@kienstra kienstra commented Mar 13, 2018

Pull Request

This PR for Issue #845 uses the test fixtures in Gutenberg, but excludes the embeds. Those fixtures usually don't have actual URLs.

From the plugin root, run this command from inside an environment like VVV:

bash bin/create-gutenberg-test-post.sh

This clones Gutenberg if it's not present, or pulls the master branch. Then, it runs the wp-cli script to create the test page, based on the test fixtures.

This uses logic from create-embed-test-post.php and amphtml-update.sh

kienstra added 3 commits Mar 13, 2018
Use the test fixtures in Gutenberg,
but exclude the embeds.
These usually don't have actual embed URLs.
@todos include adding some permutations,
and testing this more.
This uses much of the logic in create-embed-test-post.php
and amphtml-update.sh.
The matching group needed to have a ?P.
Also, change some DocBlocks,
including removing use of imperative 'Create'
in favor of 'Creates.'
Copy a line from amphtml-update.sh.
This removes the need to run this from bin/.
@kienstra kienstra changed the title Issue #845: Begin script to create Gutenberg test page. [WIP] Issue #845: Begin script to create Gutenberg test page. Mar 13, 2018
@kienstra kienstra changed the title [WIP] Issue #845: Begin script to create Gutenberg test page. [WIP] Issue #845: Script to create Gutenberg test page Mar 13, 2018
Add steps to create test post.
This mainly copies the other sections.
kienstra added 3 commits Mar 13, 2018
Variations include a gallery with 3 columns,
and some embeds and shortcodes.
Embeds and shortcodes are mainly tested in:
create-embed-test-post.php.
The slug should match the title.
Also, add echo statments in the bash script.
The user will need to run 'npm install' and 'npm run build.'
amp_create_reusable_block() inserts a new post for the block.
Also, reduce the size of the headings to <h2>.
There was a tab in the 'columns' block,
possibly from copying it.
@kienstra
Copy link
Contributor Author

@kienstra kienstra commented Mar 14, 2018

Request For Review

Hi @westonruter,
Could you please review this pull request for #845? Please ssh into VVV, cd to this plugin, and run:

bash bin/create-gutenberg-test-post.sh

This adds all of the blocks in gutenberg/tree/master/blocks/library/ to a test post. It also adds blocks with these permutations.

You might have to open the /wp-admin/post.php page for the test post, save it, and visit the front-end of the page.

@@ -0,0 +1,32 @@
#!/bin/bash
Copy link
Contributor Author

@kienstra kienstra Mar 14, 2018

Do you think this script is needed? It clones Gutenberg if it's not present, then runs create-gutenberg-test-post.php.

Copy link
Member

@westonruter westonruter Mar 14, 2018

It doesn't hurt, but it probably isn't necessary. The amp_create_gutenberg_test_post() function could just throw an exception if Gutenberg isn't active (e.g. if ! function_exists( 'do_blocks' ))

),
array(
'title' => 'Columns, With 2 Columns',
'content' => '<!-- wp:columns {"columns":2} --><div class="wp-block-columns has-2-columns"><!-- wp:paragraph {"layout":"column-1"} --> <p class="layout-column-1">Column One, Paragraph One</p><!-- /wp:paragraph --><!-- wp:paragraph {"layout":"column-1"} --><p class="layout-column-1">Column One, Paragraph Two</p><!-- /wp:paragraph --><!-- wp:paragraph {"layout":"column-2"} --><p class="layout-column-2">Column Two, Paragraph One</p><!-- /wp:paragraph --></div><!-- /wp:columns -->',
Copy link
Contributor Author

@kienstra kienstra Mar 14, 2018

This might need to be wp:core/columns instead of wp:columns, and likewise for the rest of the line.

Copy link
Contributor Author

@kienstra kienstra Mar 14, 2018

Applied with 3e41cca.

Copy link
Member

@westonruter westonruter Mar 14, 2018

@kienstra kienstra requested a review from westonruter Mar 14, 2018
@kienstra kienstra assigned kienstra and westonruter and unassigned kienstra Mar 14, 2018
@kienstra kienstra changed the title [WIP] Issue #845: Script to create Gutenberg test page Issue #845: Script to create Gutenberg test page Mar 14, 2018
This can happen if the plugin is downloaded from
wordpress.org.
Also, add 'core' to the comments:
wp:core/columns
* @throws Exception If this is script is not run inside the plugin directory.
* @return string $content Post content with all Gutenberg blocks.
*/
function amp_get_blocks() {
Copy link
Member

@westonruter westonruter Mar 14, 2018

Since we're using PHP 5.3, let's just go ahead and use namespaces for this file. This will help prevent confusion with autocompletion. So then this could be renamed to just get_test_data_blocks().

@westonruter westonruter merged commit 66e12d7 into develop Mar 14, 2018
2 checks passed
@westonruter westonruter deleted the add/845-gutenberg-test-script branch Mar 14, 2018
@westonruter westonruter added this to the v0.7 milestone Mar 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants