How to continue to use Domino as part of a new blog-system

How to continue to use Domino as part of a new blog-system

27th October 2022 by Admin

The web site that you are reading this article on, partly run on a different system than my old and trustful Domino-server.

The old system was using the Blogsphere V3 system created by Declan Lynch many years ago. The latest incarnation of the Blogsphere (version 4) is based on XPages.

 

Of course you could use the Lotus Notes-client to enter content, but just as important, you could use other content-clients such as Word and Windows Live Writer (more on this later), via the MetaWebLog API implementation within the Blogsphere template. This was based on some xml-rpc java code that was extended to interact with the Domino-database directly. For all those fullstack-people out there, it is cool to think about how Notes and Domino allowed to mingle all kinds of technologies into a single file NoSQL-database and has done so for almost 30 years. In my opinion it shows how innovation and development may go in circles Smile

I mentioned Windows Live Writer as a blog-content client. That was Microsofts take on writing a little, but very effective, tool allowing users to write their blog-content in a Word-like environment. It had powerful photo-features and works fine offline. Luckily for the users, Microsoft open sourced the code as Open Live Writer. This means that you can even download the source code and build it yourself. If you for fun search up best blog-content clients for Windows, you still see  Windows Live Writer as one of the top-rated blog-clients even though if was discontinued by Microsoft in 2017.

In this article I will show you how I can continue to use Open Live Writer to write my content onto the new Content Management System (CMS) I plan to use The XT-CMS. XT-CMS is based on PHP and knows nothing about Domino. Neither does the latest version (3.1.2 at the time of writing) have any content API for tools like Open Live Writer.

That is why I modified the xml-rpc agent within the Blogsphere database, to export both images and modified HTML coming from Open Live Writer, for direct use within XT-CMS!

Below you some original content being entered in the Open Live Writer:

SNAGHTML1d0e147

When I press Publish above, the content is sent to the Blogsphere blog on Domino. Below you see what it looks like there:

SNAGHTML1d1dd1b

As you see, the quality is very good. Via the extra code I go into detail about below, I end up with some exported image files and a modified HTML file looking like this:

SNAGHTML1d3ce3d

This can be copied to the clipboard and entered directly into XT-CMS Article (or wherever you want the text, in Categories, Products etc), like this:

SNAGHTML1daa7a8

Remember, you can click on the image above to see the original image

Click OK on the Source Code-dialog box and you instantly see the result, like this:

SNAGHTML1dbc906

Now you can add whatever extras you need on the page, and control whether to actually publish the page or not. Below you see the end-result on my website:

SNAGHTML1dd8f5f

Good enough for me!

Note that my current solution is semi-automatic in the way that I work with Open Live Write just as I would. Whenever I publish something from Open Live Writer, that is uploaded to an intermediate Blogsphere-database, which automatically export all images from the Open Live Writer-content to the images-folders on XM-CMS. Additionally it exports the HTML, with the modified references to the exported images. This HTML can then be inserted directly into the content pages in XT-CMS and published from there.

The changes on the Domino-side

I needed some code to kick in whenever the xml-rpc code woke to life, due to Open Live Writer publishing stuff to it. This means that my code is called directly after a successful publishing-event. This removes the need to have scheduled agents to post-process a publishing event.

My additional code loops over the HTML and find any references to imagery. In essence these are stored a anchor tags () or image tags (). Since the existing xml-rpc code in Blogsphere automatically will create a separate so-called QuickImage for every graphic element in an Blog Entry, my idea was to find these QuickImage-documents and simply export the raw image-file directly onto the folder structure within XT-CMS. This is possible because the XT-CMS lives on the same server as my Domino-server. When all images are exported, I modify the incoming HTML from Open Live Writer (which now will live in a Notes-document within Blogpshere), and export the HTML as a file which I grab and paste into a XT-CMS content page.

Below I will highlight some of the code on Domino.

The MetaWebLog-API in the xml-rpc java agent

Remember, whenever Open Live Writer publishes anything, the first code to be called on the Domino side, is the xml-rpc agent. Within that java-agent, I have added the following code to call the next agent. Below you see a snippet of that java code:

SNAGHTML63fbf2

The code above grabs the upcoming LotusScript-agent agnAutoConvertBlogEntryToXTCMS and passes the NoteID of the currently created document in the Blogsphere-database. This is at the very end of the xml-rpc processing, so both the blog entry itself has been saved as a NotesDocument, and all the images has been stored as QuickImages. The code above execute the next agent, and let it run through before it continues the last bits and pieces in the java-code.

The (agnAutoConvertBlogEntryToXTCMS) agent

This agent is using the script library class:CExportEntryToHTML which contains all the pepper where I scan for imagery and export files etc. This agent is constructed in a way that it will be called directly from the Java agent xml-rpc, with the current NoteID as the parameter. You see the complete code below:

SNAGHTML65bf0e

The code gets the current NoteID (ie the ID of the document that just has been processed by the preceding xml-rpc agent) for the agent-variable.   As you see above, the entrypoint for the code in my CExportEntryToHTML is ExportByNoteID.

Below you see that LotusScript-code within its LotusScript-class:

SNAGHTML1b6e740

Note that using a class, is just my way of writing Notes-applications. I like the way classes can inherit from other classes, and how they encapsulate code in clear objects. The same stuff could have been written in many other ways. Ok, the ExportByNoteID grabs the document by its NoteID, and end up calling the next method ExportByUNID (UNID = Universal Note ID, the GUID-like ID of a document). Here you see all that code (remember, you can click on the image to see the larger version):

SNAGHTML1bd1817

Marked by 1, I get the document with the blog-content by its UNID.

Marked by 2, I extract the content of the two main HTML-fields from that document, namely the fields FinalHTML and FinalHTMLMore. These fields are then combined into one.

In the block marked by 3, I call the method FindAllHTMLTagsByNames twice, to first find any images within img-tags in the HTML. Next Ill do the same with a-tags. Remember that every image coming from Open Live Write is stored in its own QuickImage-document in the database. The FindAllHTMLTagsByNames-method grab that document and simply extract the stored image file directly onto the folder-structure of XT-CMS. This means that the images are ready already!

In block marked by 4, I loop through my list of images found in block 3, and simply replace the old image URL with the new image URL. This is where the Blogsphere image URL is converted to XT-CMS URLs.

In the block marked by 5, I store the changed HTML text in a new rich text field named XTCMS within the very same document that the previous xml-rpc java agent created. This is the one of my favorite super-powers of Domino and its NoSQL-design, where it is soo easy to just add stuff without having to write schemas etc.

Finally I also output a text file containing the modified HTML with all images referencing the exported images within the XT-CMS-folder:

SNAGHTML1c52501

I hope this article gave you some ideas on how to keep an old working-horse like Domino doing powerful stuff for you.


Login to post a comment

How to continue to use Domino as part of a new blog-system

How to continue to use Domino as part of a new blog-system

27th October 2022 by Admin

The web site that you are reading this article on, partly run on a different system than my old and trustful Domino-server.

The old system was using the Blogsphere V3 system created by Declan Lynch many years ago. The latest incarnation of the Blogsphere (version 4) is based on XPages.

 

Of course you could use the Lotus Notes-client to enter content, but just as important, you could use other content-clients such as Word and Windows Live Writer (more on this later), via the MetaWebLog API implementation within the Blogsphere template. This was based on some xml-rpc java code that was extended to interact with the Domino-database directly. For all those fullstack-people out there, it is cool to think about how Notes and Domino allowed to mingle all kinds of technologies into a single file NoSQL-database and has done so for almost 30 years. In my opinion it shows how innovation and development may go in circles Smile

I mentioned Windows Live Writer as a blog-content client. That was Microsofts take on writing a little, but very effective, tool allowing users to write their blog-content in a Word-like environment. It had powerful photo-features and works fine offline. Luckily for the users, Microsoft open sourced the code as Open Live Writer. This means that you can even download the source code and build it yourself. If you for fun search up best blog-content clients for Windows, you still see  Windows Live Writer as one of the top-rated blog-clients even though if was discontinued by Microsoft in 2017.

In this article I will show you how I can continue to use Open Live Writer to write my content onto the new Content Management System (CMS) I plan to use The XT-CMS. XT-CMS is based on PHP and knows nothing about Domino. Neither does the latest version (3.1.2 at the time of writing) have any content API for tools like Open Live Writer.

That is why I modified the xml-rpc agent within the Blogsphere database, to export both images and modified HTML coming from Open Live Writer, for direct use within XT-CMS!

Below you some original content being entered in the Open Live Writer:

SNAGHTML1d0e147

When I press Publish above, the content is sent to the Blogsphere blog on Domino. Below you see what it looks like there:

SNAGHTML1d1dd1b

As you see, the quality is very good. Via the extra code I go into detail about below, I end up with some exported image files and a modified HTML file looking like this:

SNAGHTML1d3ce3d

This can be copied to the clipboard and entered directly into XT-CMS Article (or wherever you want the text, in Categories, Products etc), like this:

SNAGHTML1daa7a8

Remember, you can click on the image above to see the original image

Click OK on the Source Code-dialog box and you instantly see the result, like this:

SNAGHTML1dbc906

Now you can add whatever extras you need on the page, and control whether to actually publish the page or not. Below you see the end-result on my website:

SNAGHTML1dd8f5f

Good enough for me!

Note that my current solution is semi-automatic in the way that I work with Open Live Write just as I would. Whenever I publish something from Open Live Writer, that is uploaded to an intermediate Blogsphere-database, which automatically export all images from the Open Live Writer-content to the images-folders on XM-CMS. Additionally it exports the HTML, with the modified references to the exported images. This HTML can then be inserted directly into the content pages in XT-CMS and published from there.

The changes on the Domino-side

I needed some code to kick in whenever the xml-rpc code woke to life, due to Open Live Writer publishing stuff to it. This means that my code is called directly after a successful publishing-event. This removes the need to have scheduled agents to post-process a publishing event.

My additional code loops over the HTML and find any references to imagery. In essence these are stored a anchor tags () or image tags (). Since the existing xml-rpc code in Blogsphere automatically will create a separate so-called QuickImage for every graphic element in an Blog Entry, my idea was to find these QuickImage-documents and simply export the raw image-file directly onto the folder structure within XT-CMS. This is possible because the XT-CMS lives on the same server as my Domino-server. When all images are exported, I modify the incoming HTML from Open Live Writer (which now will live in a Notes-document within Blogpshere), and export the HTML as a file which I grab and paste into a XT-CMS content page.

Below I will highlight some of the code on Domino.

The MetaWebLog-API in the xml-rpc java agent

Remember, whenever Open Live Writer publishes anything, the first code to be called on the Domino side, is the xml-rpc agent. Within that java-agent, I have added the following code to call the next agent. Below you see a snippet of that java code:

SNAGHTML63fbf2

The code above grabs the upcoming LotusScript-agent agnAutoConvertBlogEntryToXTCMS and passes the NoteID of the currently created document in the Blogsphere-database. This is at the very end of the xml-rpc processing, so both the blog entry itself has been saved as a NotesDocument, and all the images has been stored as QuickImages. The code above execute the next agent, and let it run through before it continues the last bits and pieces in the java-code.

The (agnAutoConvertBlogEntryToXTCMS) agent

This agent is using the script library class:CExportEntryToHTML which contains all the pepper where I scan for imagery and export files etc. This agent is constructed in a way that it will be called directly from the Java agent xml-rpc, with the current NoteID as the parameter. You see the complete code below:

SNAGHTML65bf0e

The code gets the current NoteID (ie the ID of the document that just has been processed by the preceding xml-rpc agent) for the agent-variable.   As you see above, the entrypoint for the code in my CExportEntryToHTML is ExportByNoteID.

Below you see that LotusScript-code within its LotusScript-class:

SNAGHTML1b6e740

Note that using a class, is just my way of writing Notes-applications. I like the way classes can inherit from other classes, and how they encapsulate code in clear objects. The same stuff could have been written in many other ways. Ok, the ExportByNoteID grabs the document by its NoteID, and end up calling the next method ExportByUNID (UNID = Universal Note ID, the GUID-like ID of a document). Here you see all that code (remember, you can click on the image to see the larger version):

SNAGHTML1bd1817

Marked by 1, I get the document with the blog-content by its UNID.

Marked by 2, I extract the content of the two main HTML-fields from that document, namely the fields FinalHTML and FinalHTMLMore. These fields are then combined into one.

In the block marked by 3, I call the method FindAllHTMLTagsByNames twice, to first find any images within img-tags in the HTML. Next Ill do the same with a-tags. Remember that every image coming from Open Live Write is stored in its own QuickImage-document in the database. The FindAllHTMLTagsByNames-method grab that document and simply extract the stored image file directly onto the folder-structure of XT-CMS. This means that the images are ready already!

In block marked by 4, I loop through my list of images found in block 3, and simply replace the old image URL with the new image URL. This is where the Blogsphere image URL is converted to XT-CMS URLs.

In the block marked by 5, I store the changed HTML text in a new rich text field named XTCMS within the very same document that the previous xml-rpc java agent created. This is the one of my favorite super-powers of Domino and its NoSQL-design, where it is soo easy to just add stuff without having to write schemas etc.

Finally I also output a text file containing the modified HTML with all images referencing the exported images within the XT-CMS-folder:

SNAGHTML1c52501

I hope this article gave you some ideas on how to keep an old working-horse like Domino doing powerful stuff for you.


Login to post a comment