Skip to content

Commit

Permalink
Merge pull request #390 from Automattic/master
Browse files Browse the repository at this point in the history
Release: first production release
  • Loading branch information
adekbadek authored Mar 2, 2020
2 parents 3add1f0 + ce2f8fe commit abf7fb3
Show file tree
Hide file tree
Showing 39 changed files with 4,402 additions and 1,218 deletions.
7 changes: 2 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,13 @@ jobs:
- image: circleci/node:12
steps:
- checkout_code
- run:
name: Build release
command: npm run release:archive
- run:
name: Release new version
command: npm run semantic-release
command: npm run release

workflows:
version: 2
quality_assurance:
all:
jobs:
- build
- lint:
Expand Down
3 changes: 3 additions & 0 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties -->
<config name="minimum_supported_wp_version" value="4.6"/>
<rule ref="WordPress">
</rule>
<rule ref="WordPress">
<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found" />
</rule>
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
Expand Down
13 changes: 7 additions & 6 deletions amp/homepage-articles/view.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
let isFetching = false;
let isEndOfData = false;
buildLoadMoreHandler( document.querySelector( '.wp-block-newspack-blocks-homepage-articles') );
buildLoadMoreHandler( document.querySelector( '.wp-block-newspack-blocks-homepage-articles' ) );
function buildLoadMoreHandler( blockWrapperEl ) {
const btnEl = blockWrapperEl.querySelector( '[data-next]' );
if ( ! btnEl ) {
Expand All @@ -26,10 +26,11 @@ function buildLoadMoreHandler( blockWrapperEl ) {
} );
} );
if ( isPostsDataValid( data ) ) {
const postsHTML = data.items.map( item => item.html ).join( '' );
const ampLayout = document.createElement( 'amp-layout' );
ampLayout.innerHTML = postsHTML;
postsContainerEl.appendChild( ampLayout );
data.items.forEach( item => {
const tempDIV = document.createElement( 'div' );
tempDIV.innerHTML = item.html.trim();
postsContainerEl.appendChild( tempDIV.childNodes[ 0 ] );
} );
if ( data.next ) {
btnEl.setAttribute( 'data-next', data.next );
}
Expand All @@ -40,7 +41,7 @@ function buildLoadMoreHandler( blockWrapperEl ) {
isFetching = false;
blockWrapperEl.classList.remove( 'is-loading' );
}
};
}
function onError() {
isFetching = false;
blockWrapperEl.classList.remove( 'is-loading' );
Expand Down
13 changes: 13 additions & 0 deletions bin/update-translations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
cd $(dirname "$(dirname "$0")")
wp i18n make-pot . languages/newspack-blocks.pot --domain=newspack-blocks --package-name='Newspack Blocks'

cd languages
for po in newspack-blocks-*.po; do
# Update translations according to the new POT file
msgmerge $po newspack-blocks.pot -o $po.out
mv $po.out $po
msgfmt $po -o $(basename $po .po).mo
# no-purge since we need the JS translations for the next run
wp i18n make-json --no-purge $po .
done
2 changes: 1 addition & 1 deletion block-list.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"production": [ "carousel", "donate", "homepage-articles" ]
"production": [ "carousel", "donate", "homepage-articles", "video-playlist" ]
}
26 changes: 26 additions & 0 deletions class-newspack-blocks-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,32 @@ public static function newspack_blocks_get_primary_category( $object ) {

return $category->name;
}

/**
* Register the video-playlist endpoint.
*/
public static function register_video_playlist_endpoint() {
register_rest_route(
'newspack-blocks/v1',
'/video-playlist',
[
'methods' => 'GET',
'callback' => [ 'Newspack_Blocks_API', 'video_playlist_endpoint' ],
]
);
}

/**
* Process requests to the video-playlist endpoint.
*
* @param WP_REST_Request $request Request object.
* @return WP_REST_Response.
*/
public static function video_playlist_endpoint( $request ) {
$args = $request->get_params();
return new \WP_REST_Response( newspack_blocks_get_video_playlist( $args ), 200 );
}
}

add_action( 'rest_api_init', array( 'Newspack_Blocks_API', 'register_rest_fields' ) );
add_action( 'rest_api_init', array( 'Newspack_Blocks_API', 'register_video_playlist_endpoint' ) );
38 changes: 38 additions & 0 deletions class-newspack-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ public static function enqueue_block_editor_assets() {
$script_data['version'],
true
);
wp_localize_script(
'newspack-blocks-editor',
'newspack_blocks_data',
[
'patterns' => self::get_patterns_for_post_type( get_post_type() ),
]
);

wp_set_script_translations(
'newspack-blocks-editor',
Expand Down Expand Up @@ -403,5 +410,36 @@ public static function prepare_authors() {
),
);
}

/**
* Get patterns for post type.
*
* @param string $post_type Post type.
* @return array Array of patterns.
*/
public static function get_patterns_for_post_type( $post_type = null ) {
$patterns = apply_filters( 'newspack_blocks_patterns', [], $post_type );
$categorized = [];
$clean = [];
foreach ( $patterns as $pattern ) {
if ( ! isset( $pattern['preview_image'] ) || ! $pattern['preview_image'] ) {
continue;
}
$category = isset( $pattern['category'] ) ? $pattern['category'] : __( 'Common', 'newspack-blocks' );
if ( ! isset( $categorized[ $category ] ) ) {
$categorized[ $category ] = [];
}
$categorized[ $category ][] = $pattern;
}
$categories = array_keys( $categorized );
sort( $categories );
foreach ( $categories as $category ) {
$clean[] = [
'title' => $category,
'items' => $categorized[ $category ],
];
}
return $clean;
}
}
Newspack_Blocks::init();
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"require-dev": {
"automattic/vipwpcs": "^2.0.0",
"xwp/wp-dev-lib": "^1.4.0",
"xwp/wp-dev-lib": "^1.5",
"brainmaestro/composer-git-hooks": "^2.6",
"wp-coding-standards/wpcs": "*",
"dealerdirect/phpcodesniffer-composer-installer": "*",
Expand All @@ -25,7 +25,7 @@
"extra": {
"hooks": {
"pre-commit": [
"./vendor/xwp/wp-dev-lib/scripts/pre-commit && ./node_modules/.bin/lint-staged"
"DEV_LIB_SKIP=eslint ./vendor/xwp/wp-dev-lib/scripts/pre-commit && ./node_modules/.bin/lint-staged"
],
"commit-msg": [
"cat $1 | ./node_modules/.bin/commitlint"
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"translation-revision-date":"2020-02-18 13:48-0800","generator":"WP-CLI\/2.4.0","source":"dist\/editor.js","domain":"messages","locale_data":{"messages":{"":{"domain":"messages","lang":"de","plural-forms":"nplurals=2; plural=(n != 1);"},"One-time":["Einmal"],"Monthly":["Monatlich"],"Annually":["J\u00e4hrlich"],"Donation amount":["Spendenbetrag"],"Your contribution is appreciated.":["Herzlichen Dank f\u00fcr Ihre Unterst\u00fctzung."],"Donate now!":["Jetzt spenden!"],"Other":["Andere"],"Load more posts":["Mehr Beitr\u00e4ge laden"],"post author\u0004by":["von"],"post author\u0004 and ":[" und "],"(no title)":["(kein Titel)"],"(no name)":["(kein Name)"],"Choose Specific Posts":[""],"Posts":["Beitr\u00e4ge"],"Begin typing post title, click autocomplete result to select.":[""],"Authors":["Autoren"],"Categories":["Kategorien"],"Tags":["Schlagw\u00f6rter"],"Hide Advanced Filters":[""],"Show Advanced Filters":[""],"Excluded Tags":[""],"Article Meta Settings":[""],"Show Date":["Datum anzeigen"],"Show Category":["Kategorie anzeigen"],"Show Author":["Autor anzeigen"],"Show Author Avatar":[""],"Small":["Klein"],"S":["S"],"Medium":["Mittel"],"M":["M"],"Large":["Gro\u00df"],"L":["L"],"Extra Large":["Extra Gro\u00df"],"XL":["XL"],"Display Settings":["Anzeigeneinstellungen"],"Columns":["Spalten"],"Show \"More\" Button":["\"Mehr Lesen\" anzeigen"],"Featured Image Settings":["Beitragsbild-Einstellungen"],"Show Featured Image":["Beitragsbild anzeigen"],"Show Featured Image Caption":[""],"Stack on mobile":[""],"Featured Image Size":["Gr\u00f6\u00dfe des Beitragbildes"],"Minimum height":["Mindesth\u00f6he"],"Sets a minimum height for the block, using a percentage of the screen's current height.":[""],"Post Control Settings":[""],"Show Subtitle":["Datum anzeigen"],"Show Excerpt":["Textauszug anzeigen"],"Type Scale":[""],"Color Settings":["Farbeinstellungen"],"Text Color":["Textfarbe"],"Post Meta Settings":["Post Meta SET"],"List View":[""],"Grid View":[""],"Show media on top":[""],"Show media on left":[""],"Show media on right":[""],"Show media behind":[""],"Landscape Image Shape":[""],"portrait Image Shape":[""],"Square Image Shape":["Gr\u00f6\u00dfe des Beitragbildes"],"Uncropped":[""],"Write header\u2026":[""],"Sorry, no posts were found.":["Entschuldigung, wir konnten keine Beitr\u00e4ge finden."],"Homepage Posts":[""],"posts":["Beitr\u00e4ge"],"articles":["Artikel"],"latest":["letzten"],"A block for displaying homepage posts.":[""],"block style\u0004Default":["Standard"],"block style\u0004Borders":["Rahmen"],"Error":["Fehler"],"Go to donation settings to troubleshoot.":[""],"Not ready":["Nicht bereit"],"You have not set up your donation settings yet. You need to do that before you can use the Donate Block.":[""],"Set up donation settings.":[""],"Tiered":[""],"Donate Block":[""],"Configure manually":[""],"The Donate Block allows you to collect donations from readers. The fields are automatically defined based on your donation settings.":[""],"Edit donation settings.":[""],"Manual Settings":["Farbeinstellungen"],"Campaign":[""],"Campaign ID":[""],"Donate":["Spenden"],"donate":["Spenden"],"memberships":["Mitgliedschaften"],"subscriptions":["Abonnements"],"Enable donations.":[""]}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"translation-revision-date":"2020-02-18 13:48-0800","generator":"WP-CLI\/2.4.0","source":"src\/blocks\/carousel\/edit.js","domain":"messages","locale_data":{"messages":{"":{"domain":"messages","lang":"de","plural-forms":"nplurals=2; plural=(n != 1);"},"Article Meta Settings":[""],"Show Date":["Datum anzeigen"],"Show Category":["Kategorie anzeigen"],"Show Author":["Autor anzeigen"],"Show Author Avatar":[""]}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"translation-revision-date":"2020-02-18 13:48-0800","generator":"WP-CLI\/2.4.0","source":"src\/blocks\/donate\/index.js","domain":"messages","locale_data":{"messages":{"":{"domain":"messages","lang":"de","plural-forms":"nplurals=2; plural=(n != 1);"},"Donate":["Spenden"],"donate":["Spenden"],"memberships":["Mitgliedschaften"],"subscriptions":["Abonnements"],"Enable donations.":[""]}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"translation-revision-date":"2020-02-18 13:48-0800","generator":"WP-CLI\/2.4.0","source":"src\/blocks\/homepage-articles\/index.js","domain":"messages","locale_data":{"messages":{"":{"domain":"messages","lang":"de","plural-forms":"nplurals=2; plural=(n != 1);"},"Homepage Posts":[""],"posts":["Beitr\u00e4ge"],"articles":["Artikel"],"latest":["letzten"],"A block for displaying homepage posts.":[""],"block style\u0004Default":["Standard"],"block style\u0004Borders":["Rahmen"]}}}
Binary file added languages/newspack-blocks-de_DE.mo
Binary file not shown.
Loading

0 comments on commit abf7fb3

Please sign in to comment.