Beispiel #1
0
    def get(self,key):
        uri = self.request.uri
        request = {}
        board = Board()
        
        pin_keys = board.allKey()
        pin_count = len(pin_keys)
        
        query = {}
        query['q']         = "user:%s" % key
                
        query['start']  = "0"
        query['rows']   = globalSetting['max_index_board_rows']
        query['sort']   = "follow"
        
        if "page" in uri:
            request = urldecode(uri)
            page = int(request['page'])
            query['start']  = query['rows']*page
            #if pin_count < query['rows']*page:
            #    return ''
        
        board_data = board.solr(query)
        print len(board_data)
                
        boards_dict = board.formatBoards(board_data)

        if request:
            #print request['callback']
            #print request['page']            
            callback_result = {
                            'filter':'board:index',
                            'boards':boards_dict
                            }
            
            callback_response = "%s(%s)" % (request['callback'],json.dumps(callback_result))
            self.set_header("Content-Type", "text/html; charset=utf-8")            
            return self.write(callback_response)
        else:            
            user = User()
            boards = ''
            for _board_t in boards_dict:
                boards = self.render_string('board_unit.html',board=_board_t) + boards
                
            u_user = user.getInfo(key)
            
            userFollow = UserFollow()
            counts = {}
            counts['follow'] = len(userFollow.getByKeyValues("user", key))
            
            counts['fans'] = len(userFollow.getByKeyValues("follow", key)) 
 
            self.render('user_board.html',counts=counts,u_user=u_user,user=self.currentUserInfo(),boards=boards)    
Beispiel #2
0
 def get(self,key):
     uri = self.request.uri
     request = {}
     pin = Pin()
     
     pin_keys = pin.getByKeyValues("user",key)
     pin_count = len(pin_keys)
     
     query = {}
     query['q']         = "user:%s" % key    
             
     query['start']  = "0"
     query['rows']   = globalSetting['max_index_pin_rows']
     query['sort']   = "createTime"
     
     if "page" in uri:
         request = urldecode(uri)
         page = int(request['page'])
         query['start']  = query['rows']*page
         if pin_count < query['rows']*page:
             return ''
     
     pin_data = pin.solr(query)
     marks_dict = pin.formatPins(pin_data)    
     
     if request:
         #print request
         callback_result = {
                         'filter':'pin:index',
                         'pins':marks_dict
                         }
         
         callback_response = "%s(%s)" % (request['callback'],json.dumps(callback_result))
         self.set_header("Content-Type", "text/html; charset=utf-8")            
         return self.write(callback_response)
     else:
         board = Board()
         user = User()
         marks = ''
         for _mark_t in marks_dict:
             marks = self.render_string('mark.html',mark=_mark_t)+marks
         u_user = user.getInfo(key)
         
         userFollow = UserFollow()
         counts = {}
         counts['follow'] = len(userFollow.getByKeyValues("user", key))
         
         counts['fans'] = len(userFollow.getByKeyValues("follow", key)) 
         self.render('user_pins.html',counts=counts,u_user=u_user,user=self.currentUserInfo(),board = board.get(key),marks=marks)