Skip to content

Commit

Permalink
Item13897: Bootstrap configuration is starting!
Browse files Browse the repository at this point in the history
Started adapting JQueryPlugin and JsonRpcContrib.

- Converted to Moo:
   * CommentPlugin/JQuery.pm
   * ConfigurePlugin/JQuery.pm
   * UI/Configure.pm
   * UI/Viewfile.pm

- Engine is now providing queryParameters and bodyParameters attributes to
support Request's queryParam and bodyParam.

- Foswiki::Engine (the base class) initializes queryParameters using
$this->env->{QUERY_STRING} as a source of data if the engine is
HTTPCompliant and no third parameter is passed over to
_prepareQueryParameters() method. Supposed to be compatible with any HTTP
environment. Works for CGI just out of the box.

- Foswiki::Request initializes it's parameters attributes using
Foswiki::Engine query/bodyParameters interface.

- prepareBody() method is gone from Engine.

- Imported George Clark's Foswiki::Request::Attachment implementation from
Item14033 branch.

- $Foswiki::app->ui is now the object handling particular action – it was
_dispatcherObject until now. I consider 'user interface' name valid for
this purpose as browser acting as a user for the server-side application.
It is valid for RPC too.

- Some JQueryPlugin macros are converted to the new model.

- Temporarily reverted jquery versions from 2.2.1 to 2.1.4 and from 1.12.1
to 1.11.3 because the newer .js files failed to load.

- JsonRpcContrib exception is now inheriting from Foswiki::Exception.
=message= attribute/field has been replaced with text. message() method is
there for compatibility.
  • Loading branch information
vrurg committed Apr 19, 2016
1 parent 8f9eb1d commit c52ebb2
Show file tree
Hide file tree
Showing 36 changed files with 954 additions and 700 deletions.
19 changes: 8 additions & 11 deletions CommentPlugin/lib/Foswiki/Plugins/CommentPlugin/JQuery.pm
Expand Up @@ -3,17 +3,16 @@
# See Plugin topic for history and plugin information

package Foswiki::Plugins::CommentPlugin::JQuery;
use strict;
use v5.14;

use Foswiki::Plugins::JQueryPlugin::Plugin ();
our @ISA = qw( Foswiki::Plugins::JQueryPlugin::Plugin );
use Moo;
extends qw( Foswiki::Plugins::JQueryPlugin::Plugin );

sub new {
around BUILDARGS => sub {
my $orig = shift;
my $class = shift;
my $session = shift || $Foswiki::Plugins::SESSION;

my $this = $class->SUPER::new(
$session,
return $orig->(
$class, @_,
name => 'Comment',
version => '3.0',
author => 'Crawford Currie',
Expand All @@ -23,9 +22,7 @@ sub new {
css => ["comment.css"],
javascript => ["comment.js"]
);

return $this;
}
};

1;
__END__
Expand Down
31 changes: 4 additions & 27 deletions ConfigurePlugin/bin/configure
@@ -1,32 +1,9 @@
#! /usr/bin/env perl
# See bottom of file for license and copyright information
use strict;
use warnings;

use File::Spec;

BEGIN {
if ( defined $ENV{GATEWAY_INTERFACE} || defined $ENV{MOD_PERL} ) {
$Foswiki::cfg{Engine} = 'Foswiki::Engine::CGI';
use CGI::Carp qw(fatalsToBrowser);
$SIG{__DIE__} = \&CGI::Carp::confess;
}
else {
$Foswiki::cfg{Engine} = 'Foswiki::Engine::CLI';
require Carp;
$SIG{__DIE__} = \&Carp::confess;
}
my ( $volume, $binDir, $action ) = File::Spec->splitpath(__FILE__);
my $setlib = File::Spec->catpath( $volume, $binDir, 'setlib.cfg' );
@INC = ( '.', grep { $_ ne '.' } @INC ) unless $binDir;
require $setlib;
$action =~ s/\..*$//; # Remove eventual file extension
$ENV{FOSWIKI_ACTION} = $action;
}

use Foswiki ();
use Foswiki::UI ();
$Foswiki::engine->run();
use Cwd;
use lib Cwd::abs_path("../lib");
use Foswiki::App;
exit Foswiki::App->run;
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Expand Down
11 changes: 5 additions & 6 deletions ConfigurePlugin/lib/Foswiki/Plugins/ConfigurePlugin.pm
Expand Up @@ -90,7 +90,6 @@ sub initPlugin {
keys %Foswiki::Configure::Query::;

foreach my $method (@methods) {

Foswiki::Contrib::JsonRpcContrib::registerMethod( 'configure', $method,
_JSONwrap("Foswiki::Configure::Query::$method") );
}
Expand All @@ -105,19 +104,19 @@ sub initPlugin {
$viewpath = $query->param('VIEWPATH');
if ( defined $viewpath ) {
$Foswiki::cfg{ScriptUrlPaths}{view} = $viewpath;
$Foswiki::Plugins::SESSION->getLoginManager()
$Foswiki::app->users->getLoginManager()
->setSessionValue( 'VIEWPATH', $viewpath );
print STDERR "AUTOCONFIG: Applied viewpath $viewpath from URL\n"
if (Foswiki::Configure::Load::TRAUTO);
}
else {
$viewpath =
$Foswiki::Plugins::SESSION->getLoginManager()
$Foswiki::app->users->getLoginManager()
->getSessionValue('VIEWPATH');
if ( defined $viewpath ) {
$Foswiki::cfg{ScriptUrlPaths}{view} = $viewpath;
print STDERR
"AUTOCONFIG: Applied viewpath $viewpath from SESSION\n"
"AUTOCONFIG: Applied viewpath $viewpath from app\n"
if (Foswiki::Configure::Load::TRAUTO);
}
}
Expand All @@ -138,10 +137,10 @@ sub initPlugin {
sub _JSONwrap {
my $method = shift;
return sub {
my ( $session, $request ) = @_;
my ( $app, $request ) = @_;

if ( $Foswiki::cfg{isVALID} ) {
Foswiki::Configure::Auth::checkAccess( $session, 1 );
Foswiki::Configure::Auth::checkAccess( $app, 1 );
}

my $reporter = Foswiki::Configure::Reporter->new();
Expand Down
26 changes: 14 additions & 12 deletions ConfigurePlugin/lib/Foswiki/Plugins/ConfigurePlugin/JQuery.pm
Expand Up @@ -3,17 +3,21 @@
# See Plugin topic for history and plugin information

package Foswiki::Plugins::ConfigurePlugin::JQuery;
use strict;
use v5.14;

use Foswiki::Plugins::JQueryPlugin::Plugin ();
our @ISA = qw( Foswiki::Plugins::JQueryPlugin::Plugin );
use Moo;
use namespace::clean;
extends qw( Foswiki::Plugins::JQueryPlugin::Plugin );

sub new {
my $class = shift;
my $session = shift || $Foswiki::Plugins::SESSION;
around BUILDARGS => sub {
my $orig = shift;
my $class = shift;
my %params = @_;

my $this = $class->SUPER::new(
$session,
$params{app} //= $Foswiki::app;

return $orig->(
$class, %params,
name => 'Configure',
version => '1.0',
author => 'Crawford Currie',
Expand All @@ -28,11 +32,9 @@ sub new {
'UI', 'JsonRpc',
'UI::Tabs', 'pnotify',
'UI::Tooltip', 'UI::Dialog'
]
],
);

return $this;
}
};

1;
__END__
Expand Down
17 changes: 9 additions & 8 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/Config.spec
@@ -1,6 +1,6 @@
# ---+ Extensions
# ---++ JQueryPlugin
# ---+++ General settings
# ---+++ General settings
# **BOOLEAN LABEL="Debug"**
# This flag enables the debug mode for JQueryPlugin and all of its sub-modules.
# Instead of loading jquery.myplugin.js, it will load jquery.myplugin.uncompressed.js.
Expand All @@ -14,7 +14,8 @@ $Foswiki::cfg{JQueryPlugin}{MemoryCache} = 1;

# **STRING LABEL="Icon Search Path" CHECK="undefok"**
# search path for JQICONs
$Foswiki::cfg{JQueryPlugin}{IconSearchPath} = 'FamFamFamSilkIcons, FamFamFamSilkCompanion1Icons, FamFamFamSilkCompanion2Icons, FamFamFamSilkGeoSilkIcons, FamFamFamFlagIcons, FamFamFamMiniIcons, FamFamFamMintIcons';
$Foswiki::cfg{JQueryPlugin}{IconSearchPath} =
'FamFamFamSilkIcons, FamFamFamSilkCompanion1Icons, FamFamFamSilkCompanion2Icons, FamFamFamSilkGeoSilkIcons, FamFamFamFlagIcons, FamFamFamMiniIcons, FamFamFamMintIcons';

# **BOOLEAN LABEL="Enable No-Conflict Mode"**
# Enable this switch to prevent name conflicts with other javascript frameworks that
Expand All @@ -24,7 +25,7 @@ $Foswiki::cfg{JQueryPlugin}{IconSearchPath} = 'FamFamFamSilkIcons, FamFamFamSilk
$Foswiki::cfg{JQueryPlugin}{NoConflict} = 0;

# **STRING LABEL="Default Plugins"**
# List of plugins loaded by default on any page. Note that you need at least the "migrate" plugin being loaded by default in case you are using
# List of plugins loaded by default on any page. Note that you need at least the "migrate" plugin being loaded by default in case you are using
# a newer jQuery library. Starting with jquery-1.9.1 all deprecated methods have been removed from it and put into the "migrate" plugin.
$Foswiki::cfg{JQueryPlugin}{DefaultPlugins} = '';

Expand All @@ -33,13 +34,13 @@ $Foswiki::cfg{JQueryPlugin}{DefaultPlugins} = '';
# problems with plugins still using deprecated features then add the <code>migrate</code> plugin to the list
# of plugins loaded by default (see above). Further note that starting with jQuery-2.0 support for Internet Explorer 6/7/8
# has been dropped. Use jQuery-1.9 in case you still need to cover these browsers.
$Foswiki::cfg{JQueryPlugin}{JQueryVersion} = 'jquery-2.2.1';
$Foswiki::cfg{JQueryPlugin}{JQueryVersion} = 'jquery-2.1.4';

This comment has been minimized.

Copy link
@MichaelDaum

MichaelDaum Apr 20, 2016

Member

Looks like a regression. Are you in sync with master wrt JQueryPlugin?

This comment has been minimized.

Copy link
@vrurg

vrurg Apr 20, 2016

Author Member

No, I froze the code the state when it was branched. It's too many changes and not sure if I would have time to follow and adapt what's done in the master.

Though some time ago George managed to merge some changes into this branch.

# **SELECT , jquery-1.9.1, jquery-1.10.0, jquery-1.10.1, jquery-1.11.0, jquery-1.11.1, jquery-1.11.2, jquery-1.11.3, jquery-1.12.0, jquery-1.12.1**
# Use a different jQuery library for Internet Explorer 6/7/8. Since jQuery-2.0 these old browsers aren't suppored anymore.
# Use one of the jQuery-1.x libraries to still serve a compatible jQuery to these browsers. Or leave it empty to use the same
# Use one of the jQuery-1.x libraries to still serve a compatible jQuery to these browsers. Or leave it empty to use the same
# library version for all browsers.
$Foswiki::cfg{JQueryPlugin}{JQueryVersionForOldIEs} = 'jquery-1.12.1';
$Foswiki::cfg{JQueryPlugin}{JQueryVersionForOldIEs} = 'jquery-1.11.3';

# **SELECT ,base, flickr, foswiki, lightness, redmond, smoothness **
$Foswiki::cfg{JQueryPlugin}{JQueryTheme} = 'foswiki';
Expand Down Expand Up @@ -239,11 +240,11 @@ $Foswiki::cfg{JQueryPlugin}{Plugins}{WikiWord}{Enabled} = 1;
$Foswiki::cfg{JQueryPlugin}{Plugins}{Autocomplete}{Enabled} = 0;

# **BOOLEAN LABEL="Bgiframe" EXPERT**
# Warning: this plugin is deprecated.
# Warning: this plugin is deprecated.
$Foswiki::cfg{JQueryPlugin}{Plugins}{Bgiframe}{Enabled} = 0;

# **BOOLEAN LABEL="Corner" EXPERT**
# Warning: this plugin is deprecated.
# Warning: this plugin is deprecated.
$Foswiki::cfg{JQueryPlugin}{Plugins}{Corner}{Enabled} = 0;

# **BOOLEAN LABEL="Gradient" EXPERT**
Expand Down
30 changes: 13 additions & 17 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/EASING.pm
@@ -1,10 +1,9 @@
# See bottom of file for license and copyright information
package Foswiki::Plugins::JQueryPlugin::EASING;
use strict;
use warnings;
use v5.14;

use Foswiki::Plugins::JQueryPlugin::Plugin;
our @ISA = qw( Foswiki::Plugins::JQueryPlugin::Plugin );
use Moo;
extends qw( Foswiki::Plugins::JQueryPlugin::Plugin );

=begin TML
Expand All @@ -22,22 +21,19 @@ Constructor
=cut

sub new {
around BUILDARGS => sub {
my $orig = shift;
my $class = shift;

my $this = bless(
$class->SUPER::new(
name => 'Easing',
version => '1.3',
author => 'George <nop>McGinley Smith',
homepage => 'http://gsgd.co.uk/sandbox/jquery/easing',
javascript => ['jquery.easing.js'],
),
$class
return $orig->(
$class, @_,
name => 'Easing',
version => '1.3',
author => 'George <nop>McGinley Smith',
homepage => 'http://gsgd.co.uk/sandbox/jquery/easing',
javascript => ['jquery.easing.js'],
);

return $this;
}
};

1;

Expand Down
46 changes: 23 additions & 23 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/FOSWIKI.pm
@@ -1,12 +1,14 @@
# See bottom of file for license and copyright information
package Foswiki::Plugins::JQueryPlugin::FOSWIKI;
use strict;
use warnings;
use v5.14;

use Foswiki::Func;
use Foswiki::Plugins;
use Foswiki::Plugins::JQueryPlugin::Plugin;
use JSON();
our @ISA = qw( Foswiki::Plugins::JQueryPlugin::Plugin );

use Moo;
use namespace::clean;
extends qw( Foswiki::Plugins::JQueryPlugin::Plugin );

=begin TML
Expand All @@ -24,25 +26,22 @@ Constructor
=cut

sub new {
around BUILDARGS => sub {
my $orig = shift;
my $class = shift;

my $this = bless(
$class->SUPER::new(
name => 'Foswiki',
version => '2.10',
author => 'Michael Daum',
homepage => 'http://foswiki.org/Extensions/JQueryPlugin',
javascript => ['jquery.foswiki.js'],
dependencies =>
[ 'JQUERYPLUGIN', 'JQUERYPLUGIN::MIGRATE', 'livequery' ],
tags => 'JQTHEME, JQREQUIRE, JQICON, JQICONPATH, JQPLUGINS',
),
$class
return $orig->(
$class, @_,
name => 'Foswiki',
version => '2.10',
author => 'Michael Daum',
homepage => 'http://foswiki.org/Extensions/JQueryPlugin',
javascript => ['jquery.foswiki.js'],
dependencies =>
[ 'JQUERYPLUGIN', 'JQUERYPLUGIN::MIGRATE', 'livequery' ],
tags => 'JQTHEME, JQREQUIRE, JQICON, JQICONPATH, JQPLUGINS',
);

return $this;
}
};

=begin TML
Expand All @@ -52,10 +51,11 @@ Initialize this plugin by adding the required static files to the html header
=cut

sub init {
around init => sub {
my $orig = shift;
my $this = shift;

return unless $this->SUPER::init();
return unless $orig->($this);

# get exported prefs
my $prefs = Foswiki::Func::getPreferencesValue('EXPORTEDPREFERENCES') || '';
Expand Down Expand Up @@ -102,7 +102,7 @@ sub init {

Foswiki::Func::addToZone( "script", "JQUERYPLUGIN::FOSWIKI::PREFERENCES",
$text, "JQUERYPLUGIN::FOSWIKI" );
}
};

1;
__END__
Expand Down
30 changes: 13 additions & 17 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/LIVEQUERY.pm
@@ -1,10 +1,9 @@
# See bottom of file for license and copyright information
package Foswiki::Plugins::JQueryPlugin::LIVEQUERY;
use strict;
use warnings;
use v5.14;

use Foswiki::Plugins::JQueryPlugin::Plugin;
our @ISA = qw( Foswiki::Plugins::JQueryPlugin::Plugin );
use Moo;
extends qw( Foswiki::Plugins::JQueryPlugin::Plugin );

=begin TML
Expand All @@ -22,22 +21,19 @@ Constructor
=cut

sub new {
around BUILDARGS => sub {
my $orig = shift;
my $class = shift;

my $this = bless(
$class->SUPER::new(
name => 'LiveQuery',
version => '1.3.1',
author => 'Brandon Aaron, Alexander Zaytsev',
homepage => 'https://github.com/hazzik/livequery',
javascript => ['jquery.livequery.js'],
),
$class
return $orig->(
$class, @_,
name => 'LiveQuery',
version => '1.3.1',
author => 'Brandon Aaron, Alexander Zaytsev',
homepage => 'https://github.com/hazzik/livequery',
javascript => ['jquery.livequery.js'],
);

return $this;
}
};

1;

Expand Down

0 comments on commit c52ebb2

Please sign in to comment.