From b99cb511ca665bad0022de2ca43b5de78b3ffdbf Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Jan 2012 16:38:24 -0800 Subject: [PATCH 1/4] comment preview --- include/conversation.php | 5 +++-- js/main.js | 23 +++++++++++++++++++++++ mod/item.php | 2 +- mod/photos.php | 1 + view/comment_item.tpl | 3 +++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index ec1fd4152c..d4d6a55694 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -129,7 +129,7 @@ function localize_item(&$item){ * that are based on unique features of the calling module. * */ -function conversation(&$a, $items, $mode, $update) { +function conversation(&$a, $items, $mode, $update, $preview = false) { require_once('bbcode.php'); @@ -287,7 +287,7 @@ function conversation(&$a, $items, $mode, $update) { '$like' => '', '$dislike' => '', '$comment' => '', - '$conv' => array('href'=> $a->get_baseurl() . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context')), + '$conv' => (($preview) ? '' : array('href'=> $a->get_baseurl() . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))), '$wait' => t('Please wait'), )); @@ -483,6 +483,7 @@ function conversation(&$a, $items, $mode, $update) { '$myphoto' => $a->contact['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), + '$preview' => t('Preview'), '$ww' => (($mode === 'network') ? $commentww : '') )); } diff --git a/js/main.js b/js/main.js index 96c7fa642b..009fb55bbb 100644 --- a/js/main.js +++ b/js/main.js @@ -389,6 +389,7 @@ unpause(); commentBusy = true; $('body').css('cursor', 'wait'); + $("#comment-preview-inp-" + id).val("0"); $.post( "item", $("#comment-edit-form-" + id).serialize(), @@ -411,6 +412,28 @@ return false; } + + function preview_comment(id) { + $("#comment-preview-inp-" + id).val("1"); + $("#comment-edit-preview-" + id).show(); + $.post( + "item", + $("#comment-edit-form-" + id).serialize(), + function(data) { + if(data.preview) { + + $("#comment-edit-preview-" + id).html(data.preview); + $("#comment-edit-preview-" + id + " a").removeAttr('href'); + } + }, + "json" + ); + return true; + } + + + + function unpause() { // unpause auto reloads if they are currently stopped totStopped = false; diff --git a/mod/item.php b/mod/item.php index d4d337584c..069f1393cf 100644 --- a/mod/item.php +++ b/mod/item.php @@ -588,7 +588,7 @@ function item_post(&$a) { if($preview) { $b = prepare_body($datarray,true); require_once('include/conversation.php'); - $o = conversation(&$a,array(array_merge($datarray,$contact_record)),'search',false); + $o = conversation(&$a,array(array_merge($contact_record,$datarray)),'search',false,true); $json = array('preview' => $o); echo json_encode($json); killme(); diff --git a/mod/photos.php b/mod/photos.php index bf3299de07..d2f45652ff 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -1203,6 +1203,7 @@ function photos_content(&$a) { '$myphoto' => $contact['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), + '$preview' => t('Preview'), '$ww' => '' )); } diff --git a/view/comment_item.tpl b/view/comment_item.tpl index 0216e31d3d..49751c42b3 100644 --- a/view/comment_item.tpl +++ b/view/comment_item.tpl @@ -5,6 +5,7 @@ +
$mytitle @@ -15,6 +16,8 @@
From b265334c9ee55cf2270926148a094ecae2f68e54 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Jan 2012 16:47:47 -0800 Subject: [PATCH 2/4] added citations back into ping - lost somehow --- mod/ping.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mod/ping.php b/mod/ping.php index df07cb768e..35f6c53aef 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -190,6 +190,12 @@ function ping_init(&$a) { }; } + if (count($cit)){ + foreach ($cit as $i) { + echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), t("{0} mentioned you in a post") ); + }; + } + echo " "; } echo " "; From 291a82c4a465c6c3b1db7087682cb050d1943a08 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Jan 2012 18:11:53 -0800 Subject: [PATCH 3/4] backend for per-network streams --- mod/item.php | 4 +--- mod/network.php | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/mod/item.php b/mod/item.php index 069f1393cf..6b294b93e5 100644 --- a/mod/item.php +++ b/mod/item.php @@ -586,11 +586,9 @@ function item_post(&$a) { // preview mode - prepare the body for display and send it via json if($preview) { - $b = prepare_body($datarray,true); require_once('include/conversation.php'); $o = conversation(&$a,array(array_merge($contact_record,$datarray)),'search',false,true); - $json = array('preview' => $o); - echo json_encode($json); + echo json_encode(array('preview' => $o)); killme(); } diff --git a/mod/network.php b/mod/network.php index 397a701da4..76c7bb5e69 100644 --- a/mod/network.php +++ b/mod/network.php @@ -52,7 +52,8 @@ function saved_searches($search) { . ((x($_GET,'cid')) ? '?cid=' . $_GET['cid'] : '') . ((x($_GET,'star')) ? '?star=' . $_GET['star'] : '') . ((x($_GET,'bmark')) ? '?bmark=' . $_GET['bmark'] : '') - . ((x($_GET,'conv')) ? '?conv=' . $_GET['conv'] : ''); + . ((x($_GET,'conv')) ? '?conv=' . $_GET['conv'] : '') + . ((x($_GET,'nets')) ? '?nets=' . $_GET['nets'] : ''); $o = ''; @@ -203,7 +204,7 @@ function network_content(&$a, $update = 0) { $order = ((x($_GET,'order')) ? notags($_GET['order']) : 'comment'); $liked = ((x($_GET,'liked')) ? intval($_GET['liked']) : 0); $conv = ((x($_GET,'conv')) ? intval($_GET['conv']) : 0); - + $nets = ((x($_GET,'nets')) ? $_GET['nets'] : ''); if(($a->argc > 2) && $a->argv[2] === 'new') $nouveau = true; @@ -259,10 +260,12 @@ function network_content(&$a, $update = 0) { // that belongs to you, hence you can see all of it. We will filter by group if // desired. - + $sql_options = (($star) ? " and starred = 1 " : ''); $sql_options .= (($bmark) ? " and bookmark = 1 " : ''); + $sql_nets = (($nets) ? sprintf(" and `contact`.`network` = '%s' ", dbesc($nets)) : ''); + // We'll need the following line if starred/bookmarks are allowed in comments in the future // $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` $sql_options ) "; @@ -336,6 +339,7 @@ function network_content(&$a, $update = 0) { . ((x($_GET,'bmark')) ? '&bmark=' . $_GET['bmark'] : '') . ((x($_GET,'liked')) ? '&liked=' . $_GET['liked'] : '') . ((x($_GET,'conv')) ? '&conv=' . $_GET['conv'] : '') + . ((x($_GET,'nets')) ? '&nets=' . $_GET['nets'] : '') . "'; var profile_page = " . $a->pager['page'] . "; \r\n"; } @@ -374,7 +378,7 @@ function network_content(&$a, $update = 0) { WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 $sql_extra2 - $sql_extra ", + $sql_extra $sql_nets ", intval($_SESSION['uid']) ); @@ -399,7 +403,7 @@ function network_content(&$a, $update = 0) { $simple_update AND `contact`.`id` = `item`.`contact-id` AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - $sql_extra + $sql_extra $sql_nets ORDER BY `item`.`received` DESC $pager_sql ", intval($_SESSION['uid']) ); @@ -423,7 +427,7 @@ function network_content(&$a, $update = 0) { WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`unseen` = 1 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - $sql_extra ", + $sql_extra $sql_nets ", intval(local_user()) ); } @@ -433,7 +437,7 @@ function network_content(&$a, $update = 0) { WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `item`.`parent` = `item`.`id` - $sql_extra + $sql_extra $sql_nets ORDER BY `item`.$ordering DESC $pager_sql ", intval(local_user()) ); @@ -459,7 +463,7 @@ function network_content(&$a, $update = 0) { AND `contact`.`id` = `item`.`contact-id` AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `item`.`parent` IN ( %s ) - $sql_extra ", + $sql_extra $sql_nets", intval(local_user()), dbesc($parents_str) ); From c3ada095f4156bba01e77d2d250d5821ba5e859e Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Jan 2012 20:40:48 -0800 Subject: [PATCH 4/4] network select widget --- include/contact_widgets.php | 33 +++++++++++++++++++++++++++++++ mod/network.php | 3 +++ view/nets.tpl | 10 ++++++++++ view/theme/duepuntozero/style.css | 17 +++++++++++++++- view/theme/loozah/style.css | 17 +++++++++++++++- view/theme/testbubble/style.css | 19 +++++++++++++++++- 6 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 view/nets.tpl diff --git a/include/contact_widgets.php b/include/contact_widgets.php index 3a21ff2c6f..424f2997ef 100644 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -40,3 +40,36 @@ function findpeople_widget() { } +function networks_widget($baseurl,$selected = '') { + + $a = get_app(); + + if(! local_user()) + return ''; + + + $r = q("select distinct(network) from contact where uid = %d", + intval(local_user()) + ); + + $nets = array(); + if(count($r)) { + require_once('include/contact_selectors.php'); + foreach($r as $rr) { + if($rr['network']) + $nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' )); + } + } + + return replace_macros(get_markup_template('nets.tpl'),array( + '$title' => t('Networks'), + '$desc' => '', + '$sel_all' => (($selected == '') ? 'selected' : ''), + '$all' => t('All Networks'), + '$nets' => $nets, + '$base' => $baseurl, + + )); +} + + diff --git a/mod/network.php b/mod/network.php index 76c7bb5e69..9318d20ca0 100644 --- a/mod/network.php +++ b/mod/network.php @@ -10,6 +10,8 @@ function network_init(&$a) { $group_id = (($a->argc > 1 && intval($a->argv[1])) ? intval($a->argv[1]) : 0); require_once('include/group.php'); + require_once('include/contact_widgets.php'); + if(! x($a->page,'aside')) $a->page['aside'] = ''; @@ -42,6 +44,7 @@ function network_init(&$a) { } $a->page['aside'] .= group_side('network','network',true,$group_id); + $a->page['aside'] .= networks_widget($a->get_baseurl() . '/network',(($_GET['nets']) ? $_GET['nets'] : '')); $a->page['aside'] .= saved_searches($search); } diff --git a/view/nets.tpl b/view/nets.tpl new file mode 100644 index 0000000000..b0cb8890c5 --- /dev/null +++ b/view/nets.tpl @@ -0,0 +1,10 @@ +
+

$title

+
$desc
+ $all +
    + {{ for $nets as $net }} +
  • $net.name
  • + {{ endfor }} +
+
diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css index 6ce4c52c05..6fa968da36 100644 --- a/view/theme/duepuntozero/style.css +++ b/view/theme/duepuntozero/style.css @@ -300,7 +300,7 @@ div.wall-item-content-wrapper.shiny { margin-bottom: 10px; } -.group-selected { +.group-selected, .nets-selected { padding: 3px; -moz-border-radius: 3px; border-radius: 3px; @@ -1836,6 +1836,21 @@ a.mail-list-link { margin-top: 10px; } +.nets-ul { + list-style-type: none; +} + +.nets-ul li { + margin-top: 10px; +} + +.nets-link { + margin-left: 24px; +} +.nets-all { + margin-left: 42px; +} + #search-save { margin-left: 5px; } diff --git a/view/theme/loozah/style.css b/view/theme/loozah/style.css index 6b8aef500b..ff31a78074 100644 --- a/view/theme/loozah/style.css +++ b/view/theme/loozah/style.css @@ -164,7 +164,7 @@ blockquote:before { margin-bottom: 10px; } -.group-selected { +.group-selected, .nets-selected { padding: 3px; border: 1px solid #CCCCCC; background: #F8F8F8; @@ -1901,6 +1901,21 @@ a.mail-list-link { width: 12px; } +.nets-ul { + list-style-type: none; +} + +.nets-ul li { + margin-top: 10px; +} + +.nets-link { + margin-left: 24px; +} +.nets-all { + margin-left: 42px; +} + #search-save { margin-left: 5px; } diff --git a/view/theme/testbubble/style.css b/view/theme/testbubble/style.css index 3a5d9f1788..54bbdeb980 100644 --- a/view/theme/testbubble/style.css +++ b/view/theme/testbubble/style.css @@ -630,7 +630,7 @@ h3#search:before { top:1px; } -.group-selected { +.group-selected, .nets-selected { padding-bottom: 0px; padding-left: 2px; padding-right: 2px; @@ -668,6 +668,23 @@ ul .sidebar-group-li .icon{ width: 12px; } + +.nets-ul { + list-style-type: none; +} + +.nets-ul li { + margin-top: 10px; +} + +.nets-link { + margin-left: 24px; +} +.nets-all { + margin-left: 42px; +} + + .widget h3{ background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #f0edf0), color-stop(1, #e2e2e2) ); background:-moz-linear-gradient( center top, #f0edf0 5%, #e2e2e2 100% );