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

feat: initial post type and block setup #1

Merged
merged 7 commits into from
Sep 23, 2020
Merged

feat: initial post type and block setup #1

merged 7 commits into from
Sep 23, 2020

Conversation

dkoo
Copy link
Contributor

@dkoo dkoo commented Sep 11, 2020

Sets up custom post types and Listing block prototype.

All Submissions:

Changes proposed in this Pull Request:

Sets up the custom post types and the Listing blocks needed to build a curated list. Also lays out an approach for programmatically registering post metadata for all listing types.

Wanted to get this prototype code reviewed before it gets too too big. Would gladly take feedback on the code structure and technical approaches outlined here, and/or any suggestions to improve the editor experience! Maybe also suggestions for unit tests that we should plan out before the plugin gets too big?

Not included in this PR:

  • Curated List block to insert curated lists into other posts or widgets.
  • All metadata fields (only a few are registered here, to test functionality, and none are yet displayed)
  • Styles for editor and front-end.
  • Templates for rendering lists and listing items on the front-end. The front-end will render with default templates and no styles, so we can still test that the public-facing pages and permalinks work.
  • Search result handling.
  • Map functionality.
  • Newspack Ads or Sponsors integrations.
  • Unit tests and workflow scripts.

How to test the changes in this Pull Request:

The plugin is installed with the code from this PR in this demo site, which you can use to test functionality if you don't have a local environment set up:

https://tricky-click.jurassic.ninja/wp-admin/
u: demo
p: jEx4k7B7w6ug

  1. Install and activate the plugin.
  2. Go to Listings > Settings and verify that the default permalink namespace is listings.
  3. Create a new Curated List post.
  4. From here, you should be able to add listing blocks for any of the main listing types (Event, Generic, Marketplace, or Place). Add a Place.
  5. Since you don't have any listings yet, click the "Create new listing" button and create a new Place listing. For now, just fill out the post title, content, excerpt, and expand the Place Settings sidebar panel and fill out the phone number and email meta fields. Publish the place.
  6. Back in the Curated List editor, start typing the title of your new place into the search box. Verify that the place pops up as a suggestion.
  7. Select the place. Verify that the block in the editor changes to render a preview of the place listing. Note: currently, metadata is not displayed anywhere in the editor or the front-end. To verify that metadata is being retrieved correctly, you can add console.log( post.meta ); to line 166 of edit.js. You should see the email address and phone number fields logged under the meta key here, so they may be displayed in a future PR.
  8. Click "Edit this listing" to verify that a new tab opens with the editor view for that listing.
  9. Create and publish a few more listings of any type. (Also leave some as drafts.)
  10. Back in the Curated List editor, add new listing blocks matching the types of the new listings you created. Verify that all of your published listings are suggested in the search box if you start typing their titles in the correct listing type block.
  11. Verify that suggestions are only shown for published listings that haven't already been added to the current curated list. Also verify that draft listings are NOT suggested by the search box under any circumstances.
  12. Try moving the blocks around and changing the order of the items in the list. Play with the Curated List Settings sidebar options (currently only "Show numbers" does anything—should toggle display of the list item numbers in the editor view only).
  13. Try clicking "Replace listing" and verify that you're able to search for a new listing and that selecting the new listing causes that one to render in place of the old one.
  14. Publish the Curated List post. View it on the front-end and verify that the listing items match what's shown in the editor (post title, excerpt and sort order).
  15. Click into a few of the listings. Verify that all are publicly viewable as standalone singular pages by themselves.
  16. Go back to Listings > Settings and change the permalink namespace slug to something else.
  17. Go to Settings > Permalinks and click "Save" without changing anything to flush permalinks.
  18. Go back to the Curated List in the editor and verify that the permalink structure now has your new namespace in the URL instead of the default listings. Verify that the public-facing pages for the Curated List and all singular listings still load.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Sets up custom post types and Listing block prototype.
Instead of just registering a single Listing block and selecting the type in the parent post, this registers a separate block for each listing type (all of which use the same code).
@dkoo dkoo marked this pull request as ready for review September 17, 2020 22:35
Copy link
Member

@adekbadek adekbadek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments, plus two general issues:

  1. When replacing a listing in the editor, the just-removed listing is not available to be picked
  2. After publishing the listing, the site at the permalink URL returns 404. Changing the permalink base in the setting did not fix this.

includes/post-types/class-post-type-listings-generic.php Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
includes/class-newspack-listings-core.php Outdated Show resolved Hide resolved
includes/newspack-listings-utils.php Show resolved Hide resolved
includes/class-newspack-listings-settings.php Outdated Show resolved Hide resolved
includes/class-newspack-listings-core.php Show resolved Hide resolved
}
}

export default AutocompleteTokenField;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: AutocompleteTokenField could be distributed with newspack-components.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call—do we have documentation for adding components to the NPM package?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a manual process – after the code is in assets/components of newspack-plugin (regular PR to master) you just

  • $ npm version <type> (docs)
  • $ npm publish

What's your npm username, so I can add you as a maintainer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Username is dkoo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added you as a maintainer there 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I added the component to newspack-plugin here: Automattic/newspack-plugin#674

src/components/query-controls.js Outdated Show resolved Hide resolved
src/blocks/listing/view.php Outdated Show resolved Hide resolved
Addresses pull request feedback and refactors post types config into a more DRY treatment.
@dkoo
Copy link
Contributor Author

dkoo commented Sep 21, 2020

When replacing a listing in the editor, the just-removed listing is not available to be picked

This was kind of by design—the autocomplete search will only return results that aren't already in the current list, including the one you're replacing (I figured there should be no need to replace a post with the same post, since you can cancel if you decide you don't want to replace it).

After publishing the listing, the site at the permalink URL returns 404. Changing the permalink base in the setting did not fix this.

I can't replicate this—can you try flushing permalinks manually and then refreshing the page?

@dkoo dkoo requested a review from adekbadek September 21, 2020 22:31
@adekbadek
Copy link
Member

I figured there should be no need to replace a post with the same post, since you can cancel

My bad, that's true :D

can you try flushing permalinks manually and then refreshing the page?

I did that, and still no dice. But it did work after deactivating & activating Yoast plugin – there might be some conflict there :/

@dkoo
Copy link
Contributor Author

dkoo commented Sep 22, 2020

I did that, and still no dice. But it did work after deactivating & activating Yoast plugin – there might be some conflict there :/

Good to know—I might want to investigate that further in a different issue/PR, if that's okay?

@dkoo dkoo mentioned this pull request Sep 22, 2020
@adekbadek
Copy link
Member

Good to know—I might want to investigate that further in a different issue/PR, if that's okay?

On a fresh site I could see no issues after installing Yoast, so that was probably something specific to my local setup.

@dkoo dkoo merged commit 47dc0c1 into master Sep 23, 2020
@dkoo dkoo deleted the feat/initial-setup branch September 23, 2020 17:59
matticbot pushed a commit that referenced this pull request Dec 16, 2020
# 1.0.0-alpha.1 (2020-12-16)

### Features

* initial post type and block setup ([#1](#1)) ([47dc0c1](47dc0c1))
* listing taxonomies and query mode ([#6](#6)) ([528e1e5](528e1e5))
* new Curated List block, block pattern, and map functionality ([#3](#3)) ([9be6e7e](9be6e7e))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.0.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Dec 16, 2020
# 1.0.0 (2020-12-16)

### Features

* initial post type and block setup ([#1](#1)) ([47dc0c1](47dc0c1))
* listing taxonomies and query mode ([#6](#6)) ([528e1e5](528e1e5))
* new Curated List block, block pattern, and map functionality ([#3](#3)) ([9be6e7e](9be6e7e))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Jul 19, 2021
# 1.0.0-alpha.1 (2021-07-19)

### Bug Fixes

* avoid meta sync update error ([#95](#95)) ([cab16aa](cab16aa))
* do not register post-specific sidebars in widgets page ([#93](#93)) ([7716775](7716775))
* editor errors with reusable blocks ([#89](#89)) ([fdc46d3](fdc46d3))
* errors and bugs related to WP 5.8 ([#83](#83)) ([90da6c5](90da6c5))
* force alpha rebuild ([acc2075](acc2075))
* minor bug fixes ([#21](#21)) ([5f90bc7](5f90bc7))
* missing condition for block appender in list container ([#74](#74)) ([2c49896](2c49896))
* syncing attributes from curated list block to inner blocks ([#64](#64)) ([cdbc0bb](cdbc0bb))
* use synced attributes for ListContainer directly ([#73](#73)) ([f8641a7](f8641a7))

### Features

* add block patterns ([#23](#23)) ([a273a40](a273a40))
* bump max number of items per list from 20 to 50 ([#97](#97)) ([009deab](009deab))
* initial post type and block setup ([#1](#1)) ([47dc0c1](47dc0c1))
* listing taxonomies and query mode ([#6](#6)) ([528e1e5](528e1e5))
* more block patterns (real estate, classified ads) ([#84](#84)) ([a51f5af](a51f5af))
* new Curated List block, block pattern, and map functionality ([#3](#3)) ([9be6e7e](9be6e7e))
* remove borders and padding in editor to match front-end styles ([#14](#14)) ([6c47a17](6c47a17))

* v2 release (#85) ([748810d](748810d)), closes [#85](#85) [#40](#40) [#39](#39) [#32](#32) [#41](#41) [#49](#49) [#43](#43) [#56](#56) [#51](#51) [#57](#57) [#61](#61) [#67](#67) [#60](#60) [#70](#70) [#65](#65) [#71](#71) [#66](#66) [#58](#58) [#77](#77) [#81](#81)

### BREAKING CHANGES

* This feature will deprecate existing custom taxonomies, so any existing terms for those taxonomies will be lost.

To fix, we can convert terms from the deprecated taxonomies to standard post categories/tags via a migration script.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants