Skip to content
Browse files

PRE with CODE element with class language

CODE closing should be at the same line.
  • Loading branch information...
1 parent 0838c39 commit 3637277242a0b81fd6a615dc1c7d656ce7a900ae @kuba-kubula kuba-kubula committed Nov 14, 2012
Showing with 48 additions and 66 deletions.
  1. +2 −4 curl.html
  2. +30 −32 javascript.html
  3. +2 −4 nodejs.html
  4. +8 −16 php.html
  5. +2 −4 python.html
  6. +2 −2 raw.html
  7. +2 −4 ruby.html
View
6 curl.html
@@ -1,10 +1,8 @@
<section name="curl" class="curl">
<p class="ioDesc">In</p>
- <pre class="incoming brush:shell">
-curl --include<% if @headers: %><% for header,value of @headers: %> --header <%= @helpers.escape "#{header}: #{value}" %><% end %> \
+ <pre class="incoming"><code class="language-bash">curl --include<% if @headers: %><% for header,value of @headers: %> --header <%= @helpers.escape "#{header}: #{value}" %><% end %> \
<% end %><% if @method isnt 'GET' or @body: %> --request <%= @method %> \
<% end %><%if @method isnt 'GET' and (@contentType is "text/html" or @contentType is "text/plain"): %> --data "<%= ((@helpers.escape line)[1..-2] + "\n" for line in @body).join('')[0..-2] %>" \
<% else if @body: %> --data <%= @helpers.escape @body.join("") %> \
- <% end %>"<%= @apiUrl %><%= @url %>"
-</pre>
+ <% end %>"<%= @apiUrl %><%= @url %>"</code></pre>
</section>
View
62 javascript.html
@@ -1,34 +1,32 @@
<section name="javascript" class="javascript">
- <p class="ioDesc">In</p>
- <pre class="incoming brush:javascript">
- var xhr = new XMLHttpRequest();
- xhr.open('<%= @method.toUpperCase() %>', '<%= @apiUrl %><%= @url %>');
- <% for header, value of @headers: %>
- xhr.setRequestHeader(<%= @helpers.escape header %>, <%= @helpers.escape value %>);
- <% end %>
- xhr.onreadystatechange = function () {
- if (this.readyState == 4) {
- alert('Status: '+this.status+'\nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'\nBody: '+this.responseText);
- }
- };
- xhr.send(<%= @helpers.escape @body.join("\n") %>);
- </pre>
- <pre class="jsRunCode" style="display: none">
- var xhr = new XMLHttpRequest();
- xhr.open('<%= @method.toUpperCase() %>', '<%= @apiUrl %><%= @url %>');
- <% for header, value of @headers: %>
- xhr.setRequestHeader(<%= @helpers.escape header %>, <%= @helpers.escape value %>);
- <% end %>
- xhr.onreadystatechange = function () {
- if (this.readyState == 4) {
- if (typeof cb !== "undefined") {
- cb(this);
- }
- else {
- alert('Status: '+this.status+'\nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'\nBody: '+this.responseText);
- }
- }
- };
- xhr.send(<%= @helpers.escape @body.join("\n") %>);
- </pre>
+<p class="ioDesc">In</p>
+<pre class="incoming"><code class="language-javascript">var xhr = new XMLHttpRequest();
+xhr.open("<%= @method.toUpperCase() %>", "<%= @apiUrl %><%= @url %>");
+<% for header, value of @headers: %>
+xhr.setRequestHeader(<%= @helpers.escape header %>, <%= @helpers.escape value %>);
+<% end %>
+xhr.onreadystatechange = function () {
+ if (this.readyState == 4) {
+ alert('Status: '+this.status+'\nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'\nBody: '+this.responseText);
+ }
+};
+xhr.send(<%= @helpers.escape @body.join("\n") %>);</code></pre>
+<pre class="jsRunCode" style="display: none">
+var xhr = new XMLHttpRequest();
+xhr.open('<%= @method.toUpperCase() %>', '<%= @apiUrl %><%= @url %>');
+<% for header, value of @headers: %>
+xhr.setRequestHeader(<%= @helpers.escape header %>, <%= @helpers.escape value %>);
+<% end %>
+xhr.onreadystatechange = function () {
+ if (this.readyState == 4) {
+ if (typeof cb !== "undefined") {
+ cb(this);
+ }
+ else {
+ alert('Status: '+this.status+'\nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'\nBody: '+this.responseText);
+ }
+ }
+};
+xhr.send(<%= @helpers.escape @body.join("\n") %>);
+</pre>
</section>
View
6 nodejs.html
@@ -1,7 +1,6 @@
<section name="nodejs" class="nodejs">
<p class="ioDesc">In</p>
- <pre class="incoming brush:js">
-var request = require("request");
+ <pre class="incoming"><code class="language-javascript">var request = require("request");
<% if @method is "GET" and not @headers: %>
request("<%= @apiUrl %><%= @url %>", function (error, response, body) {
<% else : %>
@@ -15,6 +14,5 @@
console.log("Status", response.statusCode);
console.log("Headers", JSON.stringify(response.headers));
console.log("Reponse received", body);
-});
- </pre>
+});</code></pre>
</section>
View
24 php.html
@@ -1,30 +1,22 @@
<section name="php" class="php">
<p class="ioDesc">In</p>
- <pre class="incoming brush:php">
-
-<% headerFirst = true %>
-
-<%= "<?php" %>
+ <pre class="incoming"><code class="language-php"><% headerFirst = true %><%= "<?php" %>
<% eos = "<<<EOT\n" %>
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "<%= @apiUrl %><%= @url %>");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
-<% if @method is 'POST': %>curl_setopt($ch, CURLOPT_POST, TRUE);
-<% end %>
-<% if @method isnt 'GET' and @method isnt 'POST': %>curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "<%= @method %>");
-<% end %>
-<% if @method isnt 'GET' and (@contentType is "text/html" or @contentType is "text/plain"): %>
+<% if @method is 'POST': %>
+curl_setopt($ch, CURLOPT_POST, TRUE);
+<% end %><% if @method isnt 'GET' and @method isnt 'POST': %>
+curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "<%= @method %>");
+<% end %><% if @method isnt 'GET' and (@contentType is "text/html" or @contentType is "text/plain"): %>
$fields = <%= eos %><%= "#{line}\n" for line in @body %>EOT;
-curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
-<% else if @body and @body.length > 0: %>curl_setopt($ch, CURLOPT_POSTFIELDS, <%= @helpers.escape @body.join('') %>);
-
-<% end %>
+curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);<% else if @body and @body.length > 0: %>curl_setopt($ch, CURLOPT_POSTFIELDS, <%= @helpers.escape @body.join('') %>);<% end %>
<% if @headers and @helpers.isNotEmpty(@headers): %>curl_setopt($ch, CURLOPT_HTTPHEADER, array(<% for header, value of @headers: %><% if headerFirst: %><% headerFirst = false %><% else: %>, <% end %><%= @helpers.escape "#{header}: #{value}" %><% end %>));
<% end %>$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
-
- </pre>
+?></code></pre>
</section>
View
6 python.html
@@ -1,7 +1,6 @@
<section name="python" class="python">
<p class="ioDesc">In</p>
- <pre class="incoming brush:python">
-from urllib2 import Request, urlopen
+ <pre class="incoming"><code class="language-python">from urllib2 import Request, urlopen
<% if @contentType is "application/json": %>from json import dumps
<% else if @contentType is "application/x-www-form-urlencoded": %>from urllib import urlencode
<% end %>
@@ -13,6 +12,5 @@
<% end %>request = Request("<%= @apiUrl %><%= @url %>"<% if @method in ['POST', 'PUT'] : %>, data=values<% end %><% if @helpers.isNotEmpty @headers: %>, headers=headers<% end %>)
<% if @method not in ['GET', 'POST'] : %>request.get_method = lambda: '<%= @method %>'
<% end %>response_body = urlopen(request).read()
-print response_body
-</pre>
+print response_body</code></pre>
</section>
View
4 raw.html
@@ -1,5 +1,5 @@
<section name="raw" class="raw">
<p class="ioDesc">In</p>
- <pre class="incoming"><%= "#{header}: #{value}\n" for header, value of @headers %></pre>
- <pre class="incoming<%= @helpers.getContentTypeBrush @headers %>"><%= @body.join("\n") %></pre>
+ <pre class="incoming"><code><%= "#{header}: #{value}\n" for header, value of @headers %></code></pre>
+ <pre class="incoming"><code class="<%= @helpers.getContentTypeBrush @headers %>"><%= @body.join("\n") %></code></pre>
</section>
View
6 ruby.html
@@ -1,14 +1,12 @@
<section name="ruby" class="ruby">
<p class="ioDesc">In</p>
- <pre class="incoming brush:ruby">
-require 'rubygems'
+ <pre class="incoming"><code class="language-ruby">require 'rubygems'
require 'rest_client'
<% if @body and @contentType is "application/x-www-form-urlencoded": %>values = CGI::escape(<%= @helpers.escape @body.join('') %>)
<% else if @body and @contentType is "application/json": %>values = <%= @helpers.escape @body.join('') %>
<% else if @method isnt 'GET' and (@contentType is "text/html" or @contentType is "text/plain"): %>values = <%= @helpers.escape @body.join("\n") %>
<% else if @body and @body.join(''): %>values = <%= @helpers.escape @body.join('') %>
<% end %><% if @helpers.isNotEmpty @headers: %>headers = {<%= [':'+@helpers.rubyKey header+' => '+@helpers.escape value for header,value of @headers].join(", ") %>}
<% end %>response = RestClient.<%= @method.toLowerCase() %> "<%= @apiUrl %><%= @url %>"<% if @body and @body.join(''): %>, values<% end %><% if @helpers.isNotEmpty @headers: %>, headers<% end %>
-puts response
-</pre>
+puts response</code></pre>
</section>

0 comments on commit 3637277

Please sign in to comment.
Something went wrong with that request. Please try again.