You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2016/09/05 16:09:11 UTC
[1/2] incubator-ponymail git commit: add a multi-email view,
sorted by date
Repository: incubator-ponymail
Updated Branches:
refs/heads/coffee-and-cake 3861a6b80 -> d3fbe4889
add a multi-email view, sorted by date
displays emails as a long list, ordered by date (oldest first)
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/62ced230
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/62ced230
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/62ced230
Branch: refs/heads/coffee-and-cake
Commit: 62ced2301043c33df48d30d4f4f35403200a7cf2
Parents: 3861a6b
Author: Daniel Gruno <hu...@apache.org>
Authored: Mon Sep 5 18:08:54 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Mon Sep 5 18:08:54 2016 +0200
----------------------------------------------------------------------
site/js/coffee/email_display_bydate.coffee | 106 ++++++++++++++++++++++++
1 file changed, 106 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/62ced230/site/js/coffee/email_display_bydate.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/email_display_bydate.coffee b/site/js/coffee/email_display_bydate.coffee
new file mode 100644
index 0000000..3e66b30
--- /dev/null
+++ b/site/js/coffee/email_display_bydate.coffee
@@ -0,0 +1,106 @@
+###
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+###
+
+### date-sorted multi email display class - extends BasicEmail Display ###
+class DateEmailDisplay extends BasicEmailDisplay
+ constructor: (@parent, @mid, index) ->
+ @placeholder = get("placeholder_" + @mid) || new HTML('div', { class: "email_placeholder", id: "placeholder_" + @mid})
+
+
+ ### Inject into listview or body ###
+ @parent.inject(@placeholder)
+
+ ### Make sure it's empty, may have been used before! ###
+ @placeholder = @placeholder.empty()
+ @placeholder.show(true)
+
+ me = this
+
+ ### Find the thread or fake one ###
+ thread = {tid: @mid}
+ if index and ponymail_current_listview and ponymail_current_listview.json.thread_struct[index]
+ thread = ponymail_current_listview.json.thread_struct[index]
+
+
+ emails = [[@mid, 0]]
+ for item in @dateSort(thread)
+ emails.push(item)
+ for email in emails
+ @dateFetch(@placeholder, email[0])
+ return this
+
+ dateSort: (thread) ->
+ list = []
+ if thread.children and isArray(thread.children)
+ for item in thread.children
+ list.push([item.tid, item.epoch])
+ for citem in @dateSort(item)
+ list.push(citem)
+ list.sort((a,b) => a[1] > b[1])
+ return list
+
+ dateFetch: (parent, thread) ->
+ ### Make the thread item placeholder ###
+ bodyplace = new HTML('div', {id: "placeholder_#{@mid}_#{thread}", class:"email_boxed"})
+
+ ### Assign a random color to the left ###
+ @prevColor = @prevColor || ""
+ bcolors = ['#C93F20', '#20C94A', '#2063C9', '#C9AA20', '#AD20C9', '#99C920', '#20C9C3']
+ bcolor = bcolors[Math.round(Math.random()*bcolors.length)]
+ ### ensure we don't get the same color twice in a row ###
+ while bcolor == @prevColor
+ bcolor = bcolors[Math.round(Math.random()*bcolors.length)]
+ @prevColor = bcolor
+
+ bodyplace.style.borderLeft = "4px solid " + bcolor
+
+ replyplace = new HTML('div', {
+ id: "thread_replies_#{@mid}_#{thread}",
+ style: {
+
+ marginLeft: "20px"
+ }
+ })
+ place = new HTML('div',
+ {
+ id: "thread_parent_#{@mid}_#{thread}",
+ style: {
+ float: "left"
+ width: "100%"
+ }
+ }, [
+ bodyplace,
+ replyplace
+ ]
+ )
+ parent.inject(place)
+
+ ### Do we have this email in cache? ###
+ if ponymail_stored_email[thread]
+ @render(ponymail_stored_email[thread])
+ else
+ me = this
+ ### Not stored, fetch the email first ###
+ r = new HTTPRequest("api/email.lua?", {
+ get: {
+ id: thread
+ }
+ callback: (json, state) ->
+ me.render(json, state)
+ })
+
+
\ No newline at end of file
[2/2] incubator-ponymail git commit: regen JS
Posted by hu...@apache.org.
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/d3fbe488
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/d3fbe488
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/d3fbe488
Branch: refs/heads/coffee-and-cake
Commit: d3fbe4889c42d214e31ba84ff341f04ec5176d70
Parents: 62ced23
Author: Daniel Gruno <hu...@apache.org>
Authored: Mon Sep 5 18:08:59 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Mon Sep 5 18:08:59 2016 +0200
----------------------------------------------------------------------
site/js/ponymail-coffee.js | 143 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 142 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/d3fbe488/site/js/ponymail-coffee.js
----------------------------------------------------------------------
diff --git a/site/js/ponymail-coffee.js b/site/js/ponymail-coffee.js
index 427fea1..b3523d5 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, HTML, HTTPRequest, SingleListView, ThreadedEmailDisplay, calendar_months, cog, dbRead, dbWrite, dealWithKeyboard, e, genColors, get, hasRead, 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_domain, ponymail_email_open, ponymail_list, ponymail_list_json, ponymail_listname, ponymail_lists, ponymail_month, ponymail_preferences, ponymail_query, ponymail_quote_regex, ponymail_stored_email, ponymail_url_regex, ponymail_version, readEmail, renderListView, set, setupAccount, spinCheck, testCoffee, testToggle, toggleMonth, toggleQuote, toggleYear, txt,
+var BasicEmailDisplay, BasicListView, Calendar, DateEmailDisplay, HTML, HTTPRequest, SingleListView, ThreadedEmailDisplay, calendar_months, cog, dbRead, dbWrite, dealWithKeyboard, e, genColors, get, hasRead, 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_domain, ponymail_email_open, ponymail_list, ponymail_list_json, ponymail_listname, ponymail_lists, ponymail_month, ponymail_preferences, ponymail_query, ponymail_quote_regex, ponymail_stored_email, ponymail_url_regex, ponymail_version, readEmail, renderListView, set, setupAccount, spinCheck, testCoffee, testToggle, toggleMonth, toggleQuote, toggleYear, txt,
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;
@@ -840,6 +840,147 @@ toggleQuote = function(div) {
*/
+/* date-sorted multi email display class - extends BasicEmail Display */
+
+DateEmailDisplay = (function(superClass) {
+ extend(DateEmailDisplay, superClass);
+
+ function DateEmailDisplay(parent1, mid1, index) {
+ var email, emails, item, j, len, len1, me, o, ref, thread;
+ this.parent = parent1;
+ this.mid = mid1;
+ this.placeholder = get("placeholder_" + this.mid) || new HTML('div', {
+ "class": "email_placeholder",
+ id: "placeholder_" + this.mid
+ });
+
+ /* Inject into listview or body */
+ this.parent.inject(this.placeholder);
+
+ /* Make sure it's empty, may have been used before! */
+ this.placeholder = this.placeholder.empty();
+ this.placeholder.show(true);
+ me = this;
+
+ /* Find the thread or fake one */
+ thread = {
+ tid: this.mid
+ };
+ if (index && ponymail_current_listview && ponymail_current_listview.json.thread_struct[index]) {
+ thread = ponymail_current_listview.json.thread_struct[index];
+ }
+ emails = [[this.mid, 0]];
+ ref = this.dateSort(thread);
+ for (j = 0, len = ref.length; j < len; j++) {
+ item = ref[j];
+ emails.push(item);
+ }
+ for (o = 0, len1 = emails.length; o < len1; o++) {
+ email = emails[o];
+ this.dateFetch(this.placeholder, email[0]);
+ }
+ return this;
+ }
+
+ DateEmailDisplay.prototype.dateSort = function(thread) {
+ var citem, item, j, len, len1, list, o, ref, ref1;
+ list = [];
+ if (thread.children && isArray(thread.children)) {
+ ref = thread.children;
+ for (j = 0, len = ref.length; j < len; j++) {
+ item = ref[j];
+ list.push([item.tid, item.epoch]);
+ ref1 = this.dateSort(item);
+ for (o = 0, len1 = ref1.length; o < len1; o++) {
+ citem = ref1[o];
+ list.push(citem);
+ }
+ }
+ }
+ list.sort((function(_this) {
+ return function(a, b) {
+ return a[1] > b[1];
+ };
+ })(this));
+ return list;
+ };
+
+ DateEmailDisplay.prototype.dateFetch = function(parent, thread) {
+
+ /* Make the thread item placeholder */
+ var bcolor, bcolors, bodyplace, me, place, r, replyplace;
+ bodyplace = new HTML('div', {
+ id: "placeholder_" + this.mid + "_" + thread,
+ "class": "email_boxed"
+ });
+
+ /* Assign a random color to the left */
+ this.prevColor = this.prevColor || "";
+ bcolors = ['#C93F20', '#20C94A', '#2063C9', '#C9AA20', '#AD20C9', '#99C920', '#20C9C3'];
+ bcolor = bcolors[Math.round(Math.random() * bcolors.length)];
+
+ /* ensure we don't get the same color twice in a row */
+ while (bcolor === this.prevColor) {
+ bcolor = bcolors[Math.round(Math.random() * bcolors.length)];
+ }
+ this.prevColor = bcolor;
+ bodyplace.style.borderLeft = "4px solid " + bcolor;
+ replyplace = new HTML('div', {
+ id: "thread_replies_" + this.mid + "_" + thread,
+ style: {
+ marginLeft: "20px"
+ }
+ });
+ place = new HTML('div', {
+ id: "thread_parent_" + this.mid + "_" + thread,
+ style: {
+ float: "left",
+ width: "100%"
+ }
+ }, [bodyplace, replyplace]);
+ parent.inject(place);
+
+ /* Do we have this email in cache? */
+ if (ponymail_stored_email[thread]) {
+ return this.render(ponymail_stored_email[thread]);
+ } else {
+ me = this;
+
+ /* Not stored, fetch the email first */
+ return r = new HTTPRequest("api/email.lua?", {
+ get: {
+ id: thread
+ },
+ callback: function(json, state) {
+ return me.render(json, state);
+ }
+ });
+ }
+ };
+
+ return DateEmailDisplay;
+
+})(BasicEmailDisplay);
+
+
+/*
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+
/* threaded email display class - extends BasicEmail Display */
ThreadedEmailDisplay = (function(superClass) {