Skip to content

Commit a8ceb83

Browse files
committed
Add recognition for drafter v4 and update bootstrap
1 parent 1e6a1c4 commit a8ceb83

19 files changed

+1148
-982
lines changed

phpdraft

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ require_once 'vendor/autoload.php';
1212

1313
use PHPDraft\In\ApibFileParser;
1414
use PHPDraft\Out\UI;
15-
use PHPDraft\Parse\Drafter;
16-
use PHPDraft\Parse\DrafterAPI;
1715
use PHPDraft\Parse\JsonToHTML;
16+
use PHPDraft\Parse\ParserFactory;
1817

1918
define('VERSION', '0');
2019
try
@@ -27,58 +26,25 @@ try
2726

2827
try
2928
{
30-
$json = new Drafter($apib);
31-
$offline = TRUE;
29+
$parser = ParserFactory::get();
30+
$parser = $parser->init($apib);
3231
}
3332
catch (\PHPDraft\Parse\ResourceException $exception)
3433
{
35-
file_put_contents('php://stderr', "Offline drafter not available.\n");
36-
if (!defined('DRAFTER_ONLINE_MODE') || DRAFTER_ONLINE_MODE !== 1)
37-
{
38-
ask_version();
39-
}
40-
}
41-
if (!$offline)
42-
{
43-
try
44-
{
45-
$json = new DrafterAPI($apib);
46-
$online = TRUE;
47-
}
48-
catch (\PHPDraft\Parse\ResourceException $exception)
49-
{
50-
file_put_contents('php://stderr', $exception->getMessage() . "\n");
51-
}
52-
}
53-
if (!$online && !$offline)
54-
{
55-
throw new \RuntimeException('Could not find a suitable drafter version', 1);
34+
file_put_contents('php://stderr', "No drafter available.\n");
35+
return;
5636
}
5737

58-
59-
$html = new JsonToHTML($json->parseToJson());
38+
$html = new JsonToHTML($parser->parseToJson());
6039
$html->sorting = $values['sorting'];
6140
$generator = $html->get_html($values['template'], $values['image'], $values['css'], $values['js']);
6241
}
63-
catch (RuntimeException $exception)
42+
catch (\PHPDraft\Parse\ExecutionException $exception)
6443
{
6544
file_put_contents('php://stderr', $exception->getMessage() . PHP_EOL);
6645
exit($exception->getCode());
6746
}
6847

69-
function ask_version()
70-
{
71-
$options = [
72-
'y' => 'Yes',
73-
'n' => 'No',
74-
];
75-
$answer = UI::ask('Do you want to use the online version? [y/n]', $options, 'y');
76-
if (!$answer)
77-
{
78-
throw new \RuntimeException('Could not find a suitable drafter version', 1);
79-
}
80-
}
81-
8248
function phpdraft_var_dump(...$vars)
8349
{
8450
if (defined('__PHPDRAFT_PHAR__'))

src/PHPDraft/Out/HTML/default.css

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ button.extra-info.btn:focus {
2323
box-shadow: none;
2424
outline: 0;
2525
}
26-
.request-panel > code, .popover-content {
26+
.request-card > code, .popover-content {
2727
word-break: break-all;
2828
}
2929

@@ -37,8 +37,11 @@ body .media h1.media-heading .form-control{
3737
float: right;
3838
}
3939

40+
div.card {
41+
margin: 10px auto;
42+
}
4043

41-
.panel-title var, h4.response var {
44+
.card-title var, h4.response var {
4245
padding: 6px 12px;
4346
margin-right: 12px;
4447
border-radius: 3px;
@@ -54,7 +57,7 @@ h4.response.error var {
5457
background: rgba(201, 12, 0, 0.1);
5558
}
5659

57-
.panel-title code {
60+
.card-title code {
5861
color: #000;
5962
background-color: rgba(255, 255, 255, 0.7);
6063
padding: 1px 4px;
@@ -63,7 +66,7 @@ h4.response.error var {
6366
border-radius: 3px
6467
}
6568

66-
.panel-title a.transition-title {
69+
.card-title a.transition-title {
6770
padding: 6px 0;
6871
}
6972

@@ -84,27 +87,27 @@ body .col-md-10 h3:first-child {
8487
line-height: 26px;
8588
}
8689

87-
.method-nav ul li a span {
90+
.method-nav ul li a i {
8891
color: #fff;
8992
padding: 0 5px;
9093
box-sizing: padding-box;
9194
border-radius: 15px;
9295
line-height: 22px;
9396
}
9497

95-
.POST:not(.structure) > .panel-heading, span.POST {
98+
.POST:not(.structure) > .card-header, span.POST {
9699
background: #62c462;
97100
}
98101

99-
.GET:not(.structure) > .panel-heading, span.GET {
102+
.GET:not(.structure) > .card-header, span.GET {
100103
background: #5bc0de;
101104
}
102105

103-
.DELETE:not(.structure) > .panel-heading, span.DELETE {
106+
.DELETE:not(.structure) > .card-header, span.DELETE {
104107
background: #ee5f5b;
105108
}
106109

107-
.PUT:not(.structure) > .panel-heading, span.PUT {
110+
.PUT:not(.structure) > .card-header, span.PUT {
108111
background: #f89406;
109112
}
110113

@@ -133,7 +136,7 @@ a.code {
133136
white-space: pre-wrap;
134137
}
135138

136-
.panel-body {
139+
.card-body {
137140
position: relative;
138141
}
139142

@@ -153,6 +156,6 @@ a.code {
153156
border-bottom-right-radius: 0px
154157
}
155158

156-
h5.response-body, h4.request {
159+
/*h5.response-body, h4.request {
157160
cursor: pointer;
158-
}
161+
}*/

src/PHPDraft/Out/HTML/default.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ $(function () {
2222
};
2323
});
2424

25-
$('.collapse.request-panel').on('shown.bs.collapse', function () {
26-
$(this).parent().find('h4.request .glyphicon.indicator').removeClass('glyphicon-menu-up').addClass('glyphicon-menu-down');
25+
$('.collapse.request-card').on('shown.bs.collapse', function () {
26+
$(this).parent().find('h6.request .fas.indicator').removeClass('fa-angle-up').addClass('fa-angle-down');
2727
}).on('hidden.bs.collapse', function () {
28-
$(this).parent().find('h4.request .glyphicon.indicator').removeClass('glyphicon-menu-down').addClass('glyphicon-menu-up');
28+
$(this).parent().find('h6.request .fas.indicator').removeClass('fa-angle-down').addClass('fa-angle-up');
2929
});
3030

31-
$('.collapse.response-panel').on('shown.bs.collapse', function () {
32-
$(this).parent().find('h4.response .glyphicon.indicator').removeClass('glyphicon-menu-up').addClass("glyphicon-menu-down");
31+
$('.collapse.response-card').on('shown.bs.collapse', function () {
32+
$(this).parent().find('h6.response .fas.indicator').removeClass('fa-angle-up').addClass("fa-angle-down");
3333
}).on('hidden.bs.collapse', function () {
34-
$(this).parent().find('h4.response .glyphicon.indicator').removeClass('glyphicon-menu-down').addClass("glyphicon-menu-up");
34+
$(this).parent().find('h6.response .fas.indicator').removeClass('fa-angle-down').addClass("fa-angle-up");
3535
});
3636

3737
$('pre.collapse.response-body').on('shown.bs.collapse', function () {
38-
$(this).parent().find('h5.response-body .glyphicon.indicator').removeClass('glyphicon-menu-up').addClass('glyphicon-menu-down');
38+
$(this).parent().find('h6.response-body .fas.indicator').removeClass('fa-angle-up').addClass('fa-angle-down');
3939
}).on('hidden.bs.collapse', function () {
40-
$(this).parent().find('h5.response-body .glyphicon.indicator').removeClass('glyphicon-menu-down').addClass('glyphicon-menu-up');
40+
$(this).parent().find('h6.response-body .fas.indicator').removeClass('fa-angle-down').addClass('fa-angle-up');
4141
});

0 commit comments

Comments
 (0)