ponymail-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From humbed...@apache.org
Subject [2/2] incubator-ponymail git commit: regen JS
Date Thu, 08 Sep 2016 06:08:11 GMT
regen JS


Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/20031f53
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/20031f53
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/20031f53

Branch: refs/heads/coffee-and-cake
Commit: 20031f5323fc37a00828cf819f3bb92dbd96f99f
Parents: 5baa953
Author: Daniel Gruno <humbedooh@apache.org>
Authored: Thu Sep 8 08:07:56 2016 +0200
Committer: Daniel Gruno <humbedooh@apache.org>
Committed: Thu Sep 8 08:07:56 2016 +0200

----------------------------------------------------------------------
 site/js/ponymail-coffee.js | 58 +++++++++++++++++++++++++++++++++++------
 1 file changed, 50 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/20031f53/site/js/ponymail-coffee.js
----------------------------------------------------------------------
diff --git a/site/js/ponymail-coffee.js b/site/js/ponymail-coffee.js
index f5d67b3..6a04c45 100644
--- a/site/js/ponymail-coffee.js
+++ b/site/js/ponymail-coffee.js
@@ -1,5 +1,5 @@
 // Generated by CoffeeScript 1.9.3
-var BasicEmailDisplay, BasicListView, Calendar, DateEmailDisplay, HTML, HTTPRequest, SingleListView,
ThreadedEmailDisplay, calendar_months, cog, dbRead, dbWrite, dealWithKeyboard, e, footerScaffolding,
genColors, get, hasRead, headerScaffolding, hsl2rgb, isArray, isHash, listView, listviewScaffolding,
markRead, maxLists, parseURL, pendingURLStatus, pending_spinner_at, pending_url_operations,
pm_snap, pm_storage_available, pm_storage_globvar, ponymail_current_email, ponymail_current_listview,
ponymail_display_models, ponymail_domain, ponymail_email_open, ponymail_list, ponymail_list_json,
ponymail_listname, ponymail_lists, ponymail_listview_models, ponymail_month, ponymail_preferences,
ponymail_query, ponymail_quote_regex, ponymail_register_display, ponymail_register_listview,
ponymail_stored_email, ponymail_url_regex, ponymail_version, quickSearch, quickSearchBar,
readEmail, renderListView, scaffoldingEmailCallback, set, setupAccount, spinCheck, testCoffee,
testToggle, threadScaffol
 ding, toggleMonth, toggleQuote, toggleYear, txt,
+var BasicEmailDisplay, BasicListView, Calendar, DateEmailDisplay, HTML, HTTPRequest, SingleListView,
ThreadedEmailDisplay, calendar_months, cog, dbRead, dbWrite, dealWithKeyboard, e, footerScaffolding,
genColors, get, hasRead, headerScaffolding, hsl2rgb, isArray, isHash, listView, listviewScaffolding,
markRead, maxLists, parseURL, pendingURLStatus, pending_spinner_at, pending_url_operations,
pm_snap, pm_storage_available, pm_storage_globvar, ponymail_current_email, ponymail_current_listview,
ponymail_display_models, ponymail_domain, ponymail_email_open, ponymail_list, ponymail_list_json,
ponymail_listname, ponymail_lists, ponymail_listview_models, ponymail_month, ponymail_preferences,
ponymail_query, ponymail_quote_regex, ponymail_register_display, ponymail_register_listview,
ponymail_stored_email, ponymail_url_regex, ponymail_version, quickSearch, quickSearchBar,
readEmail, renderListView, scaffoldingEmailCallback, set, setupAccount, shortBits, shortenURL,
spinCheck, testCoffee, te
 stToggle, threadScaffolding, toggleMonth, toggleQuote, toggleYear, txt, unshortenURL,
   extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key))
child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype =
parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return
child; },
   hasProp = {}.hasOwnProperty;
 
@@ -661,7 +661,7 @@ BasicEmailDisplay = (function() {
   BasicEmailDisplay.prototype.render = function(json, state) {
 
     /* Store email in cache if not there already */
-    var at, att_line, b, buttons, date_line, file, from_line, fsize, headers, htmlbody, j,
len, link, list_line, pbutton, placeholder, rbutton, ref, sbutton, subject_line;
+    var at, att_line, b, buttons, date_line, file, from_line, fsize, headers, htmlbody, j,
len, link, list_line, pbutton, placeholder, rbutton, ref, sbutton, shortID, subject_line;
     if (!ponymail_stored_email[json.mid]) {
       ponymail_stored_email[json.mid] = json;
     }
@@ -755,9 +755,10 @@ BasicEmailDisplay = (function() {
     /* Action buttons */
 
     /* Permalink */
+    shortID = shortenURL(json.mid);
     pbutton = new HTML('a', {
       "class": "label_yellow",
-      href: "thread.html/" + json.mid
+      href: "thread.html/" + shortID
     }, "Permalink");
 
     /* Source */
@@ -1854,7 +1855,7 @@ BasicListView = (function() {
   BasicListView.prototype.listViewItem = function(original, thread, index) {
 
     /* Be sure we actually have an email here */
-    var avatar, date, date_style, envelopeimg, item, noeml, now, people, peopleimg, readStyle,
sender, stats, subject, uid;
+    var avatar, date, date_style, envelopeimg, item, noeml, now, people, peopleimg, readStyle,
sender, sid, stats, subject, uid;
     if (original && thread) {
       now = new Date().getTime() / 1000;
 
@@ -1895,12 +1896,13 @@ BasicListView = (function() {
       }
 
       /* Subject, PLUS a bit of the body with a break before */
+      sid = shortenURL(thread.tid);
       subject = new HTML('div', {}, [
         new HTML('a', {
           style: {
             fontWeight: readStyle
           },
-          href: "thread.html/" + thread.tid,
+          href: "thread.html/#sid}",
           onclick: "readEmail(this.parentNode.parentNode.parentNode); this.style.fontWeight
= 'normal'; return false;"
         }, original.subject), new HTML('br'), new HTML('span', {
           "class": "listview_item_body"
@@ -2281,7 +2283,7 @@ SingleListView = (function(superClass) {
   SingleListView.prototype.listViewItem = function(original, thread) {
 
     /* Be sure we actually have an email here */
-    var avatar, date, date_style, item, now, readStyle, sender, subject, uid;
+    var avatar, date, date_style, item, now, readStyle, sender, sid, subject, uid;
     if (original) {
       now = new Date().getTime() / 1000;
 
@@ -2310,12 +2312,13 @@ SingleListView = (function(superClass) {
       }
 
       /* Subject, PLUS a bit of the body with a break before */
+      sid = shortenURL(original.id);
       subject = new HTML('div', {}, [
         new HTML('a', {
           style: {
             fontWeight: readStyle
           },
-          href: "thread.html/" + original.id,
+          href: "thread.html/" + sid,
           onclick: "readEmail(this.parentNode.parentNode.parentNode); this.style.fontWeight
= 'normal'; return false;"
         }, original.subject)
       ]);
@@ -2534,6 +2537,45 @@ ponymail_url_regex = new RegExp("(" + "(?:(?:[a-z]+)://)" + "(?:\\S+(?::\\S*)?@)
 
 ponymail_quote_regex = new RegExp("((?:\r?\n)((on .+ wrote:[\r\n]+)|(sent from my .+)|(>+[
\t]*[^\r\n]*\r?\n[^\n]*\n*)+)+)+", "mi");
 
+shortBits = 3;
+
+shortenURL = function(mid) {
+  var a, arr, i, j, num, out, ref, res;
+  arr = mid.split("@");
+  if (arr.length === 2 && (pm_config && pm_config.shortenLinks)) {
+    out = "";
+    for (i = j = 0, ref = shortBits - 1; 0 <= ref ? j <= ref : j >= ref; i = 0 <=
ref ? ++j : --j) {
+      a = arr[0].substr(i * 8, 8);
+      num = parseInt(a, 16);
+      res = num.toString(36);
+      while (res.length < 7) {
+        res = '-' + res;
+      }
+      out += res;
+    }
+    return "PZ" + out;
+  }
+  return mid;
+};
+
+unshortenURL = function(mid) {
+  var i, j, num, out, ref, res;
+  if (mid.substr(0, 2) === 'PZ') {
+    out = "";
+    for (i = j = 0, ref = shortBits - 1; 0 <= ref ? j <= ref : j >= ref; i = 0 <=
ref ? ++j : --j) {
+      num = parseInt(mid.substr(2 + (i * 7), 7).replace('-', ''), 36);
+      res = num.toString(16);
+      while (res.length < 8) {
+        res = '0' + res;
+      }
+      out += res;
+    }
+    return out;
+  } else {
+    return mid;
+  }
+};
+
 
 /*
  Licensed to the Apache Software Foundation (ASF) under one or more
@@ -2770,7 +2812,7 @@ threadScaffolding = function() {
 
   /* Make an API call to the preferences script, have it call back to listView once done
*/
   mid = location.href.match(/thread\.html\/(.+)/)[1];
-  return r = new HTTPRequest("api/thread.lua?id=" + mid, {
+  return r = new HTTPRequest("api/thread.lua?id=" + unshortenURL(mid), {
     callback: scaffoldingEmailCallback
   });
 };


Mime
View raw message