From b5ac6e31f2f148164860aeabec6899b75d7292ec Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Sun, 24 May 2009 04:43:34 -0400 Subject: Rearranged attachment info to only appear on each applicable notice page and thru an ajax popup. --- lib/router.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/router.php') diff --git a/lib/router.php b/lib/router.php index 70ee0f3fb..39c005609 100644 --- a/lib/router.php +++ b/lib/router.php @@ -151,26 +151,35 @@ class Router $m->connect('search/notice/rss?q=:q', array('action' => 'noticesearchrss'), array('q' => '.+')); +/* + $m->connect('attachment/ajax_by_url/*url', + array('action' => 'attachment_ajax')); +*/ $m->connect('attachment/:attachment/ajax', array('action' => 'attachment_ajax'), - array('notice' => '[0-9]+')); + array('attachment' => '[0-9]+')); +/* + TODO + not used right now, will revisit later $m->connect('attachment/:attachment', array('action' => 'attachment'), - array('notice' => '[0-9]+')); - + array('attachment' => '[0-9]+')); +*/ // notice $m->connect('notice/new', array('action' => 'newnotice')); $m->connect('notice/new?replyto=:replyto', array('action' => 'newnotice'), array('replyto' => '[A-Za-z0-9_-]+')); +/* $m->connect('notice/:notice/attachments/ajax', array('action' => 'attachments_ajax'), array('notice' => '[0-9]+')); $m->connect('notice/:notice/attachments', array('action' => 'attachments'), array('notice' => '[0-9]+')); +*/ $m->connect('notice/:notice', array('action' => 'shownotice'), array('notice' => '[0-9]+')); -- cgit v1.2.3-54-g00ecf From 84edf12791dc3d44625b156cda6296f1f74f8a9d Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Mon, 25 May 2009 11:13:13 -0400 Subject: Display thumbnail on hover over links in notices when appropriate. --- js/util.js | 13 +++++++++++++ lib/attachmentlist.php | 4 ++-- lib/router.php | 4 ++++ lib/util.php | 12 +++++++++++- theme/base/css/display.css | 8 ++++++++ 5 files changed, 38 insertions(+), 3 deletions(-) (limited to 'lib/router.php') diff --git a/js/util.js b/js/util.js index b6848abaa..9ee2a1963 100644 --- a/js/util.js +++ b/js/util.js @@ -25,6 +25,19 @@ $(document).ready(function(){ //need to link to proper url depending on site config (path name and theme, for instance) $('a.attachment').click(function() {$().jOverlay({url:'/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); return false; }); $('.entry-title a.attachment').append(' Attachment'); + $('a.thumbnail').hover(function() { + anchor = $(this); + $.get('/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/thumbnail', null, function(data) { + anchor.append(data); + $('#thumbnail').fadeIn('def'); + }); + }, + function() { + setTimeout(function() { + $('#thumbnail').fadeOut('slow', function() {$(this).remove();}); + }, 500); + } + ); // count character on keyup function counter(event){ diff --git a/lib/attachmentlist.php b/lib/attachmentlist.php index 1be7b2fee..52aa5d9ee 100644 --- a/lib/attachmentlist.php +++ b/lib/attachmentlist.php @@ -171,7 +171,7 @@ class AttachmentListItem extends Widget } function linkTitle() { - return 'Our page for ' . $this->title(); + return $this->title(); } /** @@ -256,7 +256,7 @@ class Attachment extends AttachmentListItem } function linkTitle() { - return 'Direct link to ' . $this->title(); + return $this->attachment->url; } function showRepresentation() { diff --git a/lib/router.php b/lib/router.php index 39c005609..d1e2970c5 100644 --- a/lib/router.php +++ b/lib/router.php @@ -159,6 +159,10 @@ class Router array('action' => 'attachment_ajax'), array('attachment' => '[0-9]+')); + $m->connect('attachment/:attachment/thumbnail', + array('action' => 'attachment_thumbnail'), + array('attachment' => '[0-9]+')); + /* TODO not used right now, will revisit later diff --git a/lib/util.php b/lib/util.php index 4a55cbfe5..d56f44f7b 100644 --- a/lib/util.php +++ b/lib/util.php @@ -503,8 +503,18 @@ function common_linkify($url) { $file = new File; $file->query($query); $file->fetch(); + if (!empty($file->file_id)) { - $attrs['class'] = 'attachment'; + $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 { + $attrs['class'] = 'attachment thumbnail'; + } $attrs['id'] = "attachment-{$file->file_id}"; } return XMLStringer::estring('a', $attrs, $display); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 8f72460a8..71a434c54 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -1205,3 +1205,11 @@ display:none; .guide { clear:both; } + +#thumbnail { +position:absolute; +z-index: 999; +display: none; +left: 100px; +} + -- cgit v1.2.3-54-g00ecf From 64d0767654d93de81a0779f04eb992c574bbdece Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Mon, 25 May 2009 19:42:03 +0000 Subject: Removed more cruft from old attachment/attachements pages --- actions/tag.php | 2 -- lib/router.php | 22 +--------------------- 2 files changed, 1 insertion(+), 23 deletions(-) (limited to 'lib/router.php') diff --git a/actions/tag.php b/actions/tag.php index e71ec06a8..e9351d241 100644 --- a/actions/tag.php +++ b/actions/tag.php @@ -49,8 +49,6 @@ class TagAction extends Action { $pop = new PopularNoticeSection($this); $pop->show(); -// $freqatt = new FrequentAttachmentSection($this); -// $freqatt->show(); } function title() diff --git a/lib/router.php b/lib/router.php index d1e2970c5..fc119821b 100644 --- a/lib/router.php +++ b/lib/router.php @@ -151,10 +151,6 @@ class Router $m->connect('search/notice/rss?q=:q', array('action' => 'noticesearchrss'), array('q' => '.+')); -/* - $m->connect('attachment/ajax_by_url/*url', - array('action' => 'attachment_ajax')); -*/ $m->connect('attachment/:attachment/ajax', array('action' => 'attachment_ajax'), array('attachment' => '[0-9]+')); @@ -163,27 +159,11 @@ class Router array('action' => 'attachment_thumbnail'), array('attachment' => '[0-9]+')); -/* - TODO - not used right now, will revisit later - $m->connect('attachment/:attachment', - array('action' => 'attachment'), - array('attachment' => '[0-9]+')); -*/ - // notice - $m->connect('notice/new', array('action' => 'newnotice')); $m->connect('notice/new?replyto=:replyto', array('action' => 'newnotice'), array('replyto' => '[A-Za-z0-9_-]+')); -/* - $m->connect('notice/:notice/attachments/ajax', - array('action' => 'attachments_ajax'), - array('notice' => '[0-9]+')); - $m->connect('notice/:notice/attachments', - array('action' => 'attachments'), - array('notice' => '[0-9]+')); -*/ + $m->connect('notice/:notice', array('action' => 'shownotice'), array('notice' => '[0-9]+')); -- cgit v1.2.3-54-g00ecf