def word(request, title=''): count_pv(request) page = 0 current = 0 num = len(Word.objects.order_by('-timestamp')) if num % 5 != 0: page = num // 5 + 1 else: page = num // 5 if title == '': title = '$1' if title[0] == '$' and title[1:].isdigit(): word_list = Word.objects.order_by('-timestamp')[(int(title[1:]) - 1) * 5:int(title[1:]) * 5] #按时间戳排序 current = int(title[1:]) for n in word_list: n.body = getHTML(n.body) return render_to_response( 'word.html', { 'word_list': word_list, 'current': current, 'page': range(1, page + 1), 'online': get_online() })
def debug(request,title=''): page = 0 current = 0 num = len(Debug.objects.order_by('-timestamp')) if num%5 != 0: page = num//5 + 1 else: page = num//5 if title == '': title = '$1' if title[0] == '$' and title[1:].isdigit(): debug_list = Debug.objects.order_by('-timestamp')[(int(title[1:])-1)*5:int(title[1:])*5]#按时间戳排序 current = int(title[1:]) for n in debug_list: n.que = getHTML(n.que) n.sol = getHTML(n.sol) return render_to_response('debug.html',{'debug_list' : debug_list,'current' : current,'page' : range(1,page+1)})
def essay(request,title=''): if(title == ''): essay_list = Essay.objects.order_by('-timestamp')#按时间戳排序 else: if(title[-1:] == '/'): title = title[:-1] essay_list = Essay.objects.filter(title = title) for n in essay_list: n.body = getHTML(n.body) return render_to_response('article_list.html',{'article_list' : essay_list,'item' : 'essay'})
def articles(request): page = int(request.GET.get('page','1')) print(page) num = len(Article.objects.order_by('-timestamp')) if num%5 != 0: pages = num//5 + 1 else: pages = num//5 article_list = Article.objects.order_by('-timestamp')[(page-1)*5:page*5]#按时间戳排序 current = page for n in article_list: n.body = getHTML(n.body) return render_to_response('articles.html',{'article_list' : article_list,'current' : current,'pages' : pages})
def article(request,title=''): page = 0 current = 0 num = len(Article.objects.order_by('-timestamp')) if num%5 != 0: page = num//5 + 1 else: page = num//5 if title == '': title = '$1' #article_list = Article.objects.order_by('-timestamp')#按时间戳排序 if title[0] == '$' and title[1:].isdigit(): article_list = Article.objects.order_by('-timestamp')[(int(title[1:])-1)*5:int(title[1:])*5]#按时间戳排序 current = int(title[1:]) else: if(title[-1:] == '/'): title = title[:-1] article_list = Article.objects.filter(title = title) for n in article_list: n.body = getHTML(n.body) return render_to_response('article.html',{'article_list' : article_list,'current' : current,'page' : range(1,page+1)})
def articles(request): count_pv(request) page = int(request.GET.get('page', '1')) num = len(Article.objects.order_by('-timestamp')) if num % 10 != 0: pages = num // 10 + 1 else: pages = num // 10 article_list = Article.objects.order_by('-timestamp')[(page - 1) * 10:page * 10] #按时间戳排序 current = page for n in article_list: n.body = getHTML(n.body) return render_to_response( 'articles.html', { 'article_list': article_list, 'current': current, 'pages': pages, 'online': get_online() })
def ideal_reality(request): ideal_reality_list = Ideal_Reality.objects.order_by('-ideal_timestamp')#按时间戳排序 for n in ideal_reality_list: n.ideal = getHTML(n.ideal) n.reality = getHTML(n.reality) return render_to_response('ideal_reality.html',{'ideal_reality_list' : ideal_reality_list})
def debug(request): debug_list = Debug.objects.order_by('-timestamp')#按时间戳排序 for n in debug_list: n.bug = getHTML(n.bug) n.debug = getHTML(n.debug) return render_to_response('debug.html',{'debug_list' : debug_list})