def get_bbs(req,bbs_key): bbs_key=MappingId.mapping(bbs_key) if(bbs_key==""): Alert.alert_msg_notfound(req) return None bbs=ApiObject.get_cached_object(bbs_key) if(bbs == None): Alert.alert_msg_notfound(req) return None return bbs
def get(self): try: bbs=db.get(self.request.get("bbs_key")) except: bbs=None if(bbs==None): Alert.alert_msg_notfound(self) return host_url=MappingId.mapping_host_with_scheme(self.request)+"/"; url=MappingId.get_usr_url(host_url,bbs) self.redirect(str(url))
def get_entry_comment(self,template_values,entry_key): if(entry_key==""): return True try: entry=db.get(entry_key) except: entry=None if(entry==None): Alert.alert_msg_notfound(self) return False template_values["summary"]=ReeditEscape.escape(entry.content) template_values["author"]=ReeditEscape.escape(entry.editor) return True
def get(self): try: bbs=db.get(self.request.get("bbs_key")) except: bbs=None if(bbs==None): Alert.alert_msg_notfound(self) return host_name=self.request.host if(host_name=="http://www.illust-book.appspot.com/"): host_name="http://www.illustbook.net/"; host_url="http://"+MappingId.mapping_host(host_name)+"/"; url=MappingId.get_usr_url(host_url,bbs) self.redirect(str(url+self.request.get("thread_key")+".html"))
def get_thread_comment(self,template_values,thread_key,entry_key,is_reply): if(thread_key=="" or entry_key!="" or is_reply=="1"): return True try: thread=db.get(thread_key) except: thread=None if(thread==None): Alert.alert_msg_notfound(self) return False template_values["draw_time"]=thread.draw_time template_values["is_png"]=thread.is_png template_values["summary"]=ReeditEscape.escape(thread.summary) template_values["author"]=ReeditEscape.escape(thread.author) template_values["title"]=ReeditEscape.escape(thread.title) return True
def get(self,bbs_key,thread_key): SetUtf8.set() #ホストチェック if SpamCheck.is_deny(self.request): self.response.set_status(401) return #英語版かどうか is_english=CssDesign.is_english(self) #BBSを取得 bbs_key=MappingId.mapping(bbs_key) bbs=ApiObject.get_cached_object(bbs_key) if(bbs == None): Alert.alert_msg_notfound(self) return #BBSが削除されていた場合 if(bbs.del_flag) : if(is_english): Alert.alert_msg_with_write(self,"This bbs was deleted.") else: Alert.alert_msg_with_write(self,"このBBSは削除されました。") return #ページ番号を取得 col_num = 10 page = 1 if self.request.get("page"): page = int(self.request.get("page")) if page < 1: page=1 #メンテナンス画面 is_maintenance=0 if(MaintenanceCheck.is_appengine_maintenance()): is_maintenance=1 #オーダー取得 order="update" if(bbs.default_comment_order==1): order="new" if self.request.get("order"): order=self.request.get("order") #スレッド取得 thread=ShowThread.get_thread(bbs,thread_key) if(thread == None): Alert.alert_msg_notfound(self) return #コメント数を更新 if(bbs.page_comment_n): col_num=bbs.page_comment_n if(self.request.get("limit")): col_num=int(self.request.get("limit")) #コメントの一覧を取得 query=ShowThread.get_comment_query(thread,order) entry_num = query.count() if(entry_num==0): com_list_ = [] else: com_list_ = query.fetch(limit=col_num, offset=(page-1)*col_num) #検索 search="" if(self.request.get("search")): search=self.request.get("search") query=""+search+' thread_key:"'+str(thread.key())+'"' com_list_=SearchThread.search(query,page,col_num,BbsConst.SEARCH_ENTRY_INDEX_NAME) #実体への変換 com_list_=ApiObject.get_cached_object_list(com_list_) #現在のスレッドへのURLを取得 host_url=MappingId.mapping_host_with_scheme(self.request)+"/" #編集モードか user = users.get_current_user() edit_flag = 0 if(not OwnerCheck.check(bbs,user)): edit_flag = 1 logined=0 if(user): logined=1 owner=user if(OwnerCheck.check(bbs,user)): owner=None admin_user=OwnerCheck.is_admin(user) #ページリンクを作成 page_url_base = MappingId.get_usr_url(host_url,bbs)+thread_key+'.html?page=' page_list=ShowThread.create_page_list(page,entry_num,col_num) #掲示板のデザインを取得 design=CssDesign.get_design_object(self,bbs,host_url,1) #コメントフォームを取得する show_comment_form=1 if(bbs.comment_login_require and not(owner)): show_comment_form=0 #名前取得 user_name=ShowEntry.get_user_name(user) #自分のイラストか my_illust=False if(user and thread.user_id==user.user_id()): my_illust=True #IPを表示するかどうか show_ip=False if(self.request.get("show_ip") and (owner or admin_user)): show_ip=True #コメントのレンダリング comment=ShowEntry.render_comment(self,host_url,bbs,thread,com_list_,edit_flag,bbs_key,logined,show_comment_form,admin_user,user_name,user,show_ip) #凍結されているか frozen=ApiObject.is_frozen_thread(thread) #拍手が有効かどうか applause_enable=not (user and thread.user_id and thread.user_id==user.user_id()) #メッセージ message=memcache.get(BbsConst.OBJECT_THREAD_MESSAGE_HEADER+str(thread.key())) #関連イラスト related=self._get_related(bbs,thread,design["is_iphone"],design["is_tablet"]) #スパム対策 force_login_to_create_new_image=BbsConst.FORCE_LOGIN_TO_CREATE_NEW_IMAGE force_login_to_create_new_comment=BbsConst.FORCE_LOGIN_TO_CREATE_NEW_COMMENT #描画 template_values = { 'host': host_url, 'usrhost': MappingId.get_usr_url(host_url,bbs), 'bbs': bbs, 'bbs_str_key': str(bbs.key()), 'thread': thread, 'edit_flag':edit_flag, 'url': 'edit', 'url_linktext': 'edit blogs', 'bbs_key': bbs_key, 'page':page, 'page_url_base':page_url_base, 'page_list':page_list, 'logined':logined, 'user':user, 'owner':owner, 'my_illust':my_illust, 'template_path':design["template_path"], 'css_name':design["css_name"], 'is_iphone':design["is_iphone"], 'is_tablet':design["is_tablet"], 'template_base_color':design["template_base_color"], 'admin_user':admin_user, 'order':order, 'is_maintenance':is_maintenance, 'redirect_url': self.request.path, 'comment':comment, 'show_comment_form':show_comment_form, 'user_name':user_name, 'search': search, 'limit': col_num, 'frozen': frozen, 'applause_enable': applause_enable, 'message': message, 'is_english': is_english, 'related': related, 'show_ip': show_ip, 'force_login_to_create_new_image': force_login_to_create_new_image, 'force_login_to_create_new_comment': force_login_to_create_new_comment } path = "/html/"+design["base_name"] self.response.out.write(template_select.render(path, template_values)) CounterWorker.update_counter(self,bbs,thread,owner)
def get(self): SetUtf8.set() page_name = "" mode = "access" if self.request.get("mode"): mode = self.request.get("mode") bbs = None user = None if page_name == "": try: bbs = db.get(self.request.get("bbs_key")) except: bbs = None if bbs == None: Alert.alert_msg_notfound(self) return user = users.get_current_user() if user: if bbs.user_id != user.user_id(): user = None page_name = bbs.bbs_name if self.request.get("start_date"): start_date = self.request.get("start_date") if not self.validate_date(start_date): Alert.alert_msg_with_write(self, "日付指定は0000-00-00形式である必要があります。") return else: start_date = str(datetime.date.today() + datetime.timedelta(days=-31)) if self.request.get("end_date"): end_date = self.request.get("end_date") if not self.validate_date(end_date): Alert.alert_msg_with_write(self, "日付指定は0000-00-00形式である必要があります。") return else: end_date = str(datetime.date.today() + datetime.timedelta(days=-1)) start_day = datetime.datetime.strptime(start_date, "%Y-%m-%d") end_day = datetime.datetime.strptime(end_date, "%Y-%m-%d") if start_day > end_day: Alert.alert_msg_with_write(self, "終了日よりも開始日の方が大きくなっています。") return bbs_id = bbs.short is_admin = OwnerCheck.is_admin(user) if is_admin: if self.request.get("bbs_id"): bbs_id = self.request.get("bbs_id") if bbs.short != bbs_id: page_name = bbs_id page_list = None ref_list = None keyword_list = None access_list = None show_analyze = False if user or bbs.short == "sample": show_analyze = True if show_analyze: try: result = self.get_analytics(mode, bbs_id, start_date, end_date) except: time.sleep(1) try: result = self.get_analytics(mode, bbs_id, start_date, end_date) except: Alert.alert_msg_with_write(self, "Analytics APIへのアクセスに失敗しました。リロードして下さい") logging.error("failed analytics api") return if mode == "page": page_list = result if mode == "ref": ref_list = result if mode == "keyword": keyword_list = result if mode == "access": access_list = result quota_error = mode == "access" and not access_list redirect_api = ( "analyze?start_date=" + start_date + "&end_date=" + end_date + "&bbs_id=" + bbs_id + "&bbs_key=" + str(bbs.key()) + "&" ) host_url = "./" template_values = { "host": host_url, "mode": mode, "redirect_api": redirect_api, "quota_error": quota_error, "bbs": bbs, "bbs_id": bbs_id, "page_name": page_name, "is_admin": is_admin, "user": user, "show_analyze": show_analyze, "ref_list": ref_list, "page_list": page_list, "keyword_list": keyword_list, "access_list": access_list, "start_date": start_date, "end_date": end_date, "is_iphone": CssDesign.is_iphone(self), "is_tablet": CssDesign.is_tablet(self), "is_english": CssDesign.is_english(self), "redirect_url": self.request.path, } path = "/html/analyze.html" self.response.out.write(template_select.render(path, template_values))