diff options
author | Sem <sembrestels@riseup.net> | 2012-01-06 13:25:03 +0100 |
---|---|---|
committer | Sem <sembrestels@riseup.net> | 2012-01-06 13:25:03 +0100 |
commit | 9895df4280a7be9465fe148a356327edf370f6fa (patch) | |
tree | 18a8ecb3a50fe4da0164a2b5a572ed3274343aa2 | |
download | elgg-9895df4280a7be9465fe148a356327edf370f6fa.tar.gz elgg-9895df4280a7be9465fe148a356327edf370f6fa.tar.bz2 |
Initial commit for Elgg 1.8
-rw-r--r-- | graphics/identica.png | bin | 0 -> 488 bytes | |||
-rw-r--r-- | graphics/thewire_speech_bubble.gif | bin | 0 -> 560 bytes | |||
-rw-r--r-- | languages/en.php | 16 | ||||
-rw-r--r-- | manifest.xml | 17 | ||||
-rw-r--r-- | start.php | 14 | ||||
-rw-r--r-- | views/default/identica/css.php | 63 | ||||
-rw-r--r-- | views/default/identica/identi.ca.js.php | 76 | ||||
-rw-r--r-- | views/default/widgets/identica/content.php | 33 | ||||
-rw-r--r-- | views/default/widgets/identica/edit.php | 16 |
9 files changed, 235 insertions, 0 deletions
diff --git a/graphics/identica.png b/graphics/identica.png Binary files differnew file mode 100644 index 000000000..888163d82 --- /dev/null +++ b/graphics/identica.png diff --git a/graphics/thewire_speech_bubble.gif b/graphics/thewire_speech_bubble.gif Binary files differnew file mode 100644 index 000000000..d0e8606a1 --- /dev/null +++ b/graphics/thewire_speech_bubble.gif diff --git a/languages/en.php b/languages/en.php new file mode 100644 index 000000000..44932dc4a --- /dev/null +++ b/languages/en.php @@ -0,0 +1,16 @@ +<?php +/** + * Identi.ca widget language file + */ + +$english = array( + + 'identica:title' => 'Identi.ca', + 'identica:info' => 'Display your latest tweets', + 'identica:username' => 'Enter your identi.ca username.', + 'identica:num' => 'The number of tweets to show.', + 'identica:visit' => 'visit my identi.ca', + 'identica:notset' => 'This Identi.ca widget is not yet set to go. To display your latest tweets, click on - edit - and fill in your details', +); + +add_translation("en", $english); diff --git a/manifest.xml b/manifest.xml new file mode 100644 index 000000000..2e0b61c1b --- /dev/null +++ b/manifest.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<plugin_manifest xmlns="http://www.elgg.org/plugin_manifest/1.8"> + <name>Identica Widget</name> + <author>Simon Leblanc, Lorea Developers</author> + <version>0.3-dev</version> + <category>social</category> + <category>widget</category> + <description>Elgg simple identi.ca widget (based of the Curverider Ltd's work)</description> + <website>https://www.lorea.org/</website> + <copyright>(C) Simon Leblanc 2009, Lorea 2012</copyright> + <license>GNU General Public License version 2</license> + <requires> + <type>elgg_release</type> + <version>1.8</version> + </requires> + <activate_on_install>true</activate_on_install> +</plugin_manifest> diff --git a/start.php b/start.php new file mode 100644 index 000000000..bddd41d7d --- /dev/null +++ b/start.php @@ -0,0 +1,14 @@ +<?php +/** + * Elgg identi.ca widget + * This plugin allows users to pull in their identi.ca feed to display on their profile + * + * @package ElggIdentica + */ + +elgg_register_event_handler('init', 'system', 'identica_init'); + +function identica_init() { + elgg_extend_view('css/elgg', 'identica/css'); + elgg_register_widget_type('identica', elgg_echo('identica:title'), elgg_echo('identica:info')); +} diff --git a/views/default/identica/css.php b/views/default/identica/css.php new file mode 100644 index 000000000..e87d0cf31 --- /dev/null +++ b/views/default/identica/css.php @@ -0,0 +1,63 @@ +<?php +/** + * Elgg Identi.ca CSS + * + * @package ElggIdentica + */ +?> + +#identica_widget { + margin:0 10px 0 10px; +} +#identica_widget ul { + margin:0; + padding:0; +} +#identica_widget li { + list-style-image:none; + list-style-position:outside; + list-style-type:none; + margin:0 0 5px 0; + padding:0; + overflow-x: hidden; + border: 2px solid #dedede; + -webkit-border-radius: 8px; + -moz-border-radius: 8px; + border-radius: 8px; +} +#identica_widget li span { + color:#666666; + background:white; + + -webkit-border-radius: 8px; + -moz-border-radius: 8px; + border-radius: 8px; + + padding:5px; + display:block; +} +p.visit_identica a { + background:url(<?php echo elgg_get_site_url(); ?>mod/identica/graphics/identica.png) left no-repeat; + padding:0 0 0 20px; + margin:0; +} +p.identica_username .input-text { + width:200px; +} +.visit_identica { + background:white; + + -webkit-border-radius: 8px; + -moz-border-radius: 8px; + border-radius: 8px; + + padding:2px; + margin:0 0 5px 0; +} +#identica_widget li > a { + display:block; + margin:0 0 0 4px; +} +#identica_widget li span a { + display:inline !important; +} diff --git a/views/default/identica/identi.ca.js.php b/views/default/identica/identi.ca.js.php new file mode 100644 index 000000000..1d782d040 --- /dev/null +++ b/views/default/identica/identi.ca.js.php @@ -0,0 +1,76 @@ + /** + * Elgg identica JS + * + * @package ElggIdentica + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Simon Leblanc <contact@leblanc-simon.eu> + * @copyright Simon Leblanc 2009 + * @link http://elgg.com/ + */ +<?php +$id = $_GET['id']; +?> +var identica_less_60 = 'less than a minute ago'; +var identica_minute = 'about a minute ago'; +var identica_more_minute_first = ''; +var identica_more_minute = ' minutes ago'; +var identica_hour = 'about an hour ago'; +var identica_more_hour_first = 'about '; +var identica_more_hour = ' hours ago'; +var identica_day = '1 day ago'; +var identica_more_day_first = ''; +var identica_more_day = ' days ago'; + +/** + * Parse the JSON result for show this in HTML + * + * @param JSON string the JSON result of the identi.ca's call + */ +function identicaCallback(identicas) { + var statusHTML = []; + for (var i=0; i<identicas.length; i++){ + var username = identicas[i].user.screen_name; + var status = identicas[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) { + return '<a href="'+url+'">'+url+'</a>'; + }).replace(/\B@([_a-z0-9]+)/ig, function(reply) { + return reply.charAt(0)+'<a href="http://identi.ca/'+reply.substring(1)+'">'+reply.substring(1)+'</a>'; + }).replace(/\B#([-_a-z0-9]+)/ig, function(tag) { + return tag.charAt(0)+'<a href="http://identi.ca/tag/'+tag.substring(1).replace(/[^a-z0-9]+/ig, '')+'">'+tag.substring(1)+'</a>'; + }).replace(/\B!([_a-z0-9]+)/ig, function(group) { + return group.charAt(0)+'<a href="http://identi.ca/group/'+group.substring(1)+'">'+group.substring(1)+'</a>'; + }); + statusHTML.push('<li><span>'+status+'</span> <a style="font-size:85%" href="http://identi.ca/notice/'+identicas[i].id+'">'+relative_time(identicas[i].created_at)+'</a></li>'); + } + document.getElementById('identica_update_list').innerHTML = statusHTML.join(''); +} + +/** + * Modified the time in human readable + * + * @param string time_value The time in RFC format + * @return string The time in human readable format + */ +function relative_time(time_value) { + var values = time_value.split(" "); + time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3]; + var parsed_date = Date.parse(time_value); + var relative_to = (arguments.length > 1) ? arguments[1] : new Date(); + var delta = parseInt((relative_to.getTime() - parsed_date) / 1000); + delta = delta + (relative_to.getTimezoneOffset() * 60); + + if (delta < 60) { + return identica_less_60; + } else if(delta < 120) { + return identica_minute; + } else if(delta < (60*60)) { + return identica_more_minute_first + (parseInt(delta / 60)).toString() + identica_more_minute; + } else if(delta < (120*60)) { + return identica_hour; + } else if(delta < (24*60*60)) { + return identica_more_hour_first + (parseInt(delta / 3600)).toString() + identica_more_hour; + } else if(delta < (48*60*60)) { + return identica_day; + } else { + return identica_more_day_first + (parseInt(delta / 86400)).toString() + identica_more_day; + } +} diff --git a/views/default/widgets/identica/content.php b/views/default/widgets/identica/content.php new file mode 100644 index 000000000..9209e01a6 --- /dev/null +++ b/views/default/widgets/identica/content.php @@ -0,0 +1,33 @@ +<?php + +/** + * Elgg identi.ca view page + * + * @package ElggIdentica + */ + +//some required params + +$username = $vars['entity']->identica_username; +$num = $vars['entity']->identica_num; +$id = md5($vars['entity']->identica_username.rand(0, 99999)); + +// if the identi.ca username is empty, then do not show +if ($username) { + +?> + +<div id="identica_widget"> + <ul id="identica_update_list"></ul> + <p class="visit_identica"><a href="http://identi.ca/<?php echo $username; ?>"><?php echo elgg_echo("identica:visit"); ?></a></p> + <script type="text/javascript" src="<?php echo $vars['url']; ?>mod/identica/views/default/identica/identi.ca.js.php?id=<?php echo $id ?>"></script> + + <script type="text/javascript" src="https://identi.ca/api/statuses/user_timeline/<?php echo $username; ?>.json?callback=identicaCallback&count=<?php echo $num; ?>"></script> +</div> + +<?php +} else { + + echo "<p>" . elgg_echo("identica:notset") . ".</p>"; + +} diff --git a/views/default/widgets/identica/edit.php b/views/default/widgets/identica/edit.php new file mode 100644 index 000000000..888f4e908 --- /dev/null +++ b/views/default/widgets/identica/edit.php @@ -0,0 +1,16 @@ +<?php + + /** + * Elgg identi.ca edit page + * + * @package ElggIdentica + */ + +?> + <p> + <?php echo elgg_echo("identica:username"); ?> + <input type="text" name="params[identica_username]" value="<?php echo htmlentities($vars['entity']->identica_username); ?>" /> + <br /><?php echo elgg_echo("twitter:num"); ?> + <input type="text" name="params[identica_num]" value="<?php echo htmlentities($vars['entity']->identica_num); ?>" /> + + </p> |