2012-03-07 11:30:20 -05:00
|
|
|
/*
|
|
|
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
contributor license agreements. See the NOTICE file distributed with
|
|
|
|
this work for additional information regarding copyright ownership.
|
|
|
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
(the "License"); you may not use this file except in compliance with
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2012-02-23 14:23:10 -05:00
|
|
|
sammy.bind
|
|
|
|
(
|
2012-03-07 11:30:20 -05:00
|
|
|
'plugins_load',
|
|
|
|
function( event, params )
|
|
|
|
{
|
|
|
|
var callback = function()
|
2012-02-23 14:23:10 -05:00
|
|
|
{
|
2012-03-07 11:30:20 -05:00
|
|
|
params.callback( app.plugin_data.plugin_data, app.plugin_data.sort_table, app.plugin_data.types );
|
|
|
|
}
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
if( app.plugin_data )
|
|
|
|
{
|
|
|
|
callback( app.plugin_data );
|
|
|
|
return true;
|
|
|
|
}
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
var core_basepath = params.active_core.attr( 'data-basepath' );
|
|
|
|
$.ajax
|
|
|
|
(
|
|
|
|
{
|
|
|
|
url : core_basepath + '/admin/mbeans?stats=true&wt=json',
|
|
|
|
dataType : 'json',
|
|
|
|
beforeSend : function( xhr, settings )
|
|
|
|
{
|
|
|
|
},
|
|
|
|
success : function( response, text_status, xhr )
|
|
|
|
{
|
|
|
|
var types = [];
|
|
|
|
var sort_table = {};
|
|
|
|
var plugin_data = {};
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
var types_obj = {};
|
|
|
|
var plugin_key = null;
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
for( var i = 0; i < response['solr-mbeans'].length; i++ )
|
|
|
|
{
|
|
|
|
if( !( i % 2 ) )
|
|
|
|
{
|
|
|
|
plugin_key = response['solr-mbeans'][i];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
plugin_data[plugin_key] = response['solr-mbeans'][i];
|
|
|
|
}
|
|
|
|
}
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
for( var key in plugin_data )
|
|
|
|
{
|
|
|
|
sort_table[key] = {
|
|
|
|
url : [],
|
|
|
|
component : [],
|
|
|
|
handler : []
|
|
|
|
};
|
|
|
|
for( var part_key in plugin_data[key] )
|
|
|
|
{
|
|
|
|
if( 0 < part_key.indexOf( '.' ) )
|
|
|
|
{
|
|
|
|
types_obj[key] = true;
|
|
|
|
sort_table[key]['handler'].push( part_key );
|
|
|
|
}
|
|
|
|
else if( 0 === part_key.indexOf( '/' ) )
|
|
|
|
{
|
|
|
|
types_obj[key] = true;
|
|
|
|
sort_table[key]['url'].push( part_key );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
types_obj[key] = true;
|
|
|
|
sort_table[key]['component'].push( part_key );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
for( var type in types_obj )
|
|
|
|
{
|
|
|
|
types.push( type );
|
|
|
|
}
|
|
|
|
types.sort();
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
app.plugin_data = {
|
|
|
|
'plugin_data' : plugin_data,
|
|
|
|
'sort_table' : sort_table,
|
|
|
|
'types' : types
|
|
|
|
}
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$.get
|
|
|
|
(
|
|
|
|
'tpl/plugins.html',
|
|
|
|
function( template )
|
|
|
|
{
|
|
|
|
$( '#content' )
|
|
|
|
.html( template );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
callback( app.plugin_data );
|
2012-02-23 14:23:10 -05:00
|
|
|
}
|
2012-03-07 11:30:20 -05:00
|
|
|
);
|
|
|
|
},
|
|
|
|
error : function( xhr, text_status, error_thrown)
|
|
|
|
{
|
|
|
|
},
|
|
|
|
complete : function( xhr, text_status )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2012-02-23 14:23:10 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
// #/:core/plugins/$type
|
|
|
|
sammy.get
|
|
|
|
(
|
2012-03-07 11:30:20 -05:00
|
|
|
/^#\/([\w\d-]+)\/(plugins)\/(\w+)$/,
|
|
|
|
function( context )
|
|
|
|
{
|
|
|
|
var content_element = $( '#content' );
|
|
|
|
var type = context.params.splat[2].toUpperCase();
|
|
|
|
var context_path = context.path.split( '?' ).shift();
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
sammy.trigger
|
|
|
|
(
|
|
|
|
'plugins_load',
|
|
|
|
{
|
|
|
|
active_core : this.active_core,
|
|
|
|
callback : function( plugin_data, plugin_sort, types )
|
|
|
|
{
|
|
|
|
var frame_element = $( '#frame', content_element );
|
|
|
|
var navigation_element = $( '#navigation ul', content_element );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
var navigation_content = [];
|
|
|
|
for( var i = 0; i < types.length; i++ )
|
|
|
|
{
|
|
|
|
var type_url = context.params.splat[0] + '/' + context.params.splat[1] + '/' + types[i].toLowerCase();
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
navigation_content.push
|
|
|
|
(
|
|
|
|
'<li class="' + types[i].toLowerCase() + '">' +
|
|
|
|
'<a href="#/' + type_url + '">' + types[i] + '</a>' +
|
|
|
|
'</li>'
|
|
|
|
);
|
|
|
|
}
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
navigation_element
|
|
|
|
.html( navigation_content.join( "\n" ) );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( 'a[href="' + context_path + '"]', navigation_element )
|
|
|
|
.parent().addClass( 'current' );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
var content = '<ul>';
|
|
|
|
for( var sort_key in plugin_sort[type] )
|
|
|
|
{
|
|
|
|
plugin_sort[type][sort_key].sort();
|
|
|
|
var plugin_type_length = plugin_sort[type][sort_key].length;
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
for( var i = 0; i < plugin_type_length; i++ )
|
|
|
|
{
|
|
|
|
content += '<li class="entry">' + "\n";
|
|
|
|
content += '<a href="' + context_path + '?entry=' + plugin_sort[type][sort_key][i] + '">';
|
|
|
|
content += plugin_sort[type][sort_key][i]
|
|
|
|
content += '</a>' + "\n";
|
|
|
|
content += '<ul class="detail">' + "\n";
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
var details = plugin_data[type][ plugin_sort[type][sort_key][i] ];
|
|
|
|
for( var detail_key in details )
|
|
|
|
{
|
|
|
|
if( 'stats' !== detail_key )
|
|
|
|
{
|
|
|
|
var detail_value = details[detail_key];
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
if( 'description' === detail_key )
|
|
|
|
{
|
2012-04-06 14:16:26 -04:00
|
|
|
// For list of components
|
|
|
|
if(detail_value.match(/^Search using components: /)) {
|
|
|
|
detail_value = detail_value
|
|
|
|
.replace( /: /, ':<ul><li>' )
|
|
|
|
.replace( /,/g, '</li><li>' ) +
|
|
|
|
"</li></ul>";
|
|
|
|
}
|
2012-03-07 11:30:20 -05:00
|
|
|
}
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
content += '<li><dl class="clearfix">' + "\n";
|
|
|
|
content += '<dt>' + detail_key + ':</dt>' + "\n";
|
2012-04-06 14:16:26 -04:00
|
|
|
if($.isArray(detail_value)) {
|
|
|
|
$.each(detail_value, function(index, value) {
|
|
|
|
content += '<dd>' + value + '</dd>' + "\n";
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
content += '<dd>' + detail_value + '</dd>' + "\n";
|
|
|
|
}
|
2012-03-07 11:30:20 -05:00
|
|
|
content += '</dl></li>' + "\n";
|
|
|
|
}
|
|
|
|
else if( 'stats' === detail_key && details[detail_key] )
|
|
|
|
{
|
|
|
|
content += '<li class="stats clearfix">' + "\n";
|
|
|
|
content += '<span>' + detail_key + ':</span>' + "\n";
|
|
|
|
content += '<ul>' + "\n";
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
for( var stats_key in details[detail_key] )
|
|
|
|
{
|
|
|
|
var stats_value = details[detail_key][stats_key];
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
if( 'readerDir' === stats_key )
|
|
|
|
{
|
|
|
|
stats_value = stats_value.replace( /@/g, '@​' );
|
|
|
|
}
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
content += '<li><dl class="clearfix">' + "\n";
|
|
|
|
content += '<dt>' + stats_key + ':</dt>' + "\n";
|
|
|
|
content += '<dd>' + stats_value + '</dd>' + "\n";
|
|
|
|
content += '</dl></li>' + "\n";
|
|
|
|
}
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
content += '</ul></li>' + "\n";
|
|
|
|
}
|
|
|
|
}
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
content += '</ul>' + "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
content += '</ul>' + "\n";
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
frame_element
|
|
|
|
.html( content );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( 'a[href="' + decodeURIComponent( context.path ) + '"]', frame_element )
|
|
|
|
.parent().addClass( 'expanded' );
|
2012-04-06 14:16:26 -04:00
|
|
|
|
|
|
|
// Try to make links for anythign with http (but leave the rest alone)
|
|
|
|
$( '.detail dd' ).each(function(index) {
|
|
|
|
var txt = $(this).html();
|
|
|
|
if(txt.indexOf("http") >= 0) {
|
|
|
|
$(this).linker({
|
|
|
|
target: '', //blank,self,parent,top
|
|
|
|
className : 'linker',
|
|
|
|
rel : ''
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Add invisible whitespace after each slash
|
|
|
|
$( '.detail a.linker' ).each(function(index) {
|
|
|
|
$(this).html( $(this).html().replace( /\//g, '/​' ) );
|
|
|
|
});
|
|
|
|
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( '.entry', frame_element )
|
|
|
|
.each
|
|
|
|
(
|
|
|
|
function( i, entry )
|
|
|
|
{
|
|
|
|
$( '.detail > li', entry ).not( '.stats' ).filter( ':even' )
|
|
|
|
.addClass( 'odd' );
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
$( '.stats li:odd', entry )
|
|
|
|
.addClass( 'odd' );
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2012-02-23 14:23:10 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
// #/:core/plugins
|
|
|
|
sammy.get
|
|
|
|
(
|
2012-03-07 11:30:20 -05:00
|
|
|
/^#\/([\w\d-]+)\/(plugins)$/,
|
|
|
|
function( context )
|
|
|
|
{
|
|
|
|
delete app.plugin_data;
|
2012-02-23 14:23:10 -05:00
|
|
|
|
2012-03-07 11:30:20 -05:00
|
|
|
sammy.trigger
|
|
|
|
(
|
|
|
|
'plugins_load',
|
|
|
|
{
|
|
|
|
active_core : this.active_core,
|
|
|
|
callback : function( plugin_data, plugin_sort, types )
|
|
|
|
{
|
|
|
|
context.redirect( context.path + '/' + types[0].toLowerCase() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2012-02-23 14:23:10 -05:00
|
|
|
);
|