comparison plugins/plugin_misc_cs.py @ 109:18b0cf49a6f1

Plugin CS minor changes (Events & Couch Search tabs temporarly removed, open_new_tab user to open link in browser)
author Goffi <goffi@goffi.org>
date Tue, 29 Jun 2010 15:19:59 +0800
parents e24e080e6b16
children 5c68a65548c3
comparison
equal deleted inserted replaced
108:e24e080e6b16 109:18b0cf49a6f1
175 interface.changeLayout('vertical') 175 interface.changeLayout('vertical')
176 interface.addLabel(_("Message")) 176 interface.addLabel(_("Message"))
177 interface.addText("(use %name% for contact name and %firstname% for guessed first name)") 177 interface.addText("(use %name% for contact name and %firstname% for guessed first name)")
178 interface.addTextBox('message') 178 interface.addTextBox('message')
179 interface.addButton('plugin_CS_sendMessage', 'sendMessage', _('send'), fields_back=['friends','subject','message']) 179 interface.addButton('plugin_CS_sendMessage', 'sendMessage', _('send'), fields_back=['friends','subject','message'])
180 interface.addCategory(_("Events"), "vertical") 180 #interface.addCategory(_("Events"), "vertical") #TODO: coming soon, hopefuly :)
181 interface.addCategory(_("Couch search"), "vertical") 181 #interface.addCategory(_("Couch search"), "vertical")
182 return interface.toXml() 182 return interface.toXml()
183 183
184 def __meetingPageCB(self, html): 184 def __meetingPageCB(self, html):
185 """Called when the meeting page has been received""" 185 """Called when the meeting page has been received"""
186 186
268 """Called when the inbox page has been received""" 268 """Called when the inbox page has been received"""
269 #FIXME: that's really too fragile, only works if the unread messages are in the first page, and it would be too resources consuming for the website to DL each time all pages. In addition, the show attribute doesn't work as expected. 269 #FIXME: that's really too fragile, only works if the unread messages are in the first page, and it would be too resources consuming for the website to DL each time all pages. In addition, the show attribute doesn't work as expected.
270 soup = BeautifulSoup(html) 270 soup = BeautifulSoup(html)
271 for tag in soup.findAll(lambda tag: tag.name=='strong' and tag.a and tag.a['href'].startswith('messages.html?message_status=inbox')): 271 for tag in soup.findAll(lambda tag: tag.name=='strong' and tag.a and tag.a['href'].startswith('messages.html?message_status=inbox')):
272 link = "http://www.couchsurfing.org/"+str(tag.a['href']) 272 link = "http://www.couchsurfing.org/"+str(tag.a['href'])
273 webbrowser.open(link, new=2) #TODO: the web browser need to already have CS cookies (i.e. already be opened & logged on CS, or be permanently loggued), a warning to the user should be sent 273 webbrowser.open_new_tab(link) #TODO: the web browser need to already have CS cookies (i.e. already be opened & logged on CS, or be permanently loggued), a warning to the user should be sent/or a balloon-tip
274 274
275 def showUnreadMessages(self, id, data, profile): 275 def showUnreadMessages(self, id, data, profile):
276 """Called when user want to see all unread messages in the external browser""" 276 """Called when user want to see all unread messages in the external browser"""
277 d = getPage("http://www.couchsurfing.org/messages.html?message_status=inbox&show=10000", agent=AGENT, cookies=self.data[profile]['cookies']) 277 d = getPage("http://www.couchsurfing.org/messages.html?message_status=inbox&show=10000", agent=AGENT, cookies=self.data[profile]['cookies'])
278 d.addCallback(self.__showUnreadMessages2, id, profile) 278 d.addCallback(self.__showUnreadMessages2, id, profile)