Skip to content

Commit edd663f

Browse files
committed
Fix #8 and #9
1 parent bba60e3 commit edd663f

File tree

7 files changed

+172
-126
lines changed

7 files changed

+172
-126
lines changed

src/PHPDraft/Model/DataStructureElement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ function __toString()
120120
{
121121
if ($this->value === NULL && $this->key === NULL)
122122
{
123-
return '{ ... }';
123+
return '<span class="example-value pull-right">{ ... }</span>';
124124
}
125125

126126
if (is_array($this->value))

src/PHPDraft/Model/HTTPRequest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,11 @@ private function parse_structure($objects)
103103
*
104104
* @param string $base_url URL to the base server
105105
*
106+
* @param array $additional Extra options to pass to cURL
107+
*
106108
* @return string An executable cURL command
107109
*/
108-
public function get_curl_command($base_url)
110+
public function get_curl_command($base_url, $additional = [])
109111
{
110112
$options = [];
111113

@@ -120,7 +122,8 @@ public function get_curl_command($base_url)
120122
{
121123
$options[] = '-H "'.$header.': '.$value. '"';
122124
}
123-
$options[] = '-v';
125+
$options = array_merge($options, $additional);
126+
124127
return htmlspecialchars('curl '.join(' ', $options). ' "'.$this->parent->build_url($base_url).'"');
125128
}
126129

src/PHPDraft/Model/Transition.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,12 @@ public function get_method()
169169
*
170170
* @param string $base_url base URL of the server
171171
*
172+
* @param array $additional additional arguments to pass
173+
*
172174
* @return string A cURL CLI command
173175
*/
174-
public function get_curl_command($base_url)
176+
public function get_curl_command($base_url, $additional = [])
175177
{
176-
return $this->request->get_curl_command($base_url);
178+
return $this->request->get_curl_command($base_url, $additional);
177179
}
178180
}

src/PHPDraft/Out/HTML/default.css

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,6 @@ var.url-value {
77
padding: 2px;
88
}
99

10-
div.main-url.fixed {
11-
position: fixed;
12-
bottom: -5px;
13-
left: 10px;
14-
z-index: 999;
15-
background: #fff;
16-
border-radius: 5px;
17-
padding: 5px;
18-
box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.5);
19-
}
20-
2110
div.main-url {
2211
text-align: justify;
2312
line-break: loose;
@@ -77,44 +66,58 @@ body .col-md-10 h2:first-of-type {
7766
line-height: 22px;
7867
}
7968

80-
.POST .panel-heading, span.POST {
69+
.POST > .panel-heading, span.POST {
8170
background: #62c462;
8271
}
8372

84-
.GET .panel-heading, span.GET {
73+
.GET > .panel-heading, span.GET {
8574
background: #5bc0de;
8675
}
8776

88-
.DELETE .panel-heading, span.DELETE {
77+
.DELETE > .panel-heading, span.DELETE {
8978
background: #ee5f5b;
9079
}
9180

92-
.PUT .panel-heading, span.PUT {
81+
.PUT > .panel-heading, span.PUT {
9382
background: #f89406;
9483
}
9584

96-
.row dl.dl-horizontal dt {
97-
width: 80px;
98-
line-height: 30px;
99-
}
100-
.row dl.dl-horizontal dd {
101-
line-height: 30px;
102-
margin-left: 100px;
103-
}
104-
105-
.row dl.dl-horizontal dd a.code,
106-
.row dl.dl-horizontal dd code{
107-
margin-right: 5px;
108-
}
109-
110-
.example-value{
111-
color: rgba(0,0,0,0.4);
85+
.example-value {
86+
color: rgba(0, 0, 0, 0.4);
87+
text-align: right;
11288
}
11389

11490
a.code {
11591
padding: 2px 4px;
11692
font-size: 90%;
11793
background-color: #f9f2f4;
11894
border-radius: 4px;
119-
font-family: Menlo,Monaco,Consolas,"Courier New",monospace;
95+
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
96+
}
97+
98+
.popover {
99+
width: auto;
100+
max-width: 50%;
101+
}
102+
103+
.popover-content {
104+
width: auto;
105+
max-width: 100%;
106+
line-break: normal;
107+
white-space: pre-wrap;
108+
}
109+
110+
.panel-body {
111+
position: relative;
112+
}
113+
114+
.curl.btn {
115+
z-index: 999;
116+
position: absolute;
117+
right: 15px;
118+
top: 15px;
119+
}
120+
121+
h5.response-body, h4.request {
122+
cursor: pointer;
120123
}

src/PHPDraft/Out/HTML/default.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,22 @@
33
*/
44
$(function () {
55
$('[data-toggle="popover"]').popover()
6-
})
6+
})
7+
8+
$('.collapse.request-panel').on('shown.bs.collapse', function () {
9+
$(this).parent().find("h4.request .glyphicon.indicator").removeClass("glyphicon-menu-up").addClass("glyphicon-menu-down");
10+
}).on('hidden.bs.collapse', function () {
11+
$(this).parent().find("h4.request .glyphicon.indicator").removeClass("glyphicon-menu-down").addClass("glyphicon-menu-up");
12+
});
13+
14+
$('.collapse.response-panel').on('shown.bs.collapse', function () {
15+
$(this).parent().find("h4.response .glyphicon.indicator").removeClass("glyphicon-menu-up").addClass("glyphicon-menu-down");
16+
}).on('hidden.bs.collapse', function () {
17+
$(this).parent().find("h4.response .glyphicon.indicator").removeClass("glyphicon-menu-down").addClass("glyphicon-menu-up");
18+
});
19+
20+
$('pre.collapse.response-body').on('shown.bs.collapse', function () {
21+
$(this).parent().find("h5.response-body .glyphicon.indicator").removeClass("glyphicon-menu-up").addClass("glyphicon-menu-down");
22+
}).on('hidden.bs.collapse', function () {
23+
$(this).parent().find("h5.response-body .glyphicon.indicator").removeClass("glyphicon-menu-down").addClass("glyphicon-menu-up");
24+
});

0 commit comments

Comments
 (0)