def single_node(node_abbr): node = Node.get_node_by_abbr(node_abbr) nodes = Node.get_nodes(16) topics = Topic.get_topics_by_node(node_abbr) for t in topics: t['Time'] = time_diff(t['Time']) return render_template('topic/single_node.html', node=node, nodes=nodes, topics=topics)
def single_node(node_abbr): node = Node.get_node_by_abbr(node_abbr) if not node: abort(404) nodes = Node.get_nodes(16) topics = Topic.get_topics_by_node(node_abbr) for t in topics: t['Time'] = time_diff(t['Time']) return render_template('topic/single_node.html', node=node, nodes=nodes, topics=topics)
def single_topic(topic_id): form = CommentForm() topic = Topic.get_topic(topic_id) topic['Time'] = time_diff(topic['Time']) topic['Content'] = topic['Content'].replace('\n', "<div class='text-gap'></div>") comments = Comment.get_comments_by_topic(topic['TopicID']) for c in comments: c['Time'] = time_diff(c['Time']) Topic.add_click_num(topic_id) nodes = Node.get_nodes(16) return render_template('topic/single_topic.html', topic=topic, comments=comments, nodes=nodes, form=form)
def topics(): topics = Topic.get_topics(15) for t in topics: t['Time'] = time_diff(t['Time']) nodes = Node.get_nodes(16) hot_topics = Topic.get_hot_topics(10) node_types = Node.get_types() for nt in node_types: nt['nodes'] = Node.get_nodes_by_type(nt['TypeID']) return render_template('topic/topics.html', topics=topics, nodes=nodes, hot_topics=hot_topics, node_types=node_types)
def single_topic(topic_id): form = CommentForm() topic = Topic.get_topic(topic_id) topic['Time'] = time_diff(topic['Time']) topic['Content'] = markdown2.markdown(topic['Content']) comments = Comment.get_comments_by_topic(topic['TopicID']) for c in comments: c['Time'] = time_diff(c['Time']) Topic.add_click_num(topic_id) nodes = Node.get_nodes(16) return render_template('single_topic.html', topic=topic, comments=comments, nodes=nodes, form=form)