Beispiel #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"))
Beispiel #2
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))
Beispiel #3
0
	def create_user_object(req,one):
		#if(one.icon):
		icon_url=MappingId.mapping_host_with_scheme(req.request)+"/show_icon?key="+one.user_id
		#else:
		#	icon_url=MappingId.mapping_host_with_scheme(req.request)+"/static_files/empty_user.png"
		profile_url=MappingId.mapping_host_with_scheme(req.request)+"/mypage?user_id="+one.user_id
		name=one.name
		if(not name):
			name="noname"
		one_dic={"user_id":one.user_id,"name":name,"homepage":one.homepage,"icon_url":icon_url,"profile_url":profile_url}
		return one_dic
Beispiel #4
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"))
Beispiel #5
0
    def get(self, bbs_key):
        SetUtf8.set()
        bbs_key_original = bbs_key

        # キャッシュに存在するか判定
        result = memcache.get("feed_" + bbs_key_original)
        # result=None
        if not result:
            # キャッシュに存在しない場合はRSS作成

            # 掲示板取得
            bbs_key = MappingId.mapping(bbs_key)
            bbs = None
            try:
                bbs = db.get(bbs_key)
            except:
                bbs = None
            if bbs == None:
                self.error(404)
                return

                # feedを作成
            result = RssFeed.generate_feed(bbs, bbs_key)

            # キャッシュに入れる
            memcache.set("feed_" + bbs_key_original, result, 60 * 60 * 3)  # 3時間

        self.response.headers["Content-Type"] = "text/xml; charset=utf-8"
        self.response.out.write(result)
Beispiel #6
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"))
Beispiel #7
0
	def add_support_forum(main,app):
		if(not app.support_forum and app.is_public):
			thread=MesThread()
			bbs_key=MappingId.mapping(BbsConst.APP_SUPPORT_BBS_ID)
			if(bbs_key==""):
				#return False
				main.response.out.write(Alert.alert_msg("サポートフォーラムBBS[ID:"+BbsConst.APP_SUPPORT_BBS_ID+"]が見つかりません。",main.request.host))
				return True

			bbs=db.get(bbs_key)
			thread.bbs_key=bbs
			thread.title=app.app_name
			thread.author=app.author
			thread.summary=app.app_name+"のサポートフォーラムです。"
			thread.user_id=app.user_id
			thread.illust_mode=BbsConst.ILLUSTMODE_NONE
			thread.create_date=datetime.datetime.today()
			thread.comment_cnt=0
			thread.date=datetime.datetime.today()

			thread.put()
			
			app.support_forum=thread
			app.put()

		#if(not app.support_forum.score):
		#	app.support_forum.score = None
		#	app.support_forum.put()
		
		return False
Beispiel #8
0
	def get(self):
		SetUtf8.set()
		
		data=""

		user = users.get_current_user()
		user_id="";
		if(user):
			user_id=user.user_id()
		
		is_iphone=CssDesign.is_iphone(self)
		is_mobile=is_iphone or CssDesign.is_tablet(self)
		app_key=ApiPerpetuation.get_app_key(self)

		host_url="http://"+MappingId.mapping_host(self.request.host)+"/";

		template_values = {
			'host': host_url,
			'user_id': user_id,
			'is_mobile': is_mobile,
			'is_iphone': is_iphone,
			'app_key': app_key
		}

		self.response.content_type = 'text/javascript'
		path = "/html/api/illustbook.js"
		self.response.out.write(template_select.render(path, template_values))
Beispiel #9
0
	def get_thread_list(self,analytics):
		start_date=str(datetime.date.today()+datetime.timedelta(days=-1))
		end_date=str(datetime.date.today())
		result=analytics.get("page",".*",start_date,end_date)

		thread_list=[]
		for one in result:
			url=one["ga:pagePath"]
			count=int(one["ga:pageviews"])

			data=url.split("/")
			try:
				bbs_name=str(data[1])
				thread_name=str(data[2].split(".")[0])
			except:
				continue

			bbs_key=MappingId.mapping(bbs_name)
			bbs=ApiObject.get_cached_object(bbs_key)
			if(not bbs):
				continue
			thread = MappingThreadId.mapping(bbs,thread_name)
			if(not thread):
				continue

			while(count>=1):
				thread_list.append(thread.key())
				count=count-1

		return thread_list
Beispiel #10
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
Beispiel #11
0
    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
Beispiel #12
0
	def _update(self,event,user,validate_all,is_create):
		event.title=self.request.get("title")
		event.summary=self.request.get("summary")

		if(is_create):
			event.summary=EscapeComment.escape_br(event.summary)
			event.summary=EscapeComment.auto_link(event.summary)

		event.id=self.request.get("id")
		if(event.id==""):
			Alert.alert_msg_with_write(self,"IDを入力する必要があります。")
			return False
		if(MappingId.key_format_check(event.id)):
			Alert.alert_msg_with_write(self,"IDは半角英数で16文字以下である必要があります。")
			return False

		try:
			event.start_date=datetime.datetime.strptime(self.request.get("start_date"), '%Y/%m/%d').replace(tzinfo=JST()).astimezone(UTC())
			event.end_date=datetime.datetime.strptime(self.request.get("end_date"), '%Y/%m/%d').replace(tzinfo=JST()).astimezone(UTC())
		except:
			Alert.alert_msg_with_write(self,"日付の変換に失敗しました。")
			return False

		if(event.end_date <= event.start_date):
			Alert.alert_msg_with_write(self,"終了日の方が開始日より早くなっています。")
			return False

		event_list=Event.all().filter("start_date <=",event.end_date).order("-start_date").fetch(limit=1)	#既存のDBが重複していないと仮定すると最新の1つだけチェックすればよい
		for e in event_list:
			if(e.id==event.id):
				continue
			err=False
			if(e.start_date.replace(tzinfo=UTC()).astimezone(UTC()) <= event.start_date):
				if(e.end_date.replace(tzinfo=UTC()).astimezone(UTC()) > event.start_date):
					err=True
			if(e.start_date.replace(tzinfo=UTC()).astimezone(UTC()) < event.end_date):
				if(e.end_date.replace(tzinfo=UTC()).astimezone(UTC()) > event.end_date):
					err=True
			if(err):
				mes ="今回のイベント&nbsp;"+str(event.start_date.replace(tzinfo=UTC()).astimezone(JST()).strftime('%Y/%m/%d'))+"〜"+str(event.end_date.replace(tzinfo=UTC()).astimezone(JST()).strftime('%Y/%m/%d'))+"<br/>";
				mes+="他のイベント&nbsp;"+str(e.start_date.replace(tzinfo=UTC()).astimezone(JST()).strftime('%Y/%m/%d'))+"〜"+str(e.end_date.replace(tzinfo=UTC()).astimezone(JST()).strftime('%Y/%m/%d'))+"<br/>";
				Alert.alert_msg_with_write(self,"日程が他のイベントと重複しています。<br/>"+mes)
				return False

		if(event.end_date - event.start_date > datetime.timedelta(days=BbsConst.EVENT_MAX_DAYS)):
			Alert.alert_msg_with_write(self,"日程が2週間を超えています。")
			return False

		if(validate_all):
			if(event.title=="" or event.id==""):
				Alert.alert_msg_with_write(self,"タイトルとIDを入力して下さい。")
				return False
		if(is_create):
			event.user_id=user.user_id()
		if(is_create or event.user_id==user.user_id()):
			event.author=self.request.get("author")
		return True
Beispiel #13
0
	def check_id_available(main,app_id):
		if(app_id=="" or MappingId.key_format_check(app_id)):
			main.response.out.write(Alert.alert_msg("アプリIDは半角英数である必要があります。",main.request.host))
			return False
		query=AppCode.all().filter("app_id =",app_id)
		if(query.count()==0):
			return True
		main.response.out.write(Alert.alert_msg("このアプリIDは既に使われています。",main.request.host))
		return False
Beispiel #14
0
	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
Beispiel #15
0
	def _get_bbs_url(req,bbs):
		if(req):
			bbs_url=MappingId.mapping_host_with_scheme(req.request)+"/"
		else:
			bbs_url="."
		if(bbs.short):
			bbs_url+=bbs.short+"/"
		else:
			bbs_url+="usr/"+str(bbs.key())+"/"
		return bbs_url
Beispiel #16
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"))
Beispiel #17
0
	def get(self):
		host_url=MappingId.mapping_host_with_scheme(self.request)+"/"
		page = 1
		if(self.request.get("page")):
			page=int(self.request.get("page"))
		
		template_values = {
		'host': host_url,
		'page': page
		}		  
		path = '/html/comic.html'
		self.response.out.write(template_select.render(path, template_values))
Beispiel #18
0
	def get(self):
		SetUtf8.set()

		is_english=CssDesign.is_english(self)

		short=self.request.get('id')
		if(MappingId.key_format_check(short)):
			txt="IDは半角英数である必要があります。"
			if(is_english):
				txt="ID must be 16 characters or less"
			Alert.alert_msg_with_write(self,txt)
			return
		if(MappingId.check_capability(short,"")==0):
			txt="ID:"+short+"は既に登録されていて利用できません。"
			if(is_english):
				txt="ID:"+short+" is not available"
			Alert.alert_msg_with_write(self,txt)
			return
		txt="ID:"+short+"は利用可能です。"
		if(is_english):
			txt="ID:"+short+" is available"
		Alert.alert_msg_with_write(self,txt)
Beispiel #19
0
	def _render_page(self,template_values):
		host="http://"+MappingId.mapping_host(self.request.host)+"/";
		template_values['host']=host
		template_values['is_iphone']=CssDesign.is_iphone(self)
		template_values['is_tablet']=CssDesign.is_tablet(self)
		template_values['tag_display_n']=40
		template_values['is_maintenance']=MaintenanceCheck.is_appengine_maintenance()
		if(template_values['user']):
			template_values['login_flag']=1
		else:
			template_values['login_flag']=0
		render=template_select.render("/html/pinterest.html", template_values)
		#render=strip_spaces_between_tags(render)
		self.response.out.write(render)
Beispiel #20
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))
Beispiel #21
0
	def get(self):
		user = users.get_current_user()
		user_name=ShowEntry.get_user_name(user)

		bbs_list=[]

		if(user):
			user_id=user.user_id()
			
			bookmark_bbs_list=ApiBookmark.bookmark_get_bbs_list(self,user_id)
			rental_bbs_list=ApiUser.user_get_bbs_list(self,user_id)
			
			if(rental_bbs_list):
				bbs_list.extend(rental_bbs_list)
			if(bookmark_bbs_list):
				bbs_list.extend(bookmark_bbs_list)

			sample_bbs={
			"title":"サンプルお絵描き掲示板",
			"key":MappingId.mapping("sample")
			}
			bbs_list.append(sample_bbs)

		temp_key=self.request.get("temp_key")

		args=None
		if(temp_key):
			temp=db.get(temp_key)
			if(temp.args):
				args=temp.args

		target_bbs=self.get_target_bbs(args);
		if(target_bbs):
			bbs_list=target_bbs

		template_values={
		'host':"./",
		'is_iphone':CssDesign.is_iphone(self),
		'is_tablet':CssDesign.is_tablet(self),
		'is_english':CssDesign.is_english(self),
		'temp_key':temp_key,
		'redirect_url':self.request.path+"?temp_key="+temp_key,
		'user':user,
		'bbs_list':bbs_list,
		'args':args,
		'user_name':user_name
		}
		render=template_select.render("/html/upload_temp.html", template_values)
		self.response.out.write(render)
Beispiel #22
0
	def post(self,mode_url):
		mode=self.request.get("mode")

		user = users.get_current_user()
		if(not user):
			Alert.alert_msg_with_write(self,"ログインが必要です。")
			return

		msg=""

		if(mode=="add"):
			if(Event.all().filter("id =",self.request.get("id")).count()>=1):
				Alert.alert_msg_with_write(self,"このIDのイベントは既に存在しています")
				return
			
			event=Event()
			if(not self._update(event,user,True,True)):
				return
			event.put()

		if(mode=="edit"):
			event=Event.all().filter("id =",self.request.get("id")).fetch(limit=2)
			if(not event or len(event)==0):
				Alert.alert_msg_with_write(self,"イベントが存在しません")
				return
			if(len(event)>=2):
				Alert.alert_msg_with_write(self,"イベントが重複しています")
				return
			event=event[0]
			if(not self._update(event,user,True,False)):
				return
			event.put()

		if(mode=="del"):
			event=Event.all().filter("id =",self.request.get("id")).fetch(limit=2)
			if(not event or len(event)==0):
				Alert.alert_msg_with_write(self,"イベントが存在しません")
				return
			event[0].delete()

		host=MappingId.mapping_host_with_scheme(self.request)+"/"

		if(mode=="del"):
			self.redirect(str(host+"?order=event"))
		else:
			self.redirect(str(host+"?order=event&event_id="+event.id))
Beispiel #23
0
	def create_bbs_object(req,bbs):
		if(not bbs):
			return None
	
		bookmark_cnt=0
		if(bbs.bookmark_count):
			bookmark_cnt=bbs.bookmark_count

		bbs_url=ApiObject._get_bbs_url(req,bbs)
		
		thumbnail_url=""
		if(bbs.cached_thumbnail_key and not bbs.del_flag):
			thumbnail_url=MappingId.mapping_host_with_scheme(req.request)+"/thumbnail/"+bbs.cached_thumbnail_key+".jpg"

		summary=ApiObject.truncate_html(bbs.summary,20)

		one_dic={"title":bbs.bbs_name,"summary":summary,"bbs_url":bbs_url,"bookmark":bookmark_cnt,"key":str(bbs.key()),"thumbnail_url":thumbnail_url,"mode":bbs.bbs_mode}
		return one_dic
Beispiel #24
0
	def get(self):
		host_url="http://"+MappingId.mapping_host(self.request.host)+"/"
		bbs_key=self.request.get("bbs_key")
		thread_key=self.request.get("thread_key")

		try:
			bbs = db.get(self.request.get("bbs_key"))
			thread = db.get(self.request.get("thread_key"))
		except:
			bbs = None
			thread = None
		
		if(bbs==None or thread==None):
			self.response.out.write(Alert.alert_msg("スレッドが見つかりません。",self.request.host))
			return
		
		image=thread.image_key#db.get(thread.image);
		width=400
		height=400
		if(image.width):
			width=image.width
		if(image.height):
			height=image.height
		if(self.request.get("width")):
			width=self.request.get("width")
		if(self.request.get("height")):
			height=self.request.get("height")
		
		if(CssDesign.is_iphone(self)==1):
			if(width>=300):
				height=300*height/width
				width=300
		
		template_values = {
		'host': host_url,
		'bbs': bbs,
		'bbs_key': bbs_key,
		'thread': thread,
		'thread_key': thread_key,
		'width': width,
		'height': height
		}		  
		path = '/html/moper/moper_embedded.htm'
		self.response.out.write(template_select.render(path, template_values))
Beispiel #25
0
	def feed_get_thread_list(req,order,offset,limit):
		#最大取得数
		if(limit>100):
			limit=100

		#キャッシュが有効かどうか
		cache_enable=ApiFeed._is_cache_enable(offset,limit,order)

		#キャッシュ取得
		cache_id=ApiFeed._get_cache_id(order,req.request.get("bbs_id"),offset,limit)
		if(cache_enable):
			data=memcache.get(cache_id)
			if(data):
				dic=ApiObject.create_thread_object_list(req,data,req.request.get("bbs_id"))
				return dic
		
		#スレッド一覧取得
		if(order=="hot"):
			rank=Ranking.get_by_key_name(BbsConst.THREAD_RANKING_KEY_NAME)
			if(rank==None):
				rank=Ranking.get_or_insert(BbsConst.THREAD_RANKING_KEY_NAME)
			thread_list=rank.get_rank(offset,limit)
			bbs_id=None
		else:
			query=ApiFeed._get_query(order,req.request.get("event_id"))

			bbs_id=None
			if(req.request.get("bbs_id")):
				bbs_key=MappingId.mapping(req.request.get("bbs_id"))
				if(bbs_key==""):
					return None #bbs not found
				query.filter("bbs_key =",db.get(bbs_key))
				bbs_id=True

			thread_list=query.fetch(offset=offset,limit=limit)
		
		#キャッシュに乗せる
		if(cache_enable):
			memcache.set(cache_id,thread_list,BbsConst.TOPPAGE_FEED_CACHE_TIME)

		#リスト作成
		dic=ApiObject.create_thread_object_list(req,thread_list,bbs_id)

		return dic
Beispiel #26
0
	def redirect_main(self):
		#リダイレクト
		host=MappingId.mapping_host_with_scheme(self.request)+"/";
		redirect_url=host+"mypage?";

		#リダイレクト先は必ず自分とする(他人のタイムラインには投稿は表示されないので)
		#if(self.request.get("to_user_id")):
		#	redirect_url=redirect_url+"&user_id="+self.request.get("to_user_id")

		if(self.request.get("feed_page")):
			redirect_url=redirect_url+"&feed_page="+self.request.get("feed_page")
		if(self.request.get("tab")):
			redirect_url=redirect_url+"&tab="+self.request.get("tab")
		else:
			redirect_url=redirect_url+"&tab=feed"
		if(self.request.get("edit")):
			redirect_url=redirect_url+"&edit="+self.request.get("edit")

		self.redirect(str(redirect_url))
Beispiel #27
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)
Beispiel #28
0
	def ret(req,page):
		if(req.request.get("redirect")):
			tab=""
			if(req.request.get("tab")):
				tab="&tab="+req.request.get("tab")
			req.redirect(str(req.request.get("redirect")+tab))
			return
	
		user = users.get_current_user()

		my_app_list=None
		if(user):
			my_app_list=AppCode.all().filter("user_id =",user.user_id()).fetch(limit=100,offset=0)
		
		if user:
			url_log = users.create_logout_url(req.request.url)
		else:
			url_log = users.create_login_url(req.request.url)

		app_key=None
		if(req.request.get("app_key")):
			app_key=req.request.get("app_key")
		
		bbs_key=None
		if(req.request.get("bbs_key")):
			bbs_key=req.request.get("bbs_key")

		app=None
		if(app_key):
			app=db.get(app_key)

		app_code=""
		if(app):
			app_code=app.js_code
		
		css_code=""
		if(app):
			css_code=app.css_code
			if(not css_code or css_code==""):
				css_code=DevPortal.load_initial_css_code(None)

		if(app_code==""):
			if(app and app.mode==BbsConst.APP_MODE_PLUGIN):
				app_code=AppPortal.load_sample_app("feedplugin.js")
			else:
				app_code=AppPortal.load_sample_app("helloworld.js")
		if(app_code=="puzzle"):
			app_code=AppPortal.load_sample_app("15puzzle.js")
		if(app_code=="feed"):
			app_code=AppPortal.load_sample_app("feedplugin.js")

		if(page=="edit"):
			app_code=cgi.escape(app_code.encode("utf-8"))
		
		sample_code=AppPortal.load_sample_app("helloworld.js")
		sample_code=cgi.escape(sample_code.encode("utf-8"))
		sample_code_plugin=AppPortal.load_sample_app("feedplugin.js")
		sample_code_plugin=cgi.escape(sample_code_plugin.encode("utf-8"))
		sample_code_css=DevPortal.load_initial_css_code(None)
		sample_code_css=cgi.escape(sample_code_css.encode("utf-8"))
		
		logined=0
		if(user):
			logined=1

		host_url="http://"+MappingId.mapping_host(req.request.host)+"/";
		
		template_values = {
			'host': host_url,
			'my_app_list': my_app_list,
			'sample_code': sample_code,
			'sample_code_plugin': sample_code_plugin,
			'sample_code_css': sample_code_css,
			'page': page,
			'app': app,
			'app_code': app_code,
			'css_code': css_code,
			'url_log': url_log,
			'logined': logined,
			'bbs_key': bbs_key,
			'user': users.get_current_user(),
			'redirect_url': req.request.path
		}
		
		url='/html/dev.html'
		if(page=="edit"):
			url='/html/dev/dev_edit.html'
		if(page=="info"):
			url='/html/dev/dev_info.html'
		
		path = url
		req.response.out.write(template_select.render(path, template_values))
Beispiel #29
0
	def get(self):
		host_url=MappingId.mapping_host_with_scheme(self.request)+"/"
		bbs_key=self.request.get("bbs_key")
		thread_key=self.request.get("thread_key")
		try:
			bbs = db.get(self.request.get("bbs_key"))
		except:
			 bbs=None
		if(bbs==None):
			Alert.alert_msg_with_write(self,"ブックが見つかりません。")
			return

		ipad=CssDesign.is_tablet(self)
		iphone=CssDesign.is_iphone(self)
		if(ipad or iphone):
			Alert.alert_msg_with_write(self,"iPhoneやiPadでは動画お絵かきツールは使用できません。")
			return

		draw_time=0
		summary=""
		author=""
		title=""

		if(thread_key!=""):
			try:
				thread=db.get(thread_key)
			except:
				thread=None
			if(thread==None):
				Alert.alert_msg_with_write(self,"スレッドが見つかりません。")
				return
			draw_time=thread.draw_time

			summary=ReeditEscape.escape(thread.summary)
			author=ReeditEscape.escape(thread.author)
			title=ReeditEscape.escape(thread.title)

		canvas_url=self.request.get("canvas_url");
		if(canvas_url!=""):
			canvas_url=host_url+"moper_load?id="+canvas_url
			
		force=0
		canvas_width=400
		canvas_height=400
		if(self.request.get("canvas_width")):
			canvas_width=self.request.get("canvas_width")
		if(self.request.get("canvas_height")):
			canvas_height=self.request.get("canvas_height")
		if(self.request.get("force")):
			force=self.request.get("force")
		
		template_values = {
		'host': host_url,
		'bbs': bbs,
		'thread_key': thread_key,
		'bbs_key': bbs_key,
		'canvas_url': canvas_url,
		'canvas_width': canvas_width,
		'canvas_height': canvas_height,
		'force': force,
		'draw_time': draw_time,
		'summary': summary,
		'author': author,
		'title': title
		}
		path = '/html/tools/draw_window_moper.htm'
		self.response.out.write(template_select.render(path, template_values))
Beispiel #30
0
	def alert_msg_with_write(req,msg):
		is_iphone=CssDesign.is_iphone(req)
		is_english=CssDesign.is_english(req)
		host_url=MappingId.mapping_host_with_scheme(req.request)+"/";
		req.response.out.write(Alert._alert_msg_core(msg,host_url,is_iphone,is_english))