diff --git a/js/util.js b/js/util.js
index f82ca992c6..79fd40deba 100644
--- a/js/util.js
+++ b/js/util.js
@@ -399,58 +399,70 @@ var SN = { // StatusNet
return;
}
- $.fn.jOverlay.options = {
- method : 'GET',
- data : '',
- url : '',
- color : '#000',
- opacity : '0.6',
- zIndex : 9999,
- center : false,
- imgLoading : $('address .url')[0].href+'theme/base/images/illustrations/illu_progress_loading-01.gif',
- bgClickToClose : true,
- success : function() {
- $('#jOverlayContent').append('');
- $('#jOverlayContent button').click($.closeOverlay);
- },
- timeout : 0,
- autoHide : true,
- css : {'max-width':'542px', 'top':'5%', 'left':'32.5%'}
- };
+ var attachment_more = notice.find('.attachment.more');
+ if (attachment_more.length > 0) {
+ attachment_more.click(function() {
+ $.get($(this).attr('href')+'/ajax', null, function(data) {
+ notice.find('.entry-title .entry-content').html($(data).find('#attachment_view .entry-content').html());
+ });
- notice.find('a.attachment').click(function() {
- var attachId = ($(this).attr('id').substring('attachment'.length + 1));
- if (attachId) {
- $().jOverlay({url: $('address .url')[0].href+'attachment/' + attachId + '/ajax'});
return false;
- }
- });
-
- if ($('#shownotice').length == 0) {
- var t;
- notice.find('a.thumbnail').hover(
- function() {
- var anchor = $(this);
- $('a.thumbnail').children('img').hide();
- anchor.closest(".entry-title").addClass('ov');
-
- if (anchor.children('img').length === 0) {
- t = setTimeout(function() {
- $.get($('address .url')[0].href+'attachment/' + (anchor.attr('id').substring('attachment'.length + 1)) + '/thumbnail', null, function(data) {
- anchor.append(data);
- });
- }, 500);
- }
- else {
- anchor.children('img').show();
- }
+ });
+ }
+ else {
+ $.fn.jOverlay.options = {
+ method : 'GET',
+ data : '',
+ url : '',
+ color : '#000',
+ opacity : '0.6',
+ zIndex : 9999,
+ center : false,
+ imgLoading : $('address .url')[0].href+'theme/base/images/illustrations/illu_progress_loading-01.gif',
+ bgClickToClose : true,
+ success : function() {
+ $('#jOverlayContent').append('');
+ $('#jOverlayContent button').click($.closeOverlay);
},
- function() {
- clearTimeout(t);
- $('a.thumbnail').children('img').hide();
- $(this).closest('.entry-title').removeClass('ov');
+ timeout : 0,
+ autoHide : true,
+ css : {'max-width':'542px', 'top':'5%', 'left':'32.5%'}
+ };
+
+ notice.find('a.attachment').click(function() {
+ var attachId = ($(this).attr('id').substring('attachment'.length + 1));
+ if (attachId) {
+ $().jOverlay({url: $('address .url')[0].href+'attachment/' + attachId + '/ajax'});
+ return false;
}
- );
+ });
+
+ if ($('#shownotice').length == 0) {
+ var t;
+ notice.find('a.thumbnail').hover(
+ function() {
+ var anchor = $(this);
+ $('a.thumbnail').children('img').hide();
+ anchor.closest(".entry-title").addClass('ov');
+
+ if (anchor.children('img').length === 0) {
+ t = setTimeout(function() {
+ $.get($('address .url')[0].href+'attachment/' + (anchor.attr('id').substring('attachment'.length + 1)) + '/thumbnail', null, function(data) {
+ anchor.append(data);
+ });
+ }, 500);
+ }
+ else {
+ anchor.children('img').show();
+ }
+ },
+ function() {
+ clearTimeout(t);
+ $('a.thumbnail').children('img').hide();
+ $(this).closest('.entry-title').removeClass('ov');
+ }
+ );
+ }
}
},
diff --git a/lib/attachmentlist.php b/lib/attachmentlist.php
index dc6709d678..13dafd13e4 100644
--- a/lib/attachmentlist.php
+++ b/lib/attachmentlist.php
@@ -330,6 +330,13 @@ class Attachment extends AttachmentListItem
$this->out->element('param', array('name' => 'autoStart', 'value' => 1));
$this->out->elementEnd('object');
break;
+
+ case 'text/html':
+ if ($this->attachment->filename) {
+ // Locally-uploaded HTML. Scrub and display inline.
+ $this->showHtmlFile($this->attachment);
+ }
+ break;
}
}
} else {
@@ -356,5 +363,58 @@ class Attachment extends AttachmentListItem
}
}
}
+
+ protected function showHtmlFile(File $attachment)
+ {
+ $body = $this->scrubHtmlFile($attachment);
+ if ($body) {
+ $this->out->raw($body);
+ }
+ }
+
+ /**
+ * @return mixed false on failure, HTML fragment string on success
+ */
+ protected function scrubHtmlFile(File $attachment)
+ {
+ $path = File::path($attachment->filename);
+ if (!file_exists($path) || !is_readable($path)) {
+ common_log(LOG_ERR, "Missing local HTML attachment $path");
+ return false;
+ }
+ $raw = file_get_contents($path);
+
+ // Normalize...
+ $dom = new DOMDocument();
+ if(!$dom->loadHTML($raw)) {
+ common_log(LOG_ERR, "Bad HTML in local HTML attachment $path");
+ return false;
+ }
+
+ // Remove