Skip to content

Commit

Permalink
Adds Gravatar Antlers tag, aliases for common data properties
Browse files Browse the repository at this point in the history
Resolves #124
Resolves #123
  • Loading branch information
JohnathonKoster committed Nov 15, 2020
1 parent d66f965 commit 4574a82
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Addon.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Addon
public const CODE_ADDON_NAME = 'meerkat';
public const ROUTE_PREFIX = 'meerkat';
public const ADDON_ID = 'stillat/meerkat';
public const VERSION = '2.1.7-beta2';
public const VERSION = '2.1.8-beta2';

/**
* Gets the addon API prefix.
Expand Down
4 changes: 4 additions & 0 deletions src/Core/Comments/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,10 @@ public function toArray()
$data[CommentContract::KEY_CONTENT] = $data[CommentContract::INTERNAL_CONTENT_RAW];
}

// Create some useful aliases, mainly for templating purposes.
$data[CommentContract::KEY_ALIAS_DATE] = $this->getDataAttribute(CommentContract::KEY_COMMENT_DATE);
$data[CommentContract::KEY_ALIAS_DATE_FORMATTED] = $this->getDataAttribute(CommentContract::KEY_COMMENT_DATE_FORMATTED);

return $data;
}

Expand Down
52 changes: 40 additions & 12 deletions src/Tags/Meerkat.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,34 @@ public function index()
return '';
}

/**
* {{ meerkat:gravatar }}
*
* @return string
*/
public function gravatar()
{
$gravatarValue = $this->gravatarValue();

return '//www.gravatar.com/avatar/' . $gravatarValue . '?';
}

/**
* {{ meerkat:gravatar_value }}
*
* @return string
*/
public function gravatarValue()
{
$email = '';

if ($this->context !== null) {
$email = $this->context->get('email');
}

return md5($email);
}

/**
* Renders a Meerkat form.
*
Expand Down Expand Up @@ -190,6 +218,18 @@ public function allComments()
return $this->renderDynamic(CollectionRenderer::class);
}

/**
* {{ meerkat:thread }}
*
* @return string|string[]
* @throws BindingResolutionException
* @throws TemplateTagsException
*/
public function thread()
{
return $this->responses();
}

/**
* {{ meerkat:responses }}
*
Expand All @@ -214,18 +254,6 @@ public function responses()
});
}

/**
* {{ meerkat:thread }}
*
* @return string|string[]
* @throws BindingResolutionException
* @throws TemplateTagsException
*/
public function thread()
{
return $this->responses();
}

/**
* Creates an anchor link for the current comment context.
*
Expand Down

0 comments on commit 4574a82

Please sign in to comment.