From 610a6cee5eca3ca433506b5dfea8d239d7cd1a50 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Sat, 3 Mar 2012 22:40:07 +0100 Subject: Initial commit. --- .gitignore | 1 + COPYING | 18 ++++++++++++++++++ README.md | 4 ++++ build.sh | 3 +++ help.html | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ plugin.php | 42 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 123 insertions(+) create mode 100644 .gitignore create mode 100644 COPYING create mode 100644 README.md create mode 100755 build.sh create mode 100644 help.html create mode 100644 plugin.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..07231e7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +kch42_gravatar.rpk \ No newline at end of file diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..a74122e --- /dev/null +++ b/COPYING @@ -0,0 +1,18 @@ +kch42_gravatar: Copyright (c) 2012 Kevin Chabowski + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..a2ecd7f --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +kch42_gravatar +============== + +A Plugin for Ratatöskr that gives you [Gravatars](http://de.gravatar.com) for the comments. \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..47d991c --- /dev/null +++ b/build.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +r7r-plugin-packer --output=kch42_gravatar.rpk --codefile=plugin.php --classname=kch42_gravatar --pluginname=kch42_gravatar --author='Kevin Chabowski ' --versiontext="0.6" --versioncount=2 --api=5 --shortdesc="kch42_gravatar allows you to display [Gravatars](http://de.gravatar.com)" --helpfile=help.html --licensefile=COPYING diff --git a/help.html b/help.html new file mode 100644 index 0000000..74a0b56 --- /dev/null +++ b/help.html @@ -0,0 +1,55 @@ +

kch42_gravatar

+ +

This Plugin gives you an STE tag, which will return the Gravatar of the person, who written a comment.

+

This tag is: <ste:kch42_gravatar />.

+ +

How to use this tag

+ +

The tag will return a HTML <img /> tag.

+ +

The tag will accept these parameters:

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Parameter nameMandatory?Default valueDescription
commentYes Name of a variable that contains information about a comment (usually generated by <ste:article_comments />)
sizeNo80Size of image in pixels.
defaultNoidenticonThe default image, if no Gravatar is available. Can be a URL to an image or one of Gravatar's default values.
ratingNogOne of Gravatar's rating values.
styleNo Additional (CSS) styles for the image.
+

diff --git a/plugin.php b/plugin.php new file mode 100644 index 0000000..d0a044f --- /dev/null +++ b/plugin.php @@ -0,0 +1,42 @@ +get_var_by_name($params["comment"]); + + if(isset($ste_comment["__obj"])) + $comment = $ste_comment["__obj"]; + else + $comment = Comment::by_id($ste_comment["id"]); + + $mail_hash = md5(strtolower(trim($comment->author_mail))); + + $gravatar_args = array("default" => "identicon", "rating" => "g", "size" => "80"); + $query_fragments = array(); + foreach($gravatar_args as $key => &$value) + { + if(isset($params[$key])) + $value = $params[$key]; + $value = htmlspecialchars(urlencode($value)); + $query_fragments[] = "$key=$value"; + } + + $styles = "width: {$gravatar_args["size"]}px; height: {$gravatar_args["size"]}px;" . (isset($params["style"]) ? " " . $params["style"] : ""); + + $protocol = ((!empty($_SERVER["HTTPS"])) and ($_SERVER["HTTPS"] == "on")) ? "https" : "http"; + + return "\"\""; + } + + public function init() + { + $this->ste->register_tag("kch42_gravatar", array($this, "ste_tag_kch42_gravatar")); + } +} + +?> -- cgit v1.2.3-54-g00ecf