Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#51 | tracker-rdf_output-614508-51.patch | 11.02 KB | linclark |
#47 | tracker-rdf_output-614508-47.patch | 11.36 KB | linclark |
#45 | tracker-rdf_output-614508-45.patch | 11.29 KB | linclark |
#42 | tracker-rdf_output-614508-41.patch | 11.25 KB | linclark |
#40 | tracker-rdf_output-614508-40.patch | 10.27 KB | scor |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedThis 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.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedwoops, this should say attribute, not property
I'm on crack. Are you, too?
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedFixed some coding style, streamlined the assignment of the new row
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedI have mostly completed the test for this, test is somewhat dependent on #614444: More consistent RDFa logic for username
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedThis 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
Comment #6
scor CreditAttribution: scor commentedsetting for review
Comment #8
scor CreditAttribution: scor commentedwe should be consistent here and use the same name throughout the patch. comment_count is what is used elsewhere in Drupal.
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.
Comment #9
Anonymous (not verified) CreditAttribution: Anonymous commentedThe 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.
Comment #11
Anonymous (not verified) CreditAttribution: Anonymous commentedThis patch has the complete test.
Comment #12
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #14
Anonymous (not verified) CreditAttribution: Anonymous commentedForgot to remove a line from setup, this one should test ok.
Comment #15
scor CreditAttribution: scor commentedMinor comment: the last closing parenthesis usually also has a comma in the end.
Comment #16
Anonymous (not verified) CreditAttribution: Anonymous commentedPatch rerolled to include comma.
Comment #17
scor CreditAttribution: scor commentedI like $comment_count as variable name for the amount of 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
Comment #18
Anonymous (not verified) CreditAttribution: Anonymous commentedMapping key changed from 'replies' to 'comment_count'
Comment #19
scor CreditAttribution: scor commented- 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:
which is 2.5% impact.
Comment #20
scor CreditAttribution: scor commentedremove trailing whitespaces.
Comment #22
scor CreditAttribution: scor commentedremoving 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
Comment #23
Dries CreditAttribution: Dries commentedWe don't camel case each word.
Looks like a typo.
This comment could be rephrased for clarity a bit. I had to read it 2-3 times.
Comment #24
scor CreditAttribution: scor commentedfixed all of Dries' comments.
Comment #25
scor CreditAttribution: scor commentedfixed more documentation in rdf.test
Comment #26
scor CreditAttribution: scor commentedupdated the patch to take advantage of #642122-4: Allow for RDFa datatype attribute without callback function
Comment #27
sambrin CreditAttribution: sambrin commentedSince 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?
Comment #28
scor CreditAttribution: scor commentedThanks 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.
Comment #29
sambrin CreditAttribution: sambrin commentedI 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.
Comment #31
scor CreditAttribution: scor commentedI'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.
Comment #32
scor CreditAttribution: scor commentedThe sioc:last_activity_date property was added to the SIOC vocabulary (thanks to John Breslin). We can go ahead and update the patch:
sioc:last_activity_date
anddc:modified
(we know for sure that the last activity was triggered by a node creation or update)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.Comment #33
sambrin CreditAttribution: sambrin commentedAdded the changes scor mentioned above, and updated the tests accordingly.
Comment #34
sambrin CreditAttribution: sambrin commentedHad to re-roll the previous patch since it didn't apply on HEAD.
Comment #35
sambrin CreditAttribution: sambrin commentedsetting to needs review
Comment #37
scor CreditAttribution: scor commentednot sure what's up with the bot. rerolling.
Comment #40
scor CreditAttribution: scor commentedI 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.
Comment #42
Anonymous (not verified) CreditAttribution: Anonymous commentedJust 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.
Comment #43
scor CreditAttribution: scor commentedIn #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.
Comment #44
Anonymous (not verified) CreditAttribution: Anonymous commentedAh, 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?
Comment #45
Anonymous (not verified) CreditAttribution: Anonymous commentedThis 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.)
Comment #46
scor CreditAttribution: scor commentedThe patch improvements look good.
Is this comment appropriate or necessary here? where is the registered user created?
The comment is not finished.
indentation issue
- 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.
Comment #47
Anonymous (not verified) CreditAttribution: Anonymous commented- 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.
Comment #48
scor CreditAttribution: scor commentedlooks good, setting for review.
Comment #49
scor CreditAttribution: scor commentedI like the patch. A few minor documentation fixes below. (leaving as needs review since these are really minor).
Fix comment: this function does not actually navigate to the tracker page, this is done by the helper functions.
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 ;)
"Content attributes is numeric" does not really apply any longer.
missing ending period. Maybe could be rewritten as "the latest activity reflects the changes of the node itself"?
"Content attributes is numeric" does not really apply any longer.
9 days to code freeze. Better review yourself.
Comment #50
scor CreditAttribution: scor commentedThis will need a reroll since #652588: Update RDF mapping definition in the core modules was just committed :)
Comment #51
Anonymous (not verified) CreditAttribution: Anonymous commentedRerolled and all documentation modifications applied.
Comment #52
scor CreditAttribution: scor commentedThanks Lin for your patience! patch looks good to go now.
Comment #53
webchickI 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.