Skip to content

Commit

Permalink
Made Import inline key a downloadable link #647
Browse files Browse the repository at this point in the history
  • Loading branch information
bnvk committed Oct 20, 2014
1 parent c807a45 commit 819436d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions static/default/html/jsapi/message/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,4 @@ $(document).on('click', '.message-crypto-show-inline-key', function() {
$(this).hide();
$('#message-crypto-inline-key-' + $(this).data('mid')).fadeIn();
});

7 changes: 6 additions & 1 deletion static/default/html/jsapi/message/thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ Mailpile.thread_analyze_message = function(mid) {
if (check_inline_pgp_key) {
var pgp_key = '-----BEGIN PGP PUBLIC KEY BLOCK-----' + check_inline_pgp_key.slice(1).join().split('-----END PGP PUBLIC KEY BLOCK-----')[0];
pgp_key += '-----END PGP PUBLIC KEY BLOCK-----';

// Make HTML5 download href
var pgp_href = 'data:application/pgp-keys;charset=ascii,' + encodeURIComponent(pgp_key.replace(/<\/?[^>]+(>|$)/g, ''));

// Replace Text
var key_template = _.template($('#template-messsage-inline-pgp-key-import').html());
var import_key_html = key_template({ pgp_key: pgp_key, mid: mid });
var name = Mailpile.instance.metadata[mid].from.fn;
var import_key_html = key_template({ pgp_key: pgp_key, pgp_href: pgp_href, mid: mid, name: name });
var new_email = email.replace(pgp_key, import_key_html);
$('#message-' + mid).find('.thread-item-text').html(new_email);
}
Expand Down
2 changes: 1 addition & 1 deletion static/default/html/partials/hidden.html
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ <h4><span class="icon-fingerprint"></span> <%= Mailpile.nice_fingerprint(fingerp


<script id="template-messsage-inline-pgp-key-import" type="text/template">
<a href="#" data-mid="<%= mid %>" class="message-crypto-import-key button-secondary half-bottom"><span class="icon-key"></span> {{_("Import Encryption Key")}}</a>
<a href="<%= pgp_href %>" data-mid="<%= mid %>" download="{{_('Encryption Key from')}} <%= name %>.asc" class="message-crypto-import-key button-secondary half-bottom"><span class="icon-key"></span> {{_("Import Encryption Key")}}</a>
<a href="#" data-mid="<%= mid %>" class="message-crypto-show-inline-key">{{_("Show inline encryption key")}}</a>
<div id="message-crypto-inline-key-<%= mid %>" class="message-crypto-inline-key half-top hide"><%= pgp_key %></div>
</script>

0 comments on commit 819436d

Please sign in to comment.