Skip to content

Commit

Permalink
Item12795: make sure the directory is there before storing images
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/MathModePlugin@17395 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelDaum authored and MichaelDaum committed Mar 18, 2014
1 parent 6088773 commit 157be05
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 39 deletions.
30 changes: 6 additions & 24 deletions data/System/MathModePlugin.txt
@@ -1,25 +1,8 @@
%META:TOPICINFO{author="ProjectContributor" date="1231348349" format="1.1" version="1.2"}%
<!--

PLEASE DO NOT EDIT THIS TOPIC

It is automatically generated from the subversion repository, and any changes
you make will simply be overwritten the next time a release is generated.

Instead, you could check your fix in, raise a bug in the Bugs web, or mail the author.

NatSkin: grant to have a style with a light background
-->
%META:TOPICINFO{author="ProjectContributor" comment="autosave" date="1356278776" format="1.1" version="1"}%
---+!! %TOPIC%

%TOC%
<table style="float:right">
<tr>
<td><img src="%ATTACHURLPATH%/wikiringlogo40x40.png"></td>
<td><a href="http://wikiring.com" title="Make your Wiki ring!" style="text-decoration:none">
Powered by <br /> <nop>WikiRing Consultants </a>
</td>
</tr>
</table>

---++ Description
This plugin allows you to include mathematics in a topic, with a format
very similar to <nop>LaTeX. The external program =latex2html= is used to
Expand Down Expand Up @@ -136,7 +119,7 @@ All of the below variables can be set in your =LocalSite.cfg= file like this:
$Foswiki::cfg{MathModePlugin}{<Name>} = <value>;
</verbatim>
Some of the below variables can _only_ be set this way, some of the may be
overridden by defining the respective prefrence variable.
overridden by defining the respective preference variable.

| *Name* | *Preference Variable* | *Default* |
| =HashCodeLength= | | 32 |
Expand Down Expand Up @@ -168,11 +151,12 @@ overridden by defining the respective prefrence variable.
* Set SHORTDESCRIPTION = Include <nop>LaTeX formatted math in a topic
-->
| Plugin Author: | Graeme Lufkin, Foswiki:Main/MichaelDaum |
| Copyright &copy;: | 2002 Graeme Lufkin, gwl@u.washington.edu, 2006-2011, Michael Daum http://michaeldaumconsulting.com |
| Copyright &copy;: | 2002 Graeme Lufkin, gwl@u.washington.edu, 2006-2014, Michael Daum http://michaeldaumconsulting.com |
| License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
| Release: | %$RELEASE% |
| Version: | %$VERSION% |
| Change History: | &nbsp; |
| 18 Mar 2014: | make sure the directory is present when caching images |
| 19 Mar 2011: | added Config.spec and DEPENDENCIES to ease installation and configuration; \
improved compatibility to run this plugin on various Foswiki engines |
| 23 Apr 2009: | converted to foswiki plugin |
Expand Down Expand Up @@ -208,5 +192,3 @@ overridden by defining the respective prefrence variable.
| Perl Version: | 5.8 |
| Plugin Home: | Foswiki:Extensions/%TOPIC% |
| Support: | Foswiki:Support/%TOPIC% |

%META:FILEATTACHMENT{name="wikiringlogo40x40.png" attr="h" autoattached="1" comment="" date="1194980363" path="wikiringlogo40x40.png" size="2571" user="ProjectContributor" version="1"}%
19 changes: 11 additions & 8 deletions lib/Foswiki/Plugins/MathModePlugin.pm
Expand Up @@ -19,14 +19,17 @@
package Foswiki::Plugins::MathModePlugin;

use strict;
use vars qw(
$web $topic $VERSION $RELEASE $core %FoswikiCompatibility
$NO_PREFS_IN_TOPIC $SHORTDESCRIPTION
);
$VERSION = '$Rev$';
$RELEASE = '4.02';
$NO_PREFS_IN_TOPIC = 1;
$SHORTDESCRIPTION = 'Include <nop>LaTeX formatted math in your Foswiki pages';
use warnings;

our $web;
our $topic;
our $core;
our $VERSION = '4.03';
our $RELEASE = '4.03';
our $NO_PREFS_IN_TOPIC = 1;
our $SHORTDESCRIPTION = 'Include <nop>LaTeX formatted math in your Foswiki pages';
our %FoswikiCompatibility;

$FoswikiCompatibility{endRenderingHandler} = 1.1;

###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion lib/Foswiki/Plugins/MathModePlugin/Config.spec
Expand Up @@ -25,7 +25,7 @@ $Foswiki::cfg{MathModePlugin}{Latext2Img} = '../tools/MathModePlugin_latex2img';
# as they are obligatory
$Foswiki::cfg{MathModePlugin}{LatexPreamble} = '\usepackage{latexsym}';

# **NUMBER**
# **STRING**
# factor to scale images
$Foswiki::cfg{MathModePlugin}{ScaleFactor} = 1.2;

Expand Down
12 changes: 7 additions & 5 deletions lib/Foswiki/Plugins/MathModePlugin/Core.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2006-2011 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2006-2014 Michael Daum http://michaeldaumconsulting.com
# Copyright (C) 2002 Graeme Lufkin, gwl@u.washington.edu
#
# This program is free software; you can redistribute it and/or
Expand All @@ -15,15 +15,16 @@
# http://www.gnu.org/copyleft/gpl.html
#
###############################################################################

package Foswiki::Plugins::MathModePlugin::Core;

use strict;
use warnings;

use Foswiki::Sandbox ();
use Digest::MD5 qw( md5_hex );
use File::Copy qw( move );
use File::Temp ();
#use FindBin ();
use Foswiki::Sandbox ();

use constant DEBUG => 0; # toggle me

Expand Down Expand Up @@ -208,8 +209,9 @@ sub handleMath {
#writeDebug("hashing '$text' as $hashCode");

# construct url path to image
my $url = Foswiki::Func::getPubUrlPath().'/'.$web.'/'.$topic.
'/'.$this->{imagePrefix}.$hashCode.'.'.$this->{imageType};
my $dir = Foswiki::Func::getPubUrlPath().'/'.$web.'/'.$topic;
mkdir $dir unless -d $dir;
my $url = $dir . '/'.$this->{imagePrefix}.$hashCode.'.'.$this->{imageType};

# return a link to an attached image, which we will create later
my $container = $inlineFlag?'span':'div';
Expand Down
1 change: 0 additions & 1 deletion lib/Foswiki/Plugins/MathModePlugin/MANIFEST
Expand Up @@ -2,5 +2,4 @@ data/System/MathModePlugin.txt 0644
lib/Foswiki/Plugins/MathModePlugin/Config.spec 0644
lib/Foswiki/Plugins/MathModePlugin/Core.pm 0644
lib/Foswiki/Plugins/MathModePlugin.pm 0644
pub/System/MathModePlugin/wikiringlogo40x40.png 0644
tools/MathModePlugin_latex2img 0755
Binary file removed pub/System/MathModePlugin/wikiringlogo40x40.png
Binary file not shown.

0 comments on commit 157be05

Please sign in to comment.