From 7949cf3f5332352065ff3730b9d0d3b47e223d11 Mon Sep 17 00:00:00 2001 From: Tony Baldwin Date: Sat, 17 Mar 2012 16:40:17 -0400 Subject: [PATCH] cleaned up where "lj" was included in dwpost.css changed my profile url to the current, free-haven profile, in all plugins to which I have contributed added insanejournal.com plugin, ijpost other minor cleanup of details, where a plugin was copied and modified but incorrect details were left. --- dwpost/dwpost.css | 8 +- dwpost/dwpost.php | 2 +- ijpost.tar.gz | Bin 0 -> 20480 bytes ijpost/ijpost.css | 15 ++++ ijpost/ijpost.php | 218 ++++++++++++++++++++++++++++++++++++++++++++++ irc/irc.php | 2 +- ljpost/ljpost.php | 2 +- 7 files changed, 240 insertions(+), 7 deletions(-) create mode 100644 ijpost.tar.gz create mode 100644 ijpost/ijpost.css create mode 100644 ijpost/ijpost.php diff --git a/dwpost/dwpost.css b/dwpost/dwpost.css index 8edab3d99..3b0ee32ab 100644 --- a/dwpost/dwpost.css +++ b/dwpost/dwpost.css @@ -1,15 +1,15 @@ -#ljpost-enable-label, #ljpost-username-label, #ljpost-password-label, #ljpost-bydefault-label { +#dwpost-enable-label, #dwpost-username-label, #dwpost-password-label, #dwpost-bydefault-label { float: left; width: 200px; margin-top: 10px; } -#ljpost-checkbox, #ljpost-username, #ljpost-password, #ljpost-bydefault { +#dwpost-checkbox, #dwpost-username, #dwpost-password, #dwpost-bydefault { float: left; margin-top: 10px; } -#ljpost-submit { +#dwpost-submit { margin-top: 15px; -} \ No newline at end of file +} diff --git a/dwpost/dwpost.php b/dwpost/dwpost.php index c7bfd939f..bb4557269 100644 --- a/dwpost/dwpost.php +++ b/dwpost/dwpost.php @@ -4,7 +4,7 @@ * Name: Dreamwidth Post Connector * Description: Post to dreamwidth * Version: 1.0 - * Author: Tony Baldwin + * Author: Tony Baldwin * Author: Michael Johnston */ diff --git a/ijpost.tar.gz b/ijpost.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..c274902c05308c6dd20bfbad08813f95aad69375 GIT binary patch literal 20480 zcm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addon/ijpost/ijpost.php', 'ijpost_post_local'); + register_hook('notifier_normal', 'addon/ijpost/ijpost.php', 'ijpost_send'); + register_hook('jot_networks', 'addon/ijpost/ijpost.php', 'ijpost_jot_nets'); + register_hook('connector_settings', 'addon/ijpost/ijpost.php', 'ijpost_settings'); + register_hook('connector_settings_post', 'addon/ijpost/ijpost.php', 'ijpost_settings_post'); + +} +function ijpost_uninstall() { + unregister_hook('post_local', 'addon/ijpost/ijpost.php', 'ijpost_post_local'); + unregister_hook('notifier_normal', 'addon/ijpost/ijpost.php', 'ijpost_send'); + unregister_hook('jot_networks', 'addon/ijpost/ijpost.php', 'ijpost_jot_nets'); + unregister_hook('connector_settings', 'addon/ijpost/ijpost.php', 'ijpost_settings'); + unregister_hook('connector_settings_post', 'addon/ijpost/ijpost.php', 'ijpost_settings_post'); + +} + + +function ijpost_jot_nets(&$a,&$b) { + if(! local_user()) + return; + + $dw_post = get_pconfig(local_user(),'ijpost','post'); + if(intval($dw_post) == 1) { + $dw_defpost = get_pconfig(local_user(),'ijpost','post_by_default'); + $selected = ((intval($dw_defpost) == 1) ? ' checked="checked" ' : ''); + $b .= '
' + . t('Post to InsaneJournal') . '
'; + } +} + + +function ijpost_settings(&$a,&$s) { + + if(! local_user()) + return; + + /* Add our stylesheet to the page so we can make our settings look nice */ + + $a->page['htmlhead'] .= '' . "\r\n"; + + /* Get the current state of our config variables */ + + $enabled = get_pconfig(local_user(),'ijpost','post'); + + $checked = (($enabled) ? ' checked="checked" ' : ''); + + $def_enabled = get_pconfig(local_user(),'ijpost','post_by_default'); + + $def_checked = (($def_enabled) ? ' checked="checked" ' : ''); + + $dw_username = get_pconfig(local_user(), 'ijpost', 'dw_username'); + $dw_password = get_pconfig(local_user(), 'ijpost', 'dw_password'); + + + /* Add some HTML to the existing form */ + + $s .= '
'; + $s .= '

' . t('InsaneJournal Post Settings') . '

'; + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + /* provide a submit button */ + + $s .= '
'; + +} + + +function ijpost_settings_post(&$a,&$b) { + + if(x($_POST,'ijpost-submit')) { + + set_pconfig(local_user(),'ijpost','post',intval($_POST['ijpost'])); + set_pconfig(local_user(),'ijpost','post_by_default',intval($_POST['dw_bydefault'])); + set_pconfig(local_user(),'ijpost','dw_username',trim($_POST['dw_username'])); + set_pconfig(local_user(),'ijpost','dw_password',trim($_POST['dw_password'])); + + } + +} + +function ijpost_post_local(&$a,&$b) { + + // This can probably be changed to allow editing by pointing to a different API endpoint + + if($b['edit']) + return; + + if((! local_user()) || (local_user() != $b['uid'])) + return; + + if($b['private'] || $b['parent']) + return; + + $dw_post = intval(get_pconfig(local_user(),'ijpost','post')); + + $dw_enable = (($dw_post && x($_REQUEST,'ijpost_enable')) ? intval($_REQUEST['ijpost_enable']) : 0); + + if($_REQUEST['api_source'] && intval(get_pconfig(local_user(),'ijpost','post_by_default'))) + $dw_enable = 1; + + if(! $dw_enable) + return; + + if(strlen($b['postopts'])) + $b['postopts'] .= ','; + $b['postopts'] .= 'ijpost'; +} + + + + +function ijpost_send(&$a,&$b) { + + if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) + return; + + if(! strstr($b['postopts'],'ijpost')) + return; + + if($b['parent'] != $b['id']) + return; + + // InsaneJournal post in the IJ user's timezone. + // Hopefully the person's Friendica account + // will be set to the same thing. + + $tz = 'UTC'; + + $x = q("select timezone from user where uid = %d limit 1", + intval($b['uid']) + ); + if($x && strlen($x[0]['timezone'])) + $tz = $x[0]['timezone']; + + $dw_username = get_pconfig($b['uid'],'ijpost','dw_username'); + $dw_password = get_pconfig($b['uid'],'ijpost','dw_password'); + $dw_blog = 'http://www.insanejournal.com/interface/xmlrpc'; + + if($dw_username && $dw_password && $dw_blog) { + + require_once('include/bbcode.php'); + require_once('include/datetime.php'); + + $title = $b['title']; + $post = bbcode($b['body']); + $post = xmlify($post); + + $date = datetime_convert('UTC',$tz,$b['created'],'Y-m-d H:i:s'); + $year = intval(substr($date,0,4)); + $mon = intval(substr($date,5,2)); + $day = intval(substr($date,8,2)); + $hour = intval(substr($date,11,2)); + $min = intval(substr($date,14,2)); + + $xml = <<< EOT + +LJ.XMLRPC.postevent + + +year$year +mon$mon +day$day +hour$hour +min$min +event$post +username$dw_username +password$dw_password +subject$title +lineendingsunix +ver1 +props + +useragentFriendica +taglistfriendica + + + + + +EOT; + + logger('ijpost: data: ' . $xml, LOGGER_DATA); + + if($dw_blog !== 'test') + $x = post_url($dw_blog,$xml); + logger('posted to insanejournal: ' . ($x) ? $x : '', LOGGER_DEBUG); + + } +} + diff --git a/irc/irc.php b/irc/irc.php index a66fc8265..cf86a446e 100644 --- a/irc/irc.php +++ b/irc/irc.php @@ -3,7 +3,7 @@ * Name: IRC Chat Plugin * Description: add an Internet Relay Chat chatroom * Version: 1.0 -* Author: tony baldwin +* Author: tony baldwin */ diff --git a/ljpost/ljpost.php b/ljpost/ljpost.php index 8431b134d..14bac69e3 100644 --- a/ljpost/ljpost.php +++ b/ljpost/ljpost.php @@ -4,7 +4,7 @@ * Name: LiveJournal Post Connector * Description: Post to LiveJournal * Version: 1.0 - * Author: Tony Baldwin + * Author: Tony Baldwin * Author: Michael Johnston */