Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
nervetattoo committed Apr 24, 2013
1 parent 3623a9f commit 622997b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
27 changes: 16 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Transloadit instance like this

```php
<?php
require_once '/path/to/php-sdk/lib/transloadit/Transloadit.php';
use transloadit\Transloadit;
$Transloadit = new Transloadit(array(
'key' => 'your-key',
'secret' => 'your-secret',
Expand All @@ -44,7 +44,8 @@ resizing job on it.

```php
<?php
$response = $Transloadit->createAssembly(array(

$response = $transloadit->createAssembly(array(
'files' => array(dirname(__FILE__).'/fixture/straw-apple.jpg'),
'params' => array(
'steps' => array(
Expand All @@ -61,12 +62,12 @@ $response = $Transloadit->createAssembly(array(
echo '<pre>';
print_r($response);
echo '</pre>';
```

```

### 2. Create a simple end-user upload form

This example shows you how to create a simple Transloadit upload form
This example shows you how to create a simple transloadit upload form
that redirects back to your site after the upload is done.

Once the script receives the redirect request, the current status for
Expand All @@ -78,10 +79,11 @@ the `notify_url` parameter for this.

```php
<?php
// Check if this request is a Transloadit redirect_url notification.

// Check if this request is a transloadit redirect_url notification.
// If so fetch the response and output the current assembly status:
$Response = Transloadit::response();
if ($Response) {
$response = Transloadit::response();
if ($response) {
echo '<h1>Assembly status:</h1>';
echo '<pre>';
print_r($response);
Expand All @@ -98,7 +100,7 @@ $redirectUrl = sprintf(
);

// Setup a simple file upload form that resizes an image to 200x100px
echo $Transloadit->createAssemblyForm(array(
echo $transloadit->createAssemblyForm(array(
'params' => array(
'steps' => array(
'resize' => array(
Expand All @@ -115,6 +117,7 @@ echo $Transloadit->createAssemblyForm(array(
<input name="example_upload" type="file">
<input type="submit" value="Upload">
</form>

```

### 3. Integrate the jQuery plugin into the previous example
Expand All @@ -124,6 +127,7 @@ to the previous example. Check the HTML comments below to see what changed.

```php
<?php

$response = Transloadit::response();
if ($response) {
echo '<h1>Assembly status:</h1>';
Expand All @@ -139,7 +143,7 @@ $redirectUrl = sprintf(
$_SERVER['REQUEST_URI']
);

echo $Transloadit->createAssemblyForm(array(
echo $transloadit->createAssemblyForm(array(
'params' => array(
'steps' => array(
'resize' => array(
Expand All @@ -163,7 +167,7 @@ document.write(unescape("%3Cscript src='" + tlProtocol + "assets.transloadit.com
</script>
<script type="text/javascript">
$(document).ready(function() {
// Tell the Transloadit plugin to bind itself to our form
// Tell the transloadit plugin to bind itself to our form
$('form').transloadit();
});
</script>
Expand All @@ -172,6 +176,7 @@ document.write(unescape("%3Cscript src='" + tlProtocol + "assets.transloadit.com
<input name="example_upload" type="file">
<input type="submit" value="Upload">
</form>

```
<!-- End of generated doc section -->

Expand Down Expand Up @@ -374,7 +379,7 @@ For more information on SemVer, please visit http://semver.org/.

### [v1.0.0](https://github.com/transloadit/php-sdk/tree/v1.0.0)

A big thanks to @nervetattoo for making this version happen!
A big thanks to [@nervetattoo](https://github.com/nervetattoo) for making this version happen!

[changes since previous](https://github.com/transloadit/php-sdk/compare/v0.10.0...v1.0.0)

Expand Down
11 changes: 6 additions & 5 deletions tool/generate-example-docs.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ function parseExample($file) {
preg_match('/\/\*(.+?)\*\/\n(.+)/s', $php, $match);
list(, $markdown, $code) = $match;

$code = join("\n", array(
return join("\n", array(
$markdown,
'```php',
'<?php',
$code
$code,
'```'
));
$code = preg_replace('/^.+$/m', ' $0', $code);
return $markdown."\n".$code;
}

$examples = array();
Expand All @@ -25,7 +26,7 @@ function parseExample($file) {
$examples[] = $example;
}

$readmePath = SDK_ROOT.'/Readme.md';
$readmePath = SDK_ROOT.'/README.md';
$readme = file_get_contents($readmePath);
$exampleDocs = join("\n", $examples);

Expand Down

0 comments on commit 622997b

Please sign in to comment.