TV Memex

Just in case you have not had your fill of the previous two code dumps for the workings of the VCU Thought Vectors site… heres more. I can’t stop tinkering.

Last weekend Jon Becker emailed and asked if there was “an easy way” to mix together all of the RSS feeds from his students blog into one feed that he could use as a sidebar widget. He had done it before with Yahoo Pipes.

Now for some inexplicable web service that generates no revenue, Pipes still works. I keep a list of Feed Mixer services at Feed2JS. But why rely on a third party when we have the means right here– yep, to every nail it’s WordPress.

In the last Google Hangout with Martin Hawksey we lamented the challenge of syndication comments in an open course– only WordPress provides a feed for comment activity.

But for VCU, almost all of the students are using either the Rampages (VCU hosted_) WordPress or WordPress.com. In theory, I told the crew, we could make a site that syndicates in all the student blog comment feeds, and we could put them in categories by section. These in turn can provide an outward bound RSS feed for an entire section– which is really what Jon wanted.

In fact, Gardner Campbell had done that on his own for his section- for all students in his Clubhouse site he put their comment feeds into a second site that in turn generated an RSS feed for comments back on his site.

I suggested doing the same thing, but for all sections– if we did it right, we could not only provide the feeds to each section site, we would have all of the comment activity in one place.

Hence the Thought Vectors Comment Reader:

comment-reader

The AVH Extended Categories Widgets plugin provides on the sidebar a count of comments per section, and also an RSS Feed (these are just categories):

comments by section

One of my own stumbles was my own misunderstanding of authors for feed items. When you subscribe to a single blog for its posts, each item in the RSS feed (a post) has the same author (the dc:author item). Feed WordPress will generate a WordPress user account for that author, and associate all syndicated content to it.

But in a comment feed, the author of an item is the author of the comment, so what Feed WordPress sees for an author is whatever name the commenter put in the form. Now for the students, they are mostly logged into the Rampages site, so the comment form automatically associates a comment anywhere to the same “user”. We might have a way then to track student comment activity across blogs (or anyone else if they are consistent in filling out the comment form with the same name).

Thus adding the Authors Widget plugin makes for another widget that shows the most active commenters:

commenters

Pretty neat.

I’ve been stumped some on getting some code to generate a list of random posts, I bet any plugin is going to be hampered by WP Engines clamp down on the MySQL ORDER BY RAND() query.

One thing not in there is a quick association to match all of the comments to the feed it came from. I got in my head that there might be a way to generate a list of which posts generated the most comments. This would call for perhaps a gnarly custom query.

I was determined to figure this out.

So here’s the thing, all syndicated comments come in with a specific URL that points to an anchor in the page (where the #xx is a database ID for the comment), e.g. comments might come in with permalinks like

http://rampages.us/cogdog/2014/06/18/piggly-wiggly/#comment-24
http://rampages.us/cogdog/2014/06/18/piggly-wiggly/#comment-32
http://rampages.us/cogdog/2014/06/18/piggly-wiggly/#comment-64

what I needed was a way to do a query that would count the occurrences of post permalinks up to the #comment-XX. StackExchange to the rescue! There is a text selector to select based on a substring:

to select all rows from where columnname matched UP to the first occurrence of “_”.

Here is the winning query:

count(*) gives me the number of times the same match occurs, where the thing being counted is the guid column (that contains the post permalink( UP to the first # in the url. I was even able to deploy the same trick to get the post title since all of the syndicated comments are titled something like “Comment on I Love Piggly Wiggly Vectors By Captain Kangaroo” to get the title out by removing everything including and after “by”.

(yikes, I just figured out I would chop the title that contained “By” in it).

So the page of top 30 commented posts is now up at http://vcureader.wpengine.com/freq/

top posts

Now while excited about this, I do notice some discrepancies when I go back to the blogs where these come from. One is easy to account for since the counter listed on a WordPress site includes pingbacks, which are not syndicated.

But that does not make up for all the differences.

Another issue is how many comments we can syndicated at a time- an RSS feed for comments doe snot return every comment, but up to the last 10, that is the default setting for how many items appear in an RSS feed

most recent

We have a good situation where many student blogs are generating more than 10 comments an hour. But the feeds then are not capturing everything.

One route might be to ask all students to adjust their WordPress Reading settings to a higher number. I am hoping there is a programmatic way we might be able to bump the feed items for just the comment RSS feeds (there has to be a hook/action for that, right??). Ideally I could roll that into a plugin we might network activate on rampages, which would make it happen on all blogs.

Ahh I skipped an important step- getting all of the 100+ blog comment feeds into this site. My last gory code post included a script I made to generated a blog OPML file for each course section. With just some minor tweaking, i was able to make a second script that generates an RSS Feed for the comments from all those blogs– for WordPress, it is super easy; get the home URL of the blog (That comes right from the Links data), like http://pigglywiggly.us/ and just to it to make http://pigglywiggly.us/comments/feed

But I got even fancier- within the Notes that Feedwordpress writes in the links data as it syndicates, it pulls in a string that identifies the syndicating platform– all WordPress blogs provide feed/generator: http://wordpress.org/?v=3.9.1, Blogger gives feed/generator: Blogger, tumblr does something like feed/generator: Tumblr (3.0; @cogdog).

So I was able to include in my query that pulls data from the Links info, to skip any blogs not identified as coming from WordPress.

Here is the code for the PHP script I can call to generate a Comment Feed OPML file

Having an OPML for each section made it easy to import into Feed WordPress via the batch option (adding categories became a manual process, so be it).

A small thing I did just tonight was to modify the sidebar.php template so rather than display the site description, it provides a real time status for how many comments are fed in:

stats

This was easy! A Matter of editing

to read

Can’t stop this dog from digging in the code bin! But there has to be some data value in trying to gather as much of the comment flow as we can.

By the way, the image I created to put on the site is a hopefully obvious not to Vannevar Bush, its a screen grab from a screen recorded animation of something created in Director (go old skool multimediaO to demonstrate how the thing worked, modified with screens from the Thoughtvectors site and a student blog

UPDATE Jun 20, 2014 Thanks to Stack Exchange I have the filter for changing the number of items in a comment feed. I tried to make a plugin that had options for setting it, but was getting nowhere; for now, here is a cheap way to hardwire the number:

Now if Tom does a network enable on this for rampages.us, all blog comment feeds will have 50 items, rather than the default puny miserly 10.

If this kind of stuff has value, please support me by tossing a one time PayPal kibble or monthly on Patreon
Become a patron at Patreon!
Profile Picture for CogDog The Blog
An early 90s builder of web stuff and blogging Alan Levine barks at CogDogBlog.com on web storytelling (#ds106 #4life), photography, bending WordPress, and serendipity in the infinite internet river. He thinks it's weird to write about himself in the third person. And he is 100% into the Fediverse (or tells himself so) Tooting as @cogdog@cosocial.ca

Comments

  1. I love it. This is an awesome way to encourage interaction. I wonder though – Is there a way to highlight uncommented posts and get people to do something about it? The February is Album Writing Month (http://fawm.org/) site discourages zero-comment songs, or zongs, by highlighting them (http://fawm.org/songs/). As I recall, a user’s dashboard also gave counts for comments given and zongs busted. It’s a way of trying to make sure everybody gets some love. Just a thought.

    1. I totally agree- and that was a first response from Tom Woodward.

      It’s very tricky. FAWM can do this more easily because all of the content is on their site, so they can track comments high and none easily. One database, one query.

      First of all (as far as I know) WordPress is the only platform that provides RSS for comments, which is how this site was strung together. I could flip the query, and list the blog posts with the fewest comments, but it would be 1, not zero. Just thinking out loud, the way to get the zero comment posts would be to syndicate in all the posts, and do some sort of logical intersection to find ones that have not been syndicated into the comment reader.

      An interesting idea to mull. And beyond that, some blogs have zero comments because the content has not been seen enough, but there are some posts which maybe just do not need comments (let the audience sort that out?)

Leave a Reply

Your email address will not be published. Required fields are marked *