Skip to content

denisaleman/fnugg-block

Repository files navigation

Ski resort Gutenberg block

Instructions

See instructions.md

Description

The plugin provides the user with a Gutenberg block that displays information about one of the ski resorts in Norway.

The information includes data on the state of weather, snow, windiness. The block also displays an image of the location of the resort and its name.

The data for filling the block is loaded from the site api.fnugg.no using the appropriate endpoints.

Demo

Live: http://13.36.33.182/sample-page/
Admin: http://13.36.33.182/wp-admin/post.php?post=2&action=edit

Credentials

login: dekode
password: dekode

Dependencies and Requirements

PHP 7.1 and Wordpress 5.8

Install

The plugin uses composer in order to autoload classes only, within the plugin folder:

# composer
composer dumpautoload -o

Development

For development you need to install PHP dev dependencies, they are mostly coding style configuration files:

# composer
composer install --dev

The Gutenberg block itself is assembled with webpack provided all together with wordpress packages, to install them run:

# in plugin folder
cd assets/blocks/fnugg-whether/
npm install

In order to continue developing the block, use scripts defined in package.json.

File structure

Plugin uses folder structure of wp-strap boilerplate. Only meaningfull parts are described bellow, others are parts of the boilerplate.

## First level files
├──plugin.php                    # Main entry file for the plugin
├──composer.json                 # Composer dependencies & scripts
├──phpcs.xml                     # PHPCodeSniffer configuration
│
│ ## Folders
├──assets                        # Holds all Gutenberg block within corresponding folders
│   └── fnugg-whether            # The Gutenberg block itself
│       ├── build                # Bundles
│       ├── src                  # Source files
│       └── block.json           # Block metadata JSON file
│
└──src                           # Holds all the plugin php classes
    ├── Bootstrap.php            # Bootstraps the plugin and auto-instantiate classes
    │
    │
    ├── Fnugg                           # Namespace of the Fnugg API Integration
    │   ├── Api.php                     # Hooks/functionality shared between the back-end and frontend
    │   ├── CachingProxy.php            # Implementation of caching
    │   ├── HttpClient.php              # Client and its interface
    │   └── HttpClientInterface.php     # and its interface
    │
    └── FnuggWhetherPlugin                       # Namespace of Plugin
        ├── App                                  # Application Classes
        │     ├── General                         # General Classes
        │     │   └── Blocks.php                  # Gutenberg blocks register
        │     └── Rest                            # Rest API Controllers
        │         ├── Search.php                  # Search Resort Controller
        │         └── SuggestAutocomplete.php     # Autocomplete Controller
        │
        └── Config               # Plugin configuration
            └── Classes.php      # Defines the folders and order of classes to init

About

Gutenberg block displays information about one of the ski resorts in Norway using fnugg API.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors