JENS MALMGREN I create, that is my hobby.

Porting my blog for the second time, images part 6

This is post #13 of my series about how I port this blog from Blogengine.NET 2.5 ASPX on a Windows Server 2003 to a Linux Ubuntu server, Apache2, MySQL and PHP. A so called LAMP. The introduction to this project can be found in this blog post https://www.malmgren.nl/post/Porting-my-blog-for-the-second-time-Project-can-start.aspx.

Me superstitious? No way. A whiff of paranoia? Nope. Although this is post #13 of this series? Today at lunch time when I wanted to use my bank card the transaction failed. The card was broken. Had I not been complaining about my bank yesterday? And not just complaining, but telling the story of when my bank card was broken the last time. And now it is broken again. Oh well. This time I called the service desk and they gave me excellent help. Thanks ABN-AMRO! I get the new card in a couple of days.

Now over to my blog porting project. I got two small things to do to finish the images and URL part of the project. This episode will be a short one:

  1. If I already downloaded an image then there is no point of loading it again.
  2. Find all places in the text written up until now with examples of how the URL place holder will look like and break it so that in the future these examples will not be converted on the fly to random URLs.

To check that a file a file is available I need to use the -f routine in Perl:

# Is the URL pointing to a file to be downloaded?
# http://www.jens.malmgren.nl/post/Porting-my-blog-for-the-second-time-images-part-6.aspx
# http://www.jens.malmgren.nl/post/Porting-my-blog-for-the-second-time-images-part-4.aspx
my $strFullPathAndImageFileName = "/usr/local/bin/images/" . $strFileName;
if ($bIsLocalURL && $bIsFileContent && $downloadImages && !$bIsAlreadyLoadedInAnotherPost && !-f $strFullPathAndImageFileName)
{
	print "Get target " . $strTarget . " save to " . $strFileName . "\n";
	my $data = LWP::Simple::get($strTarget);
	open (FH, "≻$strFullPathAndImageFileName");
	binmode (FH);
	print FH $data;
	close (FH);
}

For -f to work I had to have the full path. Since I want to use it on two places I make a new variable of it.

If you are reading this blog in the future after I finished porting it you might have been wondering how it is possible that I write about an URL replacement algorithm and even give examples of how it will look like in the database, such as {URL :20}, but how is that possible because those place holders will be replaced. You might not think about it but I started think about it this morning. So this is kind of funny that this morning I realized that in the future the texts I have written in the past will not display properly in the future unless I do something today.

So what can I do about it? I decided that for examples of the placeholder I need to add a white space before the colon and for real place holders there are no space between URL and the colon. Then what the replacement routine will do is to remove that extra space. Voala!

So now I went over all earlier posts and added that extra space.

This concludes the work on URLs and Images. In my next post I will start walk the posts again.

I was born 1967 in Stockholm, Sweden. I grew up in the small village Vågdalen in north Sweden. 1989 I moved to Umeå to study Computer Science at University of Umeå. 1995 I moved to the Netherlands where I live in Almere not far from Amsterdam.

Here on this site I let you see my creations.

I create, that is my hobby.