Skip to content

Commit

Permalink
Item13276: remove some non-macros from the plate
Browse files Browse the repository at this point in the history
... when left over - such as REVISIONS, REVTITLE, REVARG, QUERYPARAMSTRING
  • Loading branch information
MichaelDaum committed Feb 23, 2015
1 parent ba97fb0 commit 427cf81
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
7 changes: 4 additions & 3 deletions data/System/PageOptimizerPlugin.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="pending" date="1332146098" format="1.1" version="2"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1424701144" format="1.1" version="1"}%
---+!! %TOPIC%
%SHORTDESCRIPTION%

Expand All @@ -25,7 +25,7 @@ The following list of transformations is performed:
* style blocks of type =text/css= don't need a =type= argument anymore as
that's the default in html5
* citations produced by foswiki's =>= at the beginning of a line are
collapsed into one =<div>= block of type =foswikiCite=, or =foswikiBlockCite=
collapsed into one =<div>= block of type =foswikiCite=, or =foswikiBlockQuote=
when there are multiple citation lines following
* =<verbatim>= blocks contained in template comments are rewritten to look nicer
for better readability of view templates coded in topics
Expand Down Expand Up @@ -73,11 +73,12 @@ the =refresh= url parameter:
-->

| Author(s): | Michael Daum|
| Copyright: | © 2012-2014 Michael Daum http://michaeldaumconsulting.com |
| Copyright: | © 2012-2015 Michael Daum http://michaeldaumconsulting.com |
| License: | [[http://www.gnu.org/licenses/gpl.html][GPL (Gnu General Public License)]] |
| Release: | %$RELEASE% |
| Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 23 Feb 2015: | remove some bogus non-macros if left over, such as REVISIONS, REVTITLE, REVARG, QUERYPARAMSTRING |
| 04 Apr 2014: | flag rest handlers that don't require authentication |
| 30 May 2013: | fixed handling if IE conditional comments; no js or css optimization by default, only html cleanup |
| 07 May 2012: | added feature to make at least some &lt;p>s real paragraphs for improved typographics |
Expand Down
20 changes: 13 additions & 7 deletions lib/Foswiki/Plugins/PageOptimizerPlugin.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2012-2014 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2012-2015 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -24,8 +24,8 @@ use Digest::MD5 ();
use URI ();
use Compress::Zlib ();

our $VERSION = '0.11';
our $RELEASE = '0.11';
our $VERSION = '1.00';
our $RELEASE = '23 Feb 2015';
our $SHORTDESCRIPTION = 'Optimize html markup, as well as js and css';
our $NO_PREFS_IN_TOPIC = 1;
our $pluginName = 'PageOptimizerPlugin';
Expand Down Expand Up @@ -63,11 +63,17 @@ sub completePageHandler {
writeDebug("completePageHandler()");

# clean up
use bytes;
$text =~ s/<!--\s+-->//g; # remove this in any case
$text =~ s/(<\/html>).*?$/$1/gs;

# remove non-macros and leftovers
$text =~ s/%(?:REVISIONS|REVTITLE|REVARG|QUERYPARAMSTRING)%//g;
$text =~ s/^%META:\w+{.*}%$//gm;

if ($Foswiki::cfg{PageOptimizerPlugin}{CleanUpHTML}) {
use bytes;
$text =~ s/<!--[^\[<].*?-->//g;
$text =~ s/^\s*$//gms;
$text =~ s/(<\/html>).*?$/$1/gs;

# EXPERIMENTAIL: make at least some <p>s real paragraphs
if (1) {
Expand All @@ -83,8 +89,8 @@ sub completePageHandler {
$text =~ s/<style +type=["']text\/css["']/<style/g;
$text =~ s/<link (.*?rel=["']stylesheet["'].*?)\/>/_processLinkStyle($1)/ge;

no bytes;
}
no bytes;

my $query = Foswiki::Func::getCgiQuery();
my $refresh = $query->param("refresh") || '';
Expand Down Expand Up @@ -120,7 +126,7 @@ sub _processCite {
$block =~ s/^>/<span class='foswikiCiteChar'>&gt;<\/span>/gm;
#$block =~ s/\n/<br \/>\n/g;

my $class = ($block =~ /\n/)?'foswikiBlockCite':'foswikiCite';
my $class = ($block =~ /\n/)?'foswikiBlockQuote':'foswikiCite';

return "<div class='$class'>".$block."</div>";
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Foswiki/Plugins/PageOptimizerPlugin/Stats.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2012 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2012-2015 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand Down

0 comments on commit 427cf81

Please sign in to comment.