GithubHelp home page GithubHelp logo

isabella232 / fm-gutenberg Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alleyinteractive/fm-gutenberg

0.0 0.0 0.0 2.26 MB

Fieldmanager Gutenberg

JavaScript 39.08% PHP 27.35% TypeScript 29.72% SCSS 3.85%

fm-gutenberg's Introduction

fm-gutenberg

A companion plugin to wp-starter-theme, which is used to create custom blocks, slotfills, and register custom post types and meta fields.

Getting Started

Do a case sensitive global search and replace for the following strings:

  • fm-gutenberg (Localization domain)
  • fm_gutenberg (Prefix for functions)
  • FM_GUTENBERG (Prefix for constants)
  • FM_Gutenberg (Prefix for class names)
  • FM Gutenberg (Commented text)

Install nvm and the version of node specified in .nvmrc if you haven't already.

Run composer setup to install composer and npm dependencies and run an initial build.

Running builds

Run npm run build to build all production assets. Run npm run dev for a development build of assets, which also watches files for changes and automatically recompiles.

Scaffolder

Run npm run scaffold to run the Alley scaffolder against the plugin. All normally-supported options are supported here.

Slotfills

This plugin is built to use slotfills for all site-specific features. The slotfill configuration can be found in slotfills/index.js. Individual slotfill sections are located in slotfills/sections.

Saving to Post Meta

In order to save data back to post meta, you need to register the meta first. Meta fields are registered by adding them to the config/post-meta.json file. There are some examples in this file for Open Graph data.

Reusable Components

A collection of reusable components is located in ./components. These components can be included in a variety of contexts, such as slotfills and blocks.

Services

Complex JavaScript logic should be broken out into separate functions, one function per file, in the services directory, grouped into subfolders by type. See services/media/get-media-url.js for an example of this. All services functions should have associated tests.

Pathing

This project utilizes module aliases to make it easier to handle JavaScript imports. The project is configured to treat paths starting with @/ as being relative to this plugin's root folder. For example:

import ImagePicker from '@/components/image-picker';

These module aliases are configured to work properly with ESLint, IDEs, Jest, and Webpack.

Running Tests

Run npm run test to run Jest tests against JavaScript files. Run npm run test:watch to keep the test runner open and watching for changes.

Run npm run lint to run ESLint against all JavaScript files. Linting will also happen when running development or production builds.

Run composer phpcs to run PHP CodeSniffer tests against PHP files.

Custom Blocks

Use the block scaffolder to create custom blocks. Create the block definition in scaffold/blocks. Ensure the name of the JSON file is the same as the non-namespaced block name (e.g., if your block is fm-gutenberg/my-block, then the JSON file must be my-block.json). After creating or updating the JSON file, run the scaffold command (npm run scaffold) to generate or regenerate assets. Block registration, script creation, etc is handled for you.

CI/CD Integration

Buddy will automatically run composer phpcs, npm run test, and npm run build (which includes eslint). If any of these checks fail, the build will fail.

Hot Reloading

Still to come. The closest you can get now is running npm run dev, which watches for changes, and reloading the page.

Built-in Components

  • AudioPicker: Allows a user to select or remove audio using the media modal or by entering a URL. A wrapper around MediaPicker that sets the file type to audio and provides an audio player preview.
  • CSVUploader: Allows a user to upload a CSV file, which is parsed in the browser, converted to a JSON structure, passed through a user specified callback function for further transformation, and saved to block attributes.
  • ImagePicker: Allows a user to select or remove an image using the media modal or by entering a URL. A wrapper around MediaPicker that sets the file type to image and provides an image preview.
  • MediaPicker: Allows a user to select or remove any attachment from the media library using the media modal.
  • PostSelector: A component used for searching for and selecting posts via the REST API.
  • VideoPicker: Allows a user to select or remove a video using the media modal or by entering a URL. A wrapper around MediaPicker that sets the file type to video and provides a video player preview.

fm-gutenberg's People

Contributors

alleyinteractive-ops avatar benpbolton avatar ethitter avatar goodguyry avatar jakewrfoster avatar joemcgill avatar jomurgel avatar kevinfodness avatar kjbenk avatar mogmarsh avatar stevenslack avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.