예제 #1
0
    def get(self):
        try:
            thread = db.get(self.request.get("thread_key"))
            bbs = db.get(self.request.get("bbs_key"))
        except:
            thread = None
            bbs = None

        if thread == None or bbs == None:
            Alert.alert_msg_with_write(self, "拍手対象のスレッドが見つかりません。")
            return

        not_spam = (
            self.request.remote_addr != thread.applause_ip
            and self.request.remote_addr != thread.applause_ip2
            and self.request.remote_addr != thread.applause_ip3
            and self.request.remote_addr != thread.applause_ip4
        )

        if not_spam or self.request.get("comment"):
            if thread.applause:
                thread.applause = thread.applause + 1
            else:
                thread.applause = 1
            thread.applause_ip4 = thread.applause_ip3
            thread.applause_ip3 = thread.applause_ip2
            thread.applause_ip2 = thread.applause_ip
            thread.applause_ip = self.request.remote_addr
            thread.applause_date = datetime.datetime.today()
            thread.search_index_version = 0
            thread.put()

            if bbs.applause_n:
                bbs.applause_n = bbs.applause_n + 1
            else:
                bbs.applause_n = 1
            bbs.put()

            user = users.get_current_user()

            comment = ""
            if self.request.get("comment"):
                comment = self.request.get("comment")

            StackFeed.feed_new_applause_thread(user, thread, comment)

            Ranking.add_rank_global(thread, BbsConst.SCORE_APPLAUSE)

        if self.request.get("mode") == "bbs":
            order = self.request.get("order")
            page = self.request.get("page")
            self.redirect(str(MappingId.get_usr_url("./", bbs) + "?order=" + order + "&page=" + page))
        else:
            thread_url = self.request.get("thread_key")
            if thread.short:
                thread_url = thread.short
            self.redirect(str(MappingId.get_usr_url("./", bbs) + thread_url + ".html"))
예제 #2
0
    def violate_thread(self):
        # スレッド
        thread = db.get(self.request.get("thread_key"))

        if self.request.get("mode") == "adult":
            if thread.adult:
                thread.adult = 0
            else:
                thread.adult = 1

        if self.request.get("mode") == "terms":
            if thread.violate_terms:
                thread.violate_terms = 0
            else:
                thread.violate_terms = 1

        if self.request.get("mode") == "photo":
            if thread.violate_photo:
                thread.violate_photo = 0
            else:
                thread.violate_photo = 1

        if self.request.get("mode") == "comment":
            if thread.prohibit_comment:
                thread.prohibit_comment = 0
            else:
                thread.prohibit_comment = 1

        thread.put()

        ApiFeed.invalidate_cache()

        bbs = db.get(self.request.get("bbs_key"))
        self.redirect(str(MappingId.get_usr_url("./", bbs) + self.request.get("thread_key") + ".html"))
예제 #3
0
	def get_thread_url(host,bbs,thread):
		url=MappingId.get_usr_url(host,bbs)
		if(thread.short):
			url+=thread.short
		else:
			url+=str(thread.key())
		url+=".html"
		return url
예제 #4
0
파일: RssFeed.py 프로젝트: abars/illustbook
    def generate_feed(bbs, bbs_key):
        url = MappingId.get_usr_url("http://www.illustbook.net/", bbs)
        feed = feedgenerator.Rss201rev2Feed(
            title=bbs.bbs_name, link=url, feed_url=url, description=bbs.summary, language="ja"
        )

        if bbs.bbs_mode == BbsConst.BBS_MODE_NO_IMAGE:
            entry_query = Entry.all().filter("bbs_key =", bbs)
            entry_query.order("-date")
            all_entry = entry_query.fetch(limit=20)
            for entry in all_entry:
                try:
                    thread = entry.thread_key
                except:
                    continue
                url2 = url + str(thread.key()) + ".html"
                txt = "" + entry.editor + "(" + str(entry.date) + ")<BR>"

                if entry.illust_reply:
                    txt += "<IMG SRC='http://www.illustbook.net/img?img_id='"
                    txt += str(entry.illust_reply_image_key.key()) + "'><BR>"
                txt += entry.content

                for res in entry.res_list:
                    response = db.get(res)
                    txt += "<BR><BR>" + response.editor + "(" + str(response.date) + ")<BR>"
                    txt += "" + response.content + "<BR>"

                feed.add_item(
                    title=thread.title,
                    link=url2,
                    description=txt,
                    author_email="",
                    author_name=entry.editor,
                    author_link=entry.homepage_addr,
                    pubdate=entry.date,
                )
        else:
            thread_query = MesThread.all().filter("bbs_key =", bbs)
            thread_query.order("-create_date")
            all_threads = thread_query.fetch(limit=20)

            for thread in all_threads:
                url2 = url + str(thread.key()) + ".html"
                if thread.image_key:
                    thumbnail = "http://www.illustbook.net/img?img_id=" + str(thread.image_key.key())
                    feed.add_item(
                        title=thread.title,
                        link=url2,
                        description="<IMG SRC=" + thumbnail + "><BR>" + thread.summary,
                        author_email="",
                        author_name=thread.author,
                        author_link=thread.homepage_addr,
                        pubdate=thread.create_date,
                    )
        result = feed.writeString("utf-8")

        return result
예제 #5
0
	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))
예제 #6
0
    def violate_entry(self):
        # エントリー
        entry = db.get(self.request.get("entry_key"))
        if entry.violate_terms:
            entry.violate_terms = 0
        else:
            entry.violate_terms = 1
        entry.put()

        bbs = db.get(self.request.get("bbs_key"))
        self.redirect(str(MappingId.get_usr_url("./", bbs) + self.request.get("thread_key") + ".html"))
예제 #7
0
	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"))
예제 #8
0
	def get(self):
		try:
			bbs = db.get(self.request.get("bbs_key"))
		except:
			bbs=None
		try:
			thread = db.get(self.request.get("thread_key"))
		except:
			thread=None
		
		if(not bbs or not thread):
			self.response.out.write(Alert.alert_msg("削除対象が見つかりません。",self.request.host))
			return

		is_english=CssDesign.is_english(self)
		
		del_ok=0		
		if(self.request.get("del_key")):
			if(thread.delete_key):
				if(thread.delete_key==self.request.get("del_key")):
					del_ok=1
				else:
					msg="削除キーが一致しません。"
					if(is_english):
						msg="invalid key"
					self.response.out.write(Alert.alert_msg(msg,self.request.host))
					return;
		
		user = users.get_current_user()

		bbs_owner = not OwnerCheck.check(bbs,user)
		thread_owner=False
		if(user and user.user_id()==thread.user_id):
			thread_owner=True
		
		if(del_ok==0):
			if(not bbs_owner and not thread_owner and not OwnerCheck.is_admin(user)):
				self.response.out.write(Alert.alert_msg("削除権限がありません。",self.request.host))
				return

		DelThread.delete_thread_core(thread)

		bbs.cached_thumbnail_key=None
		bbs.put()

		ApiFeed.invalidate_cache()

		url=MappingId.get_usr_url("./",bbs)
		self.redirect(str(url))
예제 #9
0
	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)
예제 #10
0
	def get(self,bbs_key):
		#日本語対応
		SetUtf8.set()

		#英語版かどうか
		is_english=CssDesign.is_english(self)

		
		#メンテナンス中かどうか
		is_maintenance=0
		if(MaintenanceCheck.is_appengine_maintenance()):
			is_maintenance=1

		#掲示板を取得
		bbs=ShowBbs.get_bbs(self,bbs_key)
		if(bbs==None):
			return

		#掲示板削除チェック
		if(bbs.del_flag) :
			if(is_english):
				Alert.alert_msg_with_write(self,"This bbs was deleted.")
			else:
				Alert.alert_msg_with_write(self,"この掲示板は削除されました。")
			return

		#ページ取得
		page = 1
		if self.request.get("page"):
			try:
				page = int(self.request.get("page"))
			except:
				Alert.alert_msg_with_write(self,"ページ番号が異常です。")
				return
			if page<1 :
				page=1

		#描画順を取得
		order=ShowBbs.get_order(self,bbs)
		
		#カテゴリ取得
		category=""
		if(self.request.get("category")):
			category=self.request.get("category")
		
		#スレッド一覧を取得
		thread_query=ShowBbs.get_thread_query(bbs,category,order)
		
		#1ページのイラスト数を取得
		col_num=ShowBbs.get_col_num(bbs,order)

		#スレッド数とスレッドを取得
		count_limit=(BbsConst.PAGE_LIST_COUNT+page)*col_num	#ページ番号生成用にしか使わないのでページ番号のMaxがわかれば良い
		if(category==""):
			threads_num = bbs.cached_threads_num
		else:
			threads_num = thread_query.count(limit=count_limit)
		all_threads = thread_query.fetch(limit=col_num, offset=(page-1)*col_num)
		
		#返信イラストを取得
		all_entries = None
		#if(order=="thumbnail"):
		#	all_entries=ShowBbs.get_illust_reply(bbs,page,col_num)
		#	if(threads_num<all_entries["count"]):
		#		threads_num=all_entries["count"]
		#	all_entries=all_entries["entry"]
		
		#ホストURLを取得
		host_url="http://"+MappingId.mapping_host(self.request.host)+"/";
		
		#URLを作成
		mapped_category=urllib.quote(category.encode('utf-8'))
		page_url=MappingId.get_usr_url(host_url,bbs)
		page_url_base=MappingId.get_usr_url(host_url,bbs)+'?order='+order+'&amp;category='+mapped_category+'&amp;page='
		page_url_order_base=MappingId.get_usr_url(host_url,bbs)+'?page=1&amp;category='+mapped_category+'&amp;order='
		page_url_category_base=MappingId.get_usr_url(host_url,bbs)+'?page=1&amp;order='+order+"&amp;category="

		#ページリストを作成
		page_list=PageGenerate.generate_page(page,threads_num,col_num)
		
		#ログインユーザを取得
		user = users.get_current_user()

		logined=0
		if(user):
			logined=1
		
		owner=user
		if(OwnerCheck.check(bbs,user)):
			owner=None
		
		#サイドバーコメントを取得
		side_comment=RecentCommentCache.get_entry(bbs)
		side_thread=RecentCommentCache.get_thread(bbs)
		
		#カテゴリ一覧を取得
		category_list=None
		if(bbs.category_list):
			if(bbs.category_list!=""):
				category_list=CategoryList.get_category_list(bbs) #bbs.category_list.split(",")

		#ページデザインを取得
		css_key=self.request.get("css_key")
		design=CssDesign.get_design_object(self,bbs,host_url,0)

		#サイドバー一覧を作成
		sidebar_list=ShowBbs.get_sidebar(bbs,category_list,side_comment,side_thread)

		#新規スレッドを作成できるか
		can_create_thread=ShowBbs.get_can_create_thread(bbs,user,logined)
		can_create_new_image=ShowBbs.get_can_create_new_image(bbs,owner)

		#スレッドを全て取得
		all_threads_cached=ApiObject.get_cached_object_list(all_threads)
		
		#コメントフォームを表示するか
		show_comment_form=1
		if(bbs.comment_login_require and not(owner)):
			show_comment_form=0

		#フルコメントデバッグ
		if(self.request.get("full_comment")):
			bbs.enable_full_comment=1

		#フルフラット表示をデフォルト化
		if(bbs.bbs_mode==BbsConst.BBS_MODE_NO_IMAGE):
			bbs.enable_full_flat=0
			bbs.enable_full_comment=0
		else:
			bbs.enable_full_flat=1
			#bbs.enable_full_comment=1 #デフォルト化を止める

		#コメントを全て取得
		#user_name=""
		user_name=ShowEntry.get_user_name(user)
		if(bbs.enable_full_comment):
			admin_user=OwnerCheck.is_admin(user)
			ShowEntry.render_comment_list(self,all_threads_cached,host_url,bbs,show_comment_form,logined,admin_user,user_name,user)

		#デザインの編集ができるか
		can_edit_design=False
		is_admin=OwnerCheck.is_admin(user)
		if(owner or (is_admin and bbs.bbs_mode==BbsConst.BBS_MODE_EVERYONE)):
			can_edit_design=True

		#infinite_scrollを使用するかどうか
		infinite_scroll=False
		#if(bbs.bbs_mode!=BbsConst.BBS_MODE_NO_IMAGE):# and design["is_iphone"]):
		infinite_scroll=True

		#infinite_scrollの2ページ目以降
		contents_only=0
		if(self.request.get("contents_only")=="1"):
			contents_only=1

		#メッセージ
		message=memcache.get(BbsConst.OBJECT_BBS_MESSAGE_HEADER+str(bbs.key()))

		#カウントアップコメント
		if(bbs.counter):
			bbs.counter.new_day_update()
		count_up_comment=None
		#if(bbs.dont_count_owner):
		#	if(owner):
		#		count_up_comment="管理人"
		#	else:
		#		count_up_comment="ユーザ"

		#カテゴリリスト
		show_category_list=False
		if(self.request.get("show_category_list")=="1"):
			show_category_list=True

		#レンダリング
		template_values = {
			'host': host_url,
			'usrhost': MappingId.get_usr_url(host_url,bbs),
			'threads': all_threads_cached,
			'all_entries':all_entries,
			'bbs':bbs,
			'new_url': 'create_new_thread',
			'page':page,
			'page_url':page_url,
			'page_url_base':page_url_base,
			'order':order,
			'page_url_order_base':page_url_order_base,
			'page_list':page_list,
			'user':user,
			'owner': owner,
			'side_comment':side_comment,
			'side_thread':side_thread,
			'logined':logined,
			'can_create_thread':can_create_thread,
			'category_list':category_list,
			'page_url_category_base':page_url_category_base,
			'now_category':category,
			'can_create_new_image':can_create_new_image,
			'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"],
			'sidebar_list': sidebar_list,
			'is_maintenance': is_maintenance,
			'css_key': css_key,
			'redirect_url': self.request.path,
			'show_comment_form': show_comment_form,
			'user_name': user_name,
			'is_admin': is_admin,
			'can_edit_design': can_edit_design,
			'infinite_scroll': infinite_scroll,
			'infinite_scroll_selecter': ".entry",
			'contents_only': contents_only,
			'message': message,
			'is_english': is_english,
			'count_up_comment': count_up_comment,
			'show_category_list': show_category_list
		}

		path = "/html/"+design["base_name"]
		self.response.out.write(template_select.render(path, template_values))
		
		if(is_maintenance):
			return
		
		CounterWorker.update_counter(self,bbs,None,owner)