PAD Showcase
All tags/Gravatar

Comments with Gravatars

The picture each address registered at gravatar.com - only its SHA-256 hash leaves the page, lazily, without a referrer.

1 The data gravatar/comments.php php
<?php

  $comments = [
    [ 'name' => 'Herbert Jebbink', 'email' => 'herbert@example.com', 'text' => 'The page cache halves the time of the home page.' ],
    [ 'name' => 'Ada Lovelace',    'email' => 'ada@example.org',     'text' => 'Could the sequence tags take a step of their own?' ],
    [ 'name' => 'Grace Hopper',    'email' => 'grace@example.net',   'text' => 'A bug report with a template line number - lovely.' ] ];

?>
2 The template gravatar/comments.pad pad
<div style="display:grid; gap:16px">
  {comments}
  <div style="display:flex; gap:12px; align-items:flex-start">
    {gravatar $email, size=40, default='identicon', alt=$name}
    <div><strong>{$name}</strong><br>{$text}</div>
  </div>
  {/comments}
</div>
3 The result rendered on the server
Herbert Jebbink
Herbert Jebbink
The page cache halves the time of the home page.
Ada Lovelace
Ada Lovelace
Could the sequence tags take a step of their own?
Grace Hopper
Grace Hopper
A bug report with a template line number - lovely.