| Porting my blog for the second time, render posts part 6 |
Porting my blog for the second time, render posts part 8 |
Porting my blog for the second time, render posts part 7
This is post #29 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.
The easiest way to remove the deleted posts while parsing the XML files is to avoid adding them in the first place. As soon as we know that an XML file is of a post that has been deleted we just stop processing it. Here is how I did this in my Perl program:
# http://www.jens.malmgren.nl/post/Porting-my-blog-for-the-second-time-render-posts-part-7.aspx
if ($dictBoolFieldToValue{"isdeleted"} == 1)
{
return;
}
Later when I start working on entering new blog posts I will need to come back to the deletion of posts but for now this is sufficient. In my previous post I started resolving the URLs. I prefixed all URLs with the path to the images but that is not sufficient. Only local URLs should have that prefix. To find out what type of URL it is I need to adjust the query of the URL handling routine slightly.
# http://www.jens.malmgren.nl/post/Porting-my-blog-for-the-second-time-render-posts-part-6.aspx
preg_match_all("/({URL:[0-9]+})/", $strContent, $matches, PREG_OFFSET_CAPTURE );
$matches_terms = $matches[1];
for ($i = count($matches_terms) - 1; $i ≻= 0; $i--)
{
$match_term_position = $matches_terms[$i];
$match_term = $match_term_position[0];
$match_position = $match_term_position[1];
$strDataBaseLookupId = preg_replace("/{URL:([0-9]+)}/", "$1", $match_term);
$query = "SELECT FileName, IsLocalURL, Target FROM URL WHERE ID = '$strDataBaseLookupId'";
$result = $mysqli-≻query($query) or die("Error query.." . mysqli_error($mysqli));
$strFileName = "?";
$iIsLocalURL = 1;
$strTarget = "";
if ($row = mysqli_fetch_array($result))
{
$strFileName = $row["FileName"];
$iIsLocalURL = $row["IsLocalURL"];
$strTarget = $row["Target"];
}
if ($iIsLocalURL)
{
$strContent = substr_replace($strContent, '/images/' . $strFileName, $match_position, strlen($match_term));
}
else
{
$strContent = substr_replace($strContent, $strTarget, $match_position, strlen($match_term));
}
}
The query is now also getting IsLocalURL and Target. Then if the URL is a local URL I prefix with the path to the images. Otherwise i insert the full target.
This is working really well but I have more work to do because when I linked to my own pages on my own blog then I need to detect these links and prepare them differently. But that is for another time.














Sounds in the blogsystemNext version of the slideshowLearning Python Part IIILearning Python Part IIImpressionism and beyond. A Wonderful Journey 28 January 2018Fixing unresolved links after editingThis is my summer 2016 blog!Porting my blog for the second time, linksPorting my blog for the second time, editing part 7Porting my blog for the second time, editing part 6Porting my blog for the second time, categories part 3Business cards, version 1Porting my blog for the second time, deployment part 2Not indexed but still missing? Google hypocrisy.A new era: Nikon D5100 DSLR, Nikkor 18 - 55 and 55 - 300!
I moved from Sweden to The Netherlands in 1995.
Here on this site, you find my creations because that is what I do. I create.