Commits

zuroc  committed 0d1faf6

f

  • Participants
  • Parent commits 5ba6156

Comments (0)

Files changed (5)

     format='%(message)s\n',
     datefmt='%H:%M:%S',
 )
-
+HOST = "42qu.cc"
 
 DEBUG = True
 PREFIX = dirname(abspath(__file__))

File html/home.html

+<%inherit file="/_base.html" />
+<%!
+%>
+
+<style>
+.follow, .unfollow{
+color:#fff;padding:4px 7px 4px 24px;font-size:14px;
+text-decoration:none;
+background:url(http://cdn.chanyouji.cn/assets/show-sprite-05515641e394e31cf4b7fe71d256d034.png) 4px -195px #000;
+}
+.unfollow{background-position:4px -235px}
+</style>
+%if host_user.id == current_user.id:
+<a href="javascript:void(0)">设置</a>
+%else:
+<a class="follow" href="javascript:void(0)">关注</a>
+%endif
+
+<script>
+$(".follow,.unfollow").click(function(){
+    var to
+    if(this.className=="follow"){
+        to="unfollow"
+    }else{
+        to="follow"
+    }
+    $.post("/j/"+this.className)
+    this.className = to
+})
+</script>
+
 from view._url import URL, URL_USER
 
 import tornado.web
-from config import DEBUG
+from config import DEBUG,HOST
 application = tornado.web.Application(
     [],
     debug=DEBUG
 )
 
 
-application.add_handlers(r"42qu\.cc", URL)
-application.add_handlers(r".*\.42qu\.cc", URL_USER)
+application.add_handlers(HOST, URL)
+application.add_handlers(r".*\.%s"%HOST, URL_USER)
 
 
 if __name__ == '__main__':

File view/handler.py

             self.host_user = User(int(id))
         else: 
             self.redirect("http://%s"%suffix)
+
+    def render(self, template_name=None, **kwds):
+        kwds['host_user'] = self.host_user
+        super(HandlerHostUser, self).render(template_name, **kwds)

File view/root.py

 import urllib
 from tornado import escape
 import tornado.web
-from config import  WEIBO_API_KEY, WEIBO_SECRET
+from config import  WEIBO_API_KEY, WEIBO_SECRET, HOST
 from errtip import dotdict
 from model.session import session_new, session_rm
 from model.mail import mail_new
         else:
             mail_id = mail_new(mail)
             session = session_new(mail_id) 
-            self.set_cookie('S', session)
+            self.set_cookie('S', session, ".%s"%HOST)
             self.redirect("/")