From ee70f48ccd5afcdbb21a69619db32b27c7e0675f Mon Sep 17 00:00:00 2001 From: David Newman Date: Thu, 26 Sep 2024 15:07:27 +0000 Subject: [PATCH 1/2] Fixes dynamic vars and previews with branding provided by @ajmetz --- cfg.d/z_pages.pl | 90 ++++++++++- lang/en/phrases/page.xml | 3 + .../static/javascript/auto/65_easy_pages.js | 90 +++++++++++ .../plugins/textpattern/plugin.min.js | 1 + .../plugins/textpattern/version.txt | 22 +++ plugins/EPrints/DataObj/Page.pm | 141 ++++++++++++++++-- plugins/EPrints/MetaField/Page.pm | 139 +++++++++++++++++ workflows/page/default.xml | 69 ++++++++- 8 files changed, 536 insertions(+), 19 deletions(-) create mode 100644 lang/en/static/javascript/auto/65_easy_pages.js create mode 100644 lang/en/static/javascript/plugins/textpattern/plugin.min.js create mode 100644 lang/en/static/javascript/plugins/textpattern/version.txt create mode 100644 plugins/EPrints/MetaField/Page.pm diff --git a/cfg.d/z_pages.pl b/cfg.d/z_pages.pl index be7af69..e399932 100644 --- a/cfg.d/z_pages.pl +++ b/cfg.d/z_pages.pl @@ -28,7 +28,11 @@ $c->{plugins}{"Screen::Page::New"}{params}{disable} = 0; $c->{plugins}{"Screen::Admin::PageCreate"}{params}{disable} = 0; -# make all pages public +# Explicitly specify xapian indexing method +$c->{xapian}->{indexing_methods} = {} unless defined $c->{xapian}->{indexing_methods}; +$c->{xapian}->{indexing_methods}->{'EPrints::MetaField::Page'} = 'text'; + +# Make all pages public push @{$c->{public_roles}}, "+page/view"; # Redirect /page/nice-name to /id/page/x?nice-name @@ -37,7 +41,8 @@ my( %o ) = @_; if( $o{uri} =~ m|^$o{urlpath}/page/([^*]+)| || - $o{uri} =~ m|^$o{urlpath}/(information\|policies\|contact).html| ) + $o{uri} =~ m|^$o{urlpath}/(information\|policies\|contact).html| || + $o{uri} =~ m|^$o{urlpath}/(help)/?$|i ) { my $path = EPrints::DataObj::Page::tidy_path( $1 ); my $session = new EPrints::Session; @@ -69,13 +74,92 @@ }, id => 'easy_pages_nice_url_redirect' ); +###################################################################### +# +# =pod Description for $c->{get_easy_page_substitutions} +# +# =over +# +# =item $repository->config('get_easy_page_substitutions')->($class_name, $repository) +# +# Requires C<$repository>. +# Returns an array of substitutions in array context, +# or an arrayref of substitutions otherwise. +# Substitutions would ideally be an object attribute, +# rather than being defined in this getter, +# and are intended for use by EPrints::DataObj::Page's +# put_here method/subroutine. +# +# =cut +# +###################################################################### + +$c->{get_easy_page_substitutions} = sub +{ + my $class_name = shift; # Only a string - not a blessed object + # - so no $repository available from it. + my $repository = shift; # Subsequently, $repository needs to be passed in. + + my @static_folder = ( + path => "static", + scheme => "https", + host => 1, + ); + + my $static_folder = $repository->get_url(@static_folder) + ->abs( + $repository->config('base_url') + ); + # Upgrade cgi folder to relevant scheme + # as per settings in @cgi_folder array. + +# The commented out approach of path => 'cgi' +# only works when https_cgiroot or http_cgiroot are defined in config, +# and has been commented out and only perl_url is defined in config, +# with a comment saying the base url configs such as perl_url should be depreciated. +# my @cgi_folder = ( +# path => "cgi", +# scheme => "https", +# host => 1, +# ); + + my $cgi_folder = $repository->get_url(@static_folder) + ->abs( + $repository->config('base_url') + )->as_string. + '/cgi'; + # Literally appending the string '/cgi' + # to the end of the static url. + + # The Substitutions we are getting... + my @values_in_order = ( + 'ADMIN-EMAIL' => $repository->config('adminemail'), + 'ARCHIVE-NAME' => $repository->html_phrase('archive_name')->toString, + 'ARCHIVE-URL' => $static_folder->as_string, # Assuming static folder is root! + # Is it always? + # Am I better off getting secure host from config? + 'CGI-URL' => $cgi_folder, + ); + + return wantarray? @values_in_order: + \@values_in_order; +}; + $c->{set_page_automatic_fields} = sub { my( $page ) = @_; if( !$page->is_set( "path" ) ) { - $page->set_value( "path", EPrints::DataObj::Page::tidy_path( $page->get_value( "title" ) ) ); + $page->set_value( + "path", + EPrints::DataObj::Page::tidy_path( + EPrints::DataObj::Page->put_here( + $page->repository, + $page->get_value( "title" ), + ) + ) + ); } else { diff --git a/lang/en/phrases/page.xml b/lang/en/phrases/page.xml index bb494cb..564d7ef 100644 --- a/lang/en/phrases/page.xml +++ b/lang/en/phrases/page.xml @@ -29,4 +29,7 @@ Create a Page A new page has been created. Go to 'Manage records > Pages' to start editing. + +PUT-ADMIN-EMAIL-HERE +PUT-ARCHIVE-NAME-HERE diff --git a/lang/en/static/javascript/auto/65_easy_pages.js b/lang/en/static/javascript/auto/65_easy_pages.js new file mode 100644 index 0000000..e69c7bb --- /dev/null +++ b/lang/en/static/javascript/auto/65_easy_pages.js @@ -0,0 +1,90 @@ + +// Called by EPrints::MetaField::Page::render_input_field_actual +var initTinyMCE_for_easy_pages = function(id,replacements, preview_substitutions){ + + tinymce.init({ + + // Setup: + setup: function (ed) { + ed.on( + + // On Initialisation: + 'init', function (e) { + + // Switch to default font on load: + ed.execCommand("fontName", false, "HelveticaNeueLTPro-Roman"); + this.getDoc().body.style.fontFamily = 'HelveticaNeueLTPro-Roman'; + + } + ); + }, + + // General: + selector: id, + resize: 'both', + height: 500, + width: 700, + //cache_suffix: '?'+ new Date().getTime(), // Doesn't appear to work with 4.6.1 so commented out in favour of manually adding to the end of content_css further below. + relative_urls : true, + //document_base_url : 'http://example.eprints.org/', - as a value unique to each repository, this should be passed in or commented out/left at default. + + // Functionality: + plugins: [ + 'advlist autolink lists link image charmap print anchor', + 'searchreplace visualblocks code fullscreen', // unique preview variation. + 'insertdatetime media table contextmenu paste code textpattern', // textpattern 4.9.1 not in richtext ingredient + // and so added with/alongside easy_pages implementation + ], + + // Custom values for preview_with + preview_substitutions: preview_substitutions, + preview_data_uri_embedded_fonts: '/style/easy_pages_preview_data_uri_embedded_fonts.css?'+ new Date().getTime(), + //preview_substitutions, //shorthand for - preview_substitutions: preview_substitutions, + + // Styling: + content_css: [ + '/style/auto.css?'+ new Date().getTime(), + '/style/easy_pages_imports.css?'+ new Date().getTime(), + ], + //font_css: ['/style/easy-pages-fonts.css'], // Can put @font-face statements here instead of relying on those in main.min.css if desired. + + // Get rid of blue outlines around text you are entering. + inline_boundaries: false, + content_style: ".mce-container {"+ + "border: 0px !important;"+ + "}"+ + "* [contentEditable='true']:focus"+ + "{ outline-style: none ; }", + + + // Fonts available to use/select from UI: + font_formats: "Regular HelveticaNeue LT Pro='HelveticaNeueLTPro-Roman',helvetica;"+ + "Italic HelveticaNeue LT Pro='HelveticaNeueLTPro-It';"+ + "Bold HelveticaNeue LT Pro='HelveticaNeueLTPro-Bd';"+ + "Bold Italic HelveticaNeue LT Pro='HelveticaNeueLTPro-BdIt';"+ + "Generic Sans-Serif Family Font=sans-serif;", + + // UI: + menubar: 'edit insert view format table tools', + toolbar: 'undo redo | insert | styleselect | bold italic | fontselect fontsizeselect | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | code', + link_list: [ + {title: 'PUT-ARCHIVE-NAME-HERE', value: 'PUT-ARCHIVE-URL-HERE'}, + {title: 'PUT-ADMIN-EMAIL-HERE', value: 'PUT-ADMIN-EMAIL-HERE'}, + ], + + // Find and replace patterns + textpattern_patterns: [ + + // Use find and replace values declared here: + //{start: 'INSTANTLY-INSERT-SOMETHING-HERE', replacement: 'something'}, + + // Use values sent from Perl + // - i.e. where + // my %replacements = ( 'INSTANTLY-INSERT-THE-VALUE-FOR-THIS-KEY' => 'something' ); + //{start: 'INSTANTLY-INSERT-THE-VALUE-FOR-THIS-KEY', replacement: replacements['INSTANTLY-INSERT-THE-VALUE-FOR-THIS-KEY']}, + {start: 'INSTANT-ADMIN-EMAIL-LINK', replacement: replacements['INSTANT-ADMIN-EMAIL-LINK']}, + {start: 'INSTANT-ARCHIVE-LINK', replacement: replacements['INSTANT-ARCHIVE-LINK']}, + ] + + }); +}; diff --git a/lang/en/static/javascript/plugins/textpattern/plugin.min.js b/lang/en/static/javascript/plugins/textpattern/plugin.min.js new file mode 100644 index 0000000..4b2d91f --- /dev/null +++ b/lang/en/static/javascript/plugins/textpattern/plugin.min.js @@ -0,0 +1 @@ +!function(){"use strict";var t,n,e,r,a,o=function(t){var n=t,e=function(){return n};return{get:e,set:function(t){n=t},clone:function(){return o(e())}}},i=tinymce.util.Tools.resolve("tinymce.PluginManager"),f=function(t){return function(){return t}},u=f(!1),s=f(!0),c=u,l=s,d=function(){return g},g=(r={fold:function(t,n){return t()},is:c,isSome:c,isNone:l,getOr:e=function(t){return t},getOrThunk:n=function(t){return t()},getOrDie:function(t){throw new Error(t||"error: getOrDie called on none.")},getOrNull:function(){return null},getOrUndefined:function(){return undefined},or:e,orThunk:n,map:d,ap:d,each:function(){},bind:d,flatten:d,exists:c,forall:l,filter:d,equals:t=function(t){return t.isNone()},equals_:t,toArray:function(){return[]},toString:f("none()")},Object.freeze&&Object.freeze(r),r),m=function(e){var t=function(){return e},n=function(){return a},r=function(t){return t(e)},a={fold:function(t,n){return n(e)},is:function(t){return e===t},isSome:l,isNone:c,getOr:t,getOrThunk:t,getOrDie:t,getOrNull:t,getOrUndefined:t,or:n,orThunk:n,map:function(t){return m(t(e))},ap:function(t){return t.fold(d,function(t){return m(t(e))})},each:function(t){t(e)},bind:r,flatten:t,exists:r,forall:r,filter:function(t){return t(e)?a:g},equals:function(t){return t.is(e)},equals_:function(t,n){return t.fold(c,function(t){return n(e,t)})},toArray:function(){return[e]},toString:function(){return"some("+e+")"}};return a},h={some:m,none:d,from:function(t){return null===t||t===undefined?g:m(t)}},p=(a="function",function(t){return function(t){if(null===t)return"null";var n=typeof t;return"object"===n&&Array.prototype.isPrototypeOf(t)?"array":"object"===n&&String.prototype.isPrototypeOf(t)?"string":n}(t)===a}),v=function(t,n){for(var e=[],r=0,a=t.length;rn.start.length?-1:1},(r=O.call(n,0)).sort(e),r;var n,e,r},C=function(t){return{inlinePatterns:k(v(t,x)),blockPatterns:k(v(t,T)),replacementPatterns:v(t,b)}},D=function(n){return{setPatterns:function(t){n.set(C(t))},getPatterns:function(){return n.get().inlinePatterns.concat(n.get().blockPatterns,n.get().replacementPatterns)}}},S=[{start:"*",end:"*",format:"italic"},{start:"**",end:"**",format:"bold"},{start:"***",end:"***",format:["bold","italic"]},{start:"#",format:"h1"},{start:"##",format:"h2"},{start:"###",format:"h3"},{start:"####",format:"h4"},{start:"#####",format:"h5"},{start:"######",format:"h6"},{start:"1. ",cmd:"InsertOrderedList"},{start:"* ",cmd:"InsertUnorderedList"},{start:"- ",cmd:"InsertUnorderedList"}],A=function(t){var n,e,r=(n=t,e="textpattern_patterns",P(n,e)?h.some(n[e]):h.none()).getOr(S);return C(r)},N=tinymce.util.Tools.resolve("tinymce.util.Delay"),R=tinymce.util.Tools.resolve("tinymce.util.VK"),I=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker"),j=tinymce.util.Tools.resolve("tinymce.util.Tools"),w=function(t,n){for(var e=0;e "pageid", type => "counter", sql_counter => "page", sql_index => 1 }, { name => "rev_number", type => "int", required => 1, can_clone => 0, default_value => 1 }, - { name => "title", type => "text", required => 1, input_cols => 80, sql_index => 1 }, + { name => "title", type => "text", required => 1, input_cols => 80, sql_index => 1, render_single_value => "EPrints::DataObj::Page::page_render_text" }, { name => "path", type => "text", required => 0, input_cols => 80, sql_index => 1, render_single_value => "EPrints::DataObj::Page::page_render_path" }, { name => "payload", type => "richtext", required => 0, - render_single_value => "EPrints::DataObj::Page::render_single_value", + render_single_value => sub { $class->render_single_value(@_) }, + #render_input => sub { $class->render_input_field_actual(@_) }, # Not this class. + render_input => "EPrints::MetaField::Page::render_input_field_actual", }, ); } sub create_page { - my( $class, $session, $data ) = @_; + my( $class, $repository, $data ) = @_; - my $page = $class->create_from_data( $session, $data ); + my $page = $class->create_from_data( $repository, $data ); return $page; } sub delete_page { - my( $self, $session ) = @_; + my( $self, $repository ) = @_; $self->delete; } sub render_single_value { - my( $self, $session, $value, $obj ) = @_; - - if( !defined $value ) { return $session->make_doc_fragment; } - my $dom = XML::LibXML->load_html( string => $value, recover => 2 ); + my( $class_name, $repository, $value, $page_string ) = @_; + + if( !defined $page_string ) { return $repository->make_doc_fragment; } # Why set an xhtml object as a default/fallback value for a string? + # Shouldn't $dom fall back to this, + # if XML::LibXML->load_html throws an exception (to be caught by an eval?). + my $dom = XML::LibXML->load_html( + string => $class_name->put_here($repository, $page_string), + recover => 2, + ); my @nodelist = $dom->getElementsByTagName("body"); my $body = $nodelist[0]; @@ -60,6 +68,92 @@ sub render_single_value return $body; } +=pod Description + +=over + +=item $class_name->get_substitutions($repository) + +Requires C<$repository>. +Returns an array of substitutions in array context, +or an arrayref of substitutions otherwise. +Substitutions would ideally be an object attribute, +rather than being defined in this getter, +and are intended for use by the +L<< /"$class_name->put_here($repository, $text, 'PLACEHOLDER-TEXT' => 'replacement text')" >> +subroutine. + +=cut + + +sub get_substitutions { + my $class_name = shift; # Only a string - not a blessed object + # - so no $repository available from it. + my $repository = shift; # Subsequently, $repository needs to be passed in. + + return $repository->config('get_easy_page_substitutions')->($class_name, $repository); # substitutions set at archive level config - see cfg.d/z_pages.pl +} + + +=pod Description + +=item $class_name->put_here($repository, $text, 'PLACEHOLDER-TEXT' => 'replacement text') + +Takes a $repository or $session +because these cannot be retrieved from a non-blessed class name string, +and then takes a $text template with C<< PUT-PLACEHOLDER-TEXT-HERE >> placemarkers, +followed by C<< 'PLACEHOLDER-TEXT' => 'replacement text' >> key value pairs. + +Finds placeholders and replaces them with values. + +Returns a copy of the $text template, with the values put in place. + +=back + +=cut + +sub put_here { + + #Initial values: + my $class_name = shift; + my $repository = shift; + my $text = shift; + my @values_in_order = @_; + @values_in_order = $class_name->get_substitutions($repository) unless @values_in_order; + @values_in_order = () unless @values_in_order; + my %values = @values_in_order; + + #For each value in order of array... + foreach my $current_value (@values_in_order) { + + $repository->log( + '[EPrints::DataObj::Page::put_here] - '. + 'Current value undefined warning: '. + "$text. taking values: ". + EPrints->dump(@values_in_order) + ) unless defined($current_value); + + #If current value is a hash key... + if (exists $values{$current_value}) { + + my $placeholder= $current_value; + + my $find = qr/PUT-$placeholder-HERE/; + + my $replace = $values{$placeholder}; + + #Find and Replace within Text: + $text =~ s/$find/$replace/g; + + } + + }; + + #Return the final result: + return $text; + +} + sub tidy_path { my( $path ) = @_; @@ -83,12 +177,33 @@ sub tidy_path sub page_render_path { - my( $session, $field, $value, $page ) = @_; - - my $link = $session->make_element( "a", href => "/page/" . $value ); - $link->appendChild( $session->make_text( $page->get_value( "title" ) ) ); + my( $repository, $field, $value, $page ) = @_; + + my $link = $repository->make_element( "a", href => "/page/" . $value ); + $link->appendChild( + $repository->make_text( + EPrints::DataObj::Page->put_here( + $repository, + $page->get_value( "title" ), + ) + ) + ); return $link; } +sub page_render_text +{ + + my( $repository, $field, $value, $page ) = @_; + + return $repository->make_text( + EPrints::DataObj::Page->put_here( + $repository, + $page->get_value( "title" ), + ) + ); + +} + 1; diff --git a/plugins/EPrints/MetaField/Page.pm b/plugins/EPrints/MetaField/Page.pm new file mode 100644 index 0000000..0090a74 --- /dev/null +++ b/plugins/EPrints/MetaField/Page.pm @@ -0,0 +1,139 @@ +###################################################################### +# +# EPrints::MetaField::Page; +# +###################################################################### +# +# +###################################################################### + +=pod + +=head1 NAME + +B - Input Field Rendering for Easy Pages. + +=head1 DESCRIPTION + +Input Field Rendering for Easy Pages. Modified from Rich Text ingredient original. + +=cut + +package EPrints::MetaField::Page; + +use strict; +use warnings; +use English qw( -no_match_vars ); + +BEGIN +{ + our( @ISA ); + + @ISA = qw( EPrints::MetaField::Longtext ); +} + +use EPrints::MetaField::Longtext; + +sub render_input_field_actual +{ + my( $self, $repository, $value, $dataset, $staff, $hidden_fields, $obj, $basename ) = @_; + + my $frag = $self->SUPER::render_input_field_actual( @_[1..$#_] ); + + my %replacements = ( + # Provide any hash data desired for use with TinyMCE textpattern plugin. + 'INSTANT-ADMIN-EMAIL-LINK' => $repository->html_phrase('EPrints/MetaField/Page:render_input_field_actual:replacements:instant_admin_email_link')->toString, + 'INSTANT-ARCHIVE-LINK' => $repository->html_phrase('EPrints/MetaField/Page:render_input_field_actual:replacements:instant_archive_link')->toString, + ); + + my %preview_substitutions = EPrints::DataObj::Page->get_substitutions($repository); + #$repository->log( + # '[EPrints::MetaField::Page::render_input_field_actual] - '. + # 'Substitutions are...'. + # "\n". + # EPrints->dump(%substitutions) + #); + #warn 'Subs:'.EPrints->dump(join "",%substitutions); + #EPrints->abort('Premature end.'); + + #$frag->appendChild( $repository->make_element( "script", src => "//code.jquery.com/jquery-1.12.4.js" ) ); + $frag->appendChild( $repository->make_element( "script", src=> "/javascript/tinymce.min.js" ) ); + $frag->appendChild( + $repository->make_javascript( + 'jQuery( document ).ready('. + 'function($){ '. + 'initTinyMCE_for_easy_pages('. + + # Name/id of html element + # to become the TinyMCE input window + # - i.e. '#c3_payload' + # - requires hash prefix as added below: + '"#' . $basename .'",'. + + # Javascript object with attributes based on %replacements or empty: + '{'. + ( + %replacements? join ( + ',', + map { "'$ARG': '$replacements{$ARG}'" } + (keys %replacements) + ): + q{} + ). + '},'. + # Javascript object with attributes based on %preview_substitutions or empty: + '{'. + ( + %preview_substitutions? join ( + ',', + map { "'$ARG': '$preview_substitutions{$ARG}'" } + (keys %preview_substitutions) + ): + q{} + ). + '}'. + ');'. + '}'. + ');', + ) + ); + + return $frag; +} + +###################################################################### +1; + +=head1 COPYRIGHT + +=for COPYRIGHT BEGIN + +Copyright 2024 University of Southampton. +EPrints 3.4 is supplied by EPrints Services. + +This software may be used with permission and must not be redistributed. +http://www.eprints.org/eprints-3.4/ + +=for COPYRIGHT END + +=head1 LICENSE + +=for LICENSE BEGIN + +This file is part of EPrints 3.4 L. + +EPrints 3.4 and this file are released under the terms of the +GNU Lesser General Public License version 3 as published by +the Free Software Foundation unless otherwise stated. + +EPrints 3.4 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 EPrints 3.4. +If not, see L. + +=for LICENSE END + diff --git a/workflows/page/default.xml b/workflows/page/default.xml index 8f45edb..dac51a8 100644 --- a/workflows/page/default.xml +++ b/workflows/page/default.xml @@ -1,9 +1,8 @@ - + -

How to use EASY PAGES

@@ -12,12 +11,76 @@

With the easy pages tool you can easily create a page to provide information.

1. Provide a title for the page, this will appear at the top of the page as a heading.

2. Add the page contents and use the document formatting tool to organise the information appropriately.

-

3. Lastly, enter a path name. This will be the reposities URL with /path/the-name-you-choose appeneded.

+

3. Lastly, enter a path name. This will be the repositories URL with /page/the-name-you-choose appended.


Once you have finished you can click Save and Return, this will provide you with a link to the finished page.

Use the link just as you would use a normal URL link. For example, it could be added to the repository home page, added to a workflow field description, sent out in an email etc.

Pages can be managed via 'Manage records > Pages'. This is limited to Admin users only.

All created pages are public. A list of pages can be accessed via REPO-URL/pages.html

+
+

Dynamic variables available to you:

+ +

Type placeholders when you want dynamic values shown in their place.

+ +

Use the placeholders anywhere you would like dynamic content to appear.

+

You can preview the dynamic content using View->Preview on the menubar, or the Preview icon on the toolbar.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
PlaceholderCurrent valueWhere Value is Defined:
PUT-ADMIN-EMAIL-HERERepository Configuration
PUT-ARCHIVE-NAME-HEREPhrase Editor
PUT-ARCHIVE-URL-HERERepository Configuration
PUT-CGI-URL-HERERepository Configuration
+ +
+ +

Instant Substitutions:

+ +

Type instant substitutions when you want something to appear instantly.

+ +

These are essentially convenient shortcuts.

+ + + + + + + + + + + + + + +
Typing this...Does this...
INSTANT-ADMIN-EMAIL-LINKCreates an admin email link.
INSTANT-ARCHIVE-LINKCreates an archive link.
+ +

Where these also use placeholders, you can preview their dynamic content using View->Preview on the menubar, or the Preview icon on the toolbar.

+
From 5042aed1d1f1ca6708ee325f3e40442c21b57f29 Mon Sep 17 00:00:00 2001 From: David R Newman Date: Thu, 26 Sep 2024 16:36:32 +0000 Subject: [PATCH 2/2] Re-adds preview. Adds placeholder for importing non-auto CSS needed for previews. --- lang/en/static/javascript/auto/65_easy_pages.js | 4 ++-- .../plugins/preview_with_css_branding/plugin.min.js | 1 + .../javascript/plugins/preview_with_css_branding/version.txt | 1 + lang/en/static/style/easy_pages_imports.css | 0 4 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 lang/en/static/javascript/plugins/preview_with_css_branding/plugin.min.js create mode 100644 lang/en/static/javascript/plugins/preview_with_css_branding/version.txt create mode 100644 lang/en/static/style/easy_pages_imports.css diff --git a/lang/en/static/javascript/auto/65_easy_pages.js b/lang/en/static/javascript/auto/65_easy_pages.js index e69c7bb..33d1f15 100644 --- a/lang/en/static/javascript/auto/65_easy_pages.js +++ b/lang/en/static/javascript/auto/65_easy_pages.js @@ -31,7 +31,7 @@ var initTinyMCE_for_easy_pages = function(id,replacements, preview_substitutions // Functionality: plugins: [ 'advlist autolink lists link image charmap print anchor', - 'searchreplace visualblocks code fullscreen', // unique preview variation. + 'searchreplace visualblocks code fullscreen preview_with_css_branding', // unique preview variation. 'insertdatetime media table contextmenu paste code textpattern', // textpattern 4.9.1 not in richtext ingredient // and so added with/alongside easy_pages implementation ], @@ -66,7 +66,7 @@ var initTinyMCE_for_easy_pages = function(id,replacements, preview_substitutions // UI: menubar: 'edit insert view format table tools', - toolbar: 'undo redo | insert | styleselect | bold italic | fontselect fontsizeselect | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | code', + toolbar: 'undo redo | insert | styleselect | bold italic | fontselect fontsizeselect | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | code preview_with_css_branding', link_list: [ {title: 'PUT-ARCHIVE-NAME-HERE', value: 'PUT-ARCHIVE-URL-HERE'}, {title: 'PUT-ADMIN-EMAIL-HERE', value: 'PUT-ADMIN-EMAIL-HERE'}, diff --git a/lang/en/static/javascript/plugins/preview_with_css_branding/plugin.min.js b/lang/en/static/javascript/plugins/preview_with_css_branding/plugin.min.js new file mode 100644 index 0000000..d03b240 --- /dev/null +++ b/lang/en/static/javascript/plugins/preview_with_css_branding/plugin.min.js @@ -0,0 +1 @@ +!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i",buttons:{text:"Close",onclick:function(){this.parent().parent().close()}},onPostRender:function(){var b,f="";f+='',c.each(a.contentCSS,function(b){f+=''});var g=d.body_id||"tinymce";g.indexOf("=")!=-1&&(g=a.getParam("body_id","","hash"),g=g[a.id]||g);var h=d.body_class||"";h.indexOf("=")!=-1&&(h=a.getParam("body_class","","hash"),h=h[a.id]||"");var i=' ',j=a.settings.directionality?' dir="'+a.settings.directionality+'"':"";let filteredContent = a.getContent();let substitutions = a.getParam("preview_substitutions", {});for(let currentKey in substitutions){let pattern=new RegExp (`PUT-${currentKey}-HERE`, 'g');filteredContent=filteredContent.replace(pattern, substitutions[currentKey])};if(b=""+f+''+'"+filteredContent+i+"",e)this.getEl("body").firstChild.src="data:text/html;charset=utf-8,"+encodeURIComponent(b);else{var k=this.getEl("body").firstChild.contentWindow.document;k.open(),k.write(b),k.close()}}})}),a.addButton("preview_with_css_branding",{title:"Preview",icon:"preview",cmd:"mcepreview_with_css_branding"}),a.addMenuItem("preview_with_css_branding",{text:"Preview",cmd:"mcepreview_with_css_branding",context:"view"})}),function(){}}),d("0")()}(); diff --git a/lang/en/static/javascript/plugins/preview_with_css_branding/version.txt b/lang/en/static/javascript/plugins/preview_with_css_branding/version.txt new file mode 100644 index 0000000..767e54a --- /dev/null +++ b/lang/en/static/javascript/plugins/preview_with_css_branding/version.txt @@ -0,0 +1 @@ +Preview plugin based on TinyMCE 4.6.1 Production plugin, with customisations. diff --git a/lang/en/static/style/easy_pages_imports.css b/lang/en/static/style/easy_pages_imports.css new file mode 100644 index 0000000..e69de29