diff options
-rw-r--r-- | actions/newnotice.php | 5 | ||||
-rw-r--r-- | js/util.js | 14 | ||||
-rw-r--r-- | lib/noticelist.php | 2 | ||||
-rw-r--r-- | lib/util.php | 35 | ||||
-rw-r--r-- | theme/base/css/display.css | 12 | ||||
-rw-r--r-- | theme/default/css/display.css | 2 | ||||
-rw-r--r-- | theme/identica/css/display.css | 2 |
7 files changed, 60 insertions, 12 deletions
diff --git a/actions/newnotice.php b/actions/newnotice.php index 3677f54c2..15caff6ea 100644 --- a/actions/newnotice.php +++ b/actions/newnotice.php @@ -326,6 +326,8 @@ class NewnoticeAction extends Action } $this->maybeAddRedir($file_id, $short); + + return $file; } function maybeAddRedir($file_id, $url) @@ -350,7 +352,8 @@ class NewnoticeAction extends Action { File_to_post::processNew($filerec->id, $notice->id); - $this->maybeAddRedir($filerec->id, common_local_url('file', array('notice' => $this->notice->id))); + $this->maybeAddRedir($filerec->id, + common_local_url('file', array('notice' => $notice->id))); } /** diff --git a/js/util.js b/js/util.js index 9156045bb..e7c54b74a 100644 --- a/js/util.js +++ b/js/util.js @@ -222,6 +222,7 @@ $(document).ready(function(){ } $("#notice_data-text").val(""); $("#notice_data-attach").val(""); + $('#notice_data-attach_selected').remove(); counter(); } $("#form_notice").removeClass("processing"); @@ -233,7 +234,7 @@ $(document).ready(function(){ $("#form_notice").each(addAjaxHidden); NoticeReply(); NoticeAttachments(); - NoticeDataAttachSelected(); + NoticeDataAttach(); }); function NoticeReply() { @@ -312,10 +313,15 @@ function NoticeAttachments() { ); } -function NoticeDataAttachSelected() { - $('#notice_data-attach').change(function() { - S = '<div id="notice_data-attach_selected" class="success">'+$(this).val()+'</div>'; +function NoticeDataAttach() { + NDA = $('#notice_data-attach'); + NDA.change(function() { + S = '<div id="notice_data-attach_selected" class="success"><code>'+$(this).val()+'</code> <button>×</button></div>'; NDAS = $('#notice_data-attach_selected'); (NDAS.length > 0) ? NDAS.replaceWith(S) : $('#form_notice').append(S); + $('#notice_data-attach_selected button').click(function(){ + $('#notice_data-attach_selected').remove(); + NDA.val(''); + }); }); } diff --git a/lib/noticelist.php b/lib/noticelist.php index 6f05c63d6..44726a17b 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -432,7 +432,7 @@ class NoticeListItem extends Widget $this->out->elementStart('dl', 'response'); $this->out->element('dt', null, _('To')); $this->out->elementStart('dd'); - $this->out->element('a', array('href' => $convurl), + $this->out->element('a', array('href' => $convurl.'#notice-'.$this->notice->id), _('in context')); $this->out->elementEnd('dd'); $this->out->elementEnd('dl'); diff --git a/lib/util.php b/lib/util.php index 30b767c3e..f6d50b180 100644 --- a/lib/util.php +++ b/lib/util.php @@ -497,6 +497,22 @@ function common_linkify($url) { $attrs = array('href' => $longurl, 'rel' => 'external'); + $is_attachment = false; + $attachment_id = null; + $has_thumb = false; + + // Check to see whether there's a filename associated with this URL. + // If there is, it's an upload and qualifies as an attachment + + $localfile = File::staticGet('url', $longurl); + + if (!empty($localfile)) { + if (isset($localfile->filename)) { + $is_attachment = true; + $attachment_id = $localfile->id; + } + } + // if this URL is an attachment, then we set class='attachment' and id='attahcment-ID' // where ID is the id of the attachment for the given URL. // @@ -504,24 +520,35 @@ function common_linkify($url) { // we're currently picking up oembeds only. // I think the best option is another file_view table in the db // and associated dbobject. + $query = "select file_oembed.file_id as file_id from file join file_oembed on file.id = file_oembed.file_id where file.url='$longurl'"; $file = new File; $file->query($query); $file->fetch(); if (!empty($file->file_id)) { + $is_attachment = true; + $attachment_id = $file->file_id; + $query = "select file_thumbnail.file_id as file_id from file join file_thumbnail on file.id = file_thumbnail.file_id where file.url='$longurl'"; $file2 = new File; $file2->query($query); $file2->fetch(); - if (empty($file2->file_id)) { - $attrs['class'] = 'attachment'; - } else { + if (!empty($file2)) { + $has_thumb = true; + } + } + + // Add clippy + if ($is_attachment) { + $attrs['class'] = 'attachment'; + if ($has_thumb) { $attrs['class'] = 'attachment thumbnail'; } - $attrs['id'] = "attachment-{$file->file_id}"; + $attrs['id'] = "attachment-{$attachment_id}"; } + return XMLStringer::estring('a', $attrs, $display); } diff --git a/theme/base/css/display.css b/theme/base/css/display.css index bfcc9a7fa..78fcd7ece 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -518,6 +518,18 @@ width:81.5%; margin-bottom:0; line-height:1.618; } +#form_notice #notice_data-attach_selected code { +float:left; +width:90%; +display:block; +font-size:1.1em; +line-height:1.8; +overflow:auto; +} +#form_notice #notice_data-attach_selected button { +float:right; +font-size:0.8em; +} /* entity_profile */ .entity_profile { diff --git a/theme/default/css/display.css b/theme/default/css/display.css index f592e930f..89197bddb 100644 --- a/theme/default/css/display.css +++ b/theme/default/css/display.css @@ -245,7 +245,7 @@ div.notice-options input { font-family:sans-serif; } #content .notices li:hover { -background-color:#FCFCFC; +background-color:rgba(240, 240, 240, 0.2); } #conversation .notices li:hover { background-color:transparent; diff --git a/theme/identica/css/display.css b/theme/identica/css/display.css index 09ad4c972..025debf34 100644 --- a/theme/identica/css/display.css +++ b/theme/identica/css/display.css @@ -245,7 +245,7 @@ div.notice-options input { font-family:sans-serif; } #content .notices li:hover { -background-color:#FCFCFC; +background-color:rgba(240, 240, 240, 0.2); } #conversation .notices li:hover { background-color:transparent; |