Porting my blog for the second time, images part 1 |
Porting my blog for the second time, images part 3 |
Porting my blog for the second time, images part 2
This is post #9 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.
Suppose I downloaded the images from my old blog, then what? Obviously right before everything is ported and done I got blog posts with old URLs that at some point I will need to change one by one so that they point to new locations. But that is not all, I might want to store all images in a special directory or even inside a database or maybe I will find out that after all it was not a good idea to serve the images myself so what do I do then? Instead of trying to get an answer to this question already now I need to have a feature in my new blog engine in such a way that I can administrate the images any way I want at a later stage. Lets call it a future proof handling of URLs.
What would that look like? I got it figured out but it is difficult to explain in a few words so I have to explain my idea in many more words then. Here we go...
In the future when I serve a blog post from the database I could do some processing of the blog text every time before sending the text to the browser. I can create a routine that on the fly walks the post finding all instances of an image URL place holder in the post. Lets say I have a place holder that looks like this {URL :133} where 133 is the ID identifying the place holder. For every URL place holder I could do a lookup in the database of that URL place holder and resolve it into a real and existing URL wherever that will be depending on future needs and implementations.
With this idea I need to store URL information in the database. There can be more images used in a post and a post can have more images. Several posts can have the same image. This is actually the same construction as the categories: A many to many relation between the Post entity and the URL entity.
With this idea I started to think about what else I could do with this structure. I could make an overview page showing images from the blog and when clicking an image I could make it possible to go to the posts where that image was available in. To do this I would need the width and height of the image so that the image overview would get proper aspect ratios. A consequence of this idea is that I need to know the difference between image URLs and anchor URLs.
There are more than just image URLs, there are internal and external links. All internal links in the blog will need to be changed when I am finished porting the blog. External links are no problem as they are but I like the idea that I can verify that they are not broken from time to time without me having to go over the entire blog system post by post. For that I can have a verification system that informs me that "now an external link got broken, it is used in post
When loading the posts into the database with my Perl program I can check if an URL is already present in another post. I can use a simple hash table to accomplish this. If this is the case then I link to an existing URL instead of making a duplicate.
Here I need to stop dream up more work for myself. Instead it is time to start working on this idea as it is now. I need to design the new entities in the jensblog Entity Relation ship diagram.
The field TagName is 'a' for anchors, 'img' for images and so on. If the URL is internal then IsLocalURL is set to 1 and when the URL is external it is 0. This IsLocalURL field has a little brain twist to it because at the time when I parse the old blog most of the URLs to images will point to externally located images. URLs already pointing to my own domain and URLs pointing to Blogger and Google user content will be local and the rest will be external.
So far this URL idea is a lot of talking an not so much workshop. There is work to do. But... that is for next time.
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.