Ejemplo n.º 1
0
 def get(self,key):
     uri = self.request.uri
     request = {}
     pin = Pin()
     
     pin_keys = pin.getByKeyValues("board",key)
     pin_count = len(pin_keys)
     
     query = {}
     query['q']         = "board:%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)
     print len(pin_data)
     
     marks_dict = pin.formatPins(pin_data)        
     
     if request:
         #print request['callback']
         #print request['page']            
         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:
         marks = ''            
         for _mark_t in marks_dict:                
             marks = self.render_string('mark.html',mark=_mark_t)+marks
         board = Board()
         user = User()
         category = Category() 
  
         board_data = board.get(key)
         
         b_user = user.getDetail(board_data['user'])
         b_category = category.get(board_data['category'])
         b_keys = board.getByKeyValues("user", board_data['user'])
         
         if key in b_keys:
             b_keys.remove(key)
             
         b_boards = board.all(b_keys)
     
         self.render('board_pins_list.html',f_board = self.formatFollowBoardData(key), b_boards= b_boards,b_category = b_category,b_user=b_user,user=self.currentUserInfo(),board = board.get(key),marks=marks)
Ejemplo n.º 2
0
	def get(self,cat_key):	
		if cat_key == 'All':
			self.redirect('/')
		else:
			uri = self.request.uri
			request = {}
			pin = Pin()
			
			pin_keys = pin.getByCat(cat_key)
			pin_count = len(pin_keys)
			
			query = {}
			query['q'] 		= "category:%s" % cat_key
					
			query['start']  = "0"
			query['rows']   = globalSetting['max_index_pin_rows']
			query['sort']   = "createTime"
			
			if "page" in uri:
				request = urldecode(uri)
				print request
				page = int(request['page'])
				query['start']  = query['rows']*page
				if pin_count < query['rows']*page:
					return ''
			
			pin_data = pin.solr(query)
			#print len(pin_data)
			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:
				marks = ''			
				for _mark_t in marks_dict:				
					marks = self.render_string('mark.html',mark=_mark_t)+marks
				if marks == '':
					marks = """
					<div class="pin category wfc isotope-item" style="margin-bottom: 15px; position: absolute; left: 0px; top: 0px; -webkit-transform: translate3d(0px, 0px, 0px); ">
					NO PINS
					</div>
					"""
				category = Category()
				cats = category.getCats()
				
				self.render('index.html',user=self.currentUserInfo(),marks=marks,cats = cats,urlname = cat_key)		
Ejemplo n.º 3
0
    def get(self):
        uri = self.request.uri
        request = {}
        board = BoardFollow()
        
        #in_keys = board.allKey()
        user_key = self.get_secure_cookie("user_key")
        query = {}
        query['q']         = "user:%s" % user_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_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:
            boards = ''            
            for _board_t in boards_dict:                
                boards = self.render_string('board_unit.html',board=_board_t) + boards
                
            user_key = self.get_secure_cookie("user_key")
            user = User()
            userInfo = user.getDetail(user_key)
            from models.userFollow import UserFollow
            userFollow = UserFollow()
            counts = {}
            pinM = Pin()
            boardM = Board()
            counts['fans'] = len(userFollow.getByKeyValues("follow", user_key)) 
            counts['pins'] = len(pinM.getByKeyValues("user", user_key)) 
            counts['boards'] = len(boardM.getByKeyValues("user", user_key)) 
            
            self.render('board_follow.html',counts=counts,userInfo = userInfo,user=self.currentUserInfo(),boards=boards) 
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
	def get(self):
		uri = self.request.uri
		request = {}
		pin = Pin()
		
		pin_keys = pin.getByCat('All')
		pin_count = len(pin_keys)
		
		query = {}
		query['q'] 		= "public:1"				
		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)
		#print len(pin_data)		
		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")			
			self.write(callback_response)
		else:			
			marks = ''			
			for _mark_t in marks_dict:				
				marks = self.render_string('mark.html',mark=_mark_t)+marks
			
			dump(marks)
			category = Category()
			cats = category.getCats()
			dump(cats)
			cat_key = 'All'
			
			self.render('index.html',user=self.currentUserInfo(),marks=marks,cats = cats,urlname = cat_key)		
Ejemplo n.º 6
0
    def get(self):
        uri = self.request.uri
        request = {}
        board = Board()
        
        pin_keys = board.allKey()
        
        query = {}
        query['q']         = "public:1"
                
        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_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:
            boards = ''            
            for _board_t in boards_dict:                
                boards = self.render_string('board_unit.html',board=_board_t) + boards
            
            self.render('board_pop.html',user=self.currentUserInfo(),boards=boards)    
Ejemplo n.º 7
0
    def get(self):
        uri = self.request.uri
        request = {}
        pin = Pin()
        request = urldecode(uri)
        q = request['q']    
        
        query = {}
        query['q']         = "rawtext:*%s*" % q                
        #query['start']  = "0"
        #query['rows']   = globalSetting['max_index_pin_rows']
        query['sort']   = "like"
        
        #if "page" in uri:
        #    page = int(request['page'])
        #    query['start']  = query['rows']*page
            #If pin_count < query['rows']*page:
            #    return ''
        
        pin_data = pin.solr(query)
        #print len(pin_data)        
        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")            
        #    self.write(callback_response)
        #else:            
        marks = ''            
        for _mark_t in marks_dict:                
            marks = self.render_string('mark.html',mark=_mark_t)+marks

        self.render('pins_search.html',query = q,user=self.currentUserInfo(),marks=marks)