Skip to content

Commit e33fa3d

Browse files
committed
Merge pull request with CURL support
remove locale directory from build
1 parent fc8b6c7 commit e33fa3d

File tree

6 files changed

+107
-34
lines changed

6 files changed

+107
-34
lines changed

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ echo "Creating working directory ..."
77
rm -rf build
88
mkdir build
99
cp -r \
10-
install.rdf content locale LICENSE\
10+
install.rdf content LICENSE\
1111
modules icon.png chrome.manifest \
1212
build/
1313
cd build

content/js/restclient.curl.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/* ***** BEGIN LICENSE BLOCK *****
2+
Copyright (c) 2007-2012, Chao ZHOU (chao@zhou.fr). All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
* Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
* Redistributions in binary form must reproduce the above copyright
10+
notice, this list of conditions and the following disclaimer in the
11+
documentation and/or other materials provided with the distribution.
12+
* Neither the name of the author nor the names of its contributors may
13+
be used to endorse or promote products derived from this software
14+
without specific prior written permission.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
17+
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18+
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
19+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
* ***** END LICENSE BLOCK ***** */
28+
29+
"use strict";
30+
31+
restclient.curl = {
32+
constructCommand: function(request){
33+
console.log(request);
34+
var headersStrings = "";
35+
for(var i=0, header; header = request.headers[i]; i++) {
36+
headersStrings += " -H '"+ header[0] + ':' + header[1] + "'";
37+
}
38+
var body = '';
39+
if(request.body != ''){
40+
body = " -d '" + request.body + "' ";
41+
}
42+
return 'curl -i ' + headersStrings + ' -X ' + request.method + body +" '" + request.url + "'" ;
43+
}
44+
}

content/js/restclient.http.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,4 @@ restclient.http = {
148148
restclient.main.clearResult();
149149
restclient.main.updateProgressBar(-1);
150150
}
151-
}
151+
}

content/js/restclient.main.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ restclient.main = {
9999
$('.favorite-icon').click(restclient.main.favoriteUrl);
100100
$('.toggle-request').click(restclient.main.toggleRequest);
101101
$('.toggle-response').click(restclient.main.toggleResponse);
102+
$('.toggle-curl').click(restclient.main.toggleCurl);
103+
$('.enable-curl').click(restclient.main.enableCurl);
102104
$('.toggle-page-layout').click(restclient.main.toggleLayout);
103105
$('.toggle-header-layout').click(restclient.main.toggleRequestHeaderLayout);
104106
$('.toggle-request-timer').click(restclient.main.toggleRequestTimer);
@@ -234,7 +236,7 @@ restclient.main = {
234236
if (pageLayout === 'percentage') {
235237
$('.container').addClass('container-fluid').removeClass('container');
236238
$('.toggle-page-layout').attr('data-layout', 'percentage');
237-
$('.toggle-page-layout').text('Switch to fixed page layout');
239+
$('.toggle-page-layout').text('Switch to Fixed Page Layout');
238240
}
239241

240242
if (requestHeaderLayout === 'table') {
@@ -355,6 +357,19 @@ restclient.main = {
355357
if (e) e.preventDefault();
356358
return false;
357359
},
360+
enableCurl: function (e) {
361+
$('#curl').slideToggle('slow')
362+
if (e) e.preventDefault();
363+
return false;
364+
},
365+
toggleCurl: function (e) {
366+
var toggle = $('.toggle-curl');
367+
$('#curl-container').slideToggle('slow', function () {
368+
toggle.text(toggle.text() == '-' ? '+' : '-');
369+
});
370+
if (e) e.preventDefault();
371+
return false;
372+
},
358373
toggleExpander: function (e) {
359374
var toggle = $(this),
360375
content = toggle.next().find('.expander-content').first();
@@ -383,14 +398,14 @@ restclient.main = {
383398
{
384399
$('.container').addClass('container-fluid').removeClass('container');
385400
$(this).attr('data-layout', 'percentage');
386-
$(this).text('Switch to fixed page layout');
401+
$(this).text('Switch to Fixed Page Layout');
387402
restclient.setPref('pageLayout', 'percentage');
388403
}
389404
else
390405
{
391406
$('.container-fluid').removeClass('container-fluid').addClass('container');
392407
$(this).attr('data-layout', 'fixed');
393-
$(this).text('Switch to percentage page layout');
408+
$(this).text('Switch to Percentage Page Layout');
394409
restclient.setPref('pageLayout', 'fixed');
395410
}
396411
},
@@ -1928,6 +1943,10 @@ restclient.main = {
19281943
restclient.error('updateOAuthSign');
19291944
}
19301945
},
1946+
updateCurlCommand: function() {
1947+
var request = restclient.main.getRequest();
1948+
$("#curl-command").val(restclient.curl.constructCommand(request));
1949+
},
19311950
sendRequest: function () {
19321951
$('.popover').removeClass('in').remove();
19331952
if ( $('[auto-refresh="yes"]').length > 0)
@@ -1937,6 +1956,9 @@ restclient.main = {
19371956
//restclient.log('resigned');
19381957
}
19391958
var request = restclient.main.getRequest();
1959+
// TODO: if curl enabled
1960+
restclient.main.updateCurlCommand()
1961+
19401962
if (!restclient.helper.validateUrl(request.url))
19411963
{
19421964
restclient.message.show({

content/restclient.html

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,39 @@
2222
<div class="nav-collapse">
2323
<ul class="nav">
2424
<li class="dropdown">
25-
<a class="dropdown-toggle" data-toggle="dropdown" href="#">File <b class="caret"></b></a>
25+
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Bookmarks <b class="caret"></b></a>
2626
<ul class="dropdown-menu">
27-
<li><a style="cursor:pointer" onclick="restclient.main.loadRequest();return false;">Load request</a></li>
27+
<li><a href="#" onclick="restclient.main.showModal('modal-save-request');return false;">Bookmark This Request</a></li>
28+
<li class="manage-request"><a href="#" onclick="restclient.main.manageFavoriteRequests(); return false;">Show All Bookmarks</a></li>
29+
<li class="divider"></li>
30+
<li class="nav-header">Import/Export</li>
31+
<li><a href="#" onclick="restclient.main.importFavoriteRequests(); return false;">Import Bookmarks</a></li>
32+
<li><a href="#" onclick="restclient.main.exportFavoriteRequests(); return false;">Export Bookmarks</a></li>
33+
<li class="divider"></li>
34+
<li class="nav-header">Load (Version 1.3.x)</li>
35+
<li><a style="cursor:pointer" onclick="restclient.main.loadRequest();return false;">Load Request</a></li>
2836
</ul>
2937
</li>
3038
<li class="dropdown">
3139
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Authentication <b class="caret"></b></a>
3240
<ul class="dropdown-menu">
33-
<li class="nav-header">HTTP authentication</li>
34-
<li><a onclick="restclient.main.showModal('modal-basic-authorization');">Basic authentication</a></li>
35-
<li class="hide"><a onclick="restclient.main.showModal('modal-digest-authorization');">Digest authentication</a></li>
41+
<li class="nav-header">HTTP Authentication</li>
42+
<li><a onclick="restclient.main.showModal('modal-basic-authorization');">Basic Authentication</a></li>
43+
<li class="hide"><a onclick="restclient.main.showModal('modal-digest-authorization');">Digest Authentication</a></li>
3644
<li class="divider"></li>
37-
<li class="nav-header">OAuth protocol</li>
45+
<li class="nav-header">OAuth Protocol</li>
3846
<li><a onclick="$('#modal-oauth').modal('show');">OAuth</a></li>
3947
<li><a onclick="restclient.oauth2.showDialog();">OAuth2</a></li>
4048
</ul>
4149
</li>
4250
<li class="dropdown">
4351
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Headers <b class="caret"></b></a>
4452
<ul class="dropdown-menu headers">
45-
<li class="custom-header"><a href="#" onclick="restclient.main.showModal('modal-custom-header');return false;">Custom header</a></li>
53+
<li class="custom-header"><a href="#" onclick="restclient.main.showModal('modal-custom-header');return false;">Custom Header</a></li>
4654
<li class="divider favorite"></li>
4755
<li><a class="favorite" href="#">Accept</a></li>
4856
<li class="divider"></li>
49-
<li><a href="#" onclick="restclient.main.clearFavoriteHeaders();return false;">Clear favorite headers</a></li>
57+
<li><a href="#" onclick="restclient.main.clearFavoriteHeaders();return false;">Clear Favorite Headers</a></li>
5058
</ul>
5159
</li>
5260
<li class="dropdown">
@@ -62,12 +70,13 @@
6270
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Setting <b class="caret"></b></a>
6371
<ul class="dropdown-menu">
6472
<li class="nav-header">Layout</li>
65-
<li><a style="cursor:pointer" class="toggle-page-layout" data-layout="fixed">Switch to percentage page layout</a></li>
66-
<li><a style="cursor:pointer" class="toggle-header-layout" data-layout="tag">List request headers in table</a></li>
73+
<li><a style="cursor:pointer" class="toggle-page-layout" data-layout="fixed">Switch to Percentage Page Layout</a></li>
74+
<li><a style="cursor:pointer" class="toggle-header-layout" data-layout="tag">List Request Headers in Table</a></li>
6775
<li class="divider"></li>
6876
<li class="nav-header">Develop</li>
69-
<li><a style="cursor:pointer" class="toggle-request-timer" data-timer="disabled">Enable request execution timer</a></li>
70-
<li><a style="cursor:pointer" class="clear-cached-requests">Clear cached requests</a></li>
77+
<li><a style="cursor:pointer" class="enable-curl" >Enable Curl</a></li>
78+
<li><a style="cursor:pointer" class="toggle-request-timer" data-timer="disabled">Enable Request Execution Timer</a></li>
79+
<li><a style="cursor:pointer" class="clear-cached-requests">Clear Cached Requests</a></li>
7180
<li class="divider"></li>
7281
<li class="nav-header">Skins (bootswatch.com)</li>
7382
<li><a href="#" onclick="return false;" data-theme="amelia">Amelia</a></li>
@@ -84,21 +93,6 @@
8493
<li><a href="#" onclick="return false;" data-theme="united">United</a></li>
8594
</ul>
8695
</li>
87-
<li class="dropdown">
88-
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Favorite Requests <b class="caret"></b></a>
89-
<ul class="dropdown-menu">
90-
<li class="nav-header">Favorite requests</li>
91-
<li class="manage-request"><a href="#" onclick="restclient.main.manageFavoriteRequests(); return false;">Manage favorite requests</a></li>
92-
<li><a href="#" onclick="restclient.main.showModal('modal-save-request');return false;">Favorite this request</a></li>
93-
<li class="divider"></li>
94-
<li class="nav-header">Import/export</li>
95-
<li><a href="#" onclick="restclient.main.importFavoriteRequests(); return false;">Import favorite requests</a></li>
96-
<li><a href="#" onclick="restclient.main.exportFavoriteRequests(); return false;">Export favorite requests</a></li>
97-
</ul>
98-
</li>
99-
<li><a href="#" onclick="restclient.main.toggleRequestHistoryPanel(); return false;">
100-
<i class="toggle-request-panel icon-white icon-chevron-down">&nbsp;</i>
101-
</a></li>
10296
</ul>
10397
</div>
10498
</div><!-- container //-->
@@ -317,6 +311,18 @@ <h3 style="color: #999;">[<a href="#" class="toggle-response" title="hotkey: alt
317311
<br />
318312
</div>
319313
</section>
314+
<section id="curl" class="container hide" style="margin-top: 5px;">
315+
<h3 style="color: #999;">[<a href="#" class="toggle-curl" title="hotkey: alt+c" style="color: #999;">-</a>] cUrl</h3>
316+
<div id="curl-container">
317+
<div style="margin-bottom:0px;" class="well">
318+
<h4 style="margin-left: 6px;">Body</h4>
319+
<textarea placeholder="Curl" style="width: 99%;margin: 0;height: 60px;" id="curl-command" rel="tooltip" title="hotkey: c"></textarea>
320+
</div>
321+
<br />
322+
<br />
323+
<br />
324+
</div>
325+
</section>
320326

321327
<footer class="footer container hide showForStartup" style="display:none;">
322328
<p style="float:left"><a href="http://www.restclient.net" target="_blank">Home</a> | <a href="https://github.com/chao/RESTClient" target="_blank">Github</a> | <a href="https://github.com/chao/RESTClient/issues" target="_blank">Issues</a> | <a href="#" onclick="restclient.main.donate();return false;">Donate</a></p>
@@ -763,6 +769,7 @@ <h3>OAuth2</h3>
763769
<script type="text/javascript" src="js/restclient.oauth.js"></script>
764770
<script type="text/javascript" src="js/restclient.headers.js"></script>
765771
<script type="text/javascript" src="js/restclient.http.js"></script>
772+
<script type="text/javascript" src="js/restclient.curl.js"></script>
766773
<script type="text/javascript" src="js/restclient.message.js"></script>
767774
<script type="text/javascript" src="js/restclient.helper.js"></script>
768775

install.rdf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<RDF:Description RDF:about="rdf:#$ll2uD1"
66
em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
77
em:minVersion="3.6"
8-
em:maxVersion="20.a1" />
8+
em:maxVersion="28.0" />
99
<RDF:Description RDF:about="urn:mozilla:install-manifest"
1010
em:creator="Chao Zhou; chao@zhou.fr"
1111
em:contributor="Aurelien Benel; Christophe Lejeune"
@@ -15,6 +15,6 @@
1515
em:name="RESTClient"
1616
em:type="2">
1717
<em:targetApplication RDF:resource="rdf:#$ll2uD1"/>
18-
<em:version>2.0.4</em:version>
18+
<em:version>2.1.0</em:version>
1919
</RDF:Description>
2020
</RDF:RDF>

0 commit comments

Comments
 (0)