2019-01-08 Archiving Google Plus Communities

LS has kindly sent me an archive of the One Page Dungeon Contest Community on Google+. I want to try and transform it into a static HTML file. It comes in three formats: JSON, Blogger RSS, Wordpress RSS. I figured that the Blogger format looked liked the easiest solution and I took some XSLT and CSS I had lying around and got to work.

It’s not too bad. See the repository which includes an index.html. My problem now is that I’d like to add all the comments after each post – but they’re out of order! All the comments are simply entries at the end, linked by URLs and elements and all that.

Do you know your way around XSLT and can help me out? I need help in that section around line 106 of the XSLT. I think this is where I want the replies...

The code I have already generates the HTML for posts, but the comments elude me.

First, we have a bunch of posts. Lots of stuff omitted for brevity.

    <atom:category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/blogger/2008/kind#post"/>
    <atom:link rel="self" type="application/atom+xml" href="https://www.blogger.com/feeds/4441510360404961996/posts/default/0"/>
    <thread:link xmlns:thread="http://purl.org/syndication/thread/1.0">3</ns1:link>

And then, after all the posts are done, we have all the comments. So for every comment, I need a rule that pulls in all the comments with a matching in-reply-to tag.

    <atom:category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/blogger/2008/kind#comment"/>
    <atom:link rel="self" type="application/atom+xml" href="https://www.blogger.com/feeds/4441510360404961996/0/comments/default/1"/>
    <atom:link rel="alternate" type="text/html" href="https://google-plus-exporter.blogspot.com/2019/01/no-archive.html?showComment=15469711832551#c1" title=""/>
    <thread:in-reply-to xmlns:thread="http://purl.org/syndication/thread/1.0" href="https://google-plus-exporter.blogspot.com/2019/01/no-archive.html" ref="tag:blogger.com,1999:blog-4441510360404961996.post-0" source="https://www.blogger.com/feeds/4441510360404961996/posts/default/0" type="text/html"/>

I’ve tried using the following XSLT, but it has no effect:

<xsl:variable name="parent" select="atom:link[@rel='self']/@href"/>
<xsl:apply-templates select="atom:entry[./thread:in-reply-to[@href=$parent]]"/>

I’m starting to get the feeling, reading the JSON format and generating stuff using a handwritten Perl script might have been quicker...



Hi Alex,

I think you need

<xsl:variable name="parent" select="atom:id"/>
<xsl:apply-templates select="../atom:entry[./thread:in-reply-to[@ref=$parent]]"\>

and potentially an <xsl:with-param> or global variable to track nesting level (for replies-to-replies).

– Diederik van Arkel 2019-01-09 13:45 UTC

I tried that and the resulting index.html remained unchanged, sadly.

I think the two approaches are equivalent because the URL also identifies the thread. But sadly, neither my way nor your way actually work.

For anybody interested: remember you can clone the project from https://alexschroeder.ch/cgit/blogger-rss-to-html/ (and you’ll see that I switched the code to Diederik’s variant).

– Alex Schroeder 2019-01-09 14:43 UTC

When I add the following inside your xsl:choose I do see that these entries are found (at the correct point)..

<xsl:text> {{{</xsl:text>

	      <xsl:if test="atom:author/atom:name">
		<xsl:value-of select="atom:author/atom:name"/>

	  <!-- entry content -->
	  <div class="content">
	      <xsl:when test="atom:content">
		<xsl:apply-templates select="atom:content"/>
		<xsl:apply-templates select="atom:summary"/>

	    <!-- entry footer -->
	    <div class="permalink">
	      <xsl:if test="atom:author/atom:name">
		<xsl:value-of select="atom:author/atom:name"/>

<xsl:text>}}} </xsl:text>

– Diederik van Arkel 2019-01-09 19:08 UTC

I got some help from Martijn Vos on G+ who pointed out to me that my problem was actually earlier where I had my xsl:apply-templates.

The code at the repository should now work as expected and I can think about images and CSS and all the other details. :)

– Alex Schroeder 2019-01-10 07:36 UTC

Result is available!

– Alex Schroeder 2019-01-10 12:06 UTC

Fixed Javascript as well, so now J/K should work as well.

– Alex Schroeder 2019-01-10 16:19 UTC

Please make sure you contribute only your own work, or work licensed under the GNU Free Documentation License. Note: in order to facilitate peer review and fight vandalism, we will store your IP number for a number of days. See Privacy Policy for more information. See Info for text formatting rules. You can edit the comment page if you need to fix typos. You can subscribe to new comments by email without leaving a comment.

To save this page you must answer this question:

Please say HELLO.