Exemple #1
0
 def GET(self):
     i = web.input(search="")
     results = []
     if i.search:
         papers = Paper.getall()
         matches = S().match(i.search)
         pids = [int(x['pid']) for x in matches]
         results = [p for p in papers if p['pid'] in pids]
     return render().search(i.search, results)
Exemple #2
0
 def GET(self):
     i = web.input(search="")
     results = []
     if i.search:
         papers = Paper.getall()
         matches = S().match(i.search)
         pids = [int(x['pid']) for x in matches]
         results = [p for p in papers if p['pid'] in pids]
     return render().search(i.search, results)
Exemple #3
0
 def GET(self):
     i = web.input(sort="popular", limit=30, page=0)
     papers = Paper.getall()
     limit = int(i.limit)
     page = int(i.page)
     pages = int(ceil(float(len(papers)) / limit))
     try:
         papers = globals()[i.sort](papers)
     except:
         papers = popular(papers)
     start = page * limit
     end = start + limit
     return render().index(papers[start:end], pages, i.page,
                           sort=i.sort, limit=limit)
Exemple #4
0
def items():
    """A function which generates all rss items for this website"""
    papers = Paper.getall()
    items = []
    desc = "%s - %s votes, submitted by: %s @ %s" 
    for paper in filter(lambda x: x['enabled'], newest(papers)):
        description = desc % (paper['url'], paper['votes'],
                              paper['submitter'], paper['time'])
        items.append({'title': paper['title'],
                      'link': 'https://hackerlist.net:1443/item?pid=%s' % \
                          paper['pid'],
                      'description': description,
                      'date': paper['time'],
                      'guid': paper['pid']})
    return items
Exemple #5
0
def items():
    """A function which generates all rss items for this website"""
    papers = Paper.getall()
    items = []
    desc = "%s - %s votes, submitted by: %s @ %s"
    for paper in filter(lambda x: x['enabled'], newest(papers)):
        description = desc % (paper['url'], paper['votes'], paper['submitter'],
                              paper['time'])
        items.append({'title': paper['title'],
                      'link': 'https://hackerlist.net:1443/item?pid=%s' % \
                          paper['pid'],
                      'description': description,
                      'date': paper['time'],
                      'guid': paper['pid']})
    return items
Exemple #6
0
 def GET(self):
     i = web.input(sort="popular", limit=30, page=0)
     papers = Paper.getall()
     limit = int(i.limit)
     page = int(i.page)
     pages = int(ceil(float(len(papers)) / limit))
     try:
         papers = globals()[i.sort](papers)
     except:
         papers = popular(papers)
     start = page * limit
     end = start + limit
     return render().index(papers[start:end],
                           pages,
                           i.page,
                           sort=i.sort,
                           limit=limit)