Commits

zuroc committed 3fdbfca Merge

fix

Comments (0)

Files changed (7)

 from ctrl._urlmap.j import urlmap
 from _handler import JLoginBase
 from json import dumps
-from model.zsite_user_skin import yun_form_zsite_user_skin
+from model.zsite_user_skin import yun_form_zsite_user_skin, zsite_user_skin_list_last, zsite_user_skin_list_hot, zsite_user_skin_hot_count, zsite_user_skin_last_count
+from zkit.page import page_limit_offset
 
 
 @urlmap('/j/career/rm/(\d+)')
 @urlmap('/j/i/skin/bg_(hot|last)-(\d+)')
 class Skin(JLoginBase):
     def get(self, type, n=1):
-        result = [
-[
-    '7e4029bd4a786c0e625012bf470696a1',
-    1,
-    "//xxx.x",
-    "张沈鹏"
-]
-        ]
+        if type == "hot": 
+            func_ol = zsite_user_skin_list_hot
+            total = zsite_user_skin_hot_count() 
+        elif type == "last":
+            func_ol = zsite_user_skin_list_last
+            total = zsite_user_skin_last_count() 
+ 
+        page, limit, offset = page_limit_offset(
+            '/j/i/skin/bg_%s-%%s'%type,
+            total,
+            n,
+            64
+        )
+
         self.finish(dumps([
-yun_form_zsite_user_skin.domain,
-result,
+            yun_form_zsite_user_skin.domain,
+            func_ol(limit, offset),
+            page
         ]))
 
 

model/zsite_user_skin.py

 # -*- coding: utf-8 -*-
 from _db import  redis
 from config import UPYUN_FORM_ZSITE_USER_SKIN, SITE_HTTP
+from model.zsite import Zsite
 from zkit.yun_form import YunForm
 from time import time
 from binascii import b2a_hex , a2b_hex
         p.zrem(key, id)
     p.execute()
 
+def zsite_user_skin_hot_count():
+    return redis.zcard(REDIS_ZSITE_USER_SKIN_HOT)
+
+def zsite_user_skin_last_count():
+    return redis.zcard(REDIS_ZSITE_USER_SKIN_LAST)
+
 def zsite_user_skin_list_hot(limit, offset):
     return _zsite_user_skin_list(REDIS_ZSITE_USER_SKIN_HOT, limit, offset)
 
 def zsite_user_skin_list_last(limit, offset):
     return _zsite_user_skin_list(REDIS_ZSITE_USER_SKIN_LAST, limit, offset)
 
+def _zsite_user_skin_list(key, limit, offset):
+    id_list = redis.zrevrange(key , offset, limit+offset-1)
+    md5_list = map(b2a_hex, redis.hmget(REDIS_ZSITE_USER_SKIN_ID_MD5, id_list))
+    user_id_list = redis.hmget(REDIS_ZSITE_USER_SKIN_OWNER, id_list)
+    zsite_list = Zsite.mc_get_list(user_id_list)
 
-def _zsite_user_skin_list(key, limit, offset):
-    return redis.hmget(REDIS_ZSITE_USER_SKIN_ID_MD5, redis.zrevrange(key , offset, limit+offset-1))
+    name_list = []
+    link_list = []
+    for i in zsite_list:
+        link_list.append(i.link)
+        name_list.append(i.name) 
+ 
+    return  list(zip(md5_list, id_list, link_list, name_list))
 
 def zsite_user_skin_set(user_id, id):
     md5 = redis.hget(
 
 if __name__ == '__main__':
     pass
-    print zsite_user_skin_list_last(64, 0)
-    print zsite_user_skin_list_hot(64, 0)
-    #zsite_user_skin_hide(2)
-    a = redis.hgetall(REDIS_ZSITE_USER_SKIN_MD5_ID).items()
-    redis.delete(REDIS_ZSITE_USER_SKIN_MD5_ID)
-    for key, value in a:
-        x = len(key)
-        if x == 32:
-            print key
-            x = a2b_hex(key)
-            redis.hset(REDIS_ZSITE_USER_SKIN_MD5_ID, x , value)
-        elif x == 16:
-            redis.hset(REDIS_ZSITE_USER_SKIN_MD5_ID, x , value)
-
-    a = redis.hgetall(REDIS_ZSITE_USER_SKIN_ID_MD5).items()
-    redis.delete(REDIS_ZSITE_USER_SKIN_ID_MD5)
-    for key, value in a:
-        x = len(value)
-        if x == 32:
-            x = a2b_hex(value)
-            redis.hset(REDIS_ZSITE_USER_SKIN_ID_MD5, key , x)
-        elif x == 16:
-            redis.hset(REDIS_ZSITE_USER_SKIN_ID_MD5, key , value)
-
-    a = redis.hgetall(REDIS_ZSITE_USER_SKIN).items()
-    redis.delete(REDIS_ZSITE_USER_SKIN)
-    for key, value in a:
-        x = len(value)
-        if x == 32:
-            x = a2b_hex(value)        
-            redis.hset(REDIS_ZSITE_USER_SKIN, key, x)
-        elif x == 16:
-            redis.hset(REDIS_ZSITE_USER_SKIN, key, value)
-
-
- 
-

static/css/ctrl/index.css

 #H .H
 {
     width:auto;
-    max-width:1250px;
+    max-width:1248px;
 }
 #H .site{
     margin-left:12px;

static/css/ctrl/lnav.css

 .Iwp{
 margin:-1px auto 0;
-max-width:1250px;
+max-width:1248px;
 overflow:hidden;
 }
 .Lwp{

static/css/ctrl/zsite/index/user.css

 #LVskin .img{
 width:250px;line-height:0;box-shadow:1px 1px 2px #eee;
 cursor:pointer;
+float:left;
+margin:0 0 32px 22px;
 }
 #LVskin img{
 width:250px;
 color:#d20;
 }
 #LVskin .img_from{padding: 9px; float: left;}
+.mln22{
+margin-left:-22px;
+}
 
 
 
-

static/js/ctrl/zsite/index/user/lnav/skin.js

         htm = $.tmpl('LVskin'+type.split("_")[0],{
             _xsrf:$.cookie.get('_xsrf'),
             ol:o[1],
-            domain:o[0]
+            domain:o[0],
+            page:o[2]
         }).appendTo(lv)
         //pop_hero(htm.find('.TPH')) 
     })
 
 $.template(
     'LVskinbg',
-'<div id="LVskin">'+
+'<div id="LVskin"><div class="mln22">'+
     '{{each ol}}'+
     '<div class="img">'+
 '<img src="//${domain}/${$value[0]}!1">'+
     '<span class="img_from">来自 '+
     '<a class="TPH" href="${$value[2]}">${$value[3]}</a></span></div></div>'+
     '{{/each}}'+
-'</div>'
+'</div>{{html page}}</div>'
 )
 
 def int2ip(num):
     return socket.inet_ntoa(struct.pack("!I",num))
 
+def address_to_in6 (address):
+    try:
+        return socket.inet_pton (socket.AF_INET6, address)
+    except socket.error:
+        in4 = socket.inet_pton (socket.AF_INET, address)
+        in6 = struct.pack ("!IIII", 0, 0, 0xffff, struct.unpack("!I", in4)[0])
+        return in6
+        
+        
+
 if __name__ == "__main__":
+    print socket.has_ipv6
     print int2ip(ip2int("127.0.123.249"))
     print int2ip(ip2int("201.119.123.249"))
-
+    print socket.inet_ntop (socket.AF_INET6, address_to_in6 ("::ffff:10.10.1.1"))
+    print socket.inet_ntop (socket.AF_INET6, address_to_in6 ("10.10.1.1"))