aboutsummaryrefslogtreecommitdiff
path: root/mod/identica
diff options
context:
space:
mode:
authorSem <sembrestels@riseup.net>2013-11-09 16:16:08 +0100
committerSem <sembrestels@riseup.net>2013-11-09 16:16:08 +0100
commite58937426578eac71d1447c38ae3f93cbc331bf1 (patch)
tree3bac3ed5c025f05250d7c07b14f8b83135e07233 /mod/identica
parent293fe873dcbedf45571807b722ce859e00a5a3a5 (diff)
parentd2494d74da2f015465bb340292c049d9c63756cd (diff)
downloadelgg-e58937426578eac71d1447c38ae3f93cbc331bf1.tar.gz
elgg-e58937426578eac71d1447c38ae3f93cbc331bf1.tar.bz2
Add 'mod/identica/' from commit 'd2494d74da2f015465bb340292c049d9c63756cd'
git-subtree-dir: mod/identica git-subtree-mainline: 293fe873dcbedf45571807b722ce859e00a5a3a5 git-subtree-split: d2494d74da2f015465bb340292c049d9c63756cd
Diffstat (limited to 'mod/identica')
-rw-r--r--mod/identica/graphics/identica.pngbin0 -> 488 bytes
-rw-r--r--mod/identica/graphics/thewire_speech_bubble.gifbin0 -> 560 bytes
-rw-r--r--mod/identica/languages/ca.php10
-rw-r--r--mod/identica/languages/en.php16
-rw-r--r--mod/identica/languages/es.php12
-rw-r--r--mod/identica/manifest.xml17
-rw-r--r--mod/identica/start.php16
-rw-r--r--mod/identica/views/default/identica/css.php63
-rw-r--r--mod/identica/views/default/identica/js.php40
-rw-r--r--mod/identica/views/default/js/friendly_time.php50
-rw-r--r--mod/identica/views/default/widgets/identica/content.php30
-rw-r--r--mod/identica/views/default/widgets/identica/edit.php16
12 files changed, 270 insertions, 0 deletions
diff --git a/mod/identica/graphics/identica.png b/mod/identica/graphics/identica.png
new file mode 100644
index 000000000..888163d82
--- /dev/null
+++ b/mod/identica/graphics/identica.png
Binary files differ
diff --git a/mod/identica/graphics/thewire_speech_bubble.gif b/mod/identica/graphics/thewire_speech_bubble.gif
new file mode 100644
index 000000000..d0e8606a1
--- /dev/null
+++ b/mod/identica/graphics/thewire_speech_bubble.gif
Binary files differ
diff --git a/mod/identica/languages/ca.php b/mod/identica/languages/ca.php
new file mode 100644
index 000000000..7330f1cc6
--- /dev/null
+++ b/mod/identica/languages/ca.php
@@ -0,0 +1,10 @@
+<?php
+$language = array (
+ 'identica:title' => 'Identi.ca',
+ 'identica:info' => 'Mostra els teus últims missatges',
+ 'identica:username' => 'Introdueix el teu nom d\'usuària d\'identi.ca',
+ 'identica:num' => 'Número de missatges a mostrar.',
+ 'identica:visit' => 'Visitar el meu identi.ca',
+ 'identica:notset' => 'Aquest giny d\'Identi.ca no és encara llest. Per mostrar els teus últims missatges, clica a - edita - i omple amb els teus detalls',
+);
+add_translation("ca", $language); \ No newline at end of file
diff --git a/mod/identica/languages/en.php b/mod/identica/languages/en.php
new file mode 100644
index 000000000..44932dc4a
--- /dev/null
+++ b/mod/identica/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/mod/identica/languages/es.php b/mod/identica/languages/es.php
new file mode 100644
index 000000000..7a73755f7
--- /dev/null
+++ b/mod/identica/languages/es.php
@@ -0,0 +1,12 @@
+<?php
+$es = array (
+ 'identica:title' => 'Identi.ca',
+ 'identica:info' => 'Muestra tus últimos tweets',
+ 'identica:username' => 'Tu nombre de usuario en identi.ca',
+ 'identica:num' => 'Número de tweets a mostrar.',
+ 'identica:visit' => 'visita mi identi.ca',
+ 'identica:notset' => 'El widget de Identi.ca aún no está configurado. Para mostrar tus últimos tweets, haz click en en - editar - y rellena el formulario',
+);
+
+add_translation("es", $es);
+
diff --git a/mod/identica/manifest.xml b/mod/identica/manifest.xml
new file mode 100644
index 000000000..45b8fff61
--- /dev/null
+++ b/mod/identica/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>1.8.0</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-2013</copyright>
+ <license>GNU Affero General Public License, version 3 or later</license>
+ <requires>
+ <type>elgg_release</type>
+ <version>1.8</version>
+ </requires>
+ <activate_on_install>true</activate_on_install>
+</plugin_manifest>
diff --git a/mod/identica/start.php b/mod/identica/start.php
new file mode 100644
index 000000000..d9bdf6af7
--- /dev/null
+++ b/mod/identica/start.php
@@ -0,0 +1,16 @@
+<?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_js('identica', elgg_get_site_url() . "mod/identica/views/default/identica/js.php");
+ elgg_register_js('friendly_time', elgg_get_site_url() . "mod/identica/views/default/js/friendly_time.php");
+ elgg_register_widget_type('identica', elgg_echo('identica:title'), elgg_echo('identica:info'));
+}
diff --git a/mod/identica/views/default/identica/css.php b/mod/identica/views/default/identica/css.php
new file mode 100644
index 000000000..e87d0cf31
--- /dev/null
+++ b/mod/identica/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/mod/identica/views/default/identica/js.php b/mod/identica/views/default/identica/js.php
new file mode 100644
index 000000000..1dd560836
--- /dev/null
+++ b/mod/identica/views/default/identica/js.php
@@ -0,0 +1,40 @@
+/**
+ * Elgg identi.ca widget
+ * This plugin allows users to pull in their identi.ca feed to display on their profile
+ *
+ * @package ElggIdentica
+ */
+
+elgg.identica = {};
+
+/**
+ * Parse the JSON result for show this in HTML
+ *
+ * @param JSON string the JSON result of the identi.ca's call
+ */
+elgg.identica.callback = function(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+'">'+elgg.get_friendly_time(identicas[i].created_at)+'</a></li>');
+ }
+ document.getElementById('identica_update_list').innerHTML = statusHTML.join('');
+}
+
+elgg.identica.init = function() {
+ username = $('#identica_update_list').data('username');
+ num = $('#identica_update_list').data('num');
+ js = "https://identi.ca/api/statuses/user_timeline/"+username+".json?callback=elgg.identica.callback&count="+num;
+ $.getScript(js);
+};
+
+elgg.register_hook_handler('init', 'system', elgg.identica.init);
diff --git a/mod/identica/views/default/js/friendly_time.php b/mod/identica/views/default/js/friendly_time.php
new file mode 100644
index 000000000..0b0275206
--- /dev/null
+++ b/mod/identica/views/default/js/friendly_time.php
@@ -0,0 +1,50 @@
+elgg.get_friendly_time = function(time) {
+
+ if (!time) {
+ time = new Date();
+ } else {
+ time = new Date(time);
+ }
+ diff = (new Date().getTime() - time.getTime()) / 1000;
+
+ minute = 60;
+ hour = minute * 60;
+ day = hour * 24;
+
+ if (diff < minute) {
+ return elgg.echo("friendlytime:justnow");
+ } else if (diff < hour) {
+ diff = Math.round(diff / minute);
+ if (diff == 0) {
+ diff = 1;
+ }
+
+ if (diff > 1) {
+ return elgg.echo("friendlytime:minutes", [diff]);
+ } else {
+ return elgg.echo("friendlytime:minutes:singular", [diff]);
+ }
+ } else if (diff < day) {
+ diff = Math.round(diff / hour);
+ if (diff == 0) {
+ diff = 1;
+ }
+
+ if (diff > 1) {
+ return elgg.echo("friendlytime:hours", [diff]);
+ } else {
+ return elgg.echo("friendlytime:hours:singular", [diff]);
+ }
+ } else {
+ diff = Math.round(diff / day);
+ if (diff == 0) {
+ diff = 1;
+ }
+
+ if (diff > 1) {
+ return elgg.echo("friendlytime:days", [diff]);
+ } else {
+ return elgg.echo("friendlytime:days:singular", [diff]);
+ }
+ }
+};
diff --git a/mod/identica/views/default/widgets/identica/content.php b/mod/identica/views/default/widgets/identica/content.php
new file mode 100644
index 000000000..42cbd1853
--- /dev/null
+++ b/mod/identica/views/default/widgets/identica/content.php
@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * Elgg identi.ca view page
+ *
+ * @package ElggIdentica
+ */
+
+//some required params
+
+$username = $vars['entity']->identica_username;
+$num = $vars['entity']->identica_num;
+
+// if the identi.ca username is empty, then do not show
+if ($username) {
+ elgg_load_js('friendly_time');
+ elgg_load_js('identica');
+?>
+
+<div id="identica_widget">
+ <ul id="identica_update_list" data-username="<?php echo $username; ?>" data-num="<?php echo $num; ?>"></ul>
+ <p class="visit_identica"><a href="http://identi.ca/<?php echo $username; ?>"><?php echo elgg_echo("identica:visit"); ?></a></p>
+</div>
+
+<?php
+} else {
+
+ echo "<p>" . elgg_echo("identica:notset") . ".</p>";
+
+}
diff --git a/mod/identica/views/default/widgets/identica/edit.php b/mod/identica/views/default/widgets/identica/edit.php
new file mode 100644
index 000000000..888f4e908
--- /dev/null
+++ b/mod/identica/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>