Skip to content

Commit e8752b5

Browse files
committed
Added the ability to preview the API before exporting it to ZIP
1 parent 5c7c8e7 commit e8752b5

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

config.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<api>
1+
<api preview="true">
22
<document title="Sample API" description="Providing sample APIs to the world!"/>
33

44
<sections>

parser.php

+17-8
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,28 @@
5757
}
5858
}
5959

60+
6061
$content = ConfigParser::replaceTokens($elements, $content, false, $ignoredSections);
6162

63+
$isPreview = ((string) @$config["preview"] == "true");
64+
6265
// final output to file
63-
$zip = new Zip();
64-
$zip->setComment("Created by soapbox.io's bootstrap-api");
6566

66-
$zip->addFile($content, "index.html");
67-
$zip->addDirectoryContent(dirname(__FILE__)."/assets", "assets");
68-
$zip->addDirectoryContent(dirname(__FILE__)."/docs", "docs");
69-
$zip->addDirectoryContent(dirname(__FILE__)."/img", "img");
70-
$zip->addDirectoryContent(dirname(__FILE__)."/js", "js");
67+
if(!$isPreview)
68+
{
69+
$zip = new Zip();
70+
$zip->setComment("Created by soapbox.io's bootstrap-api");
7171

72-
$zip->sendZip("api-docs.zip");
72+
$zip->addFile($content, "index.html");
73+
$zip->addDirectoryContent(dirname(__FILE__)."/assets", "assets");
74+
$zip->addDirectoryContent(dirname(__FILE__)."/docs", "docs");
75+
$zip->addDirectoryContent(dirname(__FILE__)."/img", "img");
76+
$zip->addDirectoryContent(dirname(__FILE__)."/js", "js");
77+
78+
$zip->sendZip("api-docs.zip");
79+
}
80+
else
81+
echo $content;
7382

7483

7584
function autoload($class)

0 commit comments

Comments
 (0)