Skip to content

Commit

Permalink
Item12952: add support for an extension search
Browse files Browse the repository at this point in the history
  • Loading branch information
crawford committed Oct 6, 2014
1 parent 387c058 commit 1100e27
Show file tree
Hide file tree
Showing 9 changed files with 200 additions and 123 deletions.
Expand Up @@ -233,7 +233,7 @@ function _id_ify(id) {
width: '60%',
modal: true,
buttons: {
Ok: function() {
Close: function() {
$div.dialog("close");
$div.remove();
}
Expand Down Expand Up @@ -325,10 +325,26 @@ function _id_ify(id) {
$div.find('.wizard_button').each(function() {
var data = $(this).data('wizard');
$(this).button().click(function() {
var o;
if (data.form) {
o = $.extend({}, data.args);
// Get wizard arguments from an optional form
$.each($(data.form).serializeArray(), function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
} else
o = data.args;
var params = {
wizard: data.wizard,
method: data.method,
args: data.args,
args: o,
set: find_modified_values(),
cfgusername: $('#username').val(),
cfgpassword: $('#password').val()
Expand Down Expand Up @@ -386,7 +402,7 @@ function _id_ify(id) {
width: '60%',
modal: true,
buttons: {
Ok: function() {
Close: function() {
$dlg.dialog("close");
$dlg.remove();
}
Expand Down
Expand Up @@ -71,9 +71,9 @@ var TML = {
return "PLACEHOLDER" + (removed.length - 1) + ";";
})
.replace(
/(<button(?:.|\n)*?<\/button>)/g,
/(<(button|select|option|textarea)\b(?:.|\n)*?<\/\1>)/g,
function (m, $1) {
// Protect wizard buttons
// Protect HTML types. Only <lc>...</lc> syntax supported.
removed.push($1);
return "PLACEHOLDER" + (removed.length - 1) + ";";
})
Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki.spec
Expand Up @@ -2282,7 +2282,7 @@ $Foswiki::cfg{PluginsOrder} = 'TWikiCompatibilityPlugin,SpreadSheetPlugin';
$Foswiki::cfg{Plugins}{WebSearchPath} = '$Foswiki::cfg{SystemWebName},TWiki';

#---+++ Install, Update or Remove extensions
# **STRING 80 FEEDBACK="label='Review installed extensions';wizard='ExploreExtensions';method='get_installed_extensions'" FEEDBACK="label='Search for extensions';wizard='ExploreExtensions';method='get_other_extensions'"**
# **STRING 80 FEEDBACK="label='Review installed extensions';wizard='ExploreExtensions';method='get_installed_extensions'" FEEDBACK="label='All available extensions';wizard='ExploreExtensions';method='get_other_extensions'" FEEDBACK="label='Search';wizard='ExploreExtensions';method='find_extension_1'"**
# Extensions Repositories Search List.
# Foswiki extension repositories are just Foswiki webs that are organised in the
# same way as the Extensions web on Foswiki.org. The 'Search for extensions'
Expand Down
45 changes: 29 additions & 16 deletions core/lib/Foswiki/Configure/Package.pm
Expand Up @@ -167,14 +167,18 @@ sub option {
}

{

# Subclass of reporter that writes reports to a file
# as well as passing them to another logger.
# TODO: abstract this out and share with tools/extender.pl
package LoggingReporter;

# Options hash can include:
# filename => Override of generated name including path
# action => Action - Install, Remove etc.
# path => Override the default logging path
# $super - Foswiki::Configure::Reporter to pass all reports to
# %options can include:
# filename => Override of generated name including path
# action => Action - Install, Remove etc.
# path => Override the default logging path
# pkgname => name of package being installed
# nolog => if true, don't log to file
# Default name: pkgname-[action]-yyyymmdd-hhmmss.log
sub new {
my ( $class, $super, %options ) = @_;
Expand Down Expand Up @@ -205,7 +209,15 @@ sub option {
my $this = shift;

# Don't actually write any logs if simulating the install
return if ( $this->{_options}->{SIMULATE} );
return if $this->{nolog};

my $text = join( "\n", @_ ) . "\n";

# Take out block formatting tags
$text =~ s/<\/?verbatim>//g;

# Take out active elements
$text =~ s/<button.*?<\/button?//g;

unless ( -e $this->{_logfile} ) {
my @path =
Expand All @@ -219,7 +231,7 @@ sub option {
}

if ( open( my $file, '>>', $this->{_logfile} ) ) {
print $file join( "\n", @_ ) . "\n";
print $file $text;
close($file);
}
else {
Expand Down Expand Up @@ -282,13 +294,9 @@ non-standard locations by the mapTarget utility routine. If a file is
read-only, it is temporarily overridden and the mode of the file is
restored after the move.
Files are "checked in" by creating a Topic Meta object and using the
Foswiki Meta API to save the topic.
* If the file is new, with no history, it is simply copied,
* If the file exists and has rcs history ( *,v file exists), it is
always checked in
* If the file exists without history, the Manifest "CI" flag is followed
Unless the !noci flag is set in the manifest, files are "checked in"
by creating a Topic Meta object and using the Foswiki Meta API to save
the topic.
* =%options= (optional) options to override behavior - primarily for
unit tests.
Expand All @@ -309,7 +317,8 @@ sub install {
my $reporter = LoggingReporter->new(
$supereporter,
action => 'Install',
pkgname => $this->{_pkgname}
pkgname => $this->{_pkgname},
nolog => $this->{_options}->{SIMULATE}
);

$reporter->NOTE("---+ Installing $this->{_pkgname}");
Expand Down Expand Up @@ -869,7 +878,11 @@ sub uninstall {

my @removed;
my %directories;
my $reporter = LoggingReporter->new( $supereporter, action => 'Uninstall' );
my $reporter = LoggingReporter->new(
$supereporter,
action => 'Uninstall',
nolog => $this->{_options}->{SIMULATE}
);

$reporter->NOTE("---+ Uninstalling $this->{_pkgname}");

Expand Down
26 changes: 26 additions & 0 deletions core/lib/Foswiki/Configure/Reporter.pm
Expand Up @@ -4,6 +4,8 @@ package Foswiki::Configure::Reporter;
use strict;
use warnings;

use JSON;

=begin TML
---+ package Foswiki::Configure::Reporter
Expand All @@ -24,6 +26,9 @@ to be supported by renderers.
* Text styling e.g. <nop>*bold*, <nop>=code= etc
* URL links [<nop>[http://that][text description]]
* &lt;verbatim&gt;...&lt;/verbatim&gt;
* HTML types =button=, =select=, =option= and =textarea= are supported
for wizard inputs, if the renderer supports them. Non-interactive
renderers should ignore them.
* ---+++ Headings
Each of the reporting methods (NOTE, WARN, ERROR) accepts any number of
Expand Down Expand Up @@ -114,6 +119,27 @@ sub CHANGED {

=begin TML
---++ ObjectMethod WIZARD($label, $data) -> $note
Generate a wizard button suitable for adding to the stream.
This should return '' if the reporter does not support wizards.
The default is to create an HTML button.
Caller is expected to add the result to the reporter stream using
NOTE etc.
=cut

sub WIZARD {
my ( $this, $label, $data ) = @_;
my $json = JSON->new->encode($data);
$json =~ s/"/&quot;/g;
return
"<button class=\"wizard_button\" data-wizard=\"$json\">$label</button>";
}

=begin TML
---++ ObjectMethod clear() -> $this
Clear all contents from the reporter.
Expand Down

0 comments on commit 1100e27

Please sign in to comment.