Skip to content

Commit

Permalink
Merge pull request #14 from derwassi/master
Browse files Browse the repository at this point in the history
display of multipart messages
  • Loading branch information
ian-kent committed Dec 12, 2014
2 parents 537f51a + 72ec3f7 commit 36a5728
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions MailHog-UI/assets/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ mailhogApp.controller('MailCtrl', function ($scope, $http, $sce, $timeout) {
$scope.getMessagePlain = function(message) {
var l = $scope.findMatchingMIME(message, "text/plain");
if(l != null && l !== "undefined") {
return l.Body;
return $scope.tryDecode(l);
}
return message.Content.Body;
}
Expand Down Expand Up @@ -217,11 +217,18 @@ mailhogApp.controller('MailCtrl', function ($scope, $http, $sce, $timeout) {
$scope.getMessageHTML = function(message) {
var l = $scope.findMatchingMIME(message, "text/html");
if(l != null && l !== "undefined") {
return l.Body;
return $scope.tryDecode(l);
}
return "<HTML not found>";
}

$scope.tryDecode = function(l){
if(l.Headers && l.Headers["Content-Type"] && l.Headers["Content-Transfer-Encoding"]){
return $scope.tryDecodeContent({Content:l},l.Body.replace(/=[\r\n]+/gm,""));
}else{
return l.Body;
}
};
$scope.date = function(timestamp) {
return (new Date(timestamp)).toString();
};
Expand Down
2 changes: 1 addition & 1 deletion MailHog-UI/assets/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ <h4 class="modal-title">Release message</h4>
</ul>
<div class="tab-content">
<div ng-if="hasHTML(preview)" ng-class="{ active: hasHTML(preview) }" class="tab-pane" id="preview-html" ng-bind-html="preview.previewHTML"></div>
<div class="tab-pane" ng-class="{ active: !hasHTML(preview) }" id="preview-plain">{{ tryDecodeContent(preview, getMessagePlain(preview)) }}</div>
<div class="tab-pane" ng-class="{ active: !hasHTML(preview) }" id="preview-plain">{{ getMessagePlain(preview) }}</div>
<div class="tab-pane" id="preview-source">{{ getSource(preview) }}</div>
<div class="tab-pane" id="preview-mime">
<div ng-repeat="part in preview.MIME.Parts" class="mime-part">
Expand Down

0 comments on commit 36a5728

Please sign in to comment.