Commits

Yang Zhang committed aba0bd6

user can see others' created topic
create include fold to contain some reuse template

Comments (0)

Files changed (10)

         self.create_date = None
         self.reputation = None
         self.star_counter = 0
+        self.created_topic_counter = 0
+        self.comment_counter = 0
 
 
     @staticmethod
         tempuser.create_date = result['create_date']
         tempuser.reputation = result['reputation']
         tempuser.star_counter = result['star_counter']
+        tempuser.created_topic_counter = result['created_topic_counter']
+        tempuser.comment_counter = result['comment_counter']
         tempuser.id = id
         return tempuser
 
   </head>
 
   <body id="body">
-    {%include 'header.html'%}
+    {%include 'include/header.html'%}
     <div class="container-fluid container">
       <div class="row-fluid">
         <div class="span8" id="body-content">
       </div>
     </div>
     
-    {%include 'footer.html'%}
+    {%include 'include/footer.html'%}
     <!-- Le javascript
     ================================================== -->
     <!-- Placed at the end of the document so the pages load faster -->

templates/footer.html

-<div id="footer">
-  <div class="container">
-    <p class="muted credit">Code & Design by <a href='#'>Yang</a><br/>
-        You can find source code <a href=''>here</a>
-    </p>
-</div>
-</div>

templates/header.html

-
-<div id="notifybar-container" class="row navbar-static-top">
-    {%if session['message'].content%}
-    <div class="alert {{session['message'].type}} navbar-fixed-top" id="notifybar">
-        <button type="button" class="close" data-dismiss="alert">×</button>
-        <strong><label style='text-align:center;' id='notify-content'>{{session['message'].content}}</label></strong>
-    </div>
-    {%else%}
-    <div class="alert alert-success navbar-fixed-top" id="notifybar" style='display:none'>
-        <button type="button" class="close" data-dismiss="alert">×</button>
-        <strong><label style='text-align:center;' id='notify-content'></label></strong>
-    </div>
-    {%endif%}
-</div>
-
-<div class="container-fluid container navbar-inner" id="header">
-<div class="row-fluid">
-    <div class='span2'>
-        <a href='/' style='color:black;'><h1>PY4U</h1></a>
-    </div>
-    <div class='span6'>
-    <form action="#" class="navbar-search">
-    <div class="input-prepend" id='header-searchbar'>
-        <input id="srchFld" type="text" placeholder="搜索主题..." class="search-query input-xxlarge" spellcheck="false">
-        <span class="add-on" onclick='alert(1)'><i class="icon-search"></i></span>
-     </div>
-    </form>
-    </div>
-    {%if not user%}
-    <div class='span4' id='login'>
-        <div class='span3'></div>
-        <div class='span3'><h5><a href='#login-form' onclick="$('#login-form-email').focus();">登入</a></h5></div>
-        <div class='span3'><h5><a href='/register'>注册</a></h5></div>
-    </div>
-    {%else%}
-    <div class='span4' id='login'>
-        <div class='span3'></div>
-        <div class='span3'><h5><a href='/ua/setting'>设置</a></h5></div>
-        <div class='span3'><h5><a href='/logout'>退出</a></h5></div>
-    </div>
-    
-    {%endif%}
-</div>
-</div>
-
-
-
-
-
-
-
-
-
-
-
-
-
-

templates/include/footer.html

+<div id="footer">
+  <div class="container">
+    <p class="muted credit">Code & Design by <a href='#'>Yang</a><br/>
+        You can find source code <a href=''>here</a>
+    </p>
+</div>
+</div>

templates/include/header.html

+
+<div id="notifybar-container" class="row navbar-static-top">
+    {%if session['message'].content%}
+    <div class="alert {{session['message'].type}} navbar-fixed-top" id="notifybar">
+        <button type="button" class="close" data-dismiss="alert">×</button>
+        <strong><label style='text-align:center;' id='notify-content'>{{session['message'].content}}</label></strong>
+    </div>
+    {%else%}
+    <div class="alert alert-success navbar-fixed-top" id="notifybar" style='display:none'>
+        <button type="button" class="close" data-dismiss="alert">×</button>
+        <strong><label style='text-align:center;' id='notify-content'></label></strong>
+    </div>
+    {%endif%}
+</div>
+
+<div class="container-fluid container navbar-inner" id="header">
+<div class="row-fluid">
+    <div class='span2'>
+        <a href='/' style='color:black;'><h1>PY4U</h1></a>
+    </div>
+    <div class='span6'>
+    <form action="#" class="navbar-search">
+    <div class="input-prepend" id='header-searchbar'>
+        <input id="srchFld" type="text" placeholder="搜索主题..." class="search-query input-xxlarge" spellcheck="false">
+        <span class="add-on" onclick='alert(1)'><i class="icon-search"></i></span>
+     </div>
+    </form>
+    </div>
+    {%if not user%}
+    <div class='span4' id='login'>
+        <div class='span3'></div>
+        <div class='span3'><h5><a href='#login-form' onclick="$('#login-form-email').focus();">登入</a></h5></div>
+        <div class='span3'><h5><a href='/register'>注册</a></h5></div>
+    </div>
+    {%else%}
+    <div class='span4' id='login'>
+        <div class='span3'></div>
+        <div class='span3'><h5><a href='/ua/setting'>设置</a></h5></div>
+        <div class='span3'><h5><a href='/logout'>退出</a></h5></div>
+    </div>
+    
+    {%endif%}
+</div>
+</div>
+
+
+
+
+
+
+
+
+
+
+
+
+
+

templates/include/user_info.html

+<div class='widget container-box row-fluid' style='padding-bottom:20px;'>
+    <h5>用户信息</h5>
+    <div class='span3'>
+        <a href="/user/{{user.id}}" class="thumbnail" >
+          {%if user.email%}
+          <img src="{{ user.email | gravatar(size=200) }}" alt="">
+          {%else%}
+            <img src="http://placehold.it/200x200" alt=""/>
+          {%endif%}
+        </a>
+    </div>
+    <div class='span8'>
+        <h3>{{user.nickname}}</h3>
+    </div>
+    <div id='user-info' class='span3'>
+        <p>
+        <a href="#collect-topic" title='收藏主题数'><i class="icon-star"></i> {{user.star_counter}}</a>
+        <span class="userinfo-divider"></span>
+        <a href="#" title='荣誉度'><i class="icon-heart"></i> {{user.reputation}}</a>
+        </p>
+        <p>
+        <small class='muted'>PY4U 第{{user.id}}位会员</small>
+        </p>
+        <p>
+        <small class='muted'>
+        加入于{{user.create_date.replace(second=0, microsecond=0)}}</small>
+    </div>
+    
+    <div id='user-basicinfo' class='span5'>
+        {%if setting.website%}
+        <p>
+        <a href="{{setting.website}}" title='个人主页'><i class="icon-home"></i> {{setting.website}}</a>
+        </p>
+        {%endif%}
+        {%if setting.living_place%}
+        <p>
+        <a href="http://www.google.com/maps?q={{setting.living_place}}" title='居住地'><i class="icon-map-marker"></i> {{setting.living_place}}</a>
+        </p>
+        {%endif%}
+        
+        {%if setting.website%}
+        <p>
+        <label><i class="icon-comment"></i> {{setting.slogan}}</label>
+        </p>
+        {%endif%}
+    </div>
+    {%if setting.profile%}
+    <div class='span10 offset1'>
+        <br/>
+        <label>{{setting.profile}}</label>
+    </div>
+    {%endif%}
+</div>

templates/show_topic_list.html

 {%extends 'base.html'%}
 
 {%block content%}
-<div class='container-box'>
+<div class='container'><div class='container-box span8 offset2'>
 
-{% from 'macro/topiclist.html' import make_list %}
-{{make_list(created_topic)}}
+    {% from 'macro/topiclist.html' import make_list %}
+    {{make_list(created_topic)}}
 
-{#
+
     <div class="row-fluid">
-        {%if topic_list|length==0%}
+        {%if created_topic|length==0%}
             <label style='text-align: center;'>该栏目暂时没有主题...</label>
             
         {%else%}
-        {% set total_page = (counter.topic_number-1)//15+1 %}
+        {% set total_page = (counter-1)//15+1 %}
         <ul class="pager">
           
             {%if current_page ==1%}
             
         {%endif%}
     </div>
-#}
-</div>
+
+</div></div>
 {%if user%}
 
 <div class='container-box' id='topic-post'>
 <div id='user' class='container'>
     <div class='row-fluid'>
     <div class='offset2 span8 row-fluid'>
-        <div class='widget container-box row-fluid' style='padding-bottom:20px;'>
-            <h5>用户信息</h5>
-            <div class='span3'>
-                <a href="/user/{{user.id}}" class="thumbnail" >
-                  {%if user.email%}
-                  <img src="{{ user.email | gravatar(size=200) }}" alt="">
-                  {%else%}
-                    <img src="http://placehold.it/200x200" alt=""/>
-                  {%endif%}
-                </a>
-            </div>
-            <div class='span8'>
-                <h3>{{user.nickname}}</h3>
-            </div>
-            <div id='user-info' class='span3'>
-                <p>
-                <a href="#collect-topic" title='收藏主题数'><i class="icon-star"></i> {{user.star_counter}}</a>
-                <span class="userinfo-divider"></span>
-                <a href="#" title='荣誉度'><i class="icon-heart"></i> {{user.reputation}}</a>
-                </p>
-                <p>
-                <small class='muted'>PY4U 第{{user.id}}位会员</small>
-                </p>
-                <p>
-                <small class='muted'>
-                加入于{{user.create_date.replace(second=0, microsecond=0)}}</small>
-            </div>
-            
-            <div id='user-basicinfo' class='span5'>
-                {%if setting.website%}
-                <p>
-                <a href="{{setting.website}}" title='个人主页'><i class="icon-home"></i> {{setting.website}}</a>
-                </p>
-                {%endif%}
-                {%if setting.living_place%}
-                <p>
-                <a href="http://www.google.com/maps?q={{setting.living_place}}" title='居住地'><i class="icon-map-marker"></i> {{setting.living_place}}</a>
-                </p>
-                {%endif%}
-                
-                {%if setting.website%}
-                <p>
-                <label><i class="icon-comment"></i> {{setting.slogan}}</label>
-                </p>
-                {%endif%}
-            </div>
-            {%if setting.profile%}
-            <div class='span10 offset1'>
-                <br/>
-                <label>{{setting.profile}}</label>
-            </div>
-            {%endif%}
-        </div>
+        {%include 'include/user_info.html'%}
         
         
         <div class='widget container-box row-fluid' style='padding-bottom:20px;'>
 @user.route('/<int:userid>/created_topics')
 @user.route('/<int:userid>/created_topics/<int:page>/')
 def show_user_created_topics(userid,page=1):
+    user = User.get_user_by_id(userid)
+    page_url = url_for("user.show_user_created_topics", userid= userid)
     created_topic = Topic.get_topic_created_byuserid(userid, limit=15,offset = page-1)
-    return render_template('show_topic_list.html',created_topic = created_topic)
+    return render_template('show_topic_list.html',
+                        created_topic = created_topic, 
+                        counter=user.created_topic_counter, 
+                        page_url = page_url,
+                        current_page = page)
 
 @user.route('/<int:userid>/comments')
 @user.route('/<int:userid>/comments/<int:page>/')