[Jifty-commit] r5502 - in plugins: AuthzLDAP AuthzLDAP/doc AuthzLDAP/lib AuthzLDAP/lib/Jifty AuthzLDAP/lib/Jifty/Plugin AuthzLDAP/lib/Jifty/Plugin/AuthzLDAP AuthzLDAP/lib/Jifty/Plugin/AuthzLDAP/Action AuthzLDAP/lib/Jifty/Plugin/AuthzLDAP/Model AuthzLDAP/share AuthzLDAP/share/po AuthzLDAP/share/web AuthzLDAP/share/web/static AuthzLDAP/share/web/templates AuthzLDAP/share/web/templates/error AuthzLDAP/t EditInPlace EditInPlace/debian EditInPlace/inc EditInPlace/inc/Module EditInPlace/inc/Module/Install EditInPlace/inc/Module/Install/Makefile EditInPlace/lib EditInPlace/lib/Jifty EditInPlace/lib/Jifty/Plugin EditInPlace/lib/Jifty/Plugin/EditInPlace EditInPlace/lib/Jifty/Plugin/EditInPlace/Action EditInPlace/share EditInPlace/share/web EditInPlace/share/web/templates EditInPlace/share/web/templates/__jifty WikiToolbar WikiToolbar/doc WikiToolbar/lib WikiToolbar/lib/Jifty WikiToolbar/lib/Jifty/Plugin WikiToolbar/lib/Jifty/Plugin/WikiToolbar WikiToolbar/lib/Jifty/Plugin/WikiToolbar/Action WikiToolbar/share WikiToolbar/share/po WikiToolbar/share/web WikiToolbar/share/web/static WikiToolbar/share/web/static/img WikiToolbar/share/web/static/img/wt WikiToolbar/share/web/static/js WikiToolbar/share/web/templates WikiToolbar/t WyzzEditor WyzzEditor/doc WyzzEditor/lib WyzzEditor/lib/Jifty WyzzEditor/lib/Jifty/Plugin WyzzEditor/lib/Jifty/Plugin/WyzzEditor WyzzEditor/share WyzzEditor/share/po WyzzEditor/share/web WyzzEditor/share/web/static WyzzEditor/share/web/static/img WyzzEditor/share/web/static/img/wyzzicons WyzzEditor/share/web/static/js WyzzEditor/share/web/static/js/wyzz WyzzEditor/share/web/static/wyzzstyles WyzzEditor/share/web/templates WyzzEditor/t
Jifty commits
jifty-commit at lists.jifty.org
Sat Jun 14 03:25:31 EDT 2008
Author: yves
Date: Sat Jun 14 03:25:31 2008
New Revision: 5502
Added:
plugins/AuthzLDAP/
plugins/AuthzLDAP/MANIFEST
plugins/AuthzLDAP/Makefile.PL
plugins/AuthzLDAP/doc/
plugins/AuthzLDAP/lib/
plugins/AuthzLDAP/lib/Jifty/
plugins/AuthzLDAP/lib/Jifty/Plugin/
plugins/AuthzLDAP/lib/Jifty/Plugin/AuthzLDAP/
plugins/AuthzLDAP/lib/Jifty/Plugin/AuthzLDAP.pm
plugins/AuthzLDAP/lib/Jifty/Plugin/AuthzLDAP/Action/
plugins/AuthzLDAP/lib/Jifty/Plugin/AuthzLDAP/Action/LDAPValidate.pm
plugins/AuthzLDAP/lib/Jifty/Plugin/AuthzLDAP/Model/
plugins/AuthzLDAP/lib/Jifty/Plugin/AuthzLDAP/Model/LDAPFilter.pm
plugins/AuthzLDAP/share/
plugins/AuthzLDAP/share/po/
plugins/AuthzLDAP/share/po/en.po
plugins/AuthzLDAP/share/po/fr.po
plugins/AuthzLDAP/share/web/
plugins/AuthzLDAP/share/web/static/
plugins/AuthzLDAP/share/web/templates/
plugins/AuthzLDAP/share/web/templates/error/
plugins/AuthzLDAP/share/web/templates/error/AccessDenied
plugins/AuthzLDAP/t/
plugins/AuthzLDAP/t/00-load.t
plugins/EditInPlace/
plugins/EditInPlace/Makefile.PL
plugins/EditInPlace/debian/
plugins/EditInPlace/debian/changelog
plugins/EditInPlace/debian/compat
plugins/EditInPlace/debian/control
plugins/EditInPlace/debian/rules (contents, props changed)
plugins/EditInPlace/inc/
plugins/EditInPlace/inc/Module/
plugins/EditInPlace/inc/Module/AutoInstall.pm
plugins/EditInPlace/inc/Module/Install/
plugins/EditInPlace/inc/Module/Install.pm
plugins/EditInPlace/inc/Module/Install/AutoInstall.pm
plugins/EditInPlace/inc/Module/Install/Base.pm
plugins/EditInPlace/inc/Module/Install/Can.pm
plugins/EditInPlace/inc/Module/Install/Fetch.pm
plugins/EditInPlace/inc/Module/Install/Include.pm
plugins/EditInPlace/inc/Module/Install/Makefile/
plugins/EditInPlace/inc/Module/Install/Makefile.pm
plugins/EditInPlace/inc/Module/Install/Makefile/Version.pm
plugins/EditInPlace/inc/Module/Install/Metadata.pm
plugins/EditInPlace/inc/Module/Install/Share.pm
plugins/EditInPlace/inc/Module/Install/Win32.pm
plugins/EditInPlace/inc/Module/Install/WriteAll.pm
plugins/EditInPlace/lib/
plugins/EditInPlace/lib/Jifty/
plugins/EditInPlace/lib/Jifty/Plugin/
plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace/
plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace.pm
plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace/Action/
plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace/Action/FileEditor.pm
plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace/Dispatcher.pm
plugins/EditInPlace/share/
plugins/EditInPlace/share/web/
plugins/EditInPlace/share/web/templates/
plugins/EditInPlace/share/web/templates/__jifty/
plugins/EditInPlace/share/web/templates/__jifty/create_file_inline
plugins/EditInPlace/share/web/templates/__jifty/edit_file
plugins/EditInPlace/share/web/templates/__jifty/edit_file_inline
plugins/WikiToolbar/
plugins/WikiToolbar/Makefile.PL
plugins/WikiToolbar/doc/
plugins/WikiToolbar/lib/
plugins/WikiToolbar/lib/Jifty/
plugins/WikiToolbar/lib/Jifty/Plugin/
plugins/WikiToolbar/lib/Jifty/Plugin/WikiToolbar/
plugins/WikiToolbar/lib/Jifty/Plugin/WikiToolbar.pm
plugins/WikiToolbar/lib/Jifty/Plugin/WikiToolbar/Action/
plugins/WikiToolbar/lib/Jifty/Plugin/WikiToolbar/Dispatcher.pm
plugins/WikiToolbar/lib/Jifty/Plugin/WikiToolbar/Model/
plugins/WikiToolbar/lib/Jifty/Plugin/WikiToolbar/Textarea.pm
plugins/WikiToolbar/share/
plugins/WikiToolbar/share/po/
plugins/WikiToolbar/share/web/
plugins/WikiToolbar/share/web/static/
plugins/WikiToolbar/share/web/static/img/
plugins/WikiToolbar/share/web/static/img/wt/
plugins/WikiToolbar/share/web/static/img/wt/bold.png (contents, props changed)
plugins/WikiToolbar/share/web/static/img/wt/box.png (contents, props changed)
plugins/WikiToolbar/share/web/static/img/wt/center.png (contents, props changed)
plugins/WikiToolbar/share/web/static/img/wt/code.png (contents, props changed)
plugins/WikiToolbar/share/web/static/img/wt/code1.png (contents, props changed)
plugins/WikiToolbar/share/web/static/img/wt/empty.png (contents, props changed)
plugins/WikiToolbar/share/web/static/img/wt/h1.png (contents, props changed)
plugins/WikiToolbar/share/web/static/img/wt/h2.png (contents, props changed)
plugins/WikiToolbar/share/web/static/img/wt/h3.png (contents, props changed)
plugins/WikiToolbar/share/web/static/img/wt/italic.png (contents, props changed)
plugins/WikiToolbar/share/web/static/img/wt/link.png (contents, props changed)
plugins/WikiToolbar/share/web/static/img/wt/linkextern.png (contents, props changed)
plugins/WikiToolbar/share/web/static/img/wt/new.png (contents, props changed)
plugins/WikiToolbar/share/web/static/img/wt/ol.png (contents, props changed)
plugins/WikiToolbar/share/web/static/img/wt/red.png (contents, props changed)
plugins/WikiToolbar/share/web/static/img/wt/strike.png (contents, props changed)
plugins/WikiToolbar/share/web/static/img/wt/tab.png (contents, props changed)
plugins/WikiToolbar/share/web/static/img/wt/ul.png (contents, props changed)
plugins/WikiToolbar/share/web/static/img/wt/underline.png (contents, props changed)
plugins/WikiToolbar/share/web/static/js/
plugins/WikiToolbar/share/web/static/js/wikitoolbar.js
plugins/WikiToolbar/share/web/templates/
plugins/WikiToolbar/t/
plugins/WyzzEditor/
plugins/WyzzEditor/Makefile.PL
plugins/WyzzEditor/doc/
plugins/WyzzEditor/lib/
plugins/WyzzEditor/lib/Jifty/
plugins/WyzzEditor/lib/Jifty/Plugin/
plugins/WyzzEditor/lib/Jifty/Plugin/WyzzEditor/
plugins/WyzzEditor/lib/Jifty/Plugin/WyzzEditor.pm
plugins/WyzzEditor/lib/Jifty/Plugin/WyzzEditor/Dispatcher.pm
plugins/WyzzEditor/lib/Jifty/Plugin/WyzzEditor/Textarea.pm
plugins/WyzzEditor/share/
plugins/WyzzEditor/share/po/
plugins/WyzzEditor/share/web/
plugins/WyzzEditor/share/web/static/
plugins/WyzzEditor/share/web/static/img/
plugins/WyzzEditor/share/web/static/img/wyzzicons/
plugins/WyzzEditor/share/web/static/img/wyzzicons/backcolor.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/bold.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/close.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/copy.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/cut.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/downsize.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/font.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/forecolor.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/headers.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/help.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/htmlmode.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/indent.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/inserthorizontalrule.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/insertimage.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/insertorderedlist.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/insertunorderedlist.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/italic.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/justifycenter.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/justifyfull.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/justifyleft.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/justifyright.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/link.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/outdent.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/paste.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/redo.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/removeformat.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/specialchar.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/strikethrough.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/subscript.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/superscript.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/underline.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/undo.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/upsize.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/img/wyzzicons/wyzzicon.gif (contents, props changed)
plugins/WyzzEditor/share/web/static/js/
plugins/WyzzEditor/share/web/static/js/wyzz/
plugins/WyzzEditor/share/web/static/js/wyzz.js
plugins/WyzzEditor/share/web/static/wyzzstyles/
plugins/WyzzEditor/share/web/static/wyzzstyles/editarea.css
plugins/WyzzEditor/share/web/static/wyzzstyles/style.css
plugins/WyzzEditor/share/web/templates/
plugins/WyzzEditor/t/
Log:
Start moving old but always used plugins outside trunk.
They need to be self hosted on CPAN.
Added: plugins/AuthzLDAP/MANIFEST
==============================================================================
--- (empty file)
+++ plugins/AuthzLDAP/MANIFEST Sat Jun 14 03:25:31 2008
@@ -0,0 +1,9 @@
+lib/Jifty/Plugin/AuthzLDAP.pm
+lib/Jifty/Plugin/AuthzLDAP/Action/LDAPValidate.pm
+lib/Jifty/Plugin/AuthzLDAP/Model/LDAPFilter.pm
+Makefile.PL
+MANIFEST
+share/po/en.po
+share/po/fr.po
+share/web/templates/error/AccessDenied
+t/00-load.t
Added: plugins/AuthzLDAP/Makefile.PL
==============================================================================
--- (empty file)
+++ plugins/AuthzLDAP/Makefile.PL Sat Jun 14 03:25:31 2008
@@ -0,0 +1,10 @@
+use inc::Module::Install;
+name('Jifty-Plugin-AuthzLDAP');
+license('Perl');
+version('0.01');
+requires('Jifty' => '0.60912');
+requires('Net::LDAP');
+
+install_share;
+
+WriteAll;
Added: plugins/AuthzLDAP/lib/Jifty/Plugin/AuthzLDAP.pm
==============================================================================
--- (empty file)
+++ plugins/AuthzLDAP/lib/Jifty/Plugin/AuthzLDAP.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,190 @@
+use strict;
+use warnings;
+
+=head1 NAME
+
+Jifty::Plugin::AuthzLDAP
+
+=head1 DESCRIPTION
+
+Jifty plugin.
+Provide ldap authorization with filters table and cache.
+
+NOW FOR TESTING AND COMMENTS
+
+
+=head1 CONFIGURATION NOTES
+
+in etc/config.yml
+ Plugins:
+ - AuthzLDAP:
+ LDAPbind: cn=testldap,ou=admins,dc=myorg,dc=org #
+ LDAPpass: test # password
+ LDAPhost: ldap.myorg.org # ldap host
+ LDAPbase: ou=people,dc=myorg.. # ldap base
+ LDAPuid: uid # optional
+ CacheTimout: 20 # minutes, optional, default 20 minutes
+
+in application create a LDAPFilter model
+ use base qw/Jifty::Plugin::AuthzLDAP::Model::LDAPFilter/;
+
+in LDAPFilter model create your filters, something like
+ name |filter |is_group
+ is_admin|(!eduPersonAffiliation=STUDENT)|0
+ in_admin|cn=admin,ou=groups,dc=my.org |1
+
+to protect access to /admin
+in "TestApp" application create a lib/TestApp/Dispatcher.pm
+
+ use strict;
+ use warnings;
+
+ package TestApp::Dispatcher;
+ use Jifty::Dispatcher -base;
+
+ before '/admin/*' => run {
+ # Authentication
+ Jifty->web->tangent(url => '/login')
+ if (! Jifty->web->current_user->id);
+ # Authorization
+ my $user = Jifty->web->current_user->user_object->name;
+ Jifty->web->tangent(url => '/error/AccessDenied')
+ if (! Jifty::Plugin::AuthzLDAP->ldapvalidate($user,'is_admin') );
+ };
+
+ 1
+
+=head1 SEE ALSO
+
+L<Net::LDAP>
+
+=cut
+
+
+package Jifty::Plugin::AuthzLDAP;
+use base qw/Jifty::Plugin/;
+
+our $VERSION = '0.02';
+
+use Net::LDAP;
+use Cache::MemoryCache;
+
+{
+ my ($LDAPFilterClass, $LDAP, $cache, %params);
+
+ sub init {
+ my $self = shift;
+ my %args = @_;
+
+ my $appname = Jifty->config->framework('ApplicationName');
+ $LDAPFilterClass = "Jifty::Plugin::AuthzLDAP::Model::LDAPFilter";
+
+ $params{'Hostname'} = $args{LDAPhost};
+ $params{'base'} = $args{LDAPbase};
+ $params{'uid'} = $args{LDAPuid} || "uid";
+ $params{'dn'} = $args{LDAPbind};
+ $params{'pass'} = $args{LDAPpass};
+ $params{'timeout'} = $args{CacheTimout} || "20 minutes";
+
+ $LDAP = Net::LDAP->new($params{Hostname},async=>1,onerror => 'undef', debug => 0);
+
+ $cache = new Cache::MemoryCache( { 'namespace' => $appname.'AuthzLDAP',
+ 'default_expires_in' => $params{'timeout'} } );
+ }
+
+ sub LDAPFilterClass {
+ return $LDAPFilterClass;
+ }
+
+ sub LDAP {
+ return $LDAP;
+ }
+
+ sub DN {
+ return $params{'dn'};
+ }
+
+ sub PASS {
+ return $params{'pass'};
+ }
+
+ sub UID {
+ return $params{'uid'};
+ }
+
+ sub BASE {
+ return $params{'base'};
+ }
+
+ sub CACHE {
+ return $cache;
+ }
+
+}
+
+=head2 bind
+
+Bind to ldap
+
+=cut
+
+sub bind {
+ my $self = shift;
+ my $msg = $self->LDAP()->bind($self->DN() ,'password' =>$self->PASS());
+ unless (not $msg->code) {
+ Jifty->log->error("Bind to ldap server failed");
+ return;
+ }
+}
+
+=head2 validate NAME FILTERNAME
+
+return 1 if NAME validate FILTER or NAME-FILTERNAME in cache
+else return 0
+
+If FILTERNAME is flagged as is_group, search if user is uniquemember of this group
+as supported by the Netscape Directory Server
+
+=cut
+
+sub ldapvalidate {
+ my ($self, $user, $filtername) = @_;
+ my $response = 'nok';
+
+ my $cachekey = $user.'-'.$filtername;
+ my $cache = $self->CACHE->get($cachekey);
+ return ($cache eq 'ok')?1:0 if (defined $cache);
+
+ my $record = $self->LDAPFilterClass()->new();
+ $record->load_by_cols( name => $filtername);
+
+ # (?) allow use of writing filter in filtername
+ # TODO: filtername must be cleanned
+ # my $filter = ($record->filter)?$record->filter:$filtername;
+ my $filter = $record->ldapfilter;
+
+ $user = $self->UID().'='.$user.','.$self->BASE();
+
+ # (??) how to catch AuthLDAP bind if it's used?
+ $self->bind();
+
+ my $msg;
+ # manage group as supported by the Netscape Directory Server
+ if ($record->is_group) {
+ $msg = $self->LDAP()->compare( $filter, attr=>"uniquemember", value=>$user );
+ Jifty->log->debug("search grp: ".$msg->code);
+ $response = 'ok' if ( $msg->code == 6 );
+ } else {
+ $filter = '('. $filter .')' if ( $filter !~ /^\(/ );
+ $msg = $self->LDAP()->search( base => $user, filter => $filter );
+ Jifty->log->debug("search: ".$msg->count);
+ $response = 'ok' if (! $msg->code && $msg->count );
+ }
+
+ $self->CACHE->set($cachekey,$response);
+
+ return ( $response eq 'ok' )?1:0;
+}
+
+
+1;
Added: plugins/AuthzLDAP/lib/Jifty/Plugin/AuthzLDAP/Action/LDAPValidate.pm
==============================================================================
--- (empty file)
+++ plugins/AuthzLDAP/lib/Jifty/Plugin/AuthzLDAP/Action/LDAPValidate.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,68 @@
+use warnings;
+use strict;
+
+=head1 NAME
+
+Jifty::Plugin::AuthzLDAP::Action::LDAPValidate
+
+=cut
+
+package Jifty::Plugin::AuthzLDAP::Action::LDAPValidate;
+use base qw/Jifty::Action Jifty::Plugin::AuthzLDAP/;
+
+
+=head2 arguments
+
+Return the ticket form field
+
+=cut
+
+sub arguments {
+ return (
+ {
+ name => {
+ mandatory => 1
+ },
+
+ filter => {
+ mandatory => 1
+ },
+
+ }
+ );
+
+}
+
+=head2 take_action
+
+Bind on ldap to check the user's password. If it's right, log them in.
+Otherwise, throw an error.
+
+
+=cut
+
+sub take_action {
+ my $self = shift;
+ my $user = $self->argument_value('name');
+ my $filter = $self->argument_value('filter');
+
+ Jifty->log->debug("action: $user $filter");
+
+ # Bind on ldap
+ #my $msg = $self->bind();
+
+ my $msg = $self->ldapvalidate($user,$filter);
+
+ Jifty->log->debug("validate: $msg");
+
+ if (not $msg) {
+ $self->result->error(
+ _('Access denied.') );
+ return;}
+
+ return 1;
+}
+
+1;
+
+
Added: plugins/AuthzLDAP/lib/Jifty/Plugin/AuthzLDAP/Model/LDAPFilter.pm
==============================================================================
--- (empty file)
+++ plugins/AuthzLDAP/lib/Jifty/Plugin/AuthzLDAP/Model/LDAPFilter.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,61 @@
+package Jifty::Plugin::AuthzLDAP::Model::LDAPFilter;
+use Jifty::DBI::Schema;
+use Scalar::Defer;
+
+use Jifty::Record schema {
+column
+ name => type is 'text',
+ label is 'Name',
+ is mandatory,
+ is distinct;
+
+column
+ ldapfilter => type is 'text',
+ label is 'Filter',
+ is mandatory;
+
+column
+ is_group => type is 'boolean',
+ label is 'Group';
+
+column 'created_on' =>
+ type is 'datetime',
+ is immutable,
+ default is defer { DateTime->now },
+ filters are 'Jifty::DBI::Filter::DateTime';
+};
+
+sub create {
+ my $self = shift;
+ my %args = (@_);
+ my (@ret) = $self->SUPER::create(%args);
+
+ return (@ret);
+}
+
+
+=head2 current_user_can ACTION
+
+Only superuser can create or edit filters.
+Logged-in users can read.
+
+=cut
+
+sub current_user_can {
+ my $self = shift;
+ my $type = shift;
+
+ if ($type eq 'create' || $type eq 'update') {
+ return 0 if
+ !$self->current_user->is_superuser;
+ return 1;
+ } elsif($type eq 'read') {
+ return 1 if
+ $self->current_user->id || $self->current_user->is_superuser;
+ return 0;
+ }
+
+ return $self->SUPER::current_user_can($type, @_);
+}
+
+1;
Added: plugins/AuthzLDAP/share/po/en.po
==============================================================================
--- (empty file)
+++ plugins/AuthzLDAP/share/po/en.po Sat Jun 14 03:25:31 2008
@@ -0,0 +1,20 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL at ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
+"Language-Team: LANGUAGE <LL at li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: lib/Jifty/Plugin/AuthzLDAP/Action/LDAPValidate.pm:60 share/web/templates/error/AccessDenied:1 share/web/templates/error/AccessDenied:2
+msgid "Access denied."
+msgstr ""
Added: plugins/AuthzLDAP/share/po/fr.po
==============================================================================
--- (empty file)
+++ plugins/AuthzLDAP/share/po/fr.po Sat Jun 14 03:25:31 2008
@@ -0,0 +1,20 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL at ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
+"Language-Team: LANGUAGE <LL at li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO8859-15\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: lib/Jifty/Plugin/AuthzLDAP/Action/LDAPValidate.pm:60 share/web/templates/error/AccessDenied:1 share/web/templates/error/AccessDenied:2
+msgid "Access denied."
+msgstr "Accès non autorisé."
Added: plugins/AuthzLDAP/share/web/templates/error/AccessDenied
==============================================================================
--- (empty file)
+++ plugins/AuthzLDAP/share/web/templates/error/AccessDenied Sat Jun 14 03:25:31 2008
@@ -0,0 +1,3 @@
+<&| /_elements/wrapper, title => _("Access denied.") &>
+<p><% _("Access denied.") %></p>
+</&>
Added: plugins/AuthzLDAP/t/00-load.t
==============================================================================
--- (empty file)
+++ plugins/AuthzLDAP/t/00-load.t Sat Jun 14 03:25:31 2008
@@ -0,0 +1,5 @@
+#!/usr/bin/env perl -w
+use strict;
+use Test::More tests => 1;
+
+use_ok('Jifty::Plugin::AuthzLDAP');
Added: plugins/EditInPlace/Makefile.PL
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/Makefile.PL Sat Jun 14 03:25:31 2008
@@ -0,0 +1,9 @@
+use inc::Module::Install 0.46;
+name('Jifty-Plugin-EditInPlace');
+requires('Jifty' => '0.60510' );
+&auto_install();
+
+install_share;
+
+WriteAll;
+
Added: plugins/EditInPlace/debian/changelog
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/debian/changelog Sat Jun 14 03:25:31 2008
@@ -0,0 +1,6 @@
+libjifty-plugin-editinplace-perl (0-1) unstable; urgency=low
+
+ * Initial Release.
+
+ -- AGOSTINI Yves <agostini at univ-metz.fr> Mon, 23 Oct 2006 11:26:37 +0200
+
Added: plugins/EditInPlace/debian/compat
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/debian/compat Sat Jun 14 03:25:31 2008
@@ -0,0 +1 @@
+4
Added: plugins/EditInPlace/debian/control
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/debian/control Sat Jun 14 03:25:31 2008
@@ -0,0 +1,15 @@
+Source: libjifty-plugin-editinplace-perl
+Section: perl
+Priority: optional
+Build-Depends: debhelper (>= 4.0.2)
+Build-Depends-Indep: perl (>= 5.8.0-7)
+Maintainer: AGOSTINI Yves <agostini at univ-metz.fr>
+Standards-Version: 3.6.1
+
+Package: libjifty-plugin-editinplace-perl
+Architecture: all
+Depends: ${perl:Depends}, ${misc:Depends},
+Description: Jifty::Plugin::EditInPlace
+ .
+ Jifty Plugin, file editor for devel mode.
+ .
Added: plugins/EditInPlace/debian/rules
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/debian/rules Sat Jun 14 03:25:31 2008
@@ -0,0 +1,83 @@
+#!/usr/bin/make -f
+# This debian/rules file is provided as a template for normal perl
+# packages. It was created by Marc Brockschmidt <marc at dch-faq.de> for
+# the Debian Perl Group (http://pkg-perl.alioth.debian.org/) but may
+# be used freely wherever it is useful.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+# If set to a true value then MakeMaker's prompt function will
+# always return the default without waiting for user input.
+export PERL_MM_USE_DEFAULT=1
+
+PACKAGE=$(shell dh_listpackages)
+
+ifndef PERL
+PERL = /usr/bin/perl
+endif
+
+TMP =$(CURDIR)/debian/$(PACKAGE)
+
+build: build-stamp
+build-stamp:
+ dh_testdir
+
+ # Add commands to compile the package here
+ $(PERL) Makefile.PL INSTALLDIRS=vendor
+ $(MAKE) OPTIMIZE="-Wall -O2 -g"
+
+ touch build-stamp
+
+clean:
+ dh_testdir
+ dh_testroot
+
+ # Add commands to clean up after the build process here
+ -$(MAKE) distclean
+
+ dh_clean build-stamp install-stamp
+
+install: build install-stamp
+install-stamp:
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+
+ # Add commands to install the package into debian/$PACKAGE_NAME here
+ $(MAKE) test
+ $(MAKE) install DESTDIR=$(TMP) PREFIX=/usr
+
+ # As this is a architecture independent package, we are not
+ # supposed to install stuff to /usr/lib. MakeMaker creates
+ # the dirs, we delete them from the deb:
+ rmdir --ignore-fail-on-non-empty --parents $(TMP)/usr/lib/perl5
+
+ touch install-stamp
+
+binary-arch:
+# We have nothing to do by default.
+
+binary-indep: build install
+ dh_testdir
+ dh_testroot
+# dh_installcron
+# dh_installmenu
+# dh_installexamples
+ dh_installdocs
+ dh_installchangelogs
+ dh_perl
+ dh_link
+ dh_strip
+ dh_compress
+ dh_fixperms
+ dh_installdeb
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+source diff:
+ @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary
Added: plugins/EditInPlace/inc/Module/AutoInstall.pm
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/inc/Module/AutoInstall.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,768 @@
+#line 1
+package Module::AutoInstall;
+
+use strict;
+use Cwd ();
+use ExtUtils::MakeMaker ();
+
+use vars qw{$VERSION};
+BEGIN {
+ $VERSION = '1.03';
+}
+
+# special map on pre-defined feature sets
+my %FeatureMap = (
+ '' => 'Core Features', # XXX: deprecated
+ '-core' => 'Core Features',
+);
+
+# various lexical flags
+my ( @Missing, @Existing, %DisabledTests, $UnderCPAN, $HasCPANPLUS );
+my ( $Config, $CheckOnly, $SkipInstall, $AcceptDefault, $TestOnly );
+my ( $PostambleActions, $PostambleUsed );
+
+# See if it's a testing or non-interactive session
+_accept_default( $ENV{AUTOMATED_TESTING} or ! -t STDIN );
+_init();
+
+sub _accept_default {
+ $AcceptDefault = shift;
+}
+
+sub missing_modules {
+ return @Missing;
+}
+
+sub do_install {
+ __PACKAGE__->install(
+ [
+ $Config
+ ? ( UNIVERSAL::isa( $Config, 'HASH' ) ? %{$Config} : @{$Config} )
+ : ()
+ ],
+ @Missing,
+ );
+}
+
+# initialize various flags, and/or perform install
+sub _init {
+ foreach my $arg (
+ @ARGV,
+ split(
+ /[\s\t]+/,
+ $ENV{PERL_AUTOINSTALL} || $ENV{PERL_EXTUTILS_AUTOINSTALL} || ''
+ )
+ )
+ {
+ if ( $arg =~ /^--config=(.*)$/ ) {
+ $Config = [ split( ',', $1 ) ];
+ }
+ elsif ( $arg =~ /^--installdeps=(.*)$/ ) {
+ __PACKAGE__->install( $Config, @Missing = split( /,/, $1 ) );
+ exit 0;
+ }
+ elsif ( $arg =~ /^--default(?:deps)?$/ ) {
+ $AcceptDefault = 1;
+ }
+ elsif ( $arg =~ /^--check(?:deps)?$/ ) {
+ $CheckOnly = 1;
+ }
+ elsif ( $arg =~ /^--skip(?:deps)?$/ ) {
+ $SkipInstall = 1;
+ }
+ elsif ( $arg =~ /^--test(?:only)?$/ ) {
+ $TestOnly = 1;
+ }
+ }
+}
+
+# overrides MakeMaker's prompt() to automatically accept the default choice
+sub _prompt {
+ goto &ExtUtils::MakeMaker::prompt unless $AcceptDefault;
+
+ my ( $prompt, $default ) = @_;
+ my $y = ( $default =~ /^[Yy]/ );
+
+ print $prompt, ' [', ( $y ? 'Y' : 'y' ), '/', ( $y ? 'n' : 'N' ), '] ';
+ print "$default\n";
+ return $default;
+}
+
+# the workhorse
+sub import {
+ my $class = shift;
+ my @args = @_ or return;
+ my $core_all;
+
+ print "*** $class version " . $class->VERSION . "\n";
+ print "*** Checking for Perl dependencies...\n";
+
+ my $cwd = Cwd::cwd();
+
+ $Config = [];
+
+ my $maxlen = length(
+ (
+ sort { length($b) <=> length($a) }
+ grep { /^[^\-]/ }
+ map {
+ ref($_)
+ ? ( ( ref($_) eq 'HASH' ) ? keys(%$_) : @{$_} )
+ : ''
+ }
+ map { +{@args}->{$_} }
+ grep { /^[^\-]/ or /^-core$/i } keys %{ +{@args} }
+ )[0]
+ );
+
+ while ( my ( $feature, $modules ) = splice( @args, 0, 2 ) ) {
+ my ( @required, @tests, @skiptests );
+ my $default = 1;
+ my $conflict = 0;
+
+ if ( $feature =~ m/^-(\w+)$/ ) {
+ my $option = lc($1);
+
+ # check for a newer version of myself
+ _update_to( $modules, @_ ) and return if $option eq 'version';
+
+ # sets CPAN configuration options
+ $Config = $modules if $option eq 'config';
+
+ # promote every features to core status
+ $core_all = ( $modules =~ /^all$/i ) and next
+ if $option eq 'core';
+
+ next unless $option eq 'core';
+ }
+
+ print "[" . ( $FeatureMap{ lc($feature) } || $feature ) . "]\n";
+
+ $modules = [ %{$modules} ] if UNIVERSAL::isa( $modules, 'HASH' );
+
+ unshift @$modules, -default => &{ shift(@$modules) }
+ if ( ref( $modules->[0] ) eq 'CODE' ); # XXX: bugward combatability
+
+ while ( my ( $mod, $arg ) = splice( @$modules, 0, 2 ) ) {
+ if ( $mod =~ m/^-(\w+)$/ ) {
+ my $option = lc($1);
+
+ $default = $arg if ( $option eq 'default' );
+ $conflict = $arg if ( $option eq 'conflict' );
+ @tests = @{$arg} if ( $option eq 'tests' );
+ @skiptests = @{$arg} if ( $option eq 'skiptests' );
+
+ next;
+ }
+
+ printf( "- %-${maxlen}s ...", $mod );
+
+ if ( $arg and $arg =~ /^\D/ ) {
+ unshift @$modules, $arg;
+ $arg = 0;
+ }
+
+ # XXX: check for conflicts and uninstalls(!) them.
+ if (
+ defined( my $cur = _version_check( _load($mod), $arg ||= 0 ) ) )
+ {
+ print "loaded. ($cur" . ( $arg ? " >= $arg" : '' ) . ")\n";
+ push @Existing, $mod => $arg;
+ $DisabledTests{$_} = 1 for map { glob($_) } @skiptests;
+ }
+ else {
+ print "missing." . ( $arg ? " (would need $arg)" : '' ) . "\n";
+ push @required, $mod => $arg;
+ }
+ }
+
+ next unless @required;
+
+ my $mandatory = ( $feature eq '-core' or $core_all );
+
+ if (
+ !$SkipInstall
+ and (
+ $CheckOnly
+ or _prompt(
+ qq{==> Auto-install the }
+ . ( @required / 2 )
+ . ( $mandatory ? ' mandatory' : ' optional' )
+ . qq{ module(s) from CPAN?},
+ $default ? 'y' : 'n',
+ ) =~ /^[Yy]/
+ )
+ )
+ {
+ push( @Missing, @required );
+ $DisabledTests{$_} = 1 for map { glob($_) } @skiptests;
+ }
+
+ elsif ( !$SkipInstall
+ and $default
+ and $mandatory
+ and
+ _prompt( qq{==> The module(s) are mandatory! Really skip?}, 'n', )
+ =~ /^[Nn]/ )
+ {
+ push( @Missing, @required );
+ $DisabledTests{$_} = 1 for map { glob($_) } @skiptests;
+ }
+
+ else {
+ $DisabledTests{$_} = 1 for map { glob($_) } @tests;
+ }
+ }
+
+ $UnderCPAN = _check_lock(); # check for $UnderCPAN
+
+ if ( @Missing and not( $CheckOnly or $UnderCPAN ) ) {
+ require Config;
+ print
+"*** Dependencies will be installed the next time you type '$Config::Config{make}'.\n";
+
+ # make an educated guess of whether we'll need root permission.
+ print " (You may need to do that as the 'root' user.)\n"
+ if eval '$>';
+ }
+ print "*** $class configuration finished.\n";
+
+ chdir $cwd;
+
+ # import to main::
+ no strict 'refs';
+ *{'main::WriteMakefile'} = \&Write if caller(0) eq 'main';
+}
+
+# Check to see if we are currently running under CPAN.pm and/or CPANPLUS;
+# if we are, then we simply let it taking care of our dependencies
+sub _check_lock {
+ return unless @Missing;
+
+ if ($ENV{PERL5_CPANPLUS_IS_RUNNING}) {
+ print <<'END_MESSAGE';
+
+*** Since we're running under CPANPLUS, I'll just let it take care
+ of the dependency's installation later.
+END_MESSAGE
+ return 1;
+ }
+
+ _load_cpan();
+
+ # Find the CPAN lock-file
+ my $lock = MM->catfile( $CPAN::Config->{cpan_home}, ".lock" );
+ return unless -f $lock;
+
+ # Check the lock
+ local *LOCK;
+ return unless open(LOCK, $lock);
+
+ if (
+ ( $^O eq 'MSWin32' ? _under_cpan() : <LOCK> == getppid() )
+ and ( $CPAN::Config->{prerequisites_policy} || '' ) ne 'ignore'
+ ) {
+ print <<'END_MESSAGE';
+
+*** Since we're running under CPAN, I'll just let it take care
+ of the dependency's installation later.
+END_MESSAGE
+ return 1;
+ }
+
+ close LOCK;
+ return;
+}
+
+sub install {
+ my $class = shift;
+
+ my $i; # used below to strip leading '-' from config keys
+ my @config = ( map { s/^-// if ++$i; $_ } @{ +shift } );
+
+ my ( @modules, @installed );
+ while ( my ( $pkg, $ver ) = splice( @_, 0, 2 ) ) {
+
+ # grep out those already installed
+ if ( defined( _version_check( _load($pkg), $ver ) ) ) {
+ push @installed, $pkg;
+ }
+ else {
+ push @modules, $pkg, $ver;
+ }
+ }
+
+ return @installed unless @modules; # nothing to do
+ return @installed if _check_lock(); # defer to the CPAN shell
+
+ print "*** Installing dependencies...\n";
+
+ return unless _connected_to('cpan.org');
+
+ my %args = @config;
+ my %failed;
+ local *FAILED;
+ if ( $args{do_once} and open( FAILED, '.#autoinstall.failed' ) ) {
+ while (<FAILED>) { chomp; $failed{$_}++ }
+ close FAILED;
+
+ my @newmod;
+ while ( my ( $k, $v ) = splice( @modules, 0, 2 ) ) {
+ push @newmod, ( $k => $v ) unless $failed{$k};
+ }
+ @modules = @newmod;
+ }
+
+ if ( _has_cpanplus() ) {
+ _install_cpanplus( \@modules, \@config );
+ } else {
+ _install_cpan( \@modules, \@config );
+ }
+
+ print "*** $class installation finished.\n";
+
+ # see if we have successfully installed them
+ while ( my ( $pkg, $ver ) = splice( @modules, 0, 2 ) ) {
+ if ( defined( _version_check( _load($pkg), $ver ) ) ) {
+ push @installed, $pkg;
+ }
+ elsif ( $args{do_once} and open( FAILED, '>> .#autoinstall.failed' ) ) {
+ print FAILED "$pkg\n";
+ }
+ }
+
+ close FAILED if $args{do_once};
+
+ return @installed;
+}
+
+sub _install_cpanplus {
+ my @modules = @{ +shift };
+ my @config = _cpanplus_config( @{ +shift } );
+ my $installed = 0;
+
+ require CPANPLUS::Backend;
+ my $cp = CPANPLUS::Backend->new;
+ my $conf = $cp->configure_object;
+
+ return unless $conf->can('conf') # 0.05x+ with "sudo" support
+ or _can_write($conf->_get_build('base')); # 0.04x
+
+ # if we're root, set UNINST=1 to avoid trouble unless user asked for it.
+ my $makeflags = $conf->get_conf('makeflags') || '';
+ if ( UNIVERSAL::isa( $makeflags, 'HASH' ) ) {
+ # 0.03+ uses a hashref here
+ $makeflags->{UNINST} = 1 unless exists $makeflags->{UNINST};
+
+ } else {
+ # 0.02 and below uses a scalar
+ $makeflags = join( ' ', split( ' ', $makeflags ), 'UNINST=1' )
+ if ( $makeflags !~ /\bUNINST\b/ and eval qq{ $> eq '0' } );
+
+ }
+ $conf->set_conf( makeflags => $makeflags );
+ $conf->set_conf( prereqs => 1 );
+
+
+
+ while ( my ( $key, $val ) = splice( @config, 0, 2 ) ) {
+ $conf->set_conf( $key, $val );
+ }
+
+ my $modtree = $cp->module_tree;
+ while ( my ( $pkg, $ver ) = splice( @modules, 0, 2 ) ) {
+ print "*** Installing $pkg...\n";
+
+ MY::preinstall( $pkg, $ver ) or next if defined &MY::preinstall;
+
+ my $success;
+ my $obj = $modtree->{$pkg};
+
+ if ( $obj and defined( _version_check( $obj->{version}, $ver ) ) ) {
+ my $pathname = $pkg;
+ $pathname =~ s/::/\\W/;
+
+ foreach my $inc ( grep { m/$pathname.pm/i } keys(%INC) ) {
+ delete $INC{$inc};
+ }
+
+ my $rv = $cp->install( modules => [ $obj->{module} ] );
+
+ if ( $rv and ( $rv->{ $obj->{module} } or $rv->{ok} ) ) {
+ print "*** $pkg successfully installed.\n";
+ $success = 1;
+ } else {
+ print "*** $pkg installation cancelled.\n";
+ $success = 0;
+ }
+
+ $installed += $success;
+ } else {
+ print << ".";
+*** Could not find a version $ver or above for $pkg; skipping.
+.
+ }
+
+ MY::postinstall( $pkg, $ver, $success ) if defined &MY::postinstall;
+ }
+
+ return $installed;
+}
+
+sub _cpanplus_config {
+ my @config = ();
+ while ( @_ ) {
+ my ($key, $value) = (shift(), shift());
+ if ( $key eq 'prerequisites_policy' ) {
+ if ( $value eq 'follow' ) {
+ $value = CPANPLUS::Internals::Constants::PREREQ_INSTALL();
+ } elsif ( $value eq 'ask' ) {
+ $value = CPANPLUS::Internals::Constants::PREREQ_ASK();
+ } elsif ( $value eq 'ignore' ) {
+ $value = CPANPLUS::Internals::Constants::PREREQ_IGNORE();
+ } else {
+ die "*** Cannot convert option $key = '$value' to CPANPLUS version.\n";
+ }
+ } else {
+ die "*** Cannot convert option $key to CPANPLUS version.\n";
+ }
+ }
+ return @config;
+}
+
+sub _install_cpan {
+ my @modules = @{ +shift };
+ my @config = @{ +shift };
+ my $installed = 0;
+ my %args;
+
+ _load_cpan();
+ require Config;
+
+ if (CPAN->VERSION < 1.80) {
+ # no "sudo" support, probe for writableness
+ return unless _can_write( MM->catfile( $CPAN::Config->{cpan_home}, 'sources' ) )
+ and _can_write( $Config::Config{sitelib} );
+ }
+
+ # if we're root, set UNINST=1 to avoid trouble unless user asked for it.
+ my $makeflags = $CPAN::Config->{make_install_arg} || '';
+ $CPAN::Config->{make_install_arg} =
+ join( ' ', split( ' ', $makeflags ), 'UNINST=1' )
+ if ( $makeflags !~ /\bUNINST\b/ and eval qq{ $> eq '0' } );
+
+ # don't show start-up info
+ $CPAN::Config->{inhibit_startup_message} = 1;
+
+ # set additional options
+ while ( my ( $opt, $arg ) = splice( @config, 0, 2 ) ) {
+ ( $args{$opt} = $arg, next )
+ if $opt =~ /^force$/; # pseudo-option
+ $CPAN::Config->{$opt} = $arg;
+ }
+
+ local $CPAN::Config->{prerequisites_policy} = 'follow';
+
+ while ( my ( $pkg, $ver ) = splice( @modules, 0, 2 ) ) {
+ MY::preinstall( $pkg, $ver ) or next if defined &MY::preinstall;
+
+ print "*** Installing $pkg...\n";
+
+ my $obj = CPAN::Shell->expand( Module => $pkg );
+ my $success = 0;
+
+ if ( $obj and defined( _version_check( $obj->cpan_version, $ver ) ) ) {
+ my $pathname = $pkg;
+ $pathname =~ s/::/\\W/;
+
+ foreach my $inc ( grep { m/$pathname.pm/i } keys(%INC) ) {
+ delete $INC{$inc};
+ }
+
+ my $rv = $args{force} ? CPAN::Shell->force( install => $pkg )
+ : CPAN::Shell->install($pkg);
+ $rv ||= eval {
+ $CPAN::META->instance( 'CPAN::Distribution', $obj->cpan_file, )
+ ->{install}
+ if $CPAN::META;
+ };
+
+ if ( $rv eq 'YES' ) {
+ print "*** $pkg successfully installed.\n";
+ $success = 1;
+ }
+ else {
+ print "*** $pkg installation failed.\n";
+ $success = 0;
+ }
+
+ $installed += $success;
+ }
+ else {
+ print << ".";
+*** Could not find a version $ver or above for $pkg; skipping.
+.
+ }
+
+ MY::postinstall( $pkg, $ver, $success ) if defined &MY::postinstall;
+ }
+
+ return $installed;
+}
+
+sub _has_cpanplus {
+ return (
+ $HasCPANPLUS = (
+ $INC{'CPANPLUS/Config.pm'}
+ or _load('CPANPLUS::Shell::Default')
+ )
+ );
+}
+
+# make guesses on whether we're under the CPAN installation directory
+sub _under_cpan {
+ require Cwd;
+ require File::Spec;
+
+ my $cwd = File::Spec->canonpath( Cwd::cwd() );
+ my $cpan = File::Spec->canonpath( $CPAN::Config->{cpan_home} );
+
+ return ( index( $cwd, $cpan ) > -1 );
+}
+
+sub _update_to {
+ my $class = __PACKAGE__;
+ my $ver = shift;
+
+ return
+ if defined( _version_check( _load($class), $ver ) ); # no need to upgrade
+
+ if (
+ _prompt( "==> A newer version of $class ($ver) is required. Install?",
+ 'y' ) =~ /^[Nn]/
+ )
+ {
+ die "*** Please install $class $ver manually.\n";
+ }
+
+ print << ".";
+*** Trying to fetch it from CPAN...
+.
+
+ # install ourselves
+ _load($class) and return $class->import(@_)
+ if $class->install( [], $class, $ver );
+
+ print << '.'; exit 1;
+
+*** Cannot bootstrap myself. :-( Installation terminated.
+.
+}
+
+# check if we're connected to some host, using inet_aton
+sub _connected_to {
+ my $site = shift;
+
+ return (
+ ( _load('Socket') and Socket::inet_aton($site) ) or _prompt(
+ qq(
+*** Your host cannot resolve the domain name '$site', which
+ probably means the Internet connections are unavailable.
+==> Should we try to install the required module(s) anyway?), 'n'
+ ) =~ /^[Yy]/
+ );
+}
+
+# check if a directory is writable; may create it on demand
+sub _can_write {
+ my $path = shift;
+ mkdir( $path, 0755 ) unless -e $path;
+
+ return 1 if -w $path;
+
+ print << ".";
+*** You are not allowed to write to the directory '$path';
+ the installation may fail due to insufficient permissions.
+.
+
+ if (
+ eval '$>' and lc(`sudo -V`) =~ /version/ and _prompt(
+ qq(
+==> Should we try to re-execute the autoinstall process with 'sudo'?),
+ ((-t STDIN) ? 'y' : 'n')
+ ) =~ /^[Yy]/
+ )
+ {
+
+ # try to bootstrap ourselves from sudo
+ print << ".";
+*** Trying to re-execute the autoinstall process with 'sudo'...
+.
+ my $missing = join( ',', @Missing );
+ my $config = join( ',',
+ UNIVERSAL::isa( $Config, 'HASH' ) ? %{$Config} : @{$Config} )
+ if $Config;
+
+ return
+ unless system( 'sudo', $^X, $0, "--config=$config",
+ "--installdeps=$missing" );
+
+ print << ".";
+*** The 'sudo' command exited with error! Resuming...
+.
+ }
+
+ return _prompt(
+ qq(
+==> Should we try to install the required module(s) anyway?), 'n'
+ ) =~ /^[Yy]/;
+}
+
+# load a module and return the version it reports
+sub _load {
+ my $mod = pop; # class/instance doesn't matter
+ my $file = $mod;
+
+ $file =~ s|::|/|g;
+ $file .= '.pm';
+
+ local $@;
+ return eval { require $file; $mod->VERSION } || ( $@ ? undef: 0 );
+}
+
+# Load CPAN.pm and it's configuration
+sub _load_cpan {
+ return if $CPAN::VERSION;
+ require CPAN;
+ if ( $CPAN::HandleConfig::VERSION ) {
+ # Newer versions of CPAN have a HandleConfig module
+ CPAN::HandleConfig->load;
+ } else {
+ # Older versions had the load method in Config directly
+ CPAN::Config->load;
+ }
+}
+
+# compare two versions, either use Sort::Versions or plain comparison
+sub _version_check {
+ my ( $cur, $min ) = @_;
+ return unless defined $cur;
+
+ $cur =~ s/\s+$//;
+
+ # check for version numbers that are not in decimal format
+ if ( ref($cur) or ref($min) or $cur =~ /v|\..*\./ or $min =~ /v|\..*\./ ) {
+ if ( ( $version::VERSION or defined( _load('version') )) and
+ version->can('new')
+ ) {
+
+ # use version.pm if it is installed.
+ return (
+ ( version->new($cur) >= version->new($min) ) ? $cur : undef );
+ }
+ elsif ( $Sort::Versions::VERSION or defined( _load('Sort::Versions') ) )
+ {
+
+ # use Sort::Versions as the sorting algorithm for a.b.c versions
+ return ( ( Sort::Versions::versioncmp( $cur, $min ) != -1 )
+ ? $cur
+ : undef );
+ }
+
+ warn "Cannot reliably compare non-decimal formatted versions.\n"
+ . "Please install version.pm or Sort::Versions.\n";
+ }
+
+ # plain comparison
+ local $^W = 0; # shuts off 'not numeric' bugs
+ return ( $cur >= $min ? $cur : undef );
+}
+
+# nothing; this usage is deprecated.
+sub main::PREREQ_PM { return {}; }
+
+sub _make_args {
+ my %args = @_;
+
+ $args{PREREQ_PM} = { %{ $args{PREREQ_PM} || {} }, @Existing, @Missing }
+ if $UnderCPAN or $TestOnly;
+
+ if ( $args{EXE_FILES} and -e 'MANIFEST' ) {
+ require ExtUtils::Manifest;
+ my $manifest = ExtUtils::Manifest::maniread('MANIFEST');
+
+ $args{EXE_FILES} =
+ [ grep { exists $manifest->{$_} } @{ $args{EXE_FILES} } ];
+ }
+
+ $args{test}{TESTS} ||= 't/*.t';
+ $args{test}{TESTS} = join( ' ',
+ grep { !exists( $DisabledTests{$_} ) }
+ map { glob($_) } split( /\s+/, $args{test}{TESTS} ) );
+
+ my $missing = join( ',', @Missing );
+ my $config =
+ join( ',', UNIVERSAL::isa( $Config, 'HASH' ) ? %{$Config} : @{$Config} )
+ if $Config;
+
+ $PostambleActions = (
+ $missing
+ ? "\$(PERL) $0 --config=$config --installdeps=$missing"
+ : "\$(NOECHO) \$(NOOP)"
+ );
+
+ return %args;
+}
+
+# a wrapper to ExtUtils::MakeMaker::WriteMakefile
+sub Write {
+ require Carp;
+ Carp::croak "WriteMakefile: Need even number of args" if @_ % 2;
+
+ if ($CheckOnly) {
+ print << ".";
+*** Makefile not written in check-only mode.
+.
+ return;
+ }
+
+ my %args = _make_args(@_);
+
+ no strict 'refs';
+
+ $PostambleUsed = 0;
+ local *MY::postamble = \&postamble unless defined &MY::postamble;
+ ExtUtils::MakeMaker::WriteMakefile(%args);
+
+ print << "." unless $PostambleUsed;
+*** WARNING: Makefile written with customized MY::postamble() without
+ including contents from Module::AutoInstall::postamble() --
+ auto installation features disabled. Please contact the author.
+.
+
+ return 1;
+}
+
+sub postamble {
+ $PostambleUsed = 1;
+
+ return << ".";
+
+config :: installdeps
+\t\$(NOECHO) \$(NOOP)
+
+checkdeps ::
+\t\$(PERL) $0 --checkdeps
+
+installdeps ::
+\t$PostambleActions
+
+.
+
+}
+
+1;
+
+__END__
+
+#line 1003
Added: plugins/EditInPlace/inc/Module/Install.pm
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/inc/Module/Install.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,281 @@
+#line 1
+package Module::Install;
+
+# For any maintainers:
+# The load order for Module::Install is a bit magic.
+# It goes something like this...
+#
+# IF ( host has Module::Install installed, creating author mode ) {
+# 1. Makefile.PL calls "use inc::Module::Install"
+# 2. $INC{inc/Module/Install.pm} set to installed version of inc::Module::Install
+# 3. The installed version of inc::Module::Install loads
+# 4. inc::Module::Install calls "require Module::Install"
+# 5. The ./inc/ version of Module::Install loads
+# } ELSE {
+# 1. Makefile.PL calls "use inc::Module::Install"
+# 2. $INC{inc/Module/Install.pm} set to ./inc/ version of Module::Install
+# 3. The ./inc/ version of Module::Install loads
+# }
+
+use 5.004;
+use strict 'vars';
+
+use vars qw{$VERSION};
+BEGIN {
+ # All Module::Install core packages now require synchronised versions.
+ # This will be used to ensure we don't accidentally load old or
+ # different versions of modules.
+ # This is not enforced yet, but will be some time in the next few
+ # releases once we can make sure it won't clash with custom
+ # Module::Install extensions.
+ $VERSION = '0.64';
+}
+
+# Whether or not inc::Module::Install is actually loaded, the
+# $INC{inc/Module/Install.pm} is what will still get set as long as
+# the caller loaded module this in the documented manner.
+# If not set, the caller may NOT have loaded the bundled version, and thus
+# they may not have a MI version that works with the Makefile.PL. This would
+# result in false errors or unexpected behaviour. And we don't want that.
+my $file = join( '/', 'inc', split /::/, __PACKAGE__ ) . '.pm';
+unless ( $INC{$file} ) {
+ die <<"END_DIE";
+Please invoke ${\__PACKAGE__} with:
+
+ use inc::${\__PACKAGE__};
+
+not:
+
+ use ${\__PACKAGE__};
+
+END_DIE
+}
+
+# If the script that is loading Module::Install is from the future,
+# then make will detect this and cause it to re-run over and over
+# again. This is bad. Rather than taking action to touch it (which
+# is unreliable on some platforms and requires write permissions)
+# for now we should catch this and refuse to run.
+if ( -f $0 and (stat($0))[9] > time ) {
+ die << "END_DIE";
+Your installer $0 has a modification time in the future.
+
+This is known to create infinite loops in make.
+
+Please correct this, then run $0 again.
+
+END_DIE
+}
+
+use Cwd ();
+use File::Find ();
+use File::Path ();
+use FindBin;
+
+*inc::Module::Install::VERSION = *VERSION;
+ at inc::Module::Install::ISA = __PACKAGE__;
+
+sub autoload {
+ my $self = shift;
+ my $who = $self->_caller;
+ my $cwd = Cwd::cwd();
+ my $sym = "${who}::AUTOLOAD";
+ $sym->{$cwd} = sub {
+ my $pwd = Cwd::cwd();
+ if ( my $code = $sym->{$pwd} ) {
+ # delegate back to parent dirs
+ goto &$code unless $cwd eq $pwd;
+ }
+ $$sym =~ /([^:]+)$/ or die "Cannot autoload $who - $sym";
+ unshift @_, ($self, $1);
+ goto &{$self->can('call')} unless uc($1) eq $1;
+ };
+}
+
+sub import {
+ my $class = shift;
+ my $self = $class->new(@_);
+ my $who = $self->_caller;
+
+ unless ( -f $self->{file} ) {
+ require "$self->{path}/$self->{dispatch}.pm";
+ File::Path::mkpath("$self->{prefix}/$self->{author}");
+ $self->{admin} = "$self->{name}::$self->{dispatch}"->new( _top => $self );
+ $self->{admin}->init;
+ @_ = ($class, _self => $self);
+ goto &{"$self->{name}::import"};
+ }
+
+ *{"${who}::AUTOLOAD"} = $self->autoload;
+ $self->preload;
+
+ # Unregister loader and worker packages so subdirs can use them again
+ delete $INC{"$self->{file}"};
+ delete $INC{"$self->{path}.pm"};
+}
+
+sub preload {
+ my ($self) = @_;
+
+ unless ( $self->{extensions} ) {
+ $self->load_extensions(
+ "$self->{prefix}/$self->{path}", $self
+ );
+ }
+
+ my @exts = @{$self->{extensions}};
+ unless ( @exts ) {
+ my $admin = $self->{admin};
+ @exts = $admin->load_all_extensions;
+ }
+
+ my %seen;
+ foreach my $obj ( @exts ) {
+ while (my ($method, $glob) = each %{ref($obj) . '::'}) {
+ next unless $obj->can($method);
+ next if $method =~ /^_/;
+ next if $method eq uc($method);
+ $seen{$method}++;
+ }
+ }
+
+ my $who = $self->_caller;
+ foreach my $name ( sort keys %seen ) {
+ *{"${who}::$name"} = sub {
+ ${"${who}::AUTOLOAD"} = "${who}::$name";
+ goto &{"${who}::AUTOLOAD"};
+ };
+ }
+}
+
+sub new {
+ my ($class, %args) = @_;
+
+ # ignore the prefix on extension modules built from top level.
+ my $base_path = Cwd::abs_path($FindBin::Bin);
+ unless ( Cwd::abs_path(Cwd::cwd()) eq $base_path ) {
+ delete $args{prefix};
+ }
+
+ return $args{_self} if $args{_self};
+
+ $args{dispatch} ||= 'Admin';
+ $args{prefix} ||= 'inc';
+ $args{author} ||= ($^O eq 'VMS' ? '_author' : '.author');
+ $args{bundle} ||= 'inc/BUNDLES';
+ $args{base} ||= $base_path;
+ $class =~ s/^\Q$args{prefix}\E:://;
+ $args{name} ||= $class;
+ $args{version} ||= $class->VERSION;
+ unless ( $args{path} ) {
+ $args{path} = $args{name};
+ $args{path} =~ s!::!/!g;
+ }
+ $args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm";
+
+ bless( \%args, $class );
+}
+
+sub call {
+ my ($self, $method) = @_;
+ my $obj = $self->load($method) or return;
+ splice(@_, 0, 2, $obj);
+ goto &{$obj->can($method)};
+}
+
+sub load {
+ my ($self, $method) = @_;
+
+ $self->load_extensions(
+ "$self->{prefix}/$self->{path}", $self
+ ) unless $self->{extensions};
+
+ foreach my $obj (@{$self->{extensions}}) {
+ return $obj if $obj->can($method);
+ }
+
+ my $admin = $self->{admin} or die <<"END_DIE";
+The '$method' method does not exist in the '$self->{prefix}' path!
+Please remove the '$self->{prefix}' directory and run $0 again to load it.
+END_DIE
+
+ my $obj = $admin->load($method, 1);
+ push @{$self->{extensions}}, $obj;
+
+ $obj;
+}
+
+sub load_extensions {
+ my ($self, $path, $top) = @_;
+
+ unless ( grep { lc $_ eq lc $self->{prefix} } @INC ) {
+ unshift @INC, $self->{prefix};
+ }
+
+ foreach my $rv ( $self->find_extensions($path) ) {
+ my ($file, $pkg) = @{$rv};
+ next if $self->{pathnames}{$pkg};
+
+ local $@;
+ my $new = eval { require $file; $pkg->can('new') };
+ unless ( $new ) {
+ warn $@ if $@;
+ next;
+ }
+ $self->{pathnames}{$pkg} = delete $INC{$file};
+ push @{$self->{extensions}}, &{$new}($pkg, _top => $top );
+ }
+
+ $self->{extensions} ||= [];
+}
+
+sub find_extensions {
+ my ($self, $path) = @_;
+
+ my @found;
+ File::Find::find( sub {
+ my $file = $File::Find::name;
+ return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is;
+ my $subpath = $1;
+ return if lc($subpath) eq lc($self->{dispatch});
+
+ $file = "$self->{path}/$subpath.pm";
+ my $pkg = "$self->{name}::$subpath";
+ $pkg =~ s!/!::!g;
+
+ # If we have a mixed-case package name, assume case has been preserved
+ # correctly. Otherwise, root through the file to locate the case-preserved
+ # version of the package name.
+ if ( $subpath eq lc($subpath) || $subpath eq uc($subpath) ) {
+ open PKGFILE, "<$subpath.pm" or die "find_extensions: Can't open $subpath.pm: $!";
+ my $in_pod = 0;
+ while ( <PKGFILE> ) {
+ $in_pod = 1 if /^=\w/;
+ $in_pod = 0 if /^=cut/;
+ next if ($in_pod || /^=cut/); # skip pod text
+ next if /^\s*#/; # and comments
+ if ( m/^\s*package\s+($pkg)\s*;/i ) {
+ $pkg = $1;
+ last;
+ }
+ }
+ close PKGFILE;
+ }
+
+ push @found, [ $file, $pkg ];
+ }, $path ) if -d $path;
+
+ @found;
+}
+
+sub _caller {
+ my $depth = 0;
+ my $call = caller($depth);
+ while ( $call eq __PACKAGE__ ) {
+ $depth++;
+ $call = caller($depth);
+ }
+ return $call;
+}
+
+1;
Added: plugins/EditInPlace/inc/Module/Install/AutoInstall.pm
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/inc/Module/Install/AutoInstall.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,61 @@
+#line 1
+package Module::Install::AutoInstall;
+
+use strict;
+use Module::Install::Base;
+
+use vars qw{$VERSION $ISCORE @ISA};
+BEGIN {
+ $VERSION = '0.64';
+ $ISCORE = 1;
+ @ISA = qw{Module::Install::Base};
+}
+
+sub AutoInstall { $_[0] }
+
+sub run {
+ my $self = shift;
+ $self->auto_install_now(@_);
+}
+
+sub write {
+ my $self = shift;
+ $self->auto_install(@_);
+}
+
+sub auto_install {
+ my $self = shift;
+ return if $self->{done}++;
+
+ # Flatten array of arrays into a single array
+ my @core = map @$_, map @$_, grep ref,
+ $self->build_requires, $self->requires;
+
+ my @config = @_;
+
+ # We'll need Module::AutoInstall
+ $self->include('Module::AutoInstall');
+ require Module::AutoInstall;
+
+ Module::AutoInstall->import(
+ (@config ? (-config => \@config) : ()),
+ (@core ? (-core => \@core) : ()),
+ $self->features,
+ );
+
+ $self->makemaker_args( Module::AutoInstall::_make_args() );
+
+ my $class = ref($self);
+ $self->postamble(
+ "# --- $class section:\n" .
+ Module::AutoInstall::postamble()
+ );
+}
+
+sub auto_install_now {
+ my $self = shift;
+ $self->auto_install(@_);
+ Module::AutoInstall::do_install();
+}
+
+1;
Added: plugins/EditInPlace/inc/Module/Install/Base.pm
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/inc/Module/Install/Base.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,70 @@
+#line 1
+package Module::Install::Base;
+
+$VERSION = '0.64';
+
+# Suspend handler for "redefined" warnings
+BEGIN {
+ my $w = $SIG{__WARN__};
+ $SIG{__WARN__} = sub { $w };
+}
+
+### This is the ONLY module that shouldn't have strict on
+# use strict;
+
+#line 41
+
+sub new {
+ my ($class, %args) = @_;
+
+ foreach my $method ( qw(call load) ) {
+ *{"$class\::$method"} = sub {
+ shift()->_top->$method(@_);
+ } unless defined &{"$class\::$method"};
+ }
+
+ bless( \%args, $class );
+}
+
+#line 61
+
+sub AUTOLOAD {
+ my $self = shift;
+ local $@;
+ my $autoload = eval { $self->_top->autoload } or return;
+ goto &$autoload;
+}
+
+#line 76
+
+sub _top { $_[0]->{_top} }
+
+#line 89
+
+sub admin {
+ $_[0]->_top->{admin} or Module::Install::Base::FakeAdmin->new;
+}
+
+sub is_admin {
+ $_[0]->admin->VERSION;
+}
+
+sub DESTROY {}
+
+package Module::Install::Base::FakeAdmin;
+
+my $Fake;
+sub new { $Fake ||= bless(\@_, $_[0]) }
+
+sub AUTOLOAD {}
+
+sub DESTROY {}
+
+# Restore warning handler
+BEGIN {
+ $SIG{__WARN__} = $SIG{__WARN__}->();
+}
+
+1;
+
+#line 138
Added: plugins/EditInPlace/inc/Module/Install/Can.pm
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/inc/Module/Install/Can.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,82 @@
+#line 1
+package Module::Install::Can;
+
+use strict;
+use Module::Install::Base;
+use Config ();
+### This adds a 5.005 Perl version dependency.
+### This is a bug and will be fixed.
+use File::Spec ();
+use ExtUtils::MakeMaker ();
+
+use vars qw{$VERSION $ISCORE @ISA};
+BEGIN {
+ $VERSION = '0.64';
+ $ISCORE = 1;
+ @ISA = qw{Module::Install::Base};
+}
+
+# check if we can load some module
+### Upgrade this to not have to load the module if possible
+sub can_use {
+ my ($self, $mod, $ver) = @_;
+ $mod =~ s{::|\\}{/}g;
+ $mod .= '.pm' unless $mod =~ /\.pm$/i;
+
+ my $pkg = $mod;
+ $pkg =~ s{/}{::}g;
+ $pkg =~ s{\.pm$}{}i;
+
+ local $@;
+ eval { require $mod; $pkg->VERSION($ver || 0); 1 };
+}
+
+# check if we can run some command
+sub can_run {
+ my ($self, $cmd) = @_;
+
+ my $_cmd = $cmd;
+ return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd));
+
+ for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
+ my $abs = File::Spec->catfile($dir, $_[1]);
+ return $abs if (-x $abs or $abs = MM->maybe_command($abs));
+ }
+
+ return;
+}
+
+# can we locate a (the) C compiler
+sub can_cc {
+ my $self = shift;
+ my @chunks = split(/ /, $Config::Config{cc}) or return;
+
+ # $Config{cc} may contain args; try to find out the program part
+ while (@chunks) {
+ return $self->can_run("@chunks") || (pop(@chunks), next);
+ }
+
+ return;
+}
+
+# Fix Cygwin bug on maybe_command();
+if ( $^O eq 'cygwin' ) {
+ require ExtUtils::MM_Cygwin;
+ require ExtUtils::MM_Win32;
+ if ( ! defined(&ExtUtils::MM_Cygwin::maybe_command) ) {
+ *ExtUtils::MM_Cygwin::maybe_command = sub {
+ my ($self, $file) = @_;
+ if ($file =~ m{^/cygdrive/}i and ExtUtils::MM_Win32->can('maybe_command')) {
+ ExtUtils::MM_Win32->maybe_command($file);
+ } else {
+ ExtUtils::MM_Unix->maybe_command($file);
+ }
+ }
+ }
+}
+
+1;
+
+__END__
+
+#line 157
Added: plugins/EditInPlace/inc/Module/Install/Fetch.pm
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/inc/Module/Install/Fetch.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,93 @@
+#line 1
+package Module::Install::Fetch;
+
+use strict;
+use Module::Install::Base;
+
+use vars qw{$VERSION $ISCORE @ISA};
+BEGIN {
+ $VERSION = '0.64';
+ $ISCORE = 1;
+ @ISA = qw{Module::Install::Base};
+}
+
+sub get_file {
+ my ($self, %args) = @_;
+ my ($scheme, $host, $path, $file) =
+ $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return;
+
+ if ( $scheme eq 'http' and ! eval { require LWP::Simple; 1 } ) {
+ $args{url} = $args{ftp_url}
+ or (warn("LWP support unavailable!\n"), return);
+ ($scheme, $host, $path, $file) =
+ $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return;
+ }
+
+ $|++;
+ print "Fetching '$file' from $host... ";
+
+ unless (eval { require Socket; Socket::inet_aton($host) }) {
+ warn "'$host' resolve failed!\n";
+ return;
+ }
+
+ return unless $scheme eq 'ftp' or $scheme eq 'http';
+
+ require Cwd;
+ my $dir = Cwd::getcwd();
+ chdir $args{local_dir} or return if exists $args{local_dir};
+
+ if (eval { require LWP::Simple; 1 }) {
+ LWP::Simple::mirror($args{url}, $file);
+ }
+ elsif (eval { require Net::FTP; 1 }) { eval {
+ # use Net::FTP to get past firewall
+ my $ftp = Net::FTP->new($host, Passive => 1, Timeout => 600);
+ $ftp->login("anonymous", 'anonymous at example.com');
+ $ftp->cwd($path);
+ $ftp->binary;
+ $ftp->get($file) or (warn("$!\n"), return);
+ $ftp->quit;
+ } }
+ elsif (my $ftp = $self->can_run('ftp')) { eval {
+ # no Net::FTP, fallback to ftp.exe
+ require FileHandle;
+ my $fh = FileHandle->new;
+
+ local $SIG{CHLD} = 'IGNORE';
+ unless ($fh->open("|$ftp -n")) {
+ warn "Couldn't open ftp: $!\n";
+ chdir $dir; return;
+ }
+
+ my @dialog = split(/\n/, <<"END_FTP");
+open $host
+user anonymous anonymous\@example.com
+cd $path
+binary
+get $file $file
+quit
+END_FTP
+ foreach (@dialog) { $fh->print("$_\n") }
+ $fh->close;
+ } }
+ else {
+ warn "No working 'ftp' program available!\n";
+ chdir $dir; return;
+ }
+
+ unless (-f $file) {
+ warn "Fetching failed: $@\n";
+ chdir $dir; return;
+ }
+
+ return if exists $args{size} and -s $file != $args{size};
+ system($args{run}) if exists $args{run};
+ unlink($file) if $args{remove};
+
+ print(((!exists $args{check_for} or -e $args{check_for})
+ ? "done!" : "failed! ($!)"), "\n");
+ chdir $dir; return !$?;
+}
+
+1;
Added: plugins/EditInPlace/inc/Module/Install/Include.pm
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/inc/Module/Install/Include.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,34 @@
+#line 1
+package Module::Install::Include;
+
+use strict;
+use Module::Install::Base;
+
+use vars qw{$VERSION $ISCORE @ISA};
+BEGIN {
+ $VERSION = '0.64';
+ $ISCORE = 1;
+ @ISA = qw{Module::Install::Base};
+}
+
+sub include {
+ shift()->admin->include(@_);
+}
+
+sub include_deps {
+ shift()->admin->include_deps(@_);
+}
+
+sub auto_include {
+ shift()->admin->auto_include(@_);
+}
+
+sub auto_include_deps {
+ shift()->admin->auto_include_deps(@_);
+}
+
+sub auto_include_dependent_dists {
+ shift()->admin->auto_include_dependent_dists(@_);
+}
+
+1;
Added: plugins/EditInPlace/inc/Module/Install/Makefile.pm
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/inc/Module/Install/Makefile.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,208 @@
+#line 1
+package Module::Install::Makefile;
+
+use strict 'vars';
+use Module::Install::Base;
+use ExtUtils::MakeMaker ();
+
+use vars qw{$VERSION $ISCORE @ISA};
+BEGIN {
+ $VERSION = '0.64';
+ $ISCORE = 1;
+ @ISA = qw{Module::Install::Base};
+}
+
+sub Makefile { $_[0] }
+
+my %seen = ();
+
+sub prompt {
+ shift;
+
+ # Infinite loop protection
+ my @c = caller();
+ if ( ++$seen{"$c[1]|$c[2]|$_[0]"} > 3 ) {
+ die "Caught an potential prompt infinite loop ($c[1]|$c[2]|$_[0])";
+ }
+
+ # In automated testing, always use defaults
+ if ( $ENV{AUTOMATED_TESTING} and ! $ENV{PERL_MM_USE_DEFAULT} ) {
+ local $ENV{PERL_MM_USE_DEFAULT} = 1;
+ goto &ExtUtils::MakeMaker::prompt;
+ } else {
+ goto &ExtUtils::MakeMaker::prompt;
+ }
+}
+
+sub makemaker_args {
+ my $self = shift;
+ my $args = ($self->{makemaker_args} ||= {});
+ %$args = ( %$args, @_ ) if @_;
+ $args;
+}
+
+# For mm args that take multiple space-seperated args,
+# append an argument to the current list.
+sub makemaker_append {
+ my $self = shift;
+ my $name = shift;
+ my $args = $self->makemaker_args;
+ $args->{name} = defined $args->{$name}
+ ? join( ' ', $args->{name}, @_ )
+ : join( ' ', @_ );
+}
+
+sub build_subdirs {
+ my $self = shift;
+ my $subdirs = $self->makemaker_args->{DIR} ||= [];
+ for my $subdir (@_) {
+ push @$subdirs, $subdir;
+ }
+}
+
+sub clean_files {
+ my $self = shift;
+ my $clean = $self->makemaker_args->{clean} ||= {};
+ %$clean = (
+ %$clean,
+ FILES => join(' ', grep length, $clean->{FILES}, @_),
+ );
+}
+
+sub realclean_files {
+ my $self = shift;
+ my $realclean = $self->makemaker_args->{realclean} ||= {};
+ %$realclean = (
+ %$realclean,
+ FILES => join(' ', grep length, $realclean->{FILES}, @_),
+ );
+}
+
+sub libs {
+ my $self = shift;
+ my $libs = ref $_[0] ? shift : [ shift ];
+ $self->makemaker_args( LIBS => $libs );
+}
+
+sub inc {
+ my $self = shift;
+ $self->makemaker_args( INC => shift );
+}
+
+sub write {
+ my $self = shift;
+ die "&Makefile->write() takes no arguments\n" if @_;
+
+ my $args = $self->makemaker_args;
+ $args->{DISTNAME} = $self->name;
+ $args->{NAME} = $self->module_name || $self->name || $self->determine_NAME($args);
+ $args->{VERSION} = $self->version || $self->determine_VERSION($args);
+ $args->{NAME} =~ s/-/::/g;
+ if ( $self->tests ) {
+ $args->{test} = { TESTS => $self->tests };
+ }
+ if ($] >= 5.005) {
+ $args->{ABSTRACT} = $self->abstract;
+ $args->{AUTHOR} = $self->author;
+ }
+ if ( eval($ExtUtils::MakeMaker::VERSION) >= 6.10 ) {
+ $args->{NO_META} = 1;
+ }
+ if ( eval($ExtUtils::MakeMaker::VERSION) > 6.17 and $self->sign ) {
+ $args->{SIGN} = 1;
+ }
+ unless ( $self->is_admin ) {
+ delete $args->{SIGN};
+ }
+
+ # merge both kinds of requires into prereq_pm
+ my $prereq = ($args->{PREREQ_PM} ||= {});
+ %$prereq = ( %$prereq, map { @$_ } map { @$_ } grep $_,
+ ($self->build_requires, $self->requires) );
+
+ # merge both kinds of requires into prereq_pm
+ my $subdirs = ($args->{DIR} ||= []);
+ if ($self->bundles) {
+ foreach my $bundle (@{ $self->bundles }) {
+ my ($file, $dir) = @$bundle;
+ push @$subdirs, $dir if -d $dir;
+ delete $prereq->{$file};
+ }
+ }
+
+ if ( my $perl_version = $self->perl_version ) {
+ eval "use $perl_version; 1"
+ or die "ERROR: perl: Version $] is installed, "
+ . "but we need version >= $perl_version";
+ }
+
+ my %args = map { ( $_ => $args->{$_} ) } grep {defined($args->{$_})} keys %$args;
+ if ($self->admin->preop) {
+ $args{dist} = $self->admin->preop;
+ }
+
+ my $mm = ExtUtils::MakeMaker::WriteMakefile(%args);
+ $self->fix_up_makefile($mm->{FIRST_MAKEFILE} || 'Makefile');
+}
+
+sub fix_up_makefile {
+ my $self = shift;
+ my $makefile_name = shift;
+ my $top_class = ref($self->_top) || '';
+ my $top_version = $self->_top->VERSION || '';
+
+ my $preamble = $self->preamble
+ ? "# Preamble by $top_class $top_version\n"
+ . $self->preamble
+ : '';
+ my $postamble = "# Postamble by $top_class $top_version\n"
+ . ($self->postamble || '');
+
+ local *MAKEFILE;
+ open MAKEFILE, "< $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!";
+ my $makefile = do { local $/; <MAKEFILE> };
+ close MAKEFILE or die $!;
+
+ $makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /;
+ $makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g;
+ $makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g;
+ $makefile =~ s/^(FULLPERL = .*)/$1 "-Iinc"/m;
+ $makefile =~ s/^(PERL = .*)/$1 "-Iinc"/m;
+
+ # Module::Install will never be used to build the Core Perl
+ # Sometimes PERL_LIB and PERL_ARCHLIB get written anyway, which breaks
+ # PREFIX/PERL5LIB, and thus, install_share. Blank them if they exist
+ $makefile =~ s/^PERL_LIB = .+/PERL_LIB =/m;
+ #$makefile =~ s/^PERL_ARCHLIB = .+/PERL_ARCHLIB =/m;
+
+ # Perl 5.005 mentions PERL_LIB explicitly, so we have to remove that as well.
+ $makefile =~ s/("?)-I\$\(PERL_LIB\)\1//g;
+
+ # XXX - This is currently unused; not sure if it breaks other MM-users
+ # $makefile =~ s/^pm_to_blib\s+:\s+/pm_to_blib :: /mg;
+
+ open MAKEFILE, "> $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!";
+ print MAKEFILE "$preamble$makefile$postamble" or die $!;
+ close MAKEFILE or die $!;
+
+ 1;
+}
+
+sub preamble {
+ my ($self, $text) = @_;
+ $self->{preamble} = $text . $self->{preamble} if defined $text;
+ $self->{preamble};
+}
+
+sub postamble {
+ my ($self, $text) = @_;
+ $self->{postamble} ||= $self->admin->postamble;
+ $self->{postamble} .= $text if defined $text;
+ $self->{postamble}
+}
+
+1;
+
+__END__
+
+#line 334
Added: plugins/EditInPlace/inc/Module/Install/Makefile/Version.pm
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/inc/Module/Install/Makefile/Version.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,42 @@
+#line 1
+package Module::Install::Makefile::Version;
+
+use Module::Install::Base;
+ at ISA = qw(Module::Install::Base);
+
+$VERSION = '0.64';
+
+use strict;
+
+sub determine_VERSION {
+ my $self = shift;
+ my @modules = glob('*.pm');
+
+ require File::Find;
+ File::Find::find( sub {
+ push @modules, $File::Find::name =~ /\.pm\z/i;
+ }, 'lib' );
+
+ if (@modules == 1) {
+ eval {
+ $self->version(
+ ExtUtils::MM_Unix->parse_version($modules[0])
+ );
+ };
+ print STDERR $@ if $@;
+
+ } elsif ( my $file = "lib/" . $self->name . ".pm" ) {
+ $file =~ s!-!/!g;
+ $self->version(
+ ExtUtils::MM_Unix->parse_version($file)
+ ) if -f $file;
+
+ }
+
+ $self->version or die << "END_MESSAGE";
+Can't determine a VERSION for this distribution.
+Please call the 'version' or 'version_from' function in Makefile.PL.
+END_MESSAGE
+}
+
+1;
Added: plugins/EditInPlace/inc/Module/Install/Metadata.pm
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/inc/Module/Install/Metadata.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,315 @@
+#line 1
+package Module::Install::Metadata;
+
+use strict 'vars';
+use Module::Install::Base;
+
+use vars qw{$VERSION $ISCORE @ISA};
+BEGIN {
+ $VERSION = '0.64';
+ $ISCORE = 1;
+ @ISA = qw{Module::Install::Base};
+}
+
+my @scalar_keys = qw{
+ name module_name abstract author version license
+ distribution_type perl_version tests
+};
+
+my @tuple_keys = qw{
+ build_requires requires recommends bundles
+};
+
+sub Meta { shift }
+sub Meta_ScalarKeys { @scalar_keys }
+sub Meta_TupleKeys { @tuple_keys }
+
+foreach my $key (@scalar_keys) {
+ *$key = sub {
+ my $self = shift;
+ return $self->{values}{$key} if defined wantarray and !@_;
+ $self->{values}{$key} = shift;
+ return $self;
+ };
+}
+
+foreach my $key (@tuple_keys) {
+ *$key = sub {
+ my $self = shift;
+ return $self->{values}{$key} unless @_;
+
+ my @rv;
+ while (@_) {
+ my $module = shift or last;
+ my $version = shift || 0;
+ if ( $module eq 'perl' ) {
+ $version =~ s{^(\d+)\.(\d+)\.(\d+)}
+ {$1 + $2/1_000 + $3/1_000_000}e;
+ $self->perl_version($version);
+ next;
+ }
+ my $rv = [ $module, $version ];
+ push @rv, $rv;
+ }
+ push @{ $self->{values}{$key} }, @rv;
+ @rv;
+ };
+}
+
+sub sign {
+ my $self = shift;
+ return $self->{'values'}{'sign'} if defined wantarray and !@_;
+ $self->{'values'}{'sign'} = ( @_ ? $_[0] : 1 );
+ return $self;
+}
+
+sub dynamic_config {
+ my $self = shift;
+ unless ( @_ ) {
+ warn "You MUST provide an explicit true/false value to dynamic_config, skipping\n";
+ return $self;
+ }
+ $self->{'values'}{'dynamic_config'} = $_[0] ? 1 : 0;
+ return $self;
+}
+
+sub all_from {
+ my ( $self, $file ) = @_;
+
+ unless ( defined($file) ) {
+ my $name = $self->name
+ or die "all_from called with no args without setting name() first";
+ $file = join('/', 'lib', split(/-/, $name)) . '.pm';
+ $file =~ s{.*/}{} unless -e $file;
+ die "all_from: cannot find $file from $name" unless -e $file;
+ }
+
+ $self->version_from($file) unless $self->version;
+ $self->perl_version_from($file) unless $self->perl_version;
+
+ # The remaining probes read from POD sections; if the file
+ # has an accompanying .pod, use that instead
+ my $pod = $file;
+ if ( $pod =~ s/\.pm$/.pod/i and -e $pod ) {
+ $file = $pod;
+ }
+
+ $self->author_from($file) unless $self->author;
+ $self->license_from($file) unless $self->license;
+ $self->abstract_from($file) unless $self->abstract;
+}
+
+sub provides {
+ my $self = shift;
+ my $provides = ( $self->{values}{provides} ||= {} );
+ %$provides = (%$provides, @_) if @_;
+ return $provides;
+}
+
+sub auto_provides {
+ my $self = shift;
+ return $self unless $self->is_admin;
+
+ unless (-e 'MANIFEST') {
+ warn "Cannot deduce auto_provides without a MANIFEST, skipping\n";
+ return $self;
+ }
+
+ # Avoid spurious warnings as we are not checking manifest here.
+
+ local $SIG{__WARN__} = sub {1};
+ require ExtUtils::Manifest;
+ local *ExtUtils::Manifest::manicheck = sub { return };
+
+ require Module::Build;
+ my $build = Module::Build->new(
+ dist_name => $self->name,
+ dist_version => $self->version,
+ license => $self->license,
+ );
+ $self->provides(%{ $build->find_dist_packages || {} });
+}
+
+sub feature {
+ my $self = shift;
+ my $name = shift;
+ my $features = ( $self->{values}{features} ||= [] );
+
+ my $mods;
+
+ if ( @_ == 1 and ref( $_[0] ) ) {
+ # The user used ->feature like ->features by passing in the second
+ # argument as a reference. Accomodate for that.
+ $mods = $_[0];
+ } else {
+ $mods = \@_;
+ }
+
+ my $count = 0;
+ push @$features, (
+ $name => [
+ map {
+ ref($_) ? ( ref($_) eq 'HASH' ) ? %$_
+ : @$_
+ : $_
+ } @$mods
+ ]
+ );
+
+ return @$features;
+}
+
+sub features {
+ my $self = shift;
+ while ( my ( $name, $mods ) = splice( @_, 0, 2 ) ) {
+ $self->feature( $name, @$mods );
+ }
+ return $self->{values}->{features}
+ ? @{ $self->{values}->{features} }
+ : ();
+}
+
+sub no_index {
+ my $self = shift;
+ my $type = shift;
+ push @{ $self->{values}{no_index}{$type} }, @_ if $type;
+ return $self->{values}{no_index};
+}
+
+sub read {
+ my $self = shift;
+ $self->include_deps( 'YAML', 0 );
+
+ require YAML;
+ my $data = YAML::LoadFile('META.yml');
+
+ # Call methods explicitly in case user has already set some values.
+ while ( my ( $key, $value ) = each %$data ) {
+ next unless $self->can($key);
+ if ( ref $value eq 'HASH' ) {
+ while ( my ( $module, $version ) = each %$value ) {
+ $self->can($key)->($self, $module => $version );
+ }
+ }
+ else {
+ $self->can($key)->($self, $value);
+ }
+ }
+ return $self;
+}
+
+sub write {
+ my $self = shift;
+ return $self unless $self->is_admin;
+ $self->admin->write_meta;
+ return $self;
+}
+
+sub version_from {
+ my ( $self, $file ) = @_;
+ require ExtUtils::MM_Unix;
+ $self->version( ExtUtils::MM_Unix->parse_version($file) );
+}
+
+sub abstract_from {
+ my ( $self, $file ) = @_;
+ require ExtUtils::MM_Unix;
+ $self->abstract(
+ bless(
+ { DISTNAME => $self->name },
+ 'ExtUtils::MM_Unix'
+ )->parse_abstract($file)
+ );
+}
+
+sub _slurp {
+ my ( $self, $file ) = @_;
+
+ local *FH;
+ open FH, "< $file" or die "Cannot open $file.pod: $!";
+ do { local $/; <FH> };
+}
+
+sub perl_version_from {
+ my ( $self, $file ) = @_;
+
+ if (
+ $self->_slurp($file) =~ m/
+ ^
+ use \s*
+ v?
+ ([\d_\.]+)
+ \s* ;
+ /ixms
+ )
+ {
+ my $v = $1;
+ $v =~ s{_}{}g;
+ $self->perl_version($1);
+ }
+ else {
+ warn "Cannot determine perl version info from $file\n";
+ return;
+ }
+}
+
+sub author_from {
+ my ( $self, $file ) = @_;
+ my $content = $self->_slurp($file);
+ if ($content =~ m/
+ =head \d \s+ (?:authors?)\b \s*
+ ([^\n]*)
+ |
+ =head \d \s+ (?:licen[cs]e|licensing|copyright|legal)\b \s*
+ .*? copyright .*? \d\d\d[\d.]+ \s* (?:\bby\b)? \s*
+ ([^\n]*)
+ /ixms) {
+ my $author = $1 || $2;
+ $author =~ s{E<lt>}{<}g;
+ $author =~ s{E<gt>}{>}g;
+ $self->author($author);
+ }
+ else {
+ warn "Cannot determine author info from $file\n";
+ }
+}
+
+sub license_from {
+ my ( $self, $file ) = @_;
+
+ if (
+ $self->_slurp($file) =~ m/
+ =head \d \s+
+ (?:licen[cs]e|licensing|copyright|legal)\b
+ (.*?)
+ (=head\\d.*|=cut.*|)
+ \z
+ /ixms
+ )
+ {
+ my $license_text = $1;
+ my @phrases = (
+ 'under the same (?:terms|license) as perl itself' => 'perl',
+ 'GNU public license' => 'gpl',
+ 'GNU lesser public license' => 'gpl',
+ 'BSD license' => 'bsd',
+ 'Artistic license' => 'artistic',
+ 'GPL' => 'gpl',
+ 'LGPL' => 'lgpl',
+ 'BSD' => 'bsd',
+ 'Artistic' => 'artistic',
+ );
+ while ( my ( $pattern, $license ) = splice( @phrases, 0, 2 ) ) {
+ $pattern =~ s{\s+}{\\s+}g;
+ if ( $license_text =~ /\b$pattern\b/i ) {
+ $self->license($license);
+ return 1;
+ }
+ }
+ }
+
+ warn "Cannot determine license info from $file\n";
+ return 'unknown';
+}
+
+1;
Added: plugins/EditInPlace/inc/Module/Install/Share.pm
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/inc/Module/Install/Share.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,40 @@
+#line 1
+package Module::Install::Share;
+
+use strict;
+use Module::Install::Base;
+
+use vars qw{$VERSION $ISCORE @ISA};
+BEGIN {
+ $VERSION = '0.64';
+ $ISCORE = 1;
+ @ISA = qw{Module::Install::Base};
+}
+
+sub install_share {
+ my ($self, $dir) = @_;
+
+ if ( ! defined $dir ) {
+ die "Cannot find the 'share' directory" unless -d 'share';
+ $dir = 'share';
+ }
+
+ $self->postamble(<<"END_MAKEFILE");
+config ::
+\t\$(NOECHO) \$(MOD_INSTALL) \\
+\t\t\"$dir\" \$(INST_AUTODIR)
+
+END_MAKEFILE
+
+ # The above appears to behave incorrectly when used with old versions
+ # of ExtUtils::Install (known-bad on RHEL 3, with 5.8.0)
+ # So when we need to install a share directory, make sure we add a
+ # dependency on a moderately new version of ExtUtils::MakeMaker.
+ $self->build_requires( 'ExtUtils::MakeMaker' => '6.11' );
+}
+
+1;
+
+__END__
+
+#line 98
Added: plugins/EditInPlace/inc/Module/Install/Win32.pm
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/inc/Module/Install/Win32.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,65 @@
+#line 1
+package Module::Install::Win32;
+
+use strict;
+use Module::Install::Base;
+
+use vars qw{$VERSION $ISCORE @ISA};
+BEGIN {
+ $VERSION = '0.64';
+ $ISCORE = 1;
+ @ISA = qw{Module::Install::Base};
+}
+
+# determine if the user needs nmake, and download it if needed
+sub check_nmake {
+ my $self = shift;
+ $self->load('can_run');
+ $self->load('get_file');
+
+ require Config;
+ return unless (
+ $^O eq 'MSWin32' and
+ $Config::Config{make} and
+ $Config::Config{make} =~ /^nmake\b/i and
+ ! $self->can_run('nmake')
+ );
+
+ print "The required 'nmake' executable not found, fetching it...\n";
+
+ require File::Basename;
+ my $rv = $self->get_file(
+ url => 'http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe',
+ ftp_url => 'ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe',
+ local_dir => File::Basename::dirname($^X),
+ size => 51928,
+ run => 'Nmake15.exe /o > nul',
+ check_for => 'Nmake.exe',
+ remove => 1,
+ );
+
+ if (!$rv) {
+ die <<'END_MESSAGE';
+
+-------------------------------------------------------------------------------
+
+Since you are using Microsoft Windows, you will need the 'nmake' utility
+before installation. It's available at:
+
+ http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe
+ or
+ ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe
+
+Please download the file manually, save it to a directory in %PATH% (e.g.
+C:\WINDOWS\COMMAND\), then launch the MS-DOS command line shell, "cd" to
+that directory, and run "Nmake15.exe" from there; that will create the
+'nmake.exe' file needed by this module.
+
+You may then resume the installation process described in README.
+
+-------------------------------------------------------------------------------
+END_MESSAGE
+ }
+}
+
+1;
Added: plugins/EditInPlace/inc/Module/Install/WriteAll.pm
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/inc/Module/Install/WriteAll.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,43 @@
+#line 1
+package Module::Install::WriteAll;
+
+use strict;
+use Module::Install::Base;
+
+use vars qw{$VERSION $ISCORE @ISA};
+BEGIN {
+ $VERSION = '0.64';
+ $ISCORE = 1;
+ @ISA = qw{Module::Install::Base};
+}
+
+sub WriteAll {
+ my $self = shift;
+ my %args = (
+ meta => 1,
+ sign => 0,
+ inline => 0,
+ check_nmake => 1,
+ @_
+ );
+
+ $self->sign(1) if $args{sign};
+ $self->Meta->write if $args{meta};
+ $self->admin->WriteAll(%args) if $self->is_admin;
+
+ if ( $0 =~ /Build.PL$/i ) {
+ $self->Build->write;
+ } else {
+ $self->check_nmake if $args{check_nmake};
+ unless ( $self->makemaker_args->{'PL_FILES'} ) {
+ $self->makemaker_args( PL_FILES => {} );
+ }
+ if ($args{inline}) {
+ $self->Inline->write;
+ } else {
+ $self->Makefile->write;
+ }
+ }
+}
+
+1;
Added: plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace.pm
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,34 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::EditInPlace;
+use base qw/Jifty::Plugin/;
+
+
+package HTML::Mason::Request::Jifty;
+
+=head2 fetch_comp
+
+=cut
+
+sub fetch_comp {
+ my $self = shift;
+ my $comp = $self->SUPER::fetch_comp(@_);
+ if (not $comp and Jifty->config->framework('DevelMode') ) {
+ my $comp_name = shift;
+ $comp = $self->interp->make_component(
+ comp_source =>
+ "
+ <span id=\"create-component-$comp_name\">
+<% Jifty->web->link(class => 'inline_create', label => 'Create $comp_name', onclick => [ { element => \"#create-component-$comp_name\", replace_with => '/__jifty/edit_inline/mason_component/$comp_name' } ]) %>
+ </span>
+ ");
+
+
+ }
+ return $comp;
+}
+
+
+
+1;
Added: plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace/Action/FileEditor.pm
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace/Action/FileEditor.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,181 @@
+package Jifty::Plugin::EditInPlace::Action::FileEditor;
+
+use base qw/Jifty::Action/;
+use File::Spec;
+use File::Basename ();
+
+
+=head1 NAME
+
+Jifty::Plugin::EditInPlace::Action::FileEditor
+
+=head1 DESCRIPTION
+
+This action allows you to edit mason components (and eventually libraries)
+using Jifty's I<Action> system. It should only be enabled when you're
+running Jifty in C<DevelMode>.
+
+=head1 WARNING
+
+B<THIS ACTION LETS YOU REMOTELY EDIT EXECUTABLE CODE>.
+
+B<THIS IS DANGEROUS>
+
+=cut
+
+=head2 new
+
+Create a new C<FileEditor> action.
+
+=cut
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new(@_);
+ $self->sticky_on_success(1);
+ $self->get_default_content;
+ return($self);
+
+}
+
+=head2 arguments
+
+Sets up this action's arguments.
+
+=over
+
+=item path
+
+Where to save the file
+
+=item file_type
+
+(One of mason_component or library)
+
+=item source_path
+
+Where to read the file from.
+
+=item destination_path
+
+Where to write the file to. If the current user can't write to
+the source_path, defaults to something inside the app's directory.
+
+=item content
+
+The actual content of the file we're editing.
+
+=back
+
+=cut
+
+
+sub arguments {
+ my $self = shift;
+
+ { file_type => {
+ label => 'File type',
+ default => 'mason_component',
+ render_as => 'Select',
+ valid_values => [{ value => 'mason_component', display => 'Template'} , {value => 'library', display => 'Library'}],
+ constructor => 1
+ },
+ source_path => { type => 'text', constructor => 1, label => 'Path' },
+ destination_path => { type => 'text', ajax_validates=> 1, label => 'Save as' },
+ content => { render_as => 'Textarea', cols => 80, rows => 25, label => 'Content' },
+
+ }
+
+}
+
+
+=head2 get_default_content
+
+Finds the version of the C<source_path> (of type C<file_type>) and
+loads it into C<content>.
+
+=cut
+
+sub get_default_content {
+ my $self = shift;
+
+ # Don't override content we already have
+ return if ($self->argument_value('content'));
+ my $path = $self->argument_value('source_path');
+ my $type = $self->argument_value('file_type');
+ my $out = '';
+ my %cfg = Jifty->handler->mason->config;
+
+ my($local_template_base, $qualified_path);
+ if ($type eq "mason_component") {
+ foreach my $item (@{$cfg{comp_root}}) {
+ $local_template_base = $item->[1] if $item->[0] eq 'application';
+ $qualified_path = File::Spec->catfile($item->[1],$path);
+ # We want the first match
+ last if -f $qualified_path and -r $qualified_path;
+ undef $qualified_path;
+ }
+ $self->argument_value(destination_path => File::Spec->catfile($local_template_base, $path));
+ } else {
+ $qualified_path = "/$path" if -f "/$path" and -r "/$path";
+ $self->argument_value(destination_path => $qualified_path);
+ }
+
+ if ($qualified_path) {
+ local $/;
+ my $filehandle;
+ open ($filehandle, "<$qualified_path")||die "Couldn't read $qualified_path: $!";
+ $self->argument_value(content => <$filehandle>);
+ close($filehandle);
+ }
+}
+
+=head2 validate_destination_path PATH
+
+Returns true if the user can write to the directory C<PATH>. False
+otherwise. Should be refactored to a C<path_writable> routine and a
+trivial validator.
+
+=cut
+
+sub validate_destination_path {
+ my $self = shift;
+ my $value = shift;
+ $self->{'write_to'} = $value;
+ unless ($self->{'write_to'}) {
+ return $self->validation_error( destination_path => "No destination path set. Where should I write this file?");
+ }
+ if (-f $self->{'write_to'} and not -w $self->{'write_to'}) {
+ return $self->validation_error( destination_path => "Can't save the file to ".$self->{'write_to'});
+ }
+ return $self->validation_ok( 'write_to' );
+}
+
+
+=head2 take_action
+
+Writes the C<content> out to the C<destination_path>.
+
+=cut
+
+sub take_action {
+ my $self = shift;
+ my $dest = $self->{'write_to'};
+
+
+ # discard filename. we only want to make the directory ;)
+ Jifty::Util->make_path( File::Basename::dirname( $dest ) );
+ my $writehandle = IO::File->new();
+
+ my $content = $self->argument_value('content');
+ $content =~ s/\r\n/\n/g;
+
+ $writehandle->open(">$dest") || die "Couldn't open $dest for writing: ".$!;
+ $writehandle->print( $content ) || die " Couldn't write to $dest: ".$!;
+ $writehandle->close() || die "Couldn't close filehandle $dest ".$!;
+ $self->result->message("Updated $dest");
+}
+
+
+
+1;
Added: plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace/Dispatcher.pm
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/lib/Jifty/Plugin/EditInPlace/Dispatcher.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,28 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::EditInPlace::Dispatcher;
+use Jifty::Dispatcher -base;
+
+before qr'^/__jifty/(edit|create)(_inline/|)/(.*?)/(.*)$', run {
+ # Claim this as ours -- skip ACLs, etc
+ last_rule;
+};
+
+on qr'^/__jifty/(edit|create)(_inline|)/(.*?)/(.*)$', run {
+ my $editor = Jifty->web->new_action(
+ class => 'Jifty::Plugin::EditInPlace::Action::FileEditor',
+ moniker => 'editpage',
+ arguments => {
+ source_path => $4,
+ file_type => $3,
+ }
+ );
+
+ set editor => $editor;
+ set path => $4;
+ show "/__jifty/$1_file$2";
+};
+
+
+1;
Added: plugins/EditInPlace/share/web/templates/__jifty/create_file_inline
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/share/web/templates/__jifty/create_file_inline Sat Jun 14 03:25:31 2008
@@ -0,0 +1,12 @@
+<%attr>
+edit_inline => 0
+</%attr>
+<%args>
+$path => undef
+$line => undef
+</%args>
+<% Jifty->web->link(label => _("Create $path"),
+ onclick => {
+ replace_with => '/__jifty/edit_inline/mason_component/'.$path,
+ },
+ )%>
Added: plugins/EditInPlace/share/web/templates/__jifty/edit_file
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/share/web/templates/__jifty/edit_file Sat Jun 14 03:25:31 2008
@@ -0,0 +1,15 @@
+<%args>
+$path => undef
+$editor => undef
+$line => undef
+</%args>
+<%init>
+my $title = _("Editing file %1",$editor->argument_value('source_path'));
+</%init>
+<&|/_elements/wrapper, title => $title &>
+<% Jifty->web->form->start %>
+<%$editor->form_field('destination_path')%>
+<%$editor->form_field('content')%>
+<% Jifty->web->return(label => 'Save and return', submit => $editor )%>
+<% Jifty->web->form->end %>
+</&>
Added: plugins/EditInPlace/share/web/templates/__jifty/edit_file_inline
==============================================================================
--- (empty file)
+++ plugins/EditInPlace/share/web/templates/__jifty/edit_file_inline Sat Jun 14 03:25:31 2008
@@ -0,0 +1,14 @@
+<%args>
+$path => undef
+$editor => undef
+$line => undef
+</%args>
+<% Jifty->web->form->start %>
+<%$editor->form_field('destination_path', render_as => 'hidden')%>
+<%$editor->form_field('content')->render_widget%>
+<% Jifty->web->form->submit(label => 'Save', onclick => { submit => $editor,
+ replace_with => $path,
+ },
+
+ submit => $editor )%>
+<% Jifty->web->form->end %>
Added: plugins/WikiToolbar/Makefile.PL
==============================================================================
--- (empty file)
+++ plugins/WikiToolbar/Makefile.PL Sat Jun 14 03:25:31 2008
@@ -0,0 +1,8 @@
+use inc::Module::Install;
+name('Jifty-Plugin-WikiToolbar');
+version('0.01');
+requires('Jifty' => '0.70416');
+
+install_share;
+
+WriteAll;
Added: plugins/WikiToolbar/lib/Jifty/Plugin/WikiToolbar.pm
==============================================================================
--- (empty file)
+++ plugins/WikiToolbar/lib/Jifty/Plugin/WikiToolbar.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,38 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::WikiToolbar;
+use base qw/Jifty::Plugin/;
+
+=head1 SYNOPSIS
+
+In etc/config.yml
+
+ Plugins:
+ - WikiToolbar: {}
+
+In your Model instead of
+
+ render_as 'textarea';
+
+use
+
+ render_as 'Jifty::Plugin::WikiToolbar::Textarea';
+
+To custom the toolbar, copy wikitoolbar.js in your application, at the end of the file put your changes with addButton function.
+
+=head1 DESCRIPTION
+
+Add a toolbar to your textarea field. Default toolbar provide markdown markup syntax. http://daringfireball.net/projects/markdown/
+
+=cut
+
+sub init {
+ my $self = shift;
+ Jifty->web->javascript_libs([
+ @{ Jifty->web->javascript_libs },
+ "wikitoolbar.js",
+ ]);
+}
+
+1;
Added: plugins/WikiToolbar/lib/Jifty/Plugin/WikiToolbar/Dispatcher.pm
==============================================================================
--- (empty file)
+++ plugins/WikiToolbar/lib/Jifty/Plugin/WikiToolbar/Dispatcher.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,9 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::WikiToolbar::Dispatcher;
+use Jifty::Dispatcher -base;
+
+# Put any plugin-specific dispatcher rules here.
+
+1;
Added: plugins/WikiToolbar/lib/Jifty/Plugin/WikiToolbar/Textarea.pm
==============================================================================
--- (empty file)
+++ plugins/WikiToolbar/lib/Jifty/Plugin/WikiToolbar/Textarea.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,24 @@
+package Jifty::Plugin::WikiToolbar::Textarea;
+use base qw(Jifty::Web::Form::Field::Textarea);
+
+sub rows { 30 };
+
+sub render_widget {
+ my $self = shift;
+ my $field;
+ $field .= qq!<div id='toolbar'></div>!;
+ $field .= qq!<textarea!;
+ $field .= qq! name="@{[ $self->input_name ]}"!;
+ $field .= qq! id="@{[ $self->element_id ]}"!;
+ $field .= qq! rows="@{[$self->rows || 5 ]}"!;
+ $field .= qq! cols="@{[$self->cols || 60]}"!;
+ $field .= $self->_widget_class;
+ $field .= qq! >!;
+ $field .= Jifty->web->escape($self->current_value) if $self->current_value;
+ $field .= qq!</textarea>\n!;
+ Jifty->web->out($field);
+ '';
+}
+
+
+1;
Added: plugins/WikiToolbar/share/web/static/img/wt/bold.png
==============================================================================
Binary file. No diff available.
Added: plugins/WikiToolbar/share/web/static/img/wt/box.png
==============================================================================
Binary file. No diff available.
Added: plugins/WikiToolbar/share/web/static/img/wt/center.png
==============================================================================
Binary file. No diff available.
Added: plugins/WikiToolbar/share/web/static/img/wt/code.png
==============================================================================
Binary file. No diff available.
Added: plugins/WikiToolbar/share/web/static/img/wt/code1.png
==============================================================================
Binary file. No diff available.
Added: plugins/WikiToolbar/share/web/static/img/wt/empty.png
==============================================================================
Binary file. No diff available.
Added: plugins/WikiToolbar/share/web/static/img/wt/h1.png
==============================================================================
Binary file. No diff available.
Added: plugins/WikiToolbar/share/web/static/img/wt/h2.png
==============================================================================
Binary file. No diff available.
Added: plugins/WikiToolbar/share/web/static/img/wt/h3.png
==============================================================================
Binary file. No diff available.
Added: plugins/WikiToolbar/share/web/static/img/wt/italic.png
==============================================================================
Binary file. No diff available.
Added: plugins/WikiToolbar/share/web/static/img/wt/link.png
==============================================================================
Binary file. No diff available.
Added: plugins/WikiToolbar/share/web/static/img/wt/linkextern.png
==============================================================================
Binary file. No diff available.
Added: plugins/WikiToolbar/share/web/static/img/wt/new.png
==============================================================================
Binary file. No diff available.
Added: plugins/WikiToolbar/share/web/static/img/wt/ol.png
==============================================================================
Binary file. No diff available.
Added: plugins/WikiToolbar/share/web/static/img/wt/red.png
==============================================================================
Binary file. No diff available.
Added: plugins/WikiToolbar/share/web/static/img/wt/strike.png
==============================================================================
Binary file. No diff available.
Added: plugins/WikiToolbar/share/web/static/img/wt/tab.png
==============================================================================
Binary file. No diff available.
Added: plugins/WikiToolbar/share/web/static/img/wt/ul.png
==============================================================================
Binary file. No diff available.
Added: plugins/WikiToolbar/share/web/static/img/wt/underline.png
==============================================================================
Binary file. No diff available.
Added: plugins/WikiToolbar/share/web/static/js/wikitoolbar.js
==============================================================================
--- (empty file)
+++ plugins/WikiToolbar/share/web/static/js/wikitoolbar.js Sat Jun 14 03:25:31 2008
@@ -0,0 +1,137 @@
+// Wikipedia JavaScript toolbar functions
+
+mwEditButtons = [];
+
+// this function generates the actual toolbar buttons with localized text
+// we use it to avoid creating the toolbar where javascript is not enabled
+function addButton(imageFile, speedTip, tagOpen, tagClose, sampleText) {
+ mwEditButtons[mwEditButtons.length] =
+ {"imageFile": imageFile,
+ "speedTip": speedTip,
+ "tagOpen": tagOpen,
+ "tagClose": tagClose,
+ "sampleText": sampleText};
+}
+
+// this function generates the actual toolbar buttons with localized text
+// we use it to avoid creating the toolbar where javascript is not enabled
+function mwInsertEditButton(parent, item) {
+ if (typeof item.imageFile == 'undefined') {
+ return;}
+ var image = document.createElement("img");
+ image.width = 16;
+ image.height = 16;
+ image.src = item.imageFile;
+ image.border = 0;
+ image.alt = item.speedTip;
+ image.title = item.speedTip;
+ image.style.cursor = "pointer";
+ image.onclick = function() {
+ insertTags(item.tagOpen, item.tagClose, item.sampleText);
+ return false;
+ }
+ parent.appendChild(image);
+}
+
+// apply tagOpen/tagClose to selection in textarea,
+// use sampleText instead of selection if there is none
+// copied and adapted from phpBB
+function insertTags(tagOpen, tagClose, sampleText) {
+
+ // var txtarea = document.getElementsByTagName('TEXTAREA')[0];
+ // TODO: need a better way to manage multi textarea
+ var txtarea;
+ var txtareas = document.getElementsByTagName('TEXTAREA');
+ for (i = 0; i < txtareas.length; i++) {
+ var textbox = txtareas[i];
+ if( textbox.selectionStart ) {
+ txtarea = textbox;
+ };
+ }
+
+ if (typeof txtarea == 'undefined') {
+ txtarea = document.getElementsByTagName('TEXTAREA')[0];
+ }
+
+ // IE
+ if (document.selection && !is_gecko) {
+ var theSelection = document.selection.createRange().text;
+ if (!theSelection)
+ theSelection=sampleText;
+ txtarea.focus();
+ if (theSelection.charAt(theSelection.length - 1) == " ") { // exclude ending space char, if any
+ theSelection = theSelection.substring(0, theSelection.length - 1);
+ document.selection.createRange().text = tagOpen + theSelection + tagClose + " ";
+ } else {
+ document.selection.createRange().text = tagOpen + theSelection + tagClose;
+ }
+
+ // Mozilla
+ } else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
+ var replaced = false;
+ var startPos = txtarea.selectionStart;
+ var endPos = txtarea.selectionEnd;
+ if (endPos-startPos)
+ replaced = true;
+ var scrollTop = txtarea.scrollTop;
+ var myText = (txtarea.value).substring(startPos, endPos);
+ if (!myText)
+ myText=sampleText;
+ if (myText.charAt(myText.length - 1) == " ") { // exclude ending space char, if any
+ subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " ";
+ } else {
+ subst = tagOpen + myText + tagClose;
+ }
+ txtarea.value = txtarea.value.substring(0, startPos) + subst +
+ txtarea.value.substring(endPos, txtarea.value.length);
+ txtarea.focus();
+ //set new selection
+ if (replaced) {
+ var cPos = startPos+(tagOpen.length+myText.length+tagClose.length);
+ txtarea.selectionStart = cPos;
+ txtarea.selectionEnd = cPos;
+ } else {
+ txtarea.selectionStart = startPos+tagOpen.length;
+ txtarea.selectionEnd = startPos+tagOpen.length+myText.length;
+ }
+ txtarea.scrollTop = scrollTop;
+
+ // All other browsers get no toolbar.
+ // There was previously support for a crippled "help"
+ // bar, but that caused more problems than it solved.
+ }
+ // reposition cursor if possible
+ if (txtarea.createTextRange)
+ txtarea.caretPos = document.selection.createRange().duplicate();
+}
+
+
+
+var myrules = {
+ '#toolbar' : function(e){
+ mwEditButtons = [];
+// CUSTOM your toolbar HERE
+// addButton : image, help text, first tag before selected text, last tag, default text if nothing is selected
+addButton('/static/img/wt/bold.png','Bold text','\*\*','\*\*','Bold text');
+addButton('/static/img/wt/italic.png','Italic text','\_','\_','Italic text');
+ addButton('/static/img/wt/empty.png','','','','');
+addButton('/static/img/wt/h1.png','Title','','\n=======\n','Title');
+addButton('/static/img/wt/h2.png','Sub title','','\n-------\n','Sub title');
+addButton('/static/img/wt/h3.png','Sub sub title','### ',' ###\n','Sub sub title');
+ addButton('/static/img/wt/empty.png','','','','');
+addButton('/static/img/wt/link.png','Link','[','](http://...... )','Text');
+addButton('/static/img/wt/linkextern.png','URL','<','>','http://.....');
+ addButton('/static/img/wt/empty.png','','','','');
+addButton('/static/img/wt/ul.png','List','\n- element 1\n- element 2\n- element 3\n\n ','','');
+addButton('/static/img/wt/ol.png','Ordered list','\n1. element 1\n1. element 2\n1. element 3\n\n ','','');
+// END
+
+ for(i=0;i<mwEditButtons.length;i++) {
+ mwInsertEditButton(e, mwEditButtons[i]);
+ }
+
+ }
+ };
+
+Behaviour.register(myrules);
+
Added: plugins/WyzzEditor/Makefile.PL
==============================================================================
--- (empty file)
+++ plugins/WyzzEditor/Makefile.PL Sat Jun 14 03:25:31 2008
@@ -0,0 +1,8 @@
+use inc::Module::Install;
+name('Jifty-Plugin-WyzzEditor');
+version('0.01');
+requires('Jifty' => '0.70416');
+
+install_share;
+
+WriteAll;
Added: plugins/WyzzEditor/lib/Jifty/Plugin/WyzzEditor.pm
==============================================================================
--- (empty file)
+++ plugins/WyzzEditor/lib/Jifty/Plugin/WyzzEditor.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,49 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::WyzzEditor;
+use base qw/Jifty::Plugin/;
+
+=head1 SYNOPSIS
+
+In etc/config.yml
+
+ Plugins:
+ - WyzzEditor: {}
+
+In your Model instead of
+
+ render_as 'teaxterea';
+
+use
+
+ render_as 'Jifty::Plugin::WyzzEditor::Textarea';
+
+
+In your View
+
+ Jifty->web->link(
+ label => _("Save"),
+ onclick => [
+ { beforeclick =>
+ "updateTextArea('".$action->form_field('myfield')->element_id."');" },
+ { args => .... }
+ ]
+ );
+
+=head1 DESCRIPTION
+
+Wyzz, simple WYSIWYG online editor usable in fragments
+
+=cut
+
+
+sub init {
+ my $self = shift;
+ Jifty->web->javascript_libs([
+ @{ Jifty->web->javascript_libs },
+ "wyzz.js",
+ ]);
+}
+
+1;
Added: plugins/WyzzEditor/lib/Jifty/Plugin/WyzzEditor/Dispatcher.pm
==============================================================================
--- (empty file)
+++ plugins/WyzzEditor/lib/Jifty/Plugin/WyzzEditor/Dispatcher.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,9 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::WyzzEditor::Dispatcher;
+use Jifty::Dispatcher -base;
+
+# Put any plugin-specific dispatcher rules here.
+
+1;
Added: plugins/WyzzEditor/lib/Jifty/Plugin/WyzzEditor/Textarea.pm
==============================================================================
--- (empty file)
+++ plugins/WyzzEditor/lib/Jifty/Plugin/WyzzEditor/Textarea.pm Sat Jun 14 03:25:31 2008
@@ -0,0 +1,25 @@
+package Jifty::Plugin::WyzzEditor::Textarea;
+use base qw(Jifty::Web::Form::Field::Textarea);
+
+sub render_widget {
+ my $self = shift;
+ my $field;
+ $field .= qq!<textarea!;
+ $field .= qq! name="@{[ $self->input_name ]}"!;
+ $field .= qq! id="@{[ $self->element_id ]}"!;
+ $field .= qq! rows="@{[$self->rows || 5 ]}"!;
+ $field .= qq! cols="@{[$self->cols || 60]}"!;
+ $field .= $self->_widget_class;
+ $field .= qq! >!;
+ $field .= Jifty->web->escape($self->current_value) if $self->current_value;
+ $field .= qq!</textarea>\n!;
+ $field .= qq!<script type="text/javascript">\n!;
+ $field .= qq! make_wyzz('@{[ $self->element_id ]}');\n!;
+ $field .= qq!</script>\n!;
+
+ Jifty->web->out($field);
+ '';
+}
+
+
+1;
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/backcolor.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/bold.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/close.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/copy.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/cut.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/downsize.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/font.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/forecolor.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/headers.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/help.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/htmlmode.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/indent.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/inserthorizontalrule.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/insertimage.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/insertorderedlist.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/insertunorderedlist.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/italic.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/justifycenter.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/justifyfull.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/justifyleft.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/justifyright.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/link.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/outdent.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/paste.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/redo.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/removeformat.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/specialchar.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/strikethrough.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/subscript.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/superscript.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/underline.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/undo.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/upsize.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/img/wyzzicons/wyzzicon.gif
==============================================================================
Binary file. No diff available.
Added: plugins/WyzzEditor/share/web/static/js/wyzz.js
==============================================================================
--- (empty file)
+++ plugins/WyzzEditor/share/web/static/js/wyzz.js Sat Jun 14 03:25:31 2008
@@ -0,0 +1,732 @@
+
+// WYZZ Copyright (c) 2007 The Mouse Whisperer
+// Contains code Copyright (c) 2006 openWebWare.com
+// This copyright notice MUST stay intact for use.
+//
+// An open source WYSIWYG editor for use in web based applications.
+// For full source code and docs, visit http://www.wyzz.info
+//
+// This library is free software; you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published
+// by the Free Software Foundation; either version 2.1 of the License, or
+// (at your option) any later version.
+//
+// This library 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 Lesser General Public
+// License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License along
+// with this library; if not, write to the Free Software Foundation, Inc., 59
+// Temple Place, Suite 330, Boston, MA 02111-1307 USA
+/****************************************************************************************/
+// MODIFY THE PARAMETERS IN THE FOLLOWING SECTION TO SUIT YOUR APPLICATION ///////////////
+
+// Editor Width and Height
+wyzzW = 600;
+wyzzH = 200;
+
+// Number of toolbars - must be either 1 or 2
+// If set to 1, the first tooolbar (defined in array buttonName below) will be ignored
+toolbarCount = 2;
+
+// Edit region stylesheet
+editstyle = '/static/wyzzstyles/editarea.css';
+
+// Do we want to try to clean the code to emulate xhtml? 1=Yes, 0=No
+xhtml_out = 1;
+
+// Style Sheet
+document.write('<link rel="stylesheet" type="text/css" href="/static/wyzzstyles/style.css">\n');
+
+// TOOLBARS ARRAYS
+// Order of available commands in toolbar
+// Remove from this any buttons not required in your application
+var buttonName = new Array("font","headers","separator","bold","italic","underline","strikethrough","separator","cut","copy","paste","separator","subscript","superscript","separator","justifyleft","justifycenter","justifyright","justifyfull","indent","outdent","separator","insertunorderedlist","insertorderedlist","separator","link","insertimage","separator","undo","redo");
+
+// Order of available commands in toolbar2
+// Remove from this any buttons not required in your application
+var buttonName2 = new Array("specialchar","separator","forecolor","backcolor","separator","inserthorizontalrule","separator","removeformat","separator","upsize","downsize","separator","htmlmode","separator","help");
+
+var myFonts = new Array("Andale Mono","Georgia","Verdana","Arial","Arial Black","impact","Times New Roman","Courier New","Comic Sans MS","Helvetica","Trebuchet MS","Tahoma");
+
+var specialChars = new Array("©","®","™","à","á","ç","è","é","ë","ì","í","ñ","ò","ó","ö","ù","ú","ü","£","¢","¥","€","“","”","«","»","•","—","…","¶","†","‡","×","÷","°","±","¼","½","¾","¬","<",">","Δ","λ","Φ","Ψ","Σ","∫","α","β","Ω","μ","π","θ","↔","∞","√","≈","≠","≡","≤","≥","¡","¿","♠","♣","♥","♦");
+
+// DON'T MODIFY BEYOND THIS LINE unless you know what you are doing //////////////
+/********************************************************************************/
+
+version = "0.62"; // Please leave this
+
+var Headers = new Array("P","PRE","H1","H2","H3","H4","H5","H6");
+
+// Mode wysiwyg = 1 or sourcecode = 0
+mode = 1;
+
+// Get browser
+browserName = navigator.appName;
+
+nlBefore = new Array("div","p","li","h1","h2","h3","h4","h5","h6","hr","ul","ol");
+
+function h2x(node,inPre) { // we will pass the node containing the Wyzz-generated html
+ var xout = '';
+ var i;
+ var j;
+ // for each child of the node
+ for(i=0;i<node.childNodes.length;i++) {
+ if(node.childNodes[i].parentNode && String(node.tagName).toLowerCase() != String(node.childNodes[i].parentNode.tagName).toLowerCase()) continue;
+ // alert('Nodes: '+ node.childNodes.length);
+ switch(node.childNodes[i].nodeType) {
+ case 1: { // for element nodes
+ // get tag name
+ var tagname = String(node.childNodes[i].tagName).toLowerCase();
+ if(tagname == '') break;
+ if((indexOf(nlBefore,tagname)!=-1)&&(!inPre)) { // this tag needs line break before it
+ xout += '\n';
+ }
+ xout += '<' + tagname;
+ var atts = node.childNodes[i].attributes;
+ var attvalue;
+ for(j=0;j<atts.length;j++) { // for each attribute
+ var attname = atts[j].nodeName.toLowerCase();
+ if(!atts[j].specified) continue;
+ var validatt = true;
+ switch(attname) {
+ case "style": attvalue = node.childNodes[i].style.cssText; break;
+ case "class": attvalue = node.childNodes[i].className; break;
+ case "name": attvalue = node.childNodes[i].name; break;
+ default:
+ try {
+ attvalue = node.childNodes[i].getAttribute(attname,2);
+ } catch(e) {
+ validatt = false;
+ }
+ }
+ if(validatt) {
+ if(!(tagname=='li' && attname == 'value')) {
+ xout += ' '+attname + '="' + fixatt(attvalue) + '"';
+ }
+ }
+ }
+ if(tagname == 'img' && attname == 'alt') {
+ xout += ' alt=""';
+ }
+ if(node.childNodes[i].canHaveChildren||node.childNodes[i].hasChildNodes()) {
+ xout += '>';
+ xout += h2x(node.childNodes[i],tagname=='pre'?true:false);
+ xout += '</' + tagname + '>';
+ } else {
+ if(tagname == 'style'||tagname == 'title'||tagname=='script'||tagname=='textarea'||tagname=='a') {
+ xout += '>';
+ var innertext;
+ if(tagname=='script') {
+ innertext = node.childNodes[i].text;
+ } else {
+ innertext = node.childNodes[i].innerHTML;
+ }
+ if(tagname=='style') {
+ innertext = String(innertext).replace(/[\n]+/g,'\n');
+ }
+ xout += innertext + '</' + tagname + '>';
+ } else {
+ xout += '/>';
+ }
+ }
+ break;
+ }
+// else if(node.childNodes[i].nodeType == 2) { // for attribute nodes
+
+// }
+ case 3: { // for text nodes
+ if(!inPre) { // don't change inside a <pre> tag
+ if(node.childNodes[i] != '\n') {
+ xout += fixents(fixtext(node.childNodes[i].nodeValue));
+ }
+ } else {
+ xout += node.childNodes[i].nodeValue;
+ break;
+ }
+ }
+ default:
+ break;
+ }
+ }
+ return xout;
+}
+
+function fixents(text) {
+ var i;
+ var ents = {8364 : "euro",402 : "fnof",8240 : "permil",352 : "Scaron",338 : "OElig",381 : "#381",8482 : "trade",353 : "scaron",339 : "oelig",382 : "#382",376 : "Yuml",162 : "cent",163 : "pound",164 : "curren",165 : "yen",166 : "brvbar",167 : "sect",168 : "uml",169 : "copy",170 : "ordf",171 : "laquo",172 : "not",173 : "shy",174 : "reg",175 : "macr",176 : "deg",177 : "plusmn",178 : "sup2",179 : "sup3",180 : "acute",181 : "micro",182 : "para",183 : "middot",184 : "cedil",185 : "sup1",186 : "ordm",187 : "raquo",188 : "frac14",189 : "frac12",190 : "frac34",191 : "iquest",192 : "Agrave",193 : "Aacute",194 : "Acirc",195 : "Atilde",196 : "Auml",197 : "Aring",198 : "AElig",199 : "Ccedil",200 : "Egrave",201 : "Eacute",202 : "Ecirc",203 : "Euml",204 : "Igrave",205 : "Iacute",206 : "Icirc",207 : "Iuml",208 : "ETH",209 : "Ntilde",210 : "Ograve",211 : "Oacute",212 : "Ocirc",213 : "Otilde",214 : "Ouml",215 : "times",216 : "Oslash",217 : "Ugrave",218 : "Uacute",219 : "Ucirc",220 : "Uuml",221 : "Yacute",222 : "THORN",223 : "szlig",224 : "agrave",225 : "aacute",226 : "acirc",227 : "atilde",228 : "auml",229 : "aring",230 : "aelig",231 : "ccedil",232 : "egrave",233 : "eacute",234 : "ecirc",235 : "euml",236 : "igrave",237 : "iacute",238 : "icirc",239 : "iuml",240 : "eth",241 : "ntilde",242 : "ograve",243 : "oacute",244 : "ocirc",245 : "otilde",246 : "ouml",247 : "divide",248 : "oslash",249 : "ugrave",250 : "uacute",251 : "ucirc",252 : "uuml",253 : "yacute",254 : "thorn",255 : "yuml",913 : "Alpha",914 : "Beta",915 : "Gamma",916 : "Delta",917 : "Epsilon",918 : "Zeta",919 : "Eta",920 : "Theta",921 : "Iota",922 : "Kappa",923 : "Lambda",924 : "Mu",925 : "Nu",926 : "Xi",927 : "Omicron",928 : "Pi",929 : "Rho", 931 : "Sigma",932 : "Tau",933 : "Upsilon",934 : "Phi",935 : "Chi",936 : "Psi",937 : "Omega",8756 : "there4",8869 : "perp",945 : "alpha",946 : "beta",947 : "gamma",948 : "delta",949 : "epsilon",950 : "zeta",951 : "eta",952 : "theta",953 : "iota",954 : "kappa",955 : "lambda",956 : "mu",957 : "nu",968 : "xi",969 : "omicron",960 : "pi",961 : "rho",962 : "sigmaf",963 : "sigma",964 : "tau",965 : "upsilon",966 : "phi",967 : "chi",968 : "psi",969 : "omega",8254 : "oline",8804 : "le",8260 : "frasl",8734 : "infin",8747 : "int",9827 : "clubs",9830 : "diams",9829 : "hearts",9824 : "spades",8596 : "harr",8592 : "larr",8594 : "rarr",8593 : "uarr",8595 : "darr",8220 : "ldquo",8221 : "rdquo",8222 : "bdquo",8805 : "ge",8733 : "prop",8706 : "part",8226 : "bull",8800 : "ne",8801 : "equiv",8776 : "asymp",8230 : "hellip",8212 : "mdash",8745 : "cap",8746 : "cup",8835 : "sup",8839 : "supe",8834 : "sub",8838 : "sube",8712 : "isin",8715 : "ni",8736 : "ang",8711 : "nabla",8719 : "prod",8730 : "radic",8743 : "and",8744 : "or",8660 : "hArr",8658 : "rArr",9674 : "loz",8721 : "sum",8704 : "forall",8707 : "exist",8216 : "lsquo",8217 : "rsquo",161 : "iexcl",977 : "thetasym",978 : "upsih",982 : "piv",8242 : "prime",8243 : "Prime",8472 : "weierp",8465 : "image",8476 : "real",8501 : "alefsym",8629 : "crarr",8656 : "lArr",8657 : "uArr",8659 : "dArr",8709 : "empty",8713 : "notin",8727 : "lowast",8764 : "sim",8773 : "cong",8836 : "nsub",8853 : "oplus",8855 : "otimes",8901 : "sdot",8968 : "lceil",8969 : "rceil",8970 : "lfloor",8971 : "rfloor",9001 : "lang",9002 : "rang",710 : "circ",732 : "tilde",8194 : "ensp",8195 : "emsp",8201 : "thinsp",8204 : "zwnj",8205 : "zwj",8206 : "lrm",8207 : "rlm",8211 : "ndash",8218 : "sbquo",8224 : "dagger",8225 : "Dagger",8249 : "lsaquo",8250 : "rsaquo"};
+
+ var new_text = '';
+
+ var temp = new RegExp();
+ temp.compile("[a]|[^a]", "g");
+
+ var parts = text.match(temp);
+
+ if (!parts) return text;
+ for (i=0; i<parts.length; i++) {
+ var c_code = parseInt(parts[i].charCodeAt());
+ if (ents[c_code]) {
+ new_text += "&"+ents[c_code]+";";
+ } else new_text += parts[i];
+ }
+ return new_text;
+}
+
+function fixtext(text) {
+ var temptext = String(text).replace(/\</g,"#h2x_lt").replace(/\>/g,"#h2x_gt");
+ temptext = temptext.replace(/\n{2,}/g,"\n").replace(/\&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/\u00A0/g," ");
+ return temptext.replace(/#h2x_lt/g,"&alt;").replace(/#h2x_gt/g,">");
+}
+
+function fixatt(text) {
+ var temptext = String(text).replace(/\</g,"#h2x_lt").replace(/\>/g,"#h2x_gt");
+ temptext = temptext.replace(/\&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/\"/g,""");
+ return temptext.replace(/#h2x_lt/g,"&alt;").replace(/#h2x_gt/g,">");
+}
+
+function indexOf(thisarray, value)
+{
+ var i;
+ for (i=0; i < thisarray.length; i++) {
+ if (thisarray[i] == value) {
+ return i;
+ }
+ }
+ return -1;
+}
+
+// Color picker - here we make an array of all websafe colors
+// If you want to limit the colors available to users (e.g. to fit in with
+// a site design) then use a restricted array of colors
+// e.g. var buttonName = new Array("336699","66abff", .... etc
+var buttonColors = new Array(216);
+
+// Colors - replace this function with your own if you have special requirements for colors
+function getColorArray() {
+// Color code table
+c = new Array('00', '33', '66', '99', 'cc', 'ff');
+var count = 0;
+// Iterate red
+for (r = 0; r < 6; r++)
+ {
+ // Iterate green
+ for (g = 0; g < 6; g++)
+ {
+ // Iterate blue
+ for (b = 0; b < 6; b++)
+ {
+ // Get RGB color
+ buttonColors[count] = c[r] + c[g] + c[b];
+ count++;
+ }
+ }
+ }
+}
+
+getColorArray();
+
+/* Emulates insertAdjacentHTML(), insertAdjacentText() and insertAdjacentElement() three functions
+so they work with Netscape 6/Mozilla - By Thor Larholm me at jscript.dk */
+if(typeof HTMLElement!="undefined" && !HTMLElement.prototype.insertAdjacentElement) {
+ HTMLElement.prototype.insertAdjacentElement = function (where,parsedNode) {
+ switch (where) {
+ case 'beforeBegin':
+ this.parentNode.insertBefore(parsedNode,this)
+ break;
+ case 'afterBegin':
+ this.insertBefore(parsedNode,this.firstChild);
+ break;
+ case 'beforeEnd':
+ this.appendChild(parsedNode);
+ break;
+ case 'afterEnd':
+ if (this.nextSibling) {
+ this.parentNode.insertBefore(parsedNode,this.nextSibling);
+ } else {
+ this.parentNode.appendChild(parsedNode);
+ break;
+ }
+ }
+ }
+
+ HTMLElement.prototype.insertAdjacentHTML = function (where,htmlStr) {
+ var r = this.ownerDocument.createRange();
+ r.setStartBefore(this);
+ var parsedHTML = r.createContextualFragment(htmlStr);
+ this.insertAdjacentElement(where,parsedHTML)
+ }
+
+ HTMLElement.prototype.insertAdjacentText = function (where,txtStr) {
+ var parsedText = document.createTextNode(txtStr)
+ this.insertAdjacentElement(where,parsedText)
+ }
+}
+
+function closeColorPicker(thisid) {
+ document.getElementById(thisid).style.display = "none";
+}
+
+// the hyperlink dialog
+function insertLink(n) {
+ var newWindow = '';
+ var linkurl = '';
+ var linktitle = '';
+ var targetText = grabSelectedText(n);
+ var linkurl = prompt('Enter the target URL of the link:');
+ var linktitle = prompt('Please give a title for the link:');
+ var openNew = confirm('Should this link open in a new window?\n\nOK = Open in NEW Window\nCancel = Open in THIS window');
+ if(openNew) {
+ newWindow = "blank";
+ } else {
+ newWindow = "self";
+ }
+ if(newWindow==''||linkurl==''||linktitle=='') {
+ alert('Please enter all the required information.');
+ insertLink(n);
+ } else {
+ var hyperLink = '<a href="' + linkurl + '" target="_' + newWindow + '" title="' + linktitle + '">' + targetText + '</a>';
+ insertHTML(hyperLink, n);
+ }
+}
+
+function insertImage(n) {
+ var imgurl = prompt('Enter the target URL of the image:');
+ var imgtitle = prompt('Please give a title for the link:');
+ var theImage = '<img src="' + imgurl + '" title="' + imgtitle + '" />';
+ insertHTML(theImage, n); }
+
+function make_wyzz(textareaID) {
+
+ // Hide the textarea
+ document.getElementById(textareaID).style.display = 'none';
+
+ // get textareaID
+ var n = textareaID;
+
+ // Toolbars width is 2 pixels wider than the editor
+ toolbarWidth = parseFloat(wyzzW) + 2;
+
+ var toolbar = '';
+
+ // We only generate toolbar 1 if toolbarCount is set to 2
+ if(toolbarCount == 2) {
+ // Generate WYSIWYG toolbar
+ toolbar = '<table cellpadding="0" cellspacing="0" border="0" class="toolbar" style="width:' + toolbarWidth + 'px;"><tr>';
+
+ // Output buttons for toolbar
+ var colNumbers = 0;
+ for (btn in buttonName) {
+ if ( colNumbers < buttonName.length ) {
+ colNumbers ++;
+ if(buttonName[btn] == "separator") {
+ toolbar += '<td class="separator"> </td>';
+ } else {
+ toolbar += '<td style="width: 22px;"><img src="/static/img/wyzzicons/' +buttonName[btn]+ '.gif" border=0 unselectable="on" title="' +buttonName[btn]+ '" id="' +buttonName[btn]+ '" class="cmdbutton" onClick="formatText(this.id,\'' + n + '\');" onmouseover="if(className==\'cmdbutton\'){className=\'buttonOver\'};" onmouseout="if(className==\'buttonOver\'){className=\'cmdbutton\'};" unselectable="on" width="20" height="20"></td>';
+ }
+ }
+ }
+ toolbar += '<td> </td></tr></table>';
+ }
+
+
+ // Generate WYSIWYG toolbar2
+ var toolbar2 = '<table cellpadding="0" cellspacing="0" border="0" class="toolbar" style="width:' + toolbarWidth + 'px;"><tr>';
+
+ // Output buttons for toolbar2
+ var colNumbers = 0;
+ for (btn in buttonName2) {
+ if ( colNumbers < buttonName2.length ) {
+ colNumbers ++;
+ if(buttonName2[btn] == "separator") {
+ toolbar2 += '<td class="separator"> </td>';
+ } else {
+ toolbar2 += '<td style="width: 22px;"><img src="/static/img/wyzzicons/' +buttonName2[btn]+ '.gif" border=0 unselectable="on" title="' +buttonName2[btn]+ '" id="' +buttonName2[btn]+ '" class="cmdbutton" onClick="formatText(this.id,\'' + n + '\');" onmouseover="if(className==\'cmdbutton\'){className=\'buttonOver\'};" onmouseout="if(className==\'buttonOver\'){className=\'cmdbutton\'};" unselectable="on" width="20" height="20"></td>';
+ }
+ }
+ }
+ toolbar2 += '<td> </td></tr>';
+
+// the foreground color picker
+ var swatchcount = 0;
+ toolbar2 += '<tr><td colspan=' + colNumbers + '>';
+ toolbar2 += '<div id="colorpicker' + n + '" class="colorpicker" style="display:none">';
+ for (clr in buttonColors) {
+ toolbar2 += '<a href="#" title="#' + buttonColors[clr] + '" alt="#' + buttonColors[clr] + '" "class="colorButton" onClick="formatTextColor(\'' + buttonColors[clr] + '\',\'' + n + '\');" style="background: #' + buttonColors[clr] + '"> </a>';
+ swatchcount++;
+ if(swatchcount%18==0) {
+ toolbar2 += '<br>';
+ }
+ }
+ toolbar2 += '<img class="closebutton" src="/static/img/wyzzicons/close.gif" border=0 onclick="closeColorPicker(\'colorpicker' + n + '\')"></div>';
+ // the background color picker
+ toolbar2 += '<div id="colorbackpicker' + n + '" class="colorpicker" style="display:none">';
+ for (clr in buttonColors) {
+ toolbar2 += '<a href="#" title="#' + buttonColors[clr] + '" alt="#' + buttonColors[clr] + '" class="colorButton" onClick="formatBackColor(\'' + buttonColors[clr] + '\',\'' + n + '\');" style="background: #' + buttonColors[clr] + '"> </a>';
+ swatchcount++;
+ if(swatchcount%18==0) {
+ toolbar2 += '<br>';
+ }
+ }
+ toolbar2 += '<img class="closebutton" src="/static/img/wyzzicons/close.gif" border=0 onclick="closeColorPicker(\'colorbackpicker' + n + '\')"></div>';
+ // the font picker
+ toolbar2 += '<div id="fontpicker' + n + '" class="fontpicker" style="display:none">';
+ var fCount = 0;
+ for (fnt in myFonts) {
+ if (fCount < myFonts.length) {
+ fCount ++ ;
+ toolbar2 += '<a href="#" class="fontSelect" onClick="formatFontName(\'' + myFonts[fnt] + '\',\'' + n + '\');" style="font-size:14px;padding: 0px 0px 0px 30px;font-family:' + myFonts[fnt] +'">' + myFonts[fnt] +'</a>';
+ toolbar2 += '<br>';
+ }
+ }
+ toolbar2 += '<img class="closebutton" src="/static/img/wyzzicons/close.gif" border=0 onclick="closeColorPicker(\'fontpicker' + n + '\')"></div>';
+ // the special character picker
+ toolbar2 += '<div id="specialpicker' + n + '" class="specialpicker" style="display:none"><table><tr>';
+ var charcount = 0;
+ for (chr in specialChars) {
+ if ( charcount < specialChars.length ) {
+ toolbar2 += '<td><a href="#" onClick="formatSpecialChar(\'' + specialChars[chr] + '\',\'' + n + '\');">' + specialChars[chr] + '</a> </td>';
+ charcount++;
+ if(charcount%10==0) {
+ toolbar2 += '</tr><tr>';
+ }
+ }
+ }
+ toolbar2 += '</tr></table><br><img class="closebutton" src="/static/img/wyzzicons/close.gif" border=0 onclick="closeColorPicker(\'specialpicker' + n + '\')"></div>';
+ // the header picker
+ toolbar2 += '<div id="headerpicker' + n + '" class="headerpicker" style="display:none">';
+ var hdrcount = 0;
+ for (hdr in Headers) {
+ if ( hdrcount < Headers.length ) {
+ hdrcount ++;
+ toolbar2 += '<a href="#" class="headerSelect" onClick="formatHeader(\'' + Headers[hdr] + '\',\'' + n + '\');" style="font-size:14px;padding: 0px 0px 0px 30px;font-family:arial">' + Headers[hdr] +'</a>';
+ toolbar2 += '<br>';
+ }
+ }
+ toolbar2 += '<img class="closebutton" src="/static/img/wyzzicons/close.gif" border=0 onclick="closeColorPicker(\'headerpicker' + n + '\')"></div>';
+ // Add extra popups here
+ // The help/about box
+ // The copyright and link must remain unaltered
+ toolbar2 += '<div id="helpbox' + n + '" class="helpbox" style="display:none">';
+ toolbar2 += '<div class="help"><h4><img src="/static/img/wyzzicons/wyzzicon.gif" align="middle">Wyzz v' + version + '</h4><br>© 2007 <a href="http://www.wyzz.info" target=_blank>www.wyzz.info</a><br><br></div>';
+ toolbar2 += '<img class="closebutton" src="/static/img/wyzzicons/close.gif" border=0 onclick="closeColorPicker(\'helpbox' + n + '\')"></div></td></tr></table>';
+
+// Create iframe for editor
+var iframe = '<table cellpadding="0" cellspacing="0" border="0" style="width:' + wyzzW + 'px; height:' + wyzzH + 'px;border: 1px inset #dddddd;"><tr><td valign="top">\n'
+ + '<iframe frameborder="0" id="wysiwyg' + n + '"></iframe>\n'
+ + '</td></tr></table>\n';
+
+ // Insert toolbar after the textArea
+ document.getElementById(n).insertAdjacentHTML("afterEnd", toolbar + toolbar2 + iframe);
+
+ // Give the iframe the required height and width
+ document.getElementById("wysiwyg" + n).style.height = wyzzH + "px";
+ document.getElementById("wysiwyg" + n).style.width = wyzzW + "px";
+
+ // Pass the textarea's existing text into the editor
+ var content = document.getElementById(n).value;
+ var doc = document.getElementById("wysiwyg" + n).contentWindow.document;
+
+ // Write the textarea's content into the iframe
+ doc.open();
+ if (browserName == "Microsoft Internet Explorer") {
+ doc.write('<link rel="stylesheet" media="screen" type="text/css" href="' + editstyle + '"/>' + content);
+ } else {
+ doc.write('<html><head><link rel="stylesheet" type="text/css" href="' + editstyle + '"/></head><body>' + content + '<br /></body></html>');
+ }
+ doc.close();
+
+// var browserName = navigator.appName;
+ if (browserName == "Microsoft Internet Explorer"||browserName == "Opera") {
+ // Make the iframe editable
+ doc.body.contentEditable = true;
+ } else {
+ // Make the iframe editable
+ doc.designMode = "on";
+ }
+
+ // Update the textarea with content in WYSIWYG when user submits form
+ // var browserName = navigator.appName;
+ if (browserName == "Microsoft Internet Explorer"||browserName == "Opera") {
+ for (var idx=0; idx < document.forms.length; idx++) {
+ document.forms[idx].attachEvent('onsubmit', function() { updateTextArea(n); });
+ }
+ }
+ else {
+ for (var idx=0; idx < document.forms.length; idx++) {
+ document.forms[idx].addEventListener('submit',function OnSumbmit() { updateTextArea(n); }, true);
+ }
+ }
+}
+
+function formatTextColor(color, n, selected) {
+ document.getElementById('wysiwyg' + n).contentWindow.document.execCommand('forecolor', false, color);
+ document.getElementById('colorpicker' + n).style.display = "none";
+}
+
+function formatBackColor(color, n, selected) {
+ if (browserName == "Microsoft Internet Explorer") {
+ document.getElementById('wysiwyg' + n).contentWindow.document.execCommand('backcolor', false, color);
+ } else {
+ document.getElementById('wysiwyg' + n).contentWindow.document.execCommand('hilitecolor', false, color);
+ }
+ document.getElementById('colorbackpicker' + n).style.display = "none";
+}
+
+function formatFontName(fontname, n, selected) {
+ document.getElementById('wysiwyg' + n).contentWindow.document.execCommand('fontName', false, fontname);
+ document.getElementById('fontpicker' + n).style.display = "none";
+}
+
+function formatSpecialChar(charname, n, selected) {
+ insertHTML(charname, n);
+ document.getElementById('specialpicker' + n).style.display = "none";
+}
+
+function formatHeader(headername, n, selected) {
+ document.getElementById('wysiwyg' + n).contentWindow.document.execCommand('formatBlock', false, '<'+headername+'>');
+ document.getElementById('headerpicker' + n).style.display = "none";
+}
+
+function formatText(id, n, selected) {
+ if(mode==0&&id!='htmlmode') {
+ alert('Function unavailable in "View Source" mode');
+ } else {
+ // When user clicks button make sure it always targets correct textarea
+ document.getElementById("wysiwyg" + n).contentWindow.focus();
+ if(id=="upsize") {
+ var currentFontSize = document.getElementById("wysiwyg"+n).contentWindow.document.queryCommandValue("FontSize");
+ if(currentFontSize == ''||!currentFontSize) currentFontSize = 3; // fudge for FF
+ if(currentFontSize < 7) {
+ var newFontSize = parseInt(currentFontSize) + 1;
+ } else {
+ var newFontSize = currentFontSize;
+ }
+ document.getElementById("wysiwyg" + n).contentWindow.document.execCommand("FontSize", false, newFontSize);
+ }
+ else if(id=="downsize") {
+ var currentFontSize = document.getElementById("wysiwyg"+n).contentWindow.document.queryCommandValue("FontSize");
+ if(currentFontSize > 1) {
+ var newFontSize = currentFontSize - 1;
+ } else {
+ var newFontSize = currentFontSize;
+ }
+ document.getElementById("wysiwyg" + n).contentWindow.document.execCommand("FontSize", false, newFontSize);
+ }
+ else if(id=="forecolor"){
+ if(document.getElementById('colorpicker' + n).style.display == ""){
+ document.getElementById('colorpicker' + n).style.display = "none";
+ } else {
+ document.getElementById('colorpicker' + n).style.display = "";
+ }
+ }
+ else if(id=="backcolor"){
+ if(document.getElementById('colorbackpicker' + n).style.display == ""){
+ document.getElementById('colorbackpicker' + n).style.display = "none";
+ } else {
+ document.getElementById('colorbackpicker' + n).style.display = "";
+ }
+ }
+ else if(id=="font"){
+ if(document.getElementById('fontpicker' + n).style.display == ""){
+ document.getElementById('fontpicker' + n).style.display = "none";
+ } else {
+ document.getElementById('fontpicker' + n).style.display = "";
+ }
+ }
+ else if(id=="specialchar"){
+ if(document.getElementById('specialpicker' + n).style.display == ""){
+ document.getElementById('specialpicker' + n).style.display = "none";
+ } else {
+ document.getElementById('specialpicker' + n).style.display = "";
+ }
+ }
+ else if(id=="headers"){
+ if(document.getElementById('headerpicker' + n).style.display == ""){
+ document.getElementById('headerpicker' + n).style.display = "none";
+ } else {
+ document.getElementById('headerpicker' + n).style.display = "";
+ }
+ }
+ else if(id=="htmlmode"){
+ var getDoc = document.getElementById("wysiwyg" + n).contentWindow.document;
+ if(mode == 1) {
+ if(navigator.appName == "Microsoft Internet Explorer"||browserName == "Opera") {
+ var iHTML = getDoc.body.innerHTML;
+ getDoc.body.innerText = iHTML;
+ } else {
+ var html = document.createTextNode(getDoc.body.innerHTML);
+ getDoc.body.innerHTML = "";
+ getDoc.body.appendChild(html);
+ }
+ getDoc.body.style.fontSize = "12px";
+ getDoc.body.style.fontFamily = "Courier New";
+ mode = 0;
+ } else {
+ if(navigator.appName == "Microsoft Internet Explorer"||browserName == "Opera") {
+ var iText = getDoc.body.innerText;
+ getDoc.body.innerHTML = iText;
+ } else {
+ var html = getDoc.body.ownerDocument.createRange();
+ html.selectNodeContents(getDoc.body);
+ getDoc.body.innerHTML = html.toString();
+ }
+ mode = 1;
+ }
+ }
+ else if(id=="help"){
+ if(document.getElementById('helpbox' + n).style.display == ""){
+ document.getElementById('helpbox' + n).style.display = "none";
+ } else {
+ document.getElementById('helpbox' + n).style.display = "";
+ }
+ }
+ else if(id=="link"){
+ // var browserName = navigator.appName;
+ if (browserName == "Microsoft Internet Explorer") {
+ var target = confirm('Should this link open in a new window?\n\nOK = Open in NEW Window\nCancel = Open in THIS window');
+ document.getElementById("wysiwyg" + n).contentWindow.document.execCommand('createLink',true,' ');
+ if(target == true)
+ {
+ document.getElementById("wysiwyg" + n).contentWindow.document.selection.createRange().parentElement().target="_blank";
+ }
+ } else {
+ insertLink(n);
+ }
+ }
+ else if(id=="insertimage") {
+ // var browserName = navigator.appName;
+ if (browserName == "Microsoft Internet Explorer") {
+ document.getElementById("wysiwyg" + n).contentWindow.document.execCommand(id, true, null);
+ } else {
+ insertImage(n);
+ }
+ }
+ else {
+ document.getElementById("wysiwyg" + n).contentWindow.document.execCommand(id, false, null);
+ }
+ }
+}
+
+function insertHTML(html, n) {
+ // var browserName = navigator.appName;
+ if (browserName == "Microsoft Internet Explorer") {
+ document.getElementById('wysiwyg' + n).contentWindow.document.selection.createRange().pasteHTML(html);
+ }
+
+ else {
+ var div = document.getElementById('wysiwyg' + n).contentWindow.document.createElement("span");
+
+ div.innerHTML = html;
+ var node = insertNodeAtSelection(div, n);
+ }
+}
+
+function insertNodeAtSelection(insertNode, n) {
+ // get current selection
+ var sel = document.getElementById('wysiwyg' + n).contentWindow.getSelection();
+
+ // get the first range of the selection (there's almost always only one range)
+ var range = sel.getRangeAt(0);
+
+ // deselect everything
+ sel.removeAllRanges();
+
+ // remove content of current selection from document
+ range.deleteContents();
+
+ // get location of current selection
+ var container = range.startContainer;
+ var pos = range.startOffset;
+
+ // make a new range for the new selection
+ range = document.createRange();
+
+ if (container.nodeType==3 && insertNode.nodeType==3) {
+
+ // if we insert text in a textnode, do optimized insertion
+ container.insertData(pos, insertNode.nodeValue);
+
+ // put cursor after inserted text
+ range.setEnd(container, pos+insertNode.length);
+ range.setStart(container, pos+insertNode.length);
+ }
+
+ else {
+ var afterNode;
+
+ if (container.nodeType==3) {
+ // when inserting into a textnode we create 2 new textnodes and put the insertNode in between
+ var textNode = container;
+ container = textNode.parentNode;
+ var text = textNode.nodeValue;
+
+ // text before the split
+ var textBefore = text.substr(0,pos);
+
+ // text after the split
+ var textAfter = text.substr(pos);
+
+ var beforeNode = document.createTextNode(textBefore);
+ afterNode = document.createTextNode(textAfter);
+
+ // insert the 3 new nodes before the old one
+ container.insertBefore(afterNode, textNode);
+ container.insertBefore(insertNode, afterNode);
+ container.insertBefore(beforeNode, insertNode);
+
+ // remove the old node
+ container.removeChild(textNode);
+ }
+
+ else {
+ // else simply insert the node
+ afterNode = container.childNodes[pos];
+ container.insertBefore(insertNode, afterNode);
+ }
+
+ range.setEnd(afterNode, 0);
+ range.setStart(afterNode, 0);
+ }
+
+ sel.addRange(range);
+}
+
+function updateTextArea(n) {
+ if(xhtml_out == 1) {
+ document.getElementById(n).value = h2x(document.getElementById("wysiwyg" + n).contentWindow.document.body);
+ } else {
+ document.getElementById(n).value = document.getElementById("wysiwyg" + n).contentWindow.document.body.innerHTML;
+ }
+}
+
+
+function grabSelectedText(n){
+ // var browserName = navigator.appName;
+ var selectedText = '';
+ // for IE
+ if (browserName == "Microsoft Internet Explorer"||browserName == "Opera") {
+ var theText = document.getElementById("wysiwyg" + n).contentWindow.document.selection;
+ if(theText.type =='Text') {
+ var newText = theText.createRange();
+ selectedText = newText.text;
+ }
+ }
+ // for Mozilla/Netscape
+ else {
+ var selectedText = document.getElementById("wysiwyg" + n).contentWindow.document.getSelection();
+ }
+ return selectedText;
+}
+
+/*var myrules = {
+ 'input[type=submit]' : function(element){
+ element.onclick = function(){
+ // Your onclick event goes here - eg;
+ // load a page - do an AJAX etc.;
+ }
+ }
+ };
+
+Behaviour.register(myrules);*/
Added: plugins/WyzzEditor/share/web/static/wyzzstyles/editarea.css
==============================================================================
--- (empty file)
+++ plugins/WyzzEditor/share/web/static/wyzzstyles/editarea.css Sat Jun 14 03:25:31 2008
@@ -0,0 +1,79 @@
+/**************** body and tag styles ****************/
+ body, p {
+ margin-top: 0px;
+ margin-bottom: 30px;
+ background-color: #fefefe;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ color: #333333;
+ font-size: 13px;
+ }
+
+ #container {
+ width: 750px;
+ margin: 0 auto;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 11px;
+ line-height: 1.6em;
+ color: #666666;
+ background-color: #FFFFFF;
+ }
+
+ #container2 {
+ width: 746px;
+ margin: 0 auto;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 11px;
+ line-height: 1.6em;
+ color: #666666;
+ background-color: #FFFFFF;
+ border-bottom: 2px solid #2763A5;
+ }
+
+ pre {
+ font-family: "courier new", sans-serif;
+ font-weight: normal;
+ font-size: 12px;
+ color: #6DA6E2;
+ background-color: #FFFFFF;
+ }
+
+ h1 {
+ font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
+ font-weight: normal;
+ font-size: 32px;
+ color: #6DA6E2;
+ margin-bottom: 30px;
+ background-color: #FFFFFF;
+ }
+
+ h2 {
+ font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
+ font-weight: normal;
+ font-size: 28px;
+ color: #6DA6E2;
+ margin-bottom: 30px;
+ background-color: #FFFFFF;
+ }
+
+ h3 {
+ font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
+ font-weight: normal;
+ font-size: 24px;
+ color: #6DA6E2;
+ margin-bottom: 30px;
+ background-color: #FFFFFF;
+ }
+
+ a {
+ color: #6DA6E2;
+ background-color: #FFFFFF;
+ text-decoration: none;
+ font-weight: bold;
+ }
+
+ a:hover {
+ background-color: #FFFFFF;
+ color: inherit;
+ font-weight: bold;
+ text-decoration: underline;
+ }
\ No newline at end of file
Added: plugins/WyzzEditor/share/web/static/wyzzstyles/style.css
==============================================================================
--- (empty file)
+++ plugins/WyzzEditor/share/web/static/wyzzstyles/style.css Sat Jun 14 03:25:31 2008
@@ -0,0 +1,24 @@
+/* WYSIWYG EDITOR */
+
+/* Toolbar */
+.toolbar { border: 1px solid #999999; height: 24px; background-color:#cccccc; }
+.wyzz_alleditor { display: block; border:1px #aaa solid; width:520px; background:#e0e0e0; padding:2px;position:relative;}
+.wyzz_alleditor div { display:block;}
+
+/* Command Buttons */
+.cmdbutton { width: 20px; height: 20px; border: 1px solid transparent; margin: 0px; padding: 0px; background: transparent; }
+.closebutton { float:right; padding: 2px; }
+.buttonOver { width: 20px; height: 20px; border: 1px solid #999999; margin: 0px; padding: 0px; }
+.separator { width: 2px; border-left: 1px solid #eeeeee; margin: 0px; padding: 0px; }
+
+/* others */
+.colorpicker, .colorbackpicker, .fontpicker, .headerpicker, .helpbox, .linkdialog { position:absolute; width: 216px; background:#eee; display:block; padding:0px; margin-top:0px; border:1px #555 solid;line-height:1.4}
+.specialpicker { position:absolute; width: 216px; background:#eee; display:block; padding-top:20px;padding-left:20px; margin-top:0px; border:1px #555 solid;line-height:1.4}
+.help {margin: 10px; font: 12px bold verdana,helvetica,arial,sans-serif black; text-align:center }
+.help h4 {font: 18px bold verdana,helvetica,arial,sans-serif black; padding-top:10px}
+.colorpicker a, .colorbackpicker a { border:1px #fff solid; height:10px; width:10px; font-size:0.01em; display:block;float:left; margin-right:0px;}
+.colorpicker a:hover, .colorbackpicker a:hover { border:1px #f00 solid;}
+.fontpicker a, .headerpicker a { color:#333;text-decoration:none;background:#eee;}
+.fontpicker a:hover, .headerpicker a:hover, .specialpicker a:hover { color: #666 }
+.specialpicker a { color:#333;font-family:arial;text-decoration:none;background:#eee;height:13px; width:12px;font-size:14px}
+.charbutton { width:12px;height:14px; }
More information about the Jifty-commit
mailing list