Skip to content

Commit

Permalink
python iso8601 date formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
max-mapper committed Aug 1, 2011
1 parent c19158f commit b64ee70
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
12 changes: 4 additions & 8 deletions attachments/index.html
Expand Up @@ -43,6 +43,7 @@
<body>
<div id="background"></div>
<div id="wrapper">
<div class="splash" style="margin: 0 auto; width: 537px"><img class="couch" src="images/couch.png"></div>
<div id="header">
<div class="autocompleter">
<input id="search" data-route="irc_search" placeholder="Search" />
Expand Down Expand Up @@ -155,15 +156,10 @@
</div>
</script>

<script id="mail_searchTemplate" type="text/mustache">
<script id="searchResultsTemplate" type="text/mustache">
{{#results}}
<li data-icon="false"><a data-id="{{_id}}"class="menuOption">{{subject}}</a></li>
{{/results}}
</script>

<script id="irc_searchTemplate" type="text/mustache">
{{#results}}
<li data-icon="false"><a data-id="{{_id}}"class="menuOption">{{message}}</a></li>
{{#mail}}<li data-icon="false"><a data-id="{{_id}}"class="mailResult menuOption">{{subject}}</a></li>{{/mail}}
{{#irc}}<li data-icon="false"><a data-id="{{_id}}"class="ircResult menuOption">{{message}}</a></li>{{/irc}}
{{/results}}
</script>

Expand Down
1 change: 1 addition & 0 deletions attachments/script/site.js
Expand Up @@ -20,6 +20,7 @@ app.handler = function(route) {
app.after = {
home: function() {
util.bindAutocomplete($('#search'))

// msg.latest().then(function(conversations) {
// console.log(conversations)
// var firsts = conversations.children.map(function(child) {
Expand Down
17 changes: 14 additions & 3 deletions attachments/script/util.js
Expand Up @@ -133,18 +133,29 @@ var util = function() {

function bindAutocomplete(input) {
input.keyup(function() {
var currentResults = [];
input.siblings('.loading').show();
util.delay(function() {
var searchRoute = input.attr('data-route')
, term = input.val()
;
function showResults(results, template) {
util.render(template, template + "_container", {results: results});
function showResults(results, type) {
results = _.map(results, function(result) {
var o = {};
o[type] = [result];
return o;
})
currentResults.push(results);
currentResults = _.sortBy(currentResults, function(result) {
return result;
})
util.render('searchResults', 'search-list', {results: currentResults});
}
var requests = _.map(_.keys(searchRoutes), function(route) {
var req = util.search(term, route, searchRoutes[route])
req.then(function(results) {
showResults(results, route);
var type = route.split('_')[0];
showResults(results, type);
})
return req;
})
Expand Down
8 changes: 7 additions & 1 deletion mbox2couch/jsonify_mbox.py
Expand Up @@ -5,6 +5,7 @@
import email
import quopri
from BeautifulSoup import BeautifulSoup
import dateutil.parser as parser # pip install python-dateutil==1.5 for python2.6

try:
import jsonlib2 as json # much faster then Python 2.6.x's stdlib
Expand All @@ -28,7 +29,12 @@ def cleanContent(msg):
def jsonifyMessage(msg):
headers = {}
for (k, v) in msg.items():
headers[k.lower()] = [v.decode('utf-8', 'ignore')]
k = k.lower()
v = v.decode('utf-8', 'ignore')
headers[k] = [v]
if k == "date":
date = parser.parse(v)
headers['date'] = [date.isoformat()]

json_msg = {'parts': [], 'headers': headers}

Expand Down

0 comments on commit b64ee70

Please sign in to comment.