Crawlers like this page, and RDFa crawlers will like it too if we enable RDFa on each post. This should be very easy since the RDF mapping for each node is available at the theming level. We're targeting title, author and number of replies. Last updated is a great bonus.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

This patch includes rdf output for title, user, and number of replies.

sioc:num_replies is currently directly coded in the function, but we may want to change this to get the property value from a mapping.

Extra code has been used to ensure that RDF does not display when RDF module is not enabled.

A test will need to be written for the modified function.

Anonymous’s picture

+++ modules/tracker/tracker.pages.inc	5 Nov 2009 20:42:55 -0000
@@ -58,14 +58,35 @@ function tracker_page($account = NULL, $
+      // If RDF is enabled, apply the about property to the row.

woops, this should say attribute, not property

I'm on crack. Are you, too?

Anonymous’s picture

Fixed some coding style, streamlined the assignment of the new row

Anonymous’s picture

I have mostly completed the test for this, test is somewhat dependent on #614444: More consistent RDFa logic for username

Anonymous’s picture

This patch cleans up the tracker page RDF logic, includes a mapping for replies in the node default mapping, and uses invisible markup to include the created on date.

The test has been modified, but is not complete yet

scor’s picture

Status: Active » Needs review

setting for review

Status: Needs review » Needs work

The last submitted patch failed testing.

scor’s picture

Status: Needs work » Needs review
+++ modules/tracker/tracker.pages.inc	12 Nov 2009 19:17:55 -0000
@@ -55,17 +55,52 @@ function tracker_page($account = NULL, $
+      $num_replies = array(

we should be consistent here and use the same name throughout the patch. comment_count is what is used elsewhere in Drupal.

+++ modules/tracker/tracker.pages.inc	12 Nov 2009 19:17:55 -0000
@@ -55,17 +55,52 @@ function tracker_page($account = NULL, $
+        'data' => t('!time ago', array('!time' => format_interval(REQUEST_TIME - $node->last_activity))),

last_activity is not the changed value of the node, but comes from tracker_node.changed and reflects the date the node was last saved or commented on. I suggest to add a mapping to the default node mapping, called last_activity and mapped to sioc:last_reply_date by default.

This review is powered by Dreditor.

Anonymous’s picture

The last activity property is only applied if there are comments, so the test needs to be changed to reflect that. Functionality in the tracker should be ok now, though, and all of scor's comments have been incorporated.

Status: Needs review » Needs work

The last submitted patch failed testing.

Anonymous’s picture

This patch has the complete test.

Anonymous’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch failed testing.

Anonymous’s picture

Status: Needs work » Needs review
FileSize
9.3 KB

Forgot to remove a line from setup, this one should test ok.

scor’s picture

+++ modules/node/node.module	13 Nov 2009 16:24:55 -0000
@@ -773,16 +773,26 @@ function node_rdf_mapping() {
+        'replies' => array(
+          'predicates' => array('sioc:num_replies'),
+        ),
+        'last_activity' => array(
+          'predicates' => array('sioc:last_reply_date'),
+          'datatype' => 'xsd:dateTime',
+          'callback' => 'date_iso8601',
+        )

Minor comment: the last closing parenthesis usually also has a comma in the end.

Anonymous’s picture

Patch rerolled to include comma.

scor’s picture

+++ modules/tracker/tracker.pages.inc	24 Nov 2009 11:19:13 -0000
@@ -59,13 +59,53 @@ function tracker_page($account = NULL, $
+      $comment_count = array(
+        'class' => array('replies'),
+        'data' => $comments,
+      );

I like $comment_count as variable name for the amount of replies.

+++ modules/node/node.module	24 Nov 2009 11:19:13 -0000
@@ -781,16 +781,26 @@ function node_rdf_mapping() {
+        'replies' => array(
+          'predicates' => array('sioc:num_replies'),
+        ),

Let's use it here too instead of 'replies'. It's also what is used in #632092: Number of replies of a node in RDFa

Anonymous’s picture

Mapping key changed from 'replies' to 'comment_count'

scor’s picture

- Elaborated on some of the documentation.
- Adds the number of replies in a content attribute (to avoid the "X new" being included in the count).
- Fix a bug in rdf_rdfa_attributes() where a callback function should not required when $data is provided or a datatype is specified in the mapping.

I ran some benchmarking with 100 nodes, 100 comments on each and ab -n 500 -c 1 against the tracker page:

HEAD        : 5.11 requests/sec
HEAD patched: 4.99 requests/sec

which is 2.5% impact.

scor’s picture

remove trailing whitespaces.

Status: Needs review » Needs work

The last submitted patch failed testing.

scor’s picture

Status: Needs work » Needs review
FileSize
8.72 KB

removing the number of replies in a content attribute and will create a separate issue for that. so from #18, we now have:
- Elaborated on some of the documentation.
- Removed trailing whitespaces.

The benchmark is not affected.

EDIT: see separate issue #642122: Allow for RDFa datatype attribute without callback function

Dries’s picture

+++ modules/rdf/rdf.test
@@ -189,3 +189,106 @@ class RdfMappingDefinitionTestCase extends DrupalWebTestCase {
+    $user = ($node->uid == 0) ? 'Anonymous User' : 'Registered User';

We don't camel case each word.

+++ modules/rdf/rdf.test
@@ -189,3 +189,106 @@ class RdfMappingDefinitionTestCase extends DrupalWebTestCase {
+    // Test that latest zctivitydate property has not been set if there are

Looks like a typo.

+++ modules/rdf/rdf.test
@@ -189,3 +189,106 @@ class RdfMappingDefinitionTestCase extends DrupalWebTestCase {
+    // Test that latest activity date property is set after a comment is posted.

This comment could be rephrased for clarity a bit. I had to read it 2-3 times.

scor’s picture

fixed all of Dries' comments.

scor’s picture

fixed more documentation in rdf.test

scor’s picture

sambrin’s picture

Status: Needs review » Needs work
+++ modules/tracker/tracker.pages.inc
@@ -59,13 +59,54 @@ function tracker_page($account = NULL, $set_title = FALSE) {
+        // Only use last activity mapping if there are comments on the node.
+        if ($node->comment_count > 0) {
+          $time_ago += rdf_rdfa_attributes($mapping['last_activity'], $node->last_activity);
+        }

Since the page actually displays a "last updated" date, I don't think the rdfa should be omitted just based on the inference that no comments have been posted. Furthermore, "last updated" reflects the last time the node itself was changed, and not only the last time a comment was posted.

I'm on crack. Are you, too?

scor’s picture

Status: Needs work » Needs review
FileSize
8.81 KB

Thanks sambrin for chiming in. You have a point, we should annotate the last activity regardless since it is displayed on the tracker page anyways. rerolled the patch to take this into account.

sambrin’s picture

Since the page actually displays a "last updated" date, I don't think the rdfa should be omitted just based on the inference that no comments have been posted. Furthermore, "last updated" reflects the last time the node itself was changed, and not only the last time a comment was posted.

I see now that I missed a subtlety here. The SIOC property being used for "last updated" is sioc:last_reply_date. I still think the rdfa should reflect any recent changes, including updates to the page itself, but I see now why it made sense to only use the property with comments present. This seems like a shortcoming of the SIOC vocabulary, as SIOC doesn't consider that content may be edited rather than just created. I believe scor is following up on this.

Status: Needs review » Needs work

The last submitted patch failed testing.

scor’s picture

I've open a discussion on this topic on the sioc-dev mailing list: http://groups.google.com/group/sioc-dev/browse_thread/thread/5dec36e7e43... - let's see what comes out of it.

scor’s picture

The sioc:last_activity_date property was added to the SIOC vocabulary (thanks to John Breslin). We can go ahead and update the patch:

  • when comment_count = 0, we use sioc:last_activity_date and dc:modified (we know for sure that the last activity was triggered by a node creation or update)
  • when comment_count > 0, we only use sioc:last_activity_date because we don't know whether this last activity is due to a node modification or a comment which has been added.
sambrin’s picture

Added the changes scor mentioned above, and updated the tests accordingly.

sambrin’s picture

Had to re-roll the previous patch since it didn't apply on HEAD.

sambrin’s picture

Status: Needs work » Needs review

setting to needs review

Status: Needs review » Needs work

The last submitted patch failed testing.

scor’s picture

Status: Needs work » Needs review
FileSize
10.12 KB

not sure what's up with the bot. rerolling.

Status: Needs review » Needs work
Issue tags: -RDF, -RDFa

The last submitted patch, , failed testing.

Status: Needs work » Needs review
Issue tags: +RDF, +RDFa

Re-test of from comment #2395762 was requested by @user.

scor’s picture

I was about to RTBC this, but I though I would try to clean up the logic in the previous patch instead. Not much change in the RDFa output, and so this should be easy to RTBC after someone else reviews it.

Anonymous’s picture

Just noticed something while testing.

When there is a new comment, the 'new' alert is included in the value.
<http://rdfs.org/sioc/ns#num_replies> "21 new"^^http://www.w3.org/2001/XMLSchema#integer

I have attached a patch that fixes this by adding a content attribute with the comment count.

scor’s picture

Status: Needs review » Needs work

In #26, this issue became dependent on #642122: Allow for RDFa datatype attribute without callback function so that the content attribute is taken care by rdf_rdfa_attributes(), hence the rdf_passthrough callback in the comment_count mapping of the recent patches. (which saves us having to add the content attribute manually like Lin did in #42). However, after some thinking, I'm not sure we should use this rdf_passthrough callback: the fact that we need to add a content attribute is only due to the fact that we have extra markup in the td tag which is added by the tracker module, but has nothing to do with the RDF mapping. I think in this particular case the content attribute should be added outside rdf_rdfa_attributes(), like in #42. thoughts?

We should also add this content attribute to the tests.

Anonymous’s picture

Ah, that's right. After I posted I remembered that we'd talked about it before but didn't remember that it had been moved to its own issue.

Since we wouldn't be using it in this case, would you still want to include the rdf_passthrough change to the api? Or do you think all special cases should be handled this way?

Anonymous’s picture

This patch includes a test for the content attribute on num_replies. It tests whether the value is numeric.

Based on scor's last comment, I also removed the code related to passthrough callback (the second parameter from the call to rdfa_attributes for the replies in tracker.pages.inc and the rdf_passthrough_callback for replies in the rdf mapping definition in node.module.)

scor’s picture

The patch improvements look good.

+++ modules/rdf/rdf.test	5 Jan 2010 14:38:23 -0000
@@ -188,3 +188,121 @@ class RdfMappingDefinitionTestCase exten
+    // Need to create a registered user.

Is this comment appropriate or necessary here? where is the registered user created?

+++ modules/rdf/rdf.test	5 Jan 2010 14:38:23 -0000
@@ -188,3 +188,121 @@ class RdfMappingDefinitionTestCase exten
+    // Check to see whether there is a table row for the node with the about
+    // attribute set, whether it contains a c

The comment is not finished.

+++ modules/rdf/rdf.test	5 Jan 2010 14:38:23 -0000
@@ -188,3 +188,121 @@ class RdfMappingDefinitionTestCase exten
+	// Navigate to tracker page.
+    $this->drupalGet('tracker');

indentation issue

+++ modules/rdf/rdf.test	5 Jan 2010 14:38:23 -0000
@@ -188,3 +188,121 @@ class RdfMappingDefinitionTestCase exten
+    // Tests whether the property has been set for number of comments.
+    $tracker_replies = $this->xpath("//tr[@about='$url']//td[contains(@property, 'sioc:num_replies') and contains(@content, '0')]");

- we could simply force @content='0' here because the content attribute is supposed to only contain that value.
- we should also check the value of content when a comment has been posted (@content='1') like it is done further for the last_activity attribute.

9 days to code freeze. Better review yourself.

Anonymous’s picture

- Removed comment
- Rewrote comment
- Removed this get altogether. It isn't necessary as far as I can see.
- You're right, the is_numeric check was unnecessary. Removed that and added one for when a comment is posted.

scor’s picture

Status: Needs work » Needs review

looks good, setting for review.

scor’s picture

I like the patch. A few minor documentation fixes below. (leaving as needs review since these are really minor).

+++ modules/rdf/rdf.test	5 Jan 2010 17:26:36 -0000
@@ -188,3 +188,118 @@ class RdfMappingDefinitionTestCase exten
+   * Navigate to tracker page and ensure the mapping is used.

Fix comment: this function does not actually navigate to the tracker page, this is done by the helper functions.

+++ modules/rdf/rdf.test	5 Jan 2010 17:26:36 -0000
@@ -188,3 +188,118 @@ class RdfMappingDefinitionTestCase exten
+    // Pass both the anonymously posted node and the administrator posted node
+    // through to test for the RDF properties.

Nitpick: "to test for the RDFa attributes" would be more appropriate - strictly speaking, we not only test for RDF properties, but also RDF subject and objects in the RDFa ;)

+++ modules/rdf/rdf.test	5 Jan 2010 17:26:36 -0000
@@ -188,3 +188,118 @@ class RdfMappingDefinitionTestCase exten
+    $this->assertTrue($tracker_replies, t('Num replies property and content attributes found on @user content. Content attribute is numeric.', array('@user'=> $user)));

"Content attributes is numeric" does not really apply any longer.

+++ modules/rdf/rdf.test	5 Jan 2010 17:26:36 -0000
@@ -188,3 +188,118 @@ class RdfMappingDefinitionTestCase exten
+    // posted, meaning the latest activity is changes to the node itself

missing ending period. Maybe could be rewritten as "the latest activity reflects the changes of the node itself"?

+++ modules/rdf/rdf.test	5 Jan 2010 17:26:36 -0000
@@ -188,3 +188,118 @@ class RdfMappingDefinitionTestCase exten
+    $this->assertTrue($tracker_replies, t('Num replies property and content attributes found on @user content. Content attribute is numeric.', array('@user'=> $user)));

"Content attributes is numeric" does not really apply any longer.

9 days to code freeze. Better review yourself.

scor’s picture

Status: Needs review » Needs work

This will need a reroll since #652588: Update RDF mapping definition in the core modules was just committed :)

Anonymous’s picture

Status: Needs work » Needs review
FileSize
11.02 KB

Rerolled and all documentation modifications applied.

scor’s picture

Status: Needs review » Reviewed & tested by the community

Thanks Lin for your patience! patch looks good to go now.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

I still don't really understand what this does ;), but I think it is worth having for the tests alone. It looks like Dries's feedback was addressed.

Committed to HEAD.

Status: Fixed » Closed (fixed)
Issue tags: -RDF, -RDFa

Automatically closed -- issue fixed for 2 weeks with no activity.