Commits

Anonymous committed 67d36e0

Adicionando o Spark para gravatar.

Adicionei o gravatar nos comentários.

  • Participants
  • Parent commits 3df6514

Comments (0)

Files changed (6)

File application/controllers/posts.php

     {
         $this->load->model(array('posts_model', 'comentarios_model'));
         $this->load->helper(array('datas', 'form', 'captcha'));
+        $this->load->spark('gravatar/1.1.1');
 
         $data = array();
 

File application/views/posts/post.php

 <?php if (count($post->comentarios) > 0) : ?>
     <?php foreach ($post->comentarios as $c) : ?>
         <div class="comentario">
-            <p><strong><?php echo $c->autor; ?></strong></p>
+            <p>
+                <?php echo gravatar($c->email_autor, 60); ?>
+                <strong><?php echo $c->autor; ?></strong>
+            </p>
             <p>
                 <em>Publicado em:
                     <?php echo formatar_data_exibicao($c->publicacao); ?>

File sparks/gravatar/1.1.1/README.md

+
+Gravatar Helper Spark for CodeIgniter
+============================
+
+A [CodeIgniter](http://codeigniter.com) helper [Spark](http://getsparks.org/) for working with the [Gravatar](http://gravatar.com) API to pull user avatar images, QR codes & profile URL's from email addresses.
+
+
+Installation
+-------------------------------------
+
+1. Install the spark: `php tools/spark install gravatar` - or, if not using Spark package management, copy `gravatar_helper.php` to your `application/helpers` folder.
+2. Load the spark: `$this->load->spark('gravatar/1.1.1');` - or, optionally autoload the spark in `application/config/autoload.php`: `$autoload['sparks'] = array('gravatar/1.1.1');`.
+3. Employ helper functions as needed.
+
+
+Usage
+-------------------------------------
+
+	/**
+	 * Get either a Gravatar URL or complete image tag for a specified email address.
+	 *
+	 * @param string 	$email The email address
+	 * @param string 	$s Size in pixels, defaults to 80px [ 1 - 512 ]
+	 * @param boolean 	$img True to return a complete IMG tag False for just the URL 
+	 * @param string 	$d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
+	 * @param string 	$r Maximum rating (inclusive) [ g | pg | r | x ]
+	 * @param array 	$atts Optional, additional key/value attributes to include in the IMG tag
+	 * @return 			String containing either just a URL or a complete image tag
+	 */
+
+	<?=gravatar( 'test@example.com', 100 )?>
+
+
+	/**
+	 * Get a Gravatar profile URL from a primary gravatar email address.
+	 *
+	 * @param string 	$email The email address
+	 * @return 			String containing the users gravatar profile URL.
+	 */
+
+	<?=gravatar_profile( 'test@example.com' )?>
+
+	
+	/**
+	 * Get either a Gravatar QR Code URL or complete image tag from a primary gravatar email address.
+	 *
+	 * @param string 	$email The email address
+	 * @param string 	$s Size in pixels, defaults to 80px [ 1 - 512 ]
+	 * @param boolean 	$img True to return a complete IMG tag False for just the URL 
+	 * @param array 	$atts Optional, additional key/value attributes to include in the IMG tag
+	 * @return 			String containing either just a URL or a complete image tag
+	 */
+ 
+	<?=gravatar_qr( 'test@example.com' )?> 
+	
+  	
+License
+-------------------------------------
+
+Copyright © 2012 Jason M Horwitz, Sekati LLC. All Rights Reserved.
+
+Released under the MIT License: [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php)
+
+	The MIT License
+
+	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.	
+	

File sparks/gravatar/1.1.1/config/autoload.php

+<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
+
+/**
+ * @author 		Jason M Horwitz <jason@sekati.com>
+ * @copyright	Copyright (c) 2012, Sekati.com
+ * @license		http://www.opensource.org/licenses/mit-license.php
+ */
+
+
+$autoload['helper'] = array('gravatar');

File sparks/gravatar/1.1.1/helpers/gravatar_helper.php

+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+/**
+ * Sekati CodeIgniter Gravatar Helper
+ *
+ * @package		Sekati
+ * @author		Jason M Horwitz
+ * @copyright	Copyright (c) 2012, Sekati LLC.
+ * @license		http://www.opensource.org/licenses/mit-license.php
+ * @link		http://sekati.com
+ * @version		v1.1.1
+ * @filesource
+ *
+ * @usage 		$autoload['helper'] = array('gravatar');
+ * @example 	gravatar( 'jason@sekati.com' );	 			// returns gravatar img tag
+ * 				gravatar_profile( 'jason@sekati.com' ); 	// returns URL
+ * 				gravatar_qr( 'jason@sekati.com' ); 			// returns QR img tag
+ */
+
+// ------------------------------------------------------------------------
+// GRAVATAR HELPERS
+
+/**
+ * Get either a Gravatar URL or complete image tag for a specified email address.
+ *
+ * @param string 	$email The email address
+ * @param string 	$s Size in pixels, defaults to 80px [ 1 - 512 ]
+ * @param boolean 	$img True to return a complete IMG tag False for just the URL 
+ * @param string 	$d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
+ * @param string 	$r Maximum rating (inclusive) [ g | pg | r | x ]
+ * @param array 	$atts Optional, additional key/value attributes to include in the IMG tag
+ * @return 			String containing either just a URL or a complete image tag
+ */
+if ( ! function_exists('gravatar'))
+{ 
+	function gravatar( $email, $s = 80, $img = true, $d = 'identicon', $r = 'x', $atts = array() )
+	{
+		$url = ( isset($_SERVER['HTTPS']) ) ? 'https://secure.' : 'http://www.';
+		$url .= 'gravatar.com/avatar/';
+		$url .= md5( strtolower( trim( $email ) ) );
+		$url .= "?s=$s&d=$d&r=$r";
+		if ( $img )
+		{
+			$url = '<img src="' . $url . '"';
+			foreach ( $atts as $key => $val )
+				$url .= ' ' . $key . '="' . $val . '"';
+			$url .= ' />';
+		}
+		return $url;
+	}
+} 
+
+/**
+ * Get a Gravatar profile URL from a primary gravatar email address.
+ *
+ * @param string 	$email The email address
+ * @return 			String containing the users gravatar profile URL.
+ */
+if ( ! function_exists('gravatar_profile'))
+{ 
+	function gravatar_profile( $email )
+	{
+		$url = ( isset($_SERVER['HTTPS']) ) ? 'https://secure.' : 'http://www.';
+		$url .= 'gravatar.com/';
+		$url .= md5( strtolower( trim( $email ) ) );
+		return $url;
+	}
+} 
+
+/**
+ * Get either a Gravatar QR Code URL or complete image tag from a primary gravatar email address.
+ *
+ * @param string 	$email The email address
+ * @param string 	$s Size in pixels, defaults to 80px [ 1 - 512 ]
+ * @param boolean 	$img True to return a complete IMG tag False for just the URL 
+ * @param array 	$atts Optional, additional key/value attributes to include in the IMG tag
+ * @return 			String containing either just a URL or a complete image tag
+ */
+if ( ! function_exists('gravatar_qr'))
+{ 
+	function gravatar_qr( $email, $s = 80, $img = true, $atts = array() )
+	{
+		$url = gravatar_profile($email);
+		$url .= ".qr?s=$s";
+		if ( $img )
+		{
+			$url = '<img src="' . $url . '"';
+			foreach ( $atts as $key => $val )
+				$url .= ' ' . $key . '="' . $val . '"';
+			$url .= ' />';
+		}
+		return $url;
+	}
+} 
+ 
+ 
+/* End of file gravatar_helper.php */

File sparks/gravatar/1.1.1/spark.info

+name: gravatar 
+version: 1.1.1
+compatibility: 2.1.0
+tags: ["gravatar", "avatar", "helper"]