A Wordpress plugin that adds a new Gutenberg block type called "Fnugg Fetcher".
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Kim Grytøyr 728dddb3b6
Merge branch 'master' of src.grytoyr.io:kim/fnugg-fetcher
1 month ago
build Use the new resort array when displaying the data 1 month ago
screenshots Update README with a new screenshot, a summary of the implementation and 1 month ago
src Use the new resort array when displaying the data 1 month ago
.editorconfig Initial commit 1 month ago
.gitignore Add vendor directory to .gitignore 1 month ago
README.md Added information about caching to the README 1 month ago
block.json Update block.json 1 month ago
fnugg-api-client.php Move information about caching from fetch to handle_request 1 month ago
fnugg-fetcher.php Fix plugin metadata indentation 1 month ago
package-lock.json Add React dependencies 1 month ago
package.json Add React dependencies 1 month ago
readme.txt Update readme.txt 1 month ago

README.md

Fnugg Fetcher

This plugin will add a new Gutenberg block called “Fnugg Fetcher” that allows you to add a block with information about a ski resort from the Fnugg website.

It accesses the Fnugg API via an internal API located at /wp-json/fnugg-fetcher/v1/resorts/. It supports three types of requests, all of them are GET requests:

  • fnugg-fetcher/v1/resorts/?q=search_term
    Searches for a resort and returns the necessary information about the resort.

  • fnugg-fetcher/v1/resorts/?q=search_term&autocomplete=1
    Returns autocomplete suggestions based on the provided search term.

  • fnugg-fetcher/v1/resorts/<id>
    Returns the resort with id.

If a persistent cache storage (like Redis) is available, all responses will be cached based on the URL for 1800 seconds.

A few notes:

  • Tested on Firefox 82 (Mac) and Chrome 86 (Mac)
  • The plugin folder and its basic structure was created using the npx @wordpress/create-block utility.
  • I’ve used the react-select package for the autocomplete feature.
  • The date is formatted using moment.

There is a fresh installation of WordPress for you to try this plugin on located at https://wp.dev.grytoyr.io. Contact me if you need the credentials.

Installation

  1. Download the ZIP file from releases and unzip it to the /wp-content/plugins/fnugg-fetcher directory, or install the plugin through the WordPress plugins screen directly.
  2. Activate the plugin through the ‘Plugins’ screen in WordPress.
  3. For caching to work, make sure you have a persistent cache storage (like Redis) available.

Usage

Add a new Gutenberg block by typing /fnugg-fetcher in the editor. Enter the search term in the text field and use the arrow keys and «enter» or the mouse to select the resort you’d like to add. Save the post or page and you’re done!

Screenshots

Add the new block

The plugin before search

Autocomplete

Display the resort

Changelog

0.1.0

  • Release