TXPC, a Textpattern plugin compiler.
PHP JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
README
txpc.php

README

TXPC, a Textpattern plugin compiler.
====================================

TXPC is a compiler for Textpattern plugins that allows developers to break
their source file into multiple files. It looks for `//inc <file.ext>` in the
source file and merges the contents of `file.ext` into a single PHP file to be
used by TXP's plugin cache. TXPC will then create a distributable, base64 text
file.

Features
--------

- Separate PHP from other languages like CSS and JS.
- Include external libraries without bloating the source file.
- Plugin metadata is declared in a comment at the top of the file instead of
  in `$plugin` (see "Metadata format").
- `# --- BEGIN|END CODE ---` is no longer needed.
- Likewise, explicit help sections are not needed.  Help text has moved to a
  README.textile file in the source directory.
- Releases are automatically labeled with their version.

Usage
-----

From the command line:

  php txpc.php my_plugin.php [cache_dir] [release_dir]

- `cache_dir`
    The directory for the merged plugin. Defaults to current working
    directory.
- `release_dir`
    The directory for the base64 text file. Defaults to cwd.

Calling from Bash
~~~~~~~~~~~~~~~~~

Save the following to somewhere accessible on your PATH (e.g., ~/bin) and
`chmod +x` it:

  #!/bin/env php
  <?php
  require '/path/to/txpc.php';

Running the examples
--------------------

If you have Make installed, run `make all` from the examples directory.
Otherwise, use the following:

  php ../txpc.php example.php cache releases

Metadata format
---------------

In your plugin file, use the following (order is irrelevant):

  /**
   * @name         jmd_example
   * @description  An example plugin.
   * @author       Jon-Michael Deldin
   * @author_uri   http://jmdeldin.com
   * @type         [0-3]
   * @order        [0-9]
   */

- `type`: 0 => public, 
          1 => public+admin,
          2 => library,
          3 => admin
- `order`: 0 => first, ..., 9 => last

Suggested directory structure
-----------------------------

  | plugins/
  | | cache/              <-- for TXP's plugin cache
  | | | jmd_example.php
  | | | jmd_save.php
  | | src/                <-- raw plugin files
  | | | example/
  | | | | example.js
  | | | | example.php
  | | | | Makefile
  | | | | README.textile
  | | | save/
  | | | | Makefile
  | | | | README.textile
  | | | | save.js
  | | | | save.php
  | | | ...
  | | txpc/               <-- compiler
  | | | examples/
  | | | | ...
  | | | README.textile
  | | | txpc.php
  | | releases/           <-- distributable plugins
  | | | jmd_example-0.1.txt
  | | | jmd_save-0.1.txt

Then from the command line or in your Makefile (or Rakefile), use:

  cd src/example
  php ../../txpc/txpc.php ../../cache ../../releases