summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurélien Bompard <aurelien@bompard.org>2012-09-05 14:43:39 +0200
committerAurélien Bompard <aurelien@bompard.org>2012-09-05 14:43:39 +0200
commit54f6eb7982a562a3526ee3b9be62fa6e9344dbdb (patch)
tree1bc46849e095bd5868e13ca78a6479c4c4164b29
parentf409640d25c33247d06a3f00c006426e593cb751 (diff)
downloadhyperkitty-54f6eb7982a562a3526ee3b9be62fa6e9344dbdb.tar.gz
hyperkitty-54f6eb7982a562a3526ee3b9be62fa6e9344dbdb.tar.xz
hyperkitty-54f6eb7982a562a3526ee3b9be62fa6e9344dbdb.zip
Adapt to KittyStore's API change
-rw-r--r--hyperkitty/api.py2
-rw-r--r--hyperkitty/lib/__init__.py25
-rw-r--r--hyperkitty/templates/month_view.html4
-rw-r--r--hyperkitty/templates/threads/right_col.html2
-rw-r--r--hyperkitty/templates/user_profile.html2
-rw-r--r--hyperkitty/views/list.py14
-rw-r--r--hyperkitty/views/thread.py6
7 files changed, 44 insertions, 11 deletions
diff --git a/hyperkitty/api.py b/hyperkitty/api.py
index 1cea89c..1e8a05f 100644
--- a/hyperkitty/api.py
+++ b/hyperkitty/api.py
@@ -34,7 +34,7 @@ class ThreadResource(View):
def get(self, request, mlist_fqdn, threadid):
list_name = mlist_fqdn.split('@')[0]
STORE = ThreadSafeStorePool().get()
- thread = STORE.get_thread(list_name, threadid)
+ thread = STORE.get_messages_in_thread(list_name, threadid)
if not thread:
return HttpResponse(status=404)
else:
diff --git a/hyperkitty/lib/__init__.py b/hyperkitty/lib/__init__.py
index 887cfd5..9b541f9 100644
--- a/hyperkitty/lib/__init__.py
+++ b/hyperkitty/lib/__init__.py
@@ -3,6 +3,7 @@
import urllib
from hashlib import md5
import threading
+import datetime
from django.conf import settings
@@ -35,3 +36,27 @@ def gravatar_url(email):
query_string = urllib.urlencode({'s': size, 'd': default})
identifier = md5(email).hexdigest()
return 'http://www.gravatar.com/avatar/%s?%s' % (identifier, query_string)
+
+
+def get_months(store, list_name):
+ """ Return a dictionnary of years, months for which there are
+ potentially archives available for a given list (based on the
+ oldest post on the list).
+
+ :arg list_name, name of the mailing list in which this email
+ should be searched.
+ """
+ date_first = store.get_start_date(list_name)
+ if not date_first:
+ return {}
+ archives = {}
+ now = datetime.datetime.now()
+ year = date_first.year
+ month = date_first.month
+ while year < now.year:
+ archives[year] = range(1, 13)[(month -1):]
+ year = year + 1
+ month = 1
+ archives[now.year] = range(1, 13)[:now.month]
+ return archives
+
diff --git a/hyperkitty/templates/month_view.html b/hyperkitty/templates/month_view.html
index 24e4ae7..91d40f1 100644
--- a/hyperkitty/templates/month_view.html
+++ b/hyperkitty/templates/month_view.html
@@ -36,6 +36,7 @@
</div>
<div class="thread_info">
<ul class="tags inline">
+ {% if email.tags|length %}
<li>
Tags:
</li>
@@ -44,6 +45,7 @@
<a href="/tag/{{list_address}}/{{tag}}">{{tag}}</a>
</li>
{% endfor %}
+ {% endif %}
</ul>
<ul class="inline-block">
<li class="participant">
@@ -53,11 +55,13 @@
{{email.answers}} comments
</li>
</ul>
+ {% if settings.USE_MOCKUPS %}
<ul class="inline-block">
<li class="like">
+{{email.avglike}} / - {{email.avgdislike}}
</li>
</ul>
+ {% endif %}
</div>
</div>
<!-- End of thread -->
diff --git a/hyperkitty/templates/threads/right_col.html b/hyperkitty/templates/threads/right_col.html
index 78f0621..19ac788 100644
--- a/hyperkitty/templates/threads/right_col.html
+++ b/hyperkitty/templates/threads/right_col.html
@@ -21,9 +21,11 @@
old
</div>
</div>
+ {% if settings.USE_MOCKUPS %}
<p id="add_to_fav">
<a href="#AddFav" class="notsaved">Add to favorite discussions</a>
</p>
+ {% endif %}
<!-- End dates -->
<hr id="grey"/>
<div id="tags">
diff --git a/hyperkitty/templates/user_profile.html b/hyperkitty/templates/user_profile.html
index f0aa27e..798a947 100644
--- a/hyperkitty/templates/user_profile.html
+++ b/hyperkitty/templates/user_profile.html
@@ -33,6 +33,7 @@
</tr>
</tbody>
</table>
+ {% if settings.USE_MOCKUPS %}
<h3> Up Votes : </h3>
<ul>
@@ -64,6 +65,7 @@
{% endif %}
{% endfor %}
</ul>
+ {% endif %}
{% endblock %}
diff --git a/hyperkitty/views/list.py b/hyperkitty/views/list.py
index 21a983e..eb3ecd5 100644
--- a/hyperkitty/views/list.py
+++ b/hyperkitty/views/list.py
@@ -19,7 +19,7 @@ from django.contrib.auth.decorators import (login_required,
from hyperkitty.models import Rating, Tag
#from hyperkitty.lib.mockup import *
-from hyperkitty.lib import ThreadSafeStorePool
+from hyperkitty.lib import ThreadSafeStorePool, get_months
from forms import *
from hyperkitty.utils import log
@@ -69,7 +69,7 @@ def archives(request, mlist_fqdn, year=None, month=None, day=None):
search_form = SearchForm(auto_id=False)
t = loader.get_template('month_view.html')
STORE = ThreadSafeStorePool().get()
- threads = STORE.get_archives(mlist_fqdn, start=begin_date,
+ threads = STORE.get_threads(mlist_fqdn, start=begin_date,
end=end_date)
participants = set()
@@ -88,7 +88,7 @@ def archives(request, mlist_fqdn, year=None, month=None, day=None):
totalvotes = 0
totallikes = 0
totaldislikes = 0
- messages = STORE.get_thread(mlist_fqdn, thread.thread_id)
+ messages = STORE.get_messages_in_thread(mlist_fqdn, thread.thread_id)
for message in messages:
# Extract all the votes for this message
@@ -138,7 +138,7 @@ def archives(request, mlist_fqdn, year=None, month=None, day=None):
threads = paginator.page(paginator.num_pages)
- archives_length = STORE.get_archives_length(mlist_fqdn)
+ archives_length = get_months(STORE, mlist_fqdn)
c = RequestContext(request, {
'list_name' : list_name,
@@ -174,7 +174,7 @@ def list(request, mlist_fqdn=None):
begin_date = end_date - timedelta(days=32)
STORE = ThreadSafeStorePool().get()
- threads = STORE.get_archives(list_name=mlist_fqdn, start=begin_date,
+ threads = STORE.get_threads(list_name=mlist_fqdn, start=begin_date,
end=end_date)
participants = set()
@@ -207,7 +207,7 @@ def list(request, mlist_fqdn=None):
# active threads are the ones that have the most recent posting
active_threads = sorted(threads, key=lambda entry: entry.date, reverse=True)
- archives_length = STORE.get_archives_length(mlist_fqdn)
+ archives_length = get_months(STORE, mlist_fqdn)
# top authors are the ones that have the most kudos. How do we determine
# that? Most likes for their post?
@@ -351,7 +351,7 @@ def search_tag(request, mlist_fqdn, tag=None, page=1):
threads = []
for thread in thread_ids:
- threads_tmp = STORE.get_thread(mlist_fqdn, thread.threadid)
+ threads_tmp = STORE.get_messages_in_thread(mlist_fqdn, thread.threadid)
threads.append(threads_tmp[0])
return _search_results_page(request, mlist_fqdn, threads,
diff --git a/hyperkitty/views/thread.py b/hyperkitty/views/thread.py
index 8da41b7..f8820c9 100644
--- a/hyperkitty/views/thread.py
+++ b/hyperkitty/views/thread.py
@@ -13,7 +13,7 @@ from hyperkitty.models import Rating, Tag
from forms import *
from hyperkitty.utils import log
-from hyperkitty.lib import ThreadSafeStorePool
+from hyperkitty.lib import ThreadSafeStorePool, get_months
def thread_index (request, mlist_fqdn, threadid):
@@ -23,7 +23,7 @@ def thread_index (request, mlist_fqdn, threadid):
search_form = SearchForm(auto_id=False)
t = loader.get_template('thread.html')
STORE = ThreadSafeStorePool().get()
- threads = STORE.get_thread(mlist_fqdn, threadid)
+ threads = STORE.get_messages_in_thread(mlist_fqdn, threadid)
#prev_thread = mongo.get_thread_name(list_name, int(threadid) - 1)
prev_thread = []
if len(prev_thread) > 30:
@@ -65,7 +65,7 @@ def thread_index (request, mlist_fqdn, threadid):
participants[message.sender_name] = {'email': message.sender_email}
cnt = cnt + 1
- archives_length = STORE.get_archives_length(mlist_fqdn)
+ archives_length = get_months(STORE, mlist_fqdn)
from_url = '/thread/%s/%s/' % (mlist_fqdn, threadid)
tag_form = AddTagForm(initial={'from_url' : from_url})
u32 __cpuinit ramtop(void) { u32 clip = 0xFFFFFFFFUL; u32 top = 0; int i; for (i = 0; i < e820.nr_map; i++) { unsigned long start, end; if (e820.map[i].addr > 0xFFFFFFFFUL) continue; /* * Don't MCR over reserved space. Ignore the ISA hole * we frob around that catastrophe already */ if (e820.map[i].type == E820_RESERVED) { if (e820.map[i].addr >= 0x100000UL && e820.map[i].addr < clip) clip = e820.map[i].addr; continue; } start = e820.map[i].addr; end = e820.map[i].addr + e820.map[i].size; if (start >= end) continue; if (end > top) top = end; } /* * Everything below 'top' should be RAM except for the ISA hole. * Because of the limited MCR's we want to map NV/ACPI into our * MCR range for gunk in RAM * * Clip might cause us to MCR insufficient RAM but that is an * acceptable failure mode and should only bite obscure boxes with * a VESA hole at 15Mb * * The second case Clip sometimes kicks in is when the EBDA is marked * as reserved. Again we fail safe with reasonable results */ if (top > clip) top = clip; return top; } /* * Compute a set of MCR's to give maximum coverage */ static int __cpuinit centaur_mcr_compute(int nr, int key) { u32 mem = ramtop(); u32 root = power2(mem); u32 base = root; u32 top = root; u32 floor = 0; int ct = 0; while (ct < nr) { u32 fspace = 0; u32 high; u32 low; /* * Find the largest block we will fill going upwards */ high = power2(mem-top); /* * Find the largest block we will fill going downwards */ low = base/2; /* * Don't fill below 1Mb going downwards as there * is an ISA hole in the way. */ if (base <= 1024*1024) low = 0; /* * See how much space we could cover by filling below * the ISA hole */ if (floor == 0) fspace = 512*1024; else if (floor == 512*1024) fspace = 128*1024; /* And forget ROM space */ /* * Now install the largest coverage we get */ if (fspace > high && fspace > low) { centaur_mcr_insert(ct, floor, fspace, key); floor += fspace; } else if (high > low) { centaur_mcr_insert(ct, top, high, key); top += high; } else if (low > 0) { base -= low; centaur_mcr_insert(ct, base, low, key); } else break; ct++; } /* * We loaded ct values. We now need to set the mask. The caller * must do this bit. */ return ct; } static void __cpuinit centaur_create_optimal_mcr(void) { int used; int i; /* * Allocate up to 6 mcrs to mark as much of ram as possible * as write combining and weak write ordered. * * To experiment with: Linux never uses stack operations for * mmio spaces so we could globally enable stack operation wc * * Load the registers with type 31 - full write combining, all * writes weakly ordered. */ used = centaur_mcr_compute(6, 31); /* * Wipe unused MCRs */ for (i = used; i < 8; i++) wrmsr(MSR_IDT_MCR0+i, 0, 0); } static void __cpuinit winchip2_create_optimal_mcr(void) { u32 lo, hi; int used; int i; /* * Allocate up to 6 mcrs to mark as much of ram as possible * as write combining, weak store ordered. * * Load the registers with type 25 * 8 - weak write ordering * 16 - weak read ordering * 1 - write combining */ used = centaur_mcr_compute(6, 25); /* * Mark the registers we are using. */ rdmsr(MSR_IDT_MCR_CTRL, lo, hi); for (i = 0; i < used; i++) lo |= 1<<(9+i); wrmsr(MSR_IDT_MCR_CTRL, lo, hi); /* * Wipe unused MCRs */ for (i = used; i < 8; i++) wrmsr(MSR_IDT_MCR0+i, 0, 0); } /* * Handle the MCR key on the Winchip 2. */ static void __cpuinit winchip2_unprotect_mcr(void) { u32 lo, hi; u32 key; rdmsr(MSR_IDT_MCR_CTRL, lo, hi); lo &= ~0x1C0; /* blank bits 8-6 */ key = (lo>>17) & 7; lo |= key<<6; /* replace with unlock key */ wrmsr(MSR_IDT_MCR_CTRL, lo, hi); } static void __cpuinit winchip2_protect_mcr(void) { u32 lo, hi; rdmsr(MSR_IDT_MCR_CTRL, lo, hi); lo &= ~0x1C0; /* blank bits 8-6 */ wrmsr(MSR_IDT_MCR_CTRL, lo, hi); } #endif /* CONFIG_X86_OOSTORE */ #define ACE_PRESENT (1 << 6) #define ACE_ENABLED (1 << 7) #define ACE_FCR (1 << 28) /* MSR_VIA_FCR */ #define RNG_PRESENT (1 << 2) #define RNG_ENABLED (1 << 3) #define RNG_ENABLE (1 << 6) /* MSR_VIA_RNG */ static void __cpuinit init_c3(struct cpuinfo_x86 *c) { u32 lo, hi; /* Test for Centaur Extended Feature Flags presence */ if (cpuid_eax(0xC0000000) >= 0xC0000001) { u32 tmp = cpuid_edx(0xC0000001); /* enable ACE unit, if present and disabled */ if ((tmp & (ACE_PRESENT | ACE_ENABLED)) == ACE_PRESENT) { rdmsr(MSR_VIA_FCR, lo, hi); lo |= ACE_FCR; /* enable ACE unit */ wrmsr(MSR_VIA_FCR, lo, hi); printk(KERN_INFO "CPU: Enabled ACE h/w crypto\n"); } /* enable RNG unit, if present and disabled */ if ((tmp & (RNG_PRESENT | RNG_ENABLED)) == RNG_PRESENT) { rdmsr(MSR_VIA_RNG, lo, hi); lo |= RNG_ENABLE; /* enable RNG unit */ wrmsr(MSR_VIA_RNG, lo, hi); printk(KERN_INFO "CPU: Enabled h/w RNG\n"); } /* store Centaur Extended Feature Flags as * word 5 of the CPU capability bit array */ c->x86_capability[5] = cpuid_edx(0xC0000001); } #ifdef CONFIG_X86_32 /* Cyrix III family needs CX8 & PGE explicitly enabled. */ if (c->x86_model >= 6 && c->x86_model <= 9) { rdmsr(MSR_VIA_FCR, lo, hi); lo |= (1<<1 | 1<<7); wrmsr(MSR_VIA_FCR, lo, hi); set_cpu_cap(c, X86_FEATURE_CX8); } /* Before Nehemiah, the C3's had 3dNOW! */ if (c->x86_model >= 6 && c->x86_model < 9) set_cpu_cap(c, X86_FEATURE_3DNOW);