[snowy] Return note-content with title prepended, and support notes that have no content but the title.



commit 5b8550470e86aeaed710085d93108fe791d5f598
Author: Sandy Armstrong <sanfordarmstrong gmail com>
Date:   Mon May 18 16:20:59 2009 -0700

    Return note-content with title prepended, and support notes that have no content but the title.
---
 api/handlers.py |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/api/handlers.py b/api/handlers.py
index 1176274..c6137dc 100644
--- a/api/handlers.py
+++ b/api/handlers.py
@@ -95,7 +95,8 @@ class NotesHandler(BaseHandler):
             return parser.parse(date).astimezone(pytz.timezone(settings.TIME_ZONE))
 
         def clean_content(content):
-            return content.split('\n', 1)[-1]
+            pieces = content.split('\n', 1)
+            return pieces[-1] if len(pieces) > 1 else ''
 
         user = User.objects.get(username=username)
         if request.user != user:
@@ -178,7 +179,8 @@ def describe_note(note):
     return {
         'guid': note.guid,
         'title': note.title,
-        'note-content': note.content,
+        # TODO: Not entirely sure why I need '\n\n'; where did the leading '\n' go?
+        'note-content': note.title + '\n\n' + note.content,
         'last-change-date': local_iso(note.user_modified),
         'last-metadata-change-date': local_iso(note.modified),
         'create-date': local_iso(note.created),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]