Example #1
0
 def delete(self):
     if BLOG.posts:
         idx = app.body.current()
         if BLOG.post_is_local(idx) and BLOG.post_is_remote(idx):
             # remote post with local changes - many delete option
             options = ((LABELS.loc.gm_no,lambda x: False),
                        (LABELS.loc.pt_list_yes_rem_pst,BLOG.delete_only_remote_post),
                        (LABELS.loc.pt_list_yes_loc_ch,BLOG.delete_only_local_post),
                        (LABELS.loc.pt_list_yes_del_all,BLOG.delete_post))
         else:
             # just local or remote - delete
             options = ((LABELS.loc.gm_no,lambda x: False),
                        (LABELS.loc.gm_yes,BLOG.delete_post))
         ny = popup_menu(map(lambda x:x[0],options),LABELS.loc.pt_pmenu_del_post)
         if ny is not None:
             if ny > 0:
                 self.lock_ui(LABELS.loc.pt_info_del_post)
                 funcs = map(lambda x:x[1],options)
                 res = funcs[ny](idx)
                 if res:
                     note(LABELS.loc.pt_info_post_del,"info")
                 else:
                     note(LABELS.loc.pt_err_cant_del_pt,"error")                            
                 self.unlock_ui() 
                 self.refresh()
Example #2
0
 def offline_publish(self):
     if BLOG.posts:
         idx = self.body.current()
         if BLOG.post_is_local(idx):
             self.lock_ui()
             BLOG.offline_publish(idx)
             self.unlock_ui()
             self.refresh()
Example #3
0
 def popup_menu(self):
     idx = app.body.current()
     self.last_idx = idx
     menu = [(LABELS.loc.pt_menu_updt, self.update),
             (LABELS.loc.pt_menu_cnew, self.new)]
     if BLOG.posts:                
         menu += [(LABELS.loc.pt_menu_view, self.contents),
                  (LABELS.loc.pt_menu_dele, self.delete)]
         if BLOG.post_is_remote(idx):
             menu += [(LABELS.loc.pt_menu_lstc, self.comments)]
             if DB["twitter_enabled"] == u"True":
                 menu += [(LABELS.loc.pt_menu_s2tw, self.send2twitter)]
         if BLOG.post_is_local(idx):
             menu += [(LABELS.loc.pt_menu_offl_publ,self.offline_publish)]
     op = popup_menu(map(lambda x: x[0], menu) , LABELS.loc.pt_pmenu_posts)
     if op is not None:
         map(lambda x: x[1], menu)[op]()
Example #4
0
    def refresh(self):
        Dialog.refresh(self) # must be called *before* 

        if not BLOG.posts:
            self.headlines = [ (LABELS.loc.pt_info_empty, LABELS.loc.pt_info_updt_pst_lst) ]
        else:
            self.headlines = []
            for p in BLOG.posts:
                status = u""
                (y, mo, d, h, m, s) = parse_iso8601(p['dateCreated'].value)
                if BLOG.post_is_only_local(p):
                    status = u"[@] "
                elif BLOG.post_is_local(p):
                    status = u"[*] "
                elif p.has_key('post_status'):
                    if p['post_status'] != 'publish':
                        status = u"[#]"

                line1 = status + u"%02d/%s/%02d  %02d:%02d " % (d,MONTHS[mo-1],y,h,m) 
                line2 = utf8_to_unicode(p['title'])
                self.headlines.append((line1 , line2))
                               
        self.last_idx = min(self.last_idx, len(self.headlines)-1) # avoiding problems after removing
        self.body.set_list(self.headlines, self.last_idx)