Fix Swagger console base URL location issue.

This commit is contained in:
Paulo Gustavo Veiga 2014-12-16 00:43:40 -03:00
parent 81e9fa2793
commit 8003ef73bf
4 changed files with 188 additions and 190 deletions

View File

@ -8,7 +8,7 @@ BASE_DIR=`pwd`
TARGET_DIR=$BASE_DIR/target TARGET_DIR=$BASE_DIR/target
JETTY_DIR=$TARGET_DIR/wisemapping-$WISE_VERSION JETTY_DIR=$TARGET_DIR/wisemapping-$WISE_VERSION
WISE_WEBAPP_DIR=$JETTY_DIR/webapps/wisemapping WISE_WEBAPP_DIR=$JETTY_DIR/webapps/wisemapping
JETTY_VERSION=8.1.14.v20131031 JETTY_VERSION=8.1.16.v20140903
JETTY_DIST_DIR=jetty-distribution-${JETTY_VERSION} JETTY_DIST_DIR=jetty-distribution-${JETTY_VERSION}
JETTY_ZIP=${JETTY_DIST_DIR}.zip JETTY_ZIP=${JETTY_DIST_DIR}.zip

View File

@ -143,7 +143,7 @@ security.openid.enabled=false
# REST Documentation # REST Documentation
# #
# This properties are used for REST API Documentation( http://localhost:8080/doc/rest/index.html) # This properties are used for REST API Documentation( http://localhost:8080/wisemapping/doc/rest/index.html)
# Change the URL for proper documentation console setup. # Change the URL for proper documentation console setup.
documentation.services.basePath=http://localhost:8080/wisemapping/service documentation.services.basePath=http://localhost:8080/wisemapping/service
documentation.services.version=3.0.1 documentation.services.version=3.0.1

View File

@ -24,7 +24,7 @@
supportedSubmitMethods: ['get', 'post', 'put', 'delete'], supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
onComplete: function(swaggerApi, swaggerUi){ onComplete: function(swaggerApi, swaggerUi){
if(console) { if(console) {
console.log("Loaded SwaggerUI") console.log("Loaded SwaggerUI")
} }
$('pre code').each(function(i, e) {hljs.highlightBlock(e)}); $('pre code').each(function(i, e) {hljs.highlightBlock(e)});
}, },

View File

@ -1,187 +1,187 @@
$(function() { $(function() {
// Helper function for vertically aligning DOM elements // Helper function for vertically aligning DOM elements
// http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/ // http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/
$.fn.vAlign = function() { $.fn.vAlign = function() {
return this.each(function(i){ return this.each(function(i){
var ah = $(this).height(); var ah = $(this).height();
var ph = $(this).parent().height(); var ph = $(this).parent().height();
var mh = (ph - ah) / 2; var mh = (ph - ah) / 2;
$(this).css('margin-top', mh); $(this).css('margin-top', mh);
}); });
}; };
$.fn.stretchFormtasticInputWidthToParent = function() { $.fn.stretchFormtasticInputWidthToParent = function() {
return this.each(function(i){ return this.each(function(i){
var p_width = $(this).closest("form").innerWidth(); var p_width = $(this).closest("form").innerWidth();
var p_padding = parseInt($(this).closest("form").css('padding-left') ,10) + parseInt($(this).closest("form").css('padding-right'), 10); var p_padding = parseInt($(this).closest("form").css('padding-left') ,10) + parseInt($(this).closest("form").css('padding-right'), 10);
var this_padding = parseInt($(this).css('padding-left'), 10) + parseInt($(this).css('padding-right'), 10); var this_padding = parseInt($(this).css('padding-left'), 10) + parseInt($(this).css('padding-right'), 10);
$(this).css('width', p_width - p_padding - this_padding); $(this).css('width', p_width - p_padding - this_padding);
}); });
}; };
$('form.formtastic li.string input, form.formtastic textarea').stretchFormtasticInputWidthToParent(); $('form.formtastic li.string input, form.formtastic textarea').stretchFormtasticInputWidthToParent();
// Vertically center these paragraphs // Vertically center these paragraphs
// Parent may need a min-height for this to work.. // Parent may need a min-height for this to work..
$('ul.downplayed li div.content p').vAlign(); $('ul.downplayed li div.content p').vAlign();
// When a sandbox form is submitted.. // When a sandbox form is submitted..
$("form.sandbox").submit(function(){ $("form.sandbox").submit(function(){
var error_free = true; var error_free = true;
// Cycle through the forms required inputs // Cycle through the forms required inputs
$(this).find("input.required").each(function() { $(this).find("input.required").each(function() {
// Remove any existing error styles from the input // Remove any existing error styles from the input
$(this).removeClass('error'); $(this).removeClass('error');
// Tack the error style on if the input is empty.. // Tack the error style on if the input is empty..
if ($(this).val() == '') { if ($(this).val() == '') {
$(this).addClass('error'); $(this).addClass('error');
$(this).wiggle(); $(this).wiggle();
error_free = false; error_free = false;
} }
}); });
return error_free; return error_free;
}); });
}); });
function clippyCopiedCallback(a) { function clippyCopiedCallback(a) {
$('#api_key_copied').fadeIn().delay(1000).fadeOut(); $('#api_key_copied').fadeIn().delay(1000).fadeOut();
// var b = $("#clippy_tooltip_" + a); // var b = $("#clippy_tooltip_" + a);
// b.length != 0 && (b.attr("title", "copied!").trigger("tipsy.reload"), setTimeout(function() { // b.length != 0 && (b.attr("title", "copied!").trigger("tipsy.reload"), setTimeout(function() {
// b.attr("title", "copy to clipboard") // b.attr("title", "copy to clipboard")
// }, // },
// 500)) // 500))
} }
// Logging function that accounts for browsers that don't have window.console // Logging function that accounts for browsers that don't have window.console
function log() { function log() {
if (window.console) console.log.apply(console,arguments); if (window.console) console.log.apply(console,arguments);
} }
// Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913) // Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913)
if (Function.prototype.bind && console && typeof console.log == "object") { if (Function.prototype.bind && console && typeof console.log == "object") {
[ [
"log","info","warn","error","assert","dir","clear","profile","profileEnd" "log","info","warn","error","assert","dir","clear","profile","profileEnd"
].forEach(function (method) { ].forEach(function (method) {
console[method] = this.bind(console[method], console); console[method] = this.bind(console[method], console);
}, Function.prototype.call); }, Function.prototype.call);
} }
var Docs = { var Docs = {
shebang: function() { shebang: function() {
// If shebang has an operation nickname in it.. // If shebang has an operation nickname in it..
// e.g. /docs/#!/words/get_search // e.g. /docs/#!/words/get_search
var fragments = $.param.fragment().split('/'); var fragments = $.param.fragment().split('/');
fragments.shift(); // get rid of the bang fragments.shift(); // get rid of the bang
switch (fragments.length) { switch (fragments.length) {
case 1: case 1:
// Expand all operations for the resource and scroll to it // Expand all operations for the resource and scroll to it
// log('shebang resource:' + fragments[0]); // log('shebang resource:' + fragments[0]);
var dom_id = 'resource_' + fragments[0]; var dom_id = 'resource_' + fragments[0];
Docs.expandEndpointListForResource(fragments[0]); Docs.expandEndpointListForResource(fragments[0]);
$("#"+dom_id).slideto({highlight: false}); $("#"+dom_id).slideto({highlight: false});
break; break;
case 2: case 2:
// Refer to the endpoint DOM element, e.g. #words_get_search // Refer to the endpoint DOM element, e.g. #words_get_search
// log('shebang endpoint: ' + fragments.join('_')); // log('shebang endpoint: ' + fragments.join('_'));
// Expand Resource // Expand Resource
Docs.expandEndpointListForResource(fragments[0]); Docs.expandEndpointListForResource(fragments[0]);
$("#"+dom_id).slideto({highlight: false}); $("#"+dom_id).slideto({highlight: false});
// Expand operation // Expand operation
var li_dom_id = fragments.join('_'); var li_dom_id = fragments.join('_');
var li_content_dom_id = li_dom_id + "_content"; var li_content_dom_id = li_dom_id + "_content";
// log("li_dom_id " + li_dom_id); // log("li_dom_id " + li_dom_id);
// log("li_content_dom_id " + li_content_dom_id); // log("li_content_dom_id " + li_content_dom_id);
Docs.expandOperation($('#'+li_content_dom_id)); Docs.expandOperation($('#'+li_content_dom_id));
$('#'+li_dom_id).slideto({highlight: false}); $('#'+li_dom_id).slideto({highlight: false});
break; break;
} }
}, },
toggleEndpointListForResource: function(resource) { toggleEndpointListForResource: function(resource) {
var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints'); var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints');
if (elem.is(':visible')) { if (elem.is(':visible')) {
Docs.collapseEndpointListForResource(resource); Docs.collapseEndpointListForResource(resource);
} else { } else {
Docs.expandEndpointListForResource(resource); Docs.expandEndpointListForResource(resource);
} }
}, },
// Expand resource // Expand resource
expandEndpointListForResource: function(resource) { expandEndpointListForResource: function(resource) {
var resource = Docs.escapeResourceName(resource); var resource = Docs.escapeResourceName(resource);
if (resource == '') { if (resource == '') {
$('.resource ul.endpoints').slideDown(); $('.resource ul.endpoints').slideDown();
return; return;
} }
$('li#resource_' + resource).addClass('active'); $('li#resource_' + resource).addClass('active');
var elem = $('li#resource_' + resource + ' ul.endpoints'); var elem = $('li#resource_' + resource + ' ul.endpoints');
elem.slideDown(); elem.slideDown();
}, },
// Collapse resource and mark as explicitly closed // Collapse resource and mark as explicitly closed
collapseEndpointListForResource: function(resource) { collapseEndpointListForResource: function(resource) {
var resource = Docs.escapeResourceName(resource); var resource = Docs.escapeResourceName(resource);
$('li#resource_' + resource).removeClass('active'); $('li#resource_' + resource).removeClass('active');
var elem = $('li#resource_' + resource + ' ul.endpoints'); var elem = $('li#resource_' + resource + ' ul.endpoints');
elem.slideUp(); elem.slideUp();
}, },
expandOperationsForResource: function(resource) { expandOperationsForResource: function(resource) {
// Make sure the resource container is open.. // Make sure the resource container is open..
Docs.expandEndpointListForResource(resource); Docs.expandEndpointListForResource(resource);
if (resource == '') { if (resource == '') {
$('.resource ul.endpoints li.operation div.content').slideDown(); $('.resource ul.endpoints li.operation div.content').slideDown();
return; return;
} }
$('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() { $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
Docs.expandOperation($(this)); Docs.expandOperation($(this));
}); });
}, },
collapseOperationsForResource: function(resource) { collapseOperationsForResource: function(resource) {
// Make sure the resource container is open.. // Make sure the resource container is open..
Docs.expandEndpointListForResource(resource); Docs.expandEndpointListForResource(resource);
$('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() { $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
Docs.collapseOperation($(this)); Docs.collapseOperation($(this));
}); });
}, },
escapeResourceName: function(resource) { escapeResourceName: function(resource) {
return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, "\\$&"); return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, "\\$&");
}, },
expandOperation: function(elem) { expandOperation: function(elem) {
elem.slideDown(); elem.slideDown();
}, },
collapseOperation: function(elem) { collapseOperation: function(elem) {
elem.slideUp(); elem.slideUp();
} }
}; };
(function() { (function() {
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
templates['content_type'] = template(function (Handlebars,depth0,helpers,partials,data) { templates['content_type'] = template(function (Handlebars,depth0,helpers,partials,data) {
@ -1281,10 +1281,8 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
}; };
SwaggerUi.prototype.buildUrl = function(base, url) { SwaggerUi.prototype.buildUrl = function(base, url) {
var parts;
console.log("base is " + base); console.log("base is " + base);
parts = base.split("/"); base = base.substring(0,base.indexOf("/doc/"));
base = parts[0] + "//" + parts[2];
if (url.indexOf("/") === 0) { if (url.indexOf("/") === 0) {
return base + url; return base + url;
} else { } else {