From f2793beacbb78dd2fb71cd8ab3d00824bfe2ed1d Mon Sep 17 00:00:00 2001 From: George Clark Date: Fri, 12 Aug 2016 10:11:30 -0400 Subject: [PATCH] Item13897: Convert TinyMCE JQuery plugin to object Still cannot get Wysiwyg to work, but this is now not generating any errors. SMELL: The plugin expects to pull the version from the TinyMCE code. But the new object format is static. Need guidance. --- .../Foswiki/Plugins/TinyMCEPlugin/TinyMCE.pm | 105 +++++++++++------- 1 file changed, 62 insertions(+), 43 deletions(-) diff --git a/TinyMCEPlugin/lib/Foswiki/Plugins/TinyMCEPlugin/TinyMCE.pm b/TinyMCEPlugin/lib/Foswiki/Plugins/TinyMCEPlugin/TinyMCE.pm index 4f88410058..1ceb512d78 100644 --- a/TinyMCEPlugin/lib/Foswiki/Plugins/TinyMCEPlugin/TinyMCE.pm +++ b/TinyMCEPlugin/lib/Foswiki/Plugins/TinyMCEPlugin/TinyMCE.pm @@ -1,35 +1,52 @@ -# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/ -# -# Javascript is Copyright (C) 2012 Sven Dowideit - SvenDowideit@fosiki.com -# +# See bottom of file for license and copyright information +package Foswiki::Plugins::TinyMCEPlugin::TinyMCE; +use v5.14; -# This program is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details, -# published at http://www.gnu.org/copyleft/gpl.html +use Foswiki::Func; +use Foswiki::Plugins; +use JSON(); -package Foswiki::Plugins::TinyMCEPlugin::TinyMCE; -use strict; -use warnings; -use Foswiki::Plugins::JQueryPlugin::Plugin; -our @ISA = qw( Foswiki::Plugins::JQueryPlugin::Plugin ); +use Moo; +use namespace::clean; +extends qw( Foswiki::Plugins::JQueryPlugin::Plugin ); =begin TML ----+ package Foswiki::Plugins::TinyMCEPlugin::TinyMCE +---+ package Foswiki::Plugins::JQueryPlugin::FOSWIKI -This is the perl stub for tinyMCE. +This is the perl stub for the jquery.foswiki plugin. =cut =begin TML ----++ ClassMethod new( $class, $session, ... ) +---++ ClassMethod new( $class, ... ) + +Constructor + +=cut + +our %pluginParams = ( + name => 'TinyMCE', + version => 1.2, + +# version => $encodedVersion; # SMELL: version should be dynamically determined. + author => 'Foswiki Contributors', + homepage => 'https://foswiki.org/Extensions/TinyMCEPlugin', + documentation => "$Foswiki::cfg{SystemWebName}.TinyMCEPlugin", + puburl => '%PUBURLPATH%/%SYSTEMWEB%/TinyMCEPlugin', + javascript => [ + 'foswiki_tiny.js', 'foswiki.js', + '/tinymce/jscripts/tiny_mce/tiny_mce.js' + ], + dependencies => ['foswiki'], +); + +=begin TML + +---++ ClassMethod init( $this ) + +Initialize this plugin by adding the required static files to the html header Constructor @@ -37,9 +54,8 @@ Constructor =cut -sub new { +around init => sub { my $class = shift; - my $session = shift || $Foswiki::Plugins::SESSION; # URL-encode the version number to include in the .js URLs, so that # the browser re-fetches the .js when this plugin is upgraded. @@ -51,28 +67,14 @@ sub new { #$encodedVersion =~ # s/([^0-9a-zA-Z-_.:~!*'\/%])/'%'.sprintf('%02x',ord($1))/ge; - my $this = bless( - $class->SUPER::new( - name => 'TinyMCE', - version => $encodedVersion, - author => 'Foswiki Contributors', - homepage => 'http://foswiki.org/Extensions/TinyMCEPlugin', - documentation => "$Foswiki::cfg{SystemWebName}.TinyMCEPlugin", - puburl => '%PUBURLPATH%/%SYSTEMWEB%/TinyMCEPlugin', - javascript => [ - 'foswiki_tiny.js', 'foswiki.js', - '/tinymce/jscripts/tiny_mce/tiny_mce.js' - ], - dependencies => ['foswiki'] - ), - $class - ); - - return $this; -} + return; +}; sub renderJS { - my ( $this, $text ) = @_; + my $this = shift; + my $text = shift; + + print STDERR "renderJS entered with $text\n"; $text .= '?version=' . $this->{version} if ( $this->{version} =~ '$Rev$' ); $text = @@ -81,3 +83,20 @@ sub renderJS { } 1; + +__END__ + +# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/ +# +# Javascript is Copyright (C) 2012 Sven Dowideit - SvenDowideit@fosiki.com +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details, +# published at http://www.gnu.org/copyleft/gpl.html +#