예제 #1
0
    def get(self, channel_name, template_variables = {}):
    	user_info = self.current_user
        p = int(self.get_argument("p", "1"))
        template_variables["user_info"] = user_info
        template_variables["gen_random"] = gen_random
        template_variables["navs"] = self.nav_model.get_all_navs()
        template_variables["channels"] = self.channel_model.get_all_channels()

        channel = self.channel_model.get_channel_by_channel_name(channel_name)
        if channel:
            template_variables["channel"] = channel
            template_variables["stds"] = self.std_model.get_std_posts_by_channel_id(channel.id, current_page = p)
            template_variables["hots"] = self.hot_model.get_hot_posts_by_channel_id(channel.id, current_page = p)
        else:
            nav = self.nav_model.get_nav_by_nav_name(channel_name)
            if nav:
                template_variables["channel"] = nav
                template_variables["stds"] = self.nav_model.get_std_posts_by_nav_id(nav.id, current_page = p)
                template_variables["hots"] = self.nav_model.get_hot_posts_by_nav_id(nav.id, current_page = p)
            else:
                self.render("404.html", **template_variables)
                return

        if is_mobile_browser(self):
            self.render("channel-m.html", **template_variables)
        else:
            self.render("channel.html", **template_variables)
예제 #2
0
    def get(self, post_id, template_variables = {}):
    	user_info = self.current_user
        template_variables["user_info"] = user_info
    	page = int(self.get_argument("page", "1"))
        template_variables["navs"] = self.nav_model.get_all_navs()
        template_variables["channels"] = self.channel_model.get_all_channels()
    	template_variables["hots"] = self.hot_model.get_hot_posts(current_page = page)

        post = self.post_model.get_post_by_post_id(post_id)
        self.post_model.update_post_by_post_id(post_id, {"count": post.count+1})
    	template_variables["post"] = post

        if post.via:
            vias = post.via.split(',')
            template_variables["via_title"] = vias[0]
            template_variables["via_link"] = vias[1]
        else:
            template_variables["via_title"] = 'none'
            template_variables["via_link"] = 'none'
            

        template_variables["vote"] = self.vote_model.get_vote_by_post_id(post_id)
        template_variables["tags"] = self.post_tag_model.get_post_all_tags(post_id)
	        
        if is_mobile_browser(self):
            self.render("post-m.html", **template_variables)
        else:
            if post.type == 'item':
                template_variables["item"] = self.item_model.get_item_only_by_post_id(post.id)
                self.render("item.html", **template_variables)
            else:
                self.render("post.html", **template_variables)
예제 #3
0
파일: user.py 프로젝트: simidaxu/1024nj
 def get(self, template_variables={}):
     user_info = self.get_current_user()
     template_variables["user_info"] = user_info
     if is_mobile_browser(self):
         self.render("mobile/user/setting_password.html", **template_variables)
     else:
         self.render("user/setting_password.html", **template_variables)
예제 #4
0
    def get(self, template_variables={}):
        url = self.get_argument("url", "")
        template_variables["tmall_link"] = url
        template_variables["static_path"] = self.static_path

        if is_weixin_browser(self) or is_mobile_browser(self):
            tmall_pattern = re.compile(
                r'http://detail.tmall.com/item.htm?\S*id=(\d+)')
            tmall_match = tmall_pattern.search(url)
            if tmall_match:
                sku = tmall_match.group(1)

                doc = pyq(
                    "http://djaa.cn/ajax/cm_details/to_cm_details_tmall.php",
                    headers={
                        'User-Agent':
                        'Mozilla/5.0 (MicroMessenger;iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4'
                    },
                    method='post',
                    data={
                        'id': sku,
                        'shopUrl': url,
                        'shop_type': 'tmall',
                        'small_shop_type': 'cm_details'
                    })
                #print doc
                title = doc('.dtif-h').text()
                content = doc('.viewport').outerHtml()
                template_variables["title"] = title
                template_variables["content"] = content
                template_variables["sku"] = sku
                self.render(self.template_path + "tmall.html",
                            **template_variables)
        else:
            self.redirect(url)
예제 #5
0
 def get(self, template_variables={}):
     user_info = self.get_current_user()
     template_variables["user_info"] = user_info
     if is_mobile_browser(self):
         self.render("mobile/user/setting_password.html",
                     **template_variables)
     else:
         self.render("user/setting_password.html", **template_variables)
예제 #6
0
파일: index.py 프로젝트: gaolinjie/ttx
    def get(self, template_variables = {}):
        url = self.get_argument("url", "")
        template_variables["coupon_link"] = url
        template_variables["static_path"] = self.static_path

        if is_weixin_browser(self) or is_mobile_browser(self):
            self.render(self.template_path+"coupon.html", **template_variables)  
        else:
            self.redirect(url)
예제 #7
0
    def get(self, template_variables={}):
        url = self.get_argument("url", "")
        template_variables["coupon_link"] = url
        template_variables["static_path"] = self.static_path

        if is_weixin_browser(self) or is_mobile_browser(self):
            self.render(self.template_path + "coupon.html",
                        **template_variables)
        else:
            self.redirect(url)
예제 #8
0
 def get(self, template_variables={}):
     user_info = self.get_current_user()
     template_variables["user_info"] = user_info
     template_variables["gen_random"] = gen_random
     if user_info:
         if is_mobile_browser(self):
             self.render("mobile/user/social.html", **template_variables)
         else:
             self.render("user/social.html", **template_variables)
     else:
         self.render("404.html", **template_variables)
예제 #9
0
파일: user.py 프로젝트: simidaxu/1024nj
 def get(self, template_variables={}):
     user_info = self.get_current_user()
     template_variables["user_info"] = user_info
     template_variables["gen_random"] = gen_random
     if user_info:
         if is_mobile_browser(self):
             self.render("mobile/user/social.html", **template_variables)
         else:
             self.render("user/social.html", **template_variables)
     else:
         self.render("404.html", **template_variables)
예제 #10
0
 def get(self, template_variables = {}):
     user_info = self.current_user
     p = int(self.get_argument("p", "1"))
     template_variables["user_info"] = user_info
     template_variables["gen_random"] = gen_random
     template_variables["active"] = "bbs"
     template_variables["navs"] = self.nav_model.get_all_navs()
     template_variables["channels"] = self.channel_model.get_all_channels()
 
     if is_mobile_browser(self):
         self.render("sequ.html", **template_variables)
     else:
         self.render("sequ.html", **template_variables)
예제 #11
0
파일: user.py 프로젝트: simidaxu/1024nj
 def get(self, template_variables={}):
     user_info = self.get_current_user()
     template_variables["user_info"] = user_info
     template_variables["gen_random"] = gen_random
     if not user_info:
         self.redirect("/?s=signin")
     if user_info:
         if is_mobile_browser(self):
             self.render("mobile/user/setting_cover.html", **template_variables)
         else:
             self.render("user/setting_cover.html", **template_variables)
     else:
         self.render("404.html", **template_variables)
예제 #12
0
 def get(self, template_variables={}):
     user_info = self.get_current_user()
     template_variables["user_info"] = user_info
     template_variables["gen_random"] = gen_random
     if (not user_info):
         self.redirect("/?s=signin")
     if user_info:
         if is_mobile_browser(self):
             self.render("mobile/user/setting_cover.html",
                         **template_variables)
         else:
             self.render("user/setting_cover.html", **template_variables)
     else:
         self.render("404.html", **template_variables)
예제 #13
0
파일: user.py 프로젝트: yongningfu/1024nj
    def get(self, username, template_variables={}):
        user_info = self.current_user
        template_variables["user_info"] = user_info
        p = int(self.get_argument("p", "1"))
        active_tab = self.get_argument('tab', "post")
        template_variables["active_tab"] = active_tab

        view_user = self.user_model.get_user_by_username(username)
        template_variables["view_user"] = view_user
        template_variables[
            "feeds1_len"] = self.post_model.get_user_all_posts_count(
                view_user.uid)
        template_variables[
            "feeds2_len"] = self.reply_model.get_user_all_replys_count(
                view_user.uid)
        template_variables[
            "followees_count"] = self.follow_model.get_user_followees_count(
                view_user.uid)
        template_variables[
            "followers_count"] = self.follow_model.get_user_followers_count(
                view_user.uid)

        template_variables["ad"] = self.ads_model.get_rand_ad()

        gold_coins = (view_user.income - view_user.expend) / 10000
        silver_coins = (view_user.income - view_user.expend) % 10000
        bronze_coins = silver_coins % 100
        silver_coins = silver_coins / 100
        template_variables["gold_coins"] = gold_coins
        template_variables["silver_coins"] = silver_coins
        template_variables["bronze_coins"] = bronze_coins

        template_variables["feeds1"] = self.post_model.get_user_all_posts(
            view_user.uid, current_page=p)
        template_variables["feeds2"] = self.reply_model.get_user_all_replys(
            view_user.uid, current_page=p)

        if (user_info):
            template_variables["follow"] = self.follow_model.get_follow(
                user_info.uid, view_user.uid, 'u')
        else:
            template_variables["link"] = "u"
            template_variables["link2"] = username
            template_variables["follow"] = None
        if is_mobile_browser(self):
            self.render("mobile/user.html", **template_variables)
        else:
            self.render("user.html", **template_variables)
예제 #14
0
    def get(self, template_variables = {}):
        user_info = self.current_user
        p = int(self.get_argument("p", "1"))
        template_variables["user_info"] = user_info
        template_variables["gen_random"] = gen_random
        template_variables["stds"] = self.std_model.get_std_posts(current_page = p)
        template_variables["hots"] = self.hot_model.get_hot_posts(current_page = p)
        #template_variables["heads"] = self.head_model.get_shows_head_posts()

        template_variables["navs"] = self.nav_model.get_all_navs()
        template_variables["channels"] = self.channel_model.get_all_channels()

        if is_mobile_browser(self):
            self.render("index-m.html", **template_variables)
        else:
            self.render("index.html", **template_variables)
예제 #15
0
    def get(self, user, template_variables = {}):
        user_info = self.current_user
        template_variables["user_info"] = user_info
        template_variables["gen_random"] = gen_random    
        p = int(self.get_argument("p", "1"))
        if(re.match(r'^\d+$', user)):
            view_user_info = self.user_model.get_user_by_uid(user)
        else:
            view_user_info = self.user_model.get_user_by_username(user)
        template_variables["view_user_info"] = view_user_info
        template_variables["stds"] = self.std_model.get_std_posts_by_user_id(view_user_info.uid, current_page = p)
        template_variables["hots"] = self.hot_model.get_hot_posts_by_user_id(view_user_info.uid, current_page = p)
        template_variables["navs"] = self.nav_model.get_all_navs()
        template_variables["channels"] = self.channel_model.get_all_channels()

        if is_mobile_browser(self):
            self.render("user/user-m.html", **template_variables)
        else:
            self.render("user/user.html", **template_variables)
예제 #16
0
파일: user.py 프로젝트: simidaxu/1024nj
    def get(self, username, template_variables={}):
        user_info = self.current_user
        template_variables["user_info"] = user_info
        p = int(self.get_argument("p", "1"))
        active_tab = self.get_argument("tab", "post")
        template_variables["active_tab"] = active_tab

        view_user = self.user_model.get_user_by_username(username)
        template_variables["view_user"] = view_user
        template_variables["feeds1_len"] = self.post_model.get_user_all_posts_count(view_user.uid)
        template_variables["feeds2_len"] = self.reply_model.get_user_all_replys_count(view_user.uid)
        template_variables["followees_count"] = self.follow_model.get_user_followees_count(view_user.uid)
        template_variables["followers_count"] = self.follow_model.get_user_followers_count(view_user.uid)

        template_variables["ad"] = self.ads_model.get_rand_ad()

        gold_coins = (view_user.income - view_user.expend) / 10000
        silver_coins = (view_user.income - view_user.expend) % 10000
        bronze_coins = silver_coins % 100
        silver_coins = silver_coins / 100
        template_variables["gold_coins"] = gold_coins
        template_variables["silver_coins"] = silver_coins
        template_variables["bronze_coins"] = bronze_coins

        template_variables["feeds1"] = self.post_model.get_user_all_posts(view_user.uid, current_page=p)
        template_variables["feeds2"] = self.reply_model.get_user_all_replys(view_user.uid, current_page=p)

        if user_info:
            template_variables["follow"] = self.follow_model.get_follow(user_info.uid, view_user.uid, "u")
        else:
            template_variables["link"] = "u"
            template_variables["link2"] = username
            template_variables["follow"] = None
        if is_mobile_browser(self):
            self.render("mobile/user.html", **template_variables)
        else:
            self.render("user.html", **template_variables)
예제 #17
0
파일: index.py 프로젝트: gaolinjie/ttx
    def get(self, template_variables = {}):
        url = self.get_argument("url", "")
        template_variables["tmall_link"] = url
        template_variables["static_path"] = self.static_path

        if is_weixin_browser(self) or is_mobile_browser(self):
            tmall_pattern = re.compile(r'http://detail.tmall.com/item.htm?\S*id=(\d+)')
            tmall_match = tmall_pattern.search(url) 
            if tmall_match: 
                sku = tmall_match.group(1)

                doc=pyq("http://djaa.cn/ajax/cm_details/to_cm_details_tmall.php", 
                    headers={'User-Agent': 'Mozilla/5.0 (MicroMessenger;iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4'},
                    method='post',
                    data={'id': sku, 'shopUrl': url, 'shop_type': 'tmall', 'small_shop_type': 'cm_details'})
                    #print doc
                title = doc('.dtif-h').text()
                content = doc('.viewport').outerHtml()
                template_variables["title"] = title
                template_variables["content"] = content
                template_variables["sku"] = sku
                self.render(self.template_path+"tmall.html", **template_variables)  
        else:
            self.redirect(url)
예제 #18
0
    def get(self, username, template_variables={}):
        user_info = self.current_user
        template_variables["user_info"] = user_info
        p = int(self.get_argument("p", "1"))

        view_user = self.user_model.get_user_by_username(username)
        template_variables["view_user"] = view_user
        template_variables[
            "feeds1_len"] = self.feed_model.get_user_all_feeds_count_by_type(
                view_user.uid, 1)
        template_variables[
            "feeds2_len"] = self.feed_model.get_user_all_feeds_count_by_type(
                view_user.uid, 2)
        template_variables[
            "feeds7_len"] = self.feed_model.get_user_all_feeds_count_by_type(
                view_user.uid, 7)
        template_variables[
            "feeds8_len"] = self.feed_model.get_user_all_feeds_count_by_type(
                view_user.uid, 8)
        template_variables[
            "followees_count"] = self.follow_model.get_user_followees_count(
                view_user.uid)
        template_variables[
            "followers_count"] = self.follow_model.get_user_followers_count(
                view_user.uid)

        gold_coins = (view_user.income - view_user.expend) / 10000
        silver_coins = (view_user.income - view_user.expend) % 10000
        bronze_coins = silver_coins % 100
        silver_coins = silver_coins / 100
        template_variables["gold_coins"] = gold_coins
        template_variables["silver_coins"] = silver_coins
        template_variables["bronze_coins"] = bronze_coins

        if (user_info):
            template_variables["follow"] = self.follow_model.get_follow(
                user_info.uid, view_user.uid, 'u')
            template_variables["feeds"] = self.feed_model.get_user_all_feeds(
                view_user.uid, user_info.uid, current_page=p)
            template_variables[
                "feeds1"] = self.feed_model.get_user_all_feeds_by_type(
                    view_user.uid, user_info.uid, 1, current_page=p)
            template_variables[
                "feeds2"] = self.feed_model.get_user_all_feeds_by_type(
                    view_user.uid, user_info.uid, 2, current_page=p)
            template_variables[
                "feeds7"] = self.feed_model.get_user_all_feeds_by_type(
                    view_user.uid, user_info.uid, 7, current_page=p)
            template_variables[
                "feeds8"] = self.feed_model.get_user_all_feeds_by_type(
                    view_user.uid, user_info.uid, 8, current_page=p)
        else:
            template_variables["feeds"] = self.feed_model.get_user_all_feeds2(
                view_user.uid, current_page=p)
            template_variables[
                "feeds1"] = self.feed_model.get_user_all_feeds_by_type2(
                    view_user.uid, 1, current_page=p)
            template_variables[
                "feeds2"] = self.feed_model.get_user_all_feeds_by_type2(
                    view_user.uid, 2, current_page=p)
            template_variables[
                "feeds7"] = self.feed_model.get_user_all_feeds_by_type2(
                    view_user.uid, 7, current_page=p)
            template_variables[
                "feeds8"] = self.feed_model.get_user_all_feeds_by_type2(
                    view_user.uid, 8, current_page=p)
            template_variables["link"] = "u"
            template_variables["link2"] = username
            template_variables["follow"] = None
        if is_mobile_browser(self):
            self.render("mobile/user.html", **template_variables)
        else:
            self.render("user.html", **template_variables)