Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Item14288: support pluggable edit engines
  • Loading branch information
MichaelDaum committed Jan 23, 2017
1 parent addab09 commit b7bb0c9
Show file tree
Hide file tree
Showing 21 changed files with 632 additions and 1,122 deletions.
35 changes: 17 additions & 18 deletions NatEditPlugin/data/System/NatEditPlugin.txt
@@ -1,5 +1,7 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1452118054" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1485156553" format="1.1" version="1"}%
---+!! Natural Edit Plugin
%FORMFIELD{"Description"}%

%TOC%

---++ Description
Expand Down Expand Up @@ -46,18 +48,15 @@ No extra configuration steps are needed in case you are using <nop>NatSkin.

is sufficient.

<!--
* Set STUB = %$STUB%
* Set SHORTDESCRIPTION = A Wikiwyg Editor
-->

---++ Plugin Installation Instructions
---++ Installation Instructions
%$INSTALL_INSTRUCTIONS%

| Copyright &copy;: | 2007-2015 Michael Daum http://michaeldaumconsulting.com |
| Change History: | |
---++ Dependencies
%$DEPENDENCIES%

---++ Change History
| 06 Jan 2016 | Add helper to insert a data form table header. |
| 08 Sep 2015 | Remove RevCommentPlugin hooks from templates, Hide TopicTitle when unused. |
| 08 Sep 2015 | Remove RevCommentPlugin hooks from templates, Hide ToipcTitle when unused. |
| 30 Aug 2015 | fixed default implementation for =topictitle= |
| 29 Jul 2015 | added missing image in documentation |
| 06 Mar 2015 | fixed permissions editor |
Expand Down Expand Up @@ -167,16 +166,16 @@ is sufficient.
| 03 Apr 2007 | added NATEDIT_HELPTEXT variable; \
be backwards compatible to <nop>PatternSkin |
| 31 Mar 2007 | Initial version |
| Dependencies: | %$DEPENDENCIES% |
| Perl Version: | - |

%META:FORM{name="PackageForm"}%
%META:FIELD{name="Author" title="Author" value="Michael Daum"}%
%META:FIELD{name="Version" title="Version" value="%25$VERSION%25"}%
%META:FIELD{name="Release" title="Release" value="%25$RELEASE%25"}%
%META:FIELD{name="Repository" title="Repository" value="https://github.com/foswiki/distro"}%
%META:FIELD{name="Copyright" title="Copyright" value="Foswiki Contributors, All Rights Reserved"}%
%META:FIELD{name="Description" title="Description" value="%25$SHORTDESCRIPTION%25"}%
%META:FIELD{name="Home" title="Home" value="https://foswiki.org/Extensions/%25$ROOTMODULE%25"}%
%META:FIELD{name="License" title="License" value="GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]])"}%
%META:FIELD{name="Home" title="Home" value="http://foswiki.org/Extensions/%25$ROOTMODULE%25"}%
%META:FIELD{name="Support" title="Support" value="http://foswiki.org/Support/%25$ROOTMODULE%25"}%
%META:FILEATTACHMENT{name="screenshot1.png" attr="h" comment="" date="1452118054" size="64487" user="ProjectContributor" version="1"}%
%META:FIELD{name="Release" title="Release" value="%25$RELEASE%25"}%
%META:FIELD{name="Repository" title="Repository" value="https://github.com/foswiki/distro"}%
%META:FIELD{name="Support" title="Support" value="https://foswiki.org/Support/%25$ROOTMODULE%25"}%
%META:FIELD{name="Version" title="Version" value="%25$VERSION%25"}%
%META:FILEATTACHMENT{name="screenshot1.png" attr="h" comment="" date="1485156553" size="64487" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="screenshot1.png" attr="h" comment="" date="1485156553" size="64487" user="ProjectContributor" version="1"}%
15 changes: 12 additions & 3 deletions NatEditPlugin/lib/Foswiki/Plugins/NatEditPlugin.pm
@@ -1,4 +1,4 @@
# Copyright (C) 2007-2015 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2007-2016 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -30,8 +30,8 @@ BEGIN {
}
}

our $VERSION = '9.07';
our $RELEASE = '06 Jan 2016';
our $VERSION = '9.9';
our $RELEASE = '23 Jan 2017';
our $NO_PREFS_IN_TOPIC = 1;
our $SHORTDESCRIPTION = 'A Wikiwyg Editor';
our $baseWeb;
Expand Down Expand Up @@ -107,6 +107,15 @@ sub beforeSaveHandler {

writeDebug("called beforeSaveHandler($web, $topic)");

my $session = $Foswiki::Plugins::SESSION;
my $baseWeb = $session->{webName};
my $baseTopic = $session->{topicName};

if ( $web ne $baseWeb || $topic ne $baseTopic ) {
writeDebug("not operating on the base topic");
return;
}

# find out if we received a TopicTitle
my $request = Foswiki::Func::getCgiQuery();

Expand Down
@@ -1,4 +1,4 @@
# Copyright (C) 2007-2015 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2007-2016 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand Down
@@ -1,4 +1,4 @@
# Copyright (C) 2007-2015 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2007-2016 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand Down
26 changes: 26 additions & 0 deletions NatEditPlugin/lib/Foswiki/Plugins/NatEditPlugin/MANIFEST
@@ -1,4 +1,5 @@
data/System/NatEditHelpText.txt 0644
data/System/NatEditPluginJSUnitTests.txt 0644
data/System/NatEditPlugin.txt 0644
data/System/NatEditWordHelpText.txt 0644
lib/Foswiki/Plugins/NatEditPlugin/Config.spec 0644
Expand All @@ -12,6 +13,31 @@ lib/Foswiki/Plugins/NatEditPlugin/RestSave.pm 0644
locale/NatEditPlugin/de.po 0644
locale/NatEditPlugin/Foswiki.pot 0644
pub/System/NatEditHelpText/wikitext.png 0644
pub/System/NatEditPlugin/engine/base/engine.js 0644
pub/System/NatEditPlugin/engine/base/engine.js.gz 0644
pub/System/NatEditPlugin/engine/base/engine.uncompressed.js 0644
pub/System/NatEditPlugin/engine/base/Makefile 0644
pub/System/NatEditPlugin/engine/codemirror/engine.js 0644
pub/System/NatEditPlugin/engine/codemirror/engine.js.gz 0644
pub/System/NatEditPlugin/engine/codemirror/engine.uncompressed.js 0644
pub/System/NatEditPlugin/engine/codemirror/Makefile 0644
pub/System/NatEditPlugin/engine/Makefile 0644
pub/System/NatEditPlugin/engine/prosemirror/engine.js 0644
pub/System/NatEditPlugin/engine/prosemirror/engine.js.gz 0644
pub/System/NatEditPlugin/engine/prosemirror/engine.uncompressed.js 0644
pub/System/NatEditPlugin/engine/prosemirror/Makefile 0644
pub/System/NatEditPlugin/engine/raw/engine.js 0644
pub/System/NatEditPlugin/engine/raw/engine.js.gz 0644
pub/System/NatEditPlugin/engine/raw/engine.uncompressed.js 0644
pub/System/NatEditPlugin/engine/raw/Makefile 0644
pub/System/NatEditPlugin/engine/raw/rawengine.uncompressed.js 0644
pub/System/NatEditPlugin/engine/raw/textareastate.uncompressed.js 0644
pub/System/NatEditPlugin/engine/raw/undomanager.uncompressed.js 0644
pub/System/NatEditPlugin/engine/tinymce/engine.js 0644
pub/System/NatEditPlugin/engine/tinymce/engine.js.gz 0644
pub/System/NatEditPlugin/engine/tinymce/engine.uncompressed.js 0644
pub/System/NatEditPlugin/engine/tinymce/Makefile 0644
pub/System/NatEditPlugin/i18n/de.js 0644
pub/System/NatEditPlugin/jquery.natedit.js 0644
pub/System/NatEditPlugin/jquery.natedit.js.gz 0644
pub/System/NatEditPlugin/jquery.natedit.uncompressed.js 0644
Expand Down
23 changes: 16 additions & 7 deletions NatEditPlugin/lib/Foswiki/Plugins/NatEditPlugin/NATEDIT.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2006-2015 Michael Daum, http://michaeldaumconsulting.com
# Copyright (C) 2006-2016 Michael Daum, http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -43,14 +43,15 @@ sub new {
my $this = bless(
$class->SUPER::new(
name => 'NatEdit',
version => '4.01',
version => '4.99',
author => 'Michael Daum',
homepage => 'http://foswiki.org/Extensions/NatEditPlugin',
puburl => '%PUBURLPATH%/%SYSTEMWEB%/NatEditPlugin',
css => ['styles.css'],
documentation => "$Foswiki::cfg{SystemWebName}.NatEditPlugin",
javascript => ['jquery.natedit.js'],
dependencies => [
javascript => [ 'jquery.natedit.js', 'engine/base/engine.js' ],
i18n => $Foswiki::cfg{SystemWebName} . "/NatEditPlugin/i18n",
dependencies => [
'JQUERYPLUGIN::FOSWIKI::PREFERENCES', 'textboxlist',
'pnotify', 'fontawesome',
'form', 'validate',
Expand All @@ -59,7 +60,7 @@ sub new {
'ui::autocomplete', 'ui::button',
'button', 'loader',
'JQUERYPLUGIN::UPLOADER', 'blockui',
'render',
'render', 'imagesloaded'
],
),
$class
Expand All @@ -81,11 +82,19 @@ sub init {

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

my $request = Foswiki::Func::getRequestObject();
my $engine =
$request->param("natedit_engine")
|| Foswiki::Func::getPreferencesValue("NATEDIT_ENGINE")
|| $Foswiki::cfg{NatEditPlugin}{DefaultEngine}
|| 'raw';

Foswiki::Func::addToZone(
"script", "NATEDIT::PREFERENCES",
<<'HERE', "JQUERYPLUGIN::FOSWIKI::PREFERENCES" );
<script class='$zone $id foswikiPreferences' type='text/json'>{
<<"HERE", "JQUERYPLUGIN::FOSWIKI::PREFERENCES" );
<script class='\$zone \$id foswikiPreferences' type='text/json'>{
"NatEditPlugin": {
"Engine": "$engine",
"MathEnabled": %IF{"context MathModePluginEnabled or context MathJaxPluginEnabled" then="true" else="false"}%,
"ImagePluginEnabled": %IF{"context ImagePluginEnabled" then="true" else="false"}%,
"TopicInteractionPluginEnabled": %IF{"context TopicInteractionPluginEnabled" then="true" else="false"}%,
Expand Down
@@ -1,4 +1,4 @@
# Copyright (C) 2013-2015 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2013-2016 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand Down
9 changes: 7 additions & 2 deletions NatEditPlugin/lib/Foswiki/Plugins/NatEditPlugin/RestSave.pm
@@ -1,4 +1,4 @@
# Copyright (C) 2013-2015 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2013-2016 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -17,6 +17,7 @@ use warnings;
use Foswiki::UI::Save ();
use Foswiki::OopsException ();
use Foswiki::Validation ();
use Foswiki::Func ();
use Encode ();
use Error qw( :try );

Expand Down Expand Up @@ -47,6 +48,10 @@ sub handle {
# do a normal save
my $error;
my $status = 200;

# enter save context
Foswiki::Func::getContext()->{save} = 1;

try {
Foswiki::UI::Save::save($session);

Expand Down Expand Up @@ -116,7 +121,7 @@ sub stringifyError {
sub toSiteCharSet {
my $string = shift;

return $string unless $string;
return unless defined $string;

return $string if $Foswiki::UNICODE;

Expand Down
2 changes: 1 addition & 1 deletion NatEditPlugin/lib/Foswiki/Plugins/NatEditPlugin/build.pl
@@ -1,4 +1,4 @@
#!/usr/bin/perl -w
#!/usr/bin/env perl
BEGIN {
foreach my $pc ( split( /:/, $ENV{FOSWIKI_LIBS} ) ) {
unshift @INC, $pc;
Expand Down

0 comments on commit b7bb0c9

Please sign in to comment.