2008-04-22 23:24:30 +00:00
import cgi
from urllib import urlencode
from Rss_channel import Rss_channel
from Rss_item import Rss_item
class Updates_rss ( Rss_channel ) :
def __init__ (
self ,
recent_notes ,
notebook_id ,
notebook_name ,
https_url ,
) :
if notebook_name == u " Luminotes " :
notebook_path = u " / "
elif notebook_name == u " Luminotes user guide " :
notebook_path = u " /guide "
elif notebook_name == u " Luminotes blog " :
notebook_path = u " /blog "
else :
notebook_path = u " /notebooks/ %s " % notebook_id
notebook_path = https_url + notebook_path
Rss_channel . __init__ (
self ,
cgi . escape ( notebook_name ) ,
notebook_path ,
u " Luminotes notebook " ,
2008-05-27 06:00:31 +00:00
recent_notes and [ Rss_item (
2008-04-22 23:24:30 +00:00
title = u " Note updated " ,
link = self . note_link ( notebook_id , notebook_name , note_id , revision , https_url ) ,
description = cgi . escape ( u ' A note in <a href= " %s " >this notebook</a> has been updated. <a href= " %s ?note_id= %s " >View the note.</a> ' % ( notebook_path , notebook_path , note_id ) ) ,
date = revision . strftime ( " % Y- % m- %d T % H: % M: % SZ " ) ,
guid = self . note_link ( notebook_id , notebook_name , note_id , revision , https_url ) ,
2008-05-27 06:00:31 +00:00
) for ( note_id , revision ) in recent_notes ] or [ Rss_item (
title = u " Unknown notebook " ,
link = None ,
description = cgi . escape ( u ' Sorry, that notebook is unknown. ' ) ,
date = None ,
guid = None ,
) ] ,
2008-04-22 23:24:30 +00:00
)
@staticmethod
def note_link ( notebook_id , notebook_name , note_id , revision , https_url ) :
query = urlencode ( [
( u " notebook_id " , notebook_id ) ,
2008-04-24 20:32:43 +00:00
( u " notebook_name " , notebook_name . encode ( " utf8 " ) ) ,
2008-04-22 23:24:30 +00:00
( u " note_id " , note_id ) ,
( u " revision " , unicode ( revision ) ) ,
] )
return cgi . escape ( u " %s /notebooks/get_update_link? %s " % ( https_url , query ) )