GithubHelp home page GithubHelp logo

pb-api's Introduction

Pressbooks

Contributors: Pressbooks [email protected] Tags: ebooks, publishing, webbooks Requires at least: 6.5.0 Tested up to: 6.5.0 Stable tag: 6.18.1 Requires PHP: 8.1 License: GPL v3.0 or later License URI: https://github.com/pressbooks/pressbooks/blob/production/LICENSE.md

Pressbooks is an open source book publishing tool built on a WordPress multisite platform.

Description

Packagist Current Release Packagist PHP from Packagist

Packagist Code Coverage Translate Pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS. Pressbooks is free software, released under the GPL v3.0 or later license.

Our webbooks and EPUB/PDF exports are all driven by HTML + CSS. XML outputs have no styling.

Requirements

Pressbooks works with PHP 8.1 and WordPress 6.5.0. Lower versions are not supported.

Installing the Plugin

Pressbooks is not for use on an existing blog. Instead it should be used with a fresh, multisite WordPress installation.

To install Pressbooks on your site, download the latest release and follow our installation instructions.

You may want to try Pressbooks.com before deciding whether or not you wish to host and maintain your own instance of Pressbooks. We can also host and maintain an instance of Pressbooks for you.

Contributor guidelines

Developers who are interested in contributing to our project should consult our "Contributing" guidelines and the developer guides published on our documentation website.

Disclaimers

The Pressbooks plugin is supplied "as is" and all use is at your own risk.

Changelog

6.18.1

Upgrade Notices

6.18.0

6.17.0

6.15.2

6.15.1

6.12.0

6.10.0

6.9.0

  • Pressbooks 6.9.0 requires PHP >= 8.1

6.4.0

  • Pressbooks 6.4.0 requires PHP >= 8.0
  • Pressbooks 6.4.0 requires WordPress 6.1.1

6.0.0

5.34.1

5.34.0

5.33.0

5.32.0

5.31.0

5.30.0

5.27.0

5.25.0

5.21.0

5.20.1

5.18.0

  • Pressbooks 5.18.0 requires PHP >= 7.3
  • Pressbooks 5.18.0 requires WordPress 5.5.3

5.16.0

  • If you are using the plugin (Lord of the Files)[https://wordpress.org/plugins/blob-mimes/] version <=1.0.0, this upgrade will break your application. To fix this, you would need to update Lord of the files plugin to at least 1.1.0.

5.15.1

pb-api's People

Contributors

dependabot[bot] avatar steelwagstaff avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pb-api's Issues

Move all pb-api code out of Pressbooks core, and into this repo

Refactor the following code into this module, so that it works stand-alone, without any code inside Pressbooks core.

/hooks.php

$enable_network_api = \Pressbooks\Api\is_enabled();
if ( $enable_network_api ) {
	add_filter( 'init', '\Pressbooks\Redirect\rewrite_rules_for_api', 1 ); // API V1
}

/inc/redirect/namespace.php

/**
 * PB API v1
 * Adding a rewrite rule for Book API
 *
 * @see https://github.com/pressbooks/pb-api
 * @deprecated
 */
function rewrite_rules_for_api() {
	add_rewrite_endpoint( 'api', EP_ROOT );
	add_action( 'template_redirect', __NAMESPACE__ . '\do_api', 0 );
}

/**
 * PB API v1
 * Expects the pattern `api/v1/books/{id}`
 *
 * @see https://github.com/pressbooks/pb-api
 * @deprecated
 */
function do_api() {
	// Don't do anything and return if `api` isn't part of the URL
	if ( ! array_key_exists( 'api', $GLOBALS['wp_query']->query_vars ) ) {
		return;
	}

	// Support only GET requests for now
	if ( 'GET' !== $_SERVER['REQUEST_METHOD'] ) {
		\Pressbooks\Modules\Api_v1\Api::apiErrors( 'method' );
	}

	// Deal with the rest of the URL
	$nouns = get_query_var( 'api' );
	if ( '' === trim( $nouns, '/' ) || empty( $nouns ) ) {
		\Pressbooks\Modules\Api_v1\Api::apiErrors( 'resource' );
	}

	// parse url, at minimum we need `v1` and `books`
	$parts = explode( '/', $nouns );

	// required 'v1'
	$version = array_shift( $parts );

	// required 'books'
	$resource = array_shift( $parts );

	// optional 'id'
	$books_id = ( isset( $parts[0] ) ) ? $parts[0] : '';
	$variations = [];

	if ( 'v1' !== $version ) {
		\Pressbooks\Modules\Api_v1\Api::apiErrors( 'version' );
	}

	// Filter user input
	if ( is_array( $_GET ) ) {

		$args = [
			'titles' => [
				'filter' => FILTER_SANITIZE_STRING,
				'flags' => FILTER_FLAG_STRIP_HIGH,
			],
			'offset' => FILTER_SANITIZE_NUMBER_INT,
			'limit' => FILTER_SANITIZE_NUMBER_INT,
			'json' => FILTER_SANITIZE_NUMBER_INT,
			'xml' => FILTER_SANITIZE_NUMBER_INT,
			'subjects' => [
				'filter' => FILTER_SANITIZE_STRING,
				'flags' => FILTER_FLAG_STRIP_LOW,
			],
			'authors' => [
				'filter' => FILTER_SANITIZE_STRING,
				'flags' => FILTER_FLAG_STRIP_LOW,
			],
			'licenses' => [
				'filter' => FILTER_SANITIZE_STRING,
				'flags' => FILTER_FLAG_STRIP_HIGH,
			],
			'keywords' => [
				'filter' => FILTER_SANITIZE_STRING,
				'flags' => FILTER_FLAG_STRIP_LOW,
			],
		];

		$variations = filter_input_array( INPUT_GET, $args, false );

		if ( $variations ) {
			// Trim whitespace
			array_filter( $variations, __NAMESPACE__ . '\trim_value' );
		}
	}

	switch ( $resource ) {
		case 'books':
			try {
				new \Pressbooks\Modules\Api_v1\Books\BooksApi( $books_id, $variations );
			} catch ( \Exception $e ) {
				echo $e->getMessage();
			}
			break;
		case 'docs':
			$docs = [
				PB_PLUGIN_DIR . 'vendor/pressbooks/pb-api/includes/modules/api_v1/docs/api-documentation.php', // Packaged
				WP_CONTENT_DIR . '/../../vendor/pressbooks/pb-api/includes/modules/api_v1/docs/api-documentation.php', // Bedrock
				WP_CONTENT_DIR . '/vendor/pressbooks/pb-api/includes/modules/api_v1/docs/api-documentation.php', // Maybe here?
			];
			foreach ( $docs as $path ) {
				if ( file_exists( $path ) ) {
					require( $path );
					break;
				}
			}
			break;
		default:
			\Pressbooks\Modules\Api_v1\Api::apiErrors( 'resource' );
			break;
	}

	exit;
}

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.