Пример #1
0
def time_UTC_progress(value):
	return TimeProgress.get_date_diff_str(value," ago",True)
Пример #2
0
	def create_feed_object(req,feed,user_hash,object_hash,feed_key):
		#フィードが削除された
		if(feed==None):
			deleted_feed={"mode":"deleted","from_user":"","to_user":"","follow_user":"","bbs":"","thread":"","message":"ツイートは削除されました。","create_date":"","key":str(feed_key)}
			return deleted_feed

		#送信元ユーザ取得
		from_user=""
		if(feed.from_user_id):
			from_user=user_hash[feed.from_user_id]

		#送信先ユーザ取得
		to_user=""
		if(feed.to_user_id):
			to_user=user_hash[feed.to_user_id]

		#フォローユーザ取得
		follow_user=""
		if(feed.user_key):
			follow_user=user_hash[feed.user_key]
		
		#イベント発生掲示板取得
		bbs_object_key=StackFeedData.bbs_key.get_value_for_datastore(feed)
		bbs=""
		bbs_object=None
		if(bbs_object_key):
			bbs_object=object_hash[bbs_object_key]
			if(bbs_object):
				bbs=ApiObject.create_bbs_object(req,bbs_object)
			else:
				bbs=None
			if(not bbs):
				bbs={"title":"","bbs_url":""}	#deleted bbs
			
		#イベント発生スレッド取得
		thread_object_key=StackFeedData.thread_key.get_value_for_datastore(feed)
		thread=""
		if(thread_object_key):
			thread_object=object_hash[thread_object_key]
			if(thread_object):
				only_image=False
				thread=ApiObject._create_thread_object_core(req,thread_object,bbs_object,only_image)
			else:
				thread=None
			if(not thread):
				thread={"title":"","thread_url":""}	#deleted thread

		#発生日取得
		is_english=CssDesign.is_english(req)
		create_date=TimeProgress.get_date_diff_str(feed.create_date,"",is_english)
		
		#コメントを取得
		message=feed.message
		entry=[]
		if(feed.feed_mode=="new_comment_thread"):
			entry_mes_obj=ApiObject._get_entry_comment(feed,object_hash)
			message=entry_mes_obj["message"]
			author=entry_mes_obj["author"]
			image_key=entry_mes_obj["image_key"]
			thumbnail_url=None
			thumbnail2_url=None
			if(image_key):
				if(req):
					url_header="http://"+req.request.host
				else:
					url_header="."
				thumbnail_url=url_header+"/thumbnail/"+str(image_key)+".jpg"
				thumbnail2_url=url_header+"/thumbnail2/"+str(image_key)+".jpg"
			entry={"key":str(StackFeedData.entry_key.get_value_for_datastore(feed)),"author":author,"thumbnail_url":thumbnail_url,"thumbnail2_url":thumbnail2_url}

		#オブジェクトを返す
		one_dic={"mode":feed.feed_mode,"from_user":from_user,"to_user":to_user,"follow_user":follow_user,"bbs":bbs,"thread":thread,"entry":entry,"message":message,"create_date":create_date,"key":str(feed.key())}
		return one_dic
Пример #3
0
def time_JST_progress(value):
	return TimeProgress.get_date_diff_str(value,"前",False)
Пример #4
0
	def _create_thread_object_core(req,thread,bbs,only_image_thread):
		if(not thread or not bbs):
			return None
		if(not thread.cached_image_key and only_image_thread):
			return None
		if(bbs.del_flag):
			return None

		disable_news=0
		violate_terms=0
		if(bbs.disable_news):
			disable_news=1
		if(bbs.violate_terms):
			disable_news=1
		if(thread.violate_terms):
			disable_news=1
			violate_terms=1
		if(thread.violate_photo):
			disable_news=1

		#4分未満の画像でアップロードでもない場合は新着に非表示
		#アップロード時は-1、iPhone時は0が入る
		#if(thread.draw_time and thread.draw_time!=-1 and thread.draw_time<240):
		#	disable_news=1

		adult=0
		if(thread.adult):
			adult=thread.adult

		if(bbs.short and bbs.short=="mopersample" and thread.illust_mode!=BbsConst.ILLUSTMODE_MOPER):
			disable_news=1;

		if(req):
			url_header="http://"+req.request.host
		else:
			url_header="."

		thumbnail_url=""
		thumbnail2_url=""
		if(thread.cached_image_key):
			thumbnail_url=url_header+"/thumbnail/"+str(thread.cached_image_key)
			thumbnail2_url=url_header+"/thumbnail2/"+str(thread.cached_image_key)
			if(thread.illust_mode==BbsConst.ILLUSTMODE_MOPER):
				thumbnail_url+=".gif"
				thumbnail2_url=thumbnail_url
			else:
				thumbnail_url+=".jpg"
				thumbnail2_url+=".jpg"

			#サムネイルの作成に失敗している場合は再作成を促す
			if(thread.thumbnail2_version!=BbsConst.THUMBNAIL2_VERSION):
				memcache.delete(BbsConst.OBJECT_CACHE_HEADER+str(thread.key()))

		if(bbs.del_flag):
			thumbnail_url=""
			thumbnail2_url=""

		create_date=TimeProgress.get_date_str(thread.create_date)

		thread_url=url_header+"/"
		if(bbs.short):
			thread_url+=bbs.short+"/"
		else:
			thread_url+="usr/"+str(bbs.key())+"/"
		if(thread.short):
			thread_url+=thread.short+".html"
		else:
			thread_url+=str(thread.key())+".html"

		image_url=""
		if(thread.cached_image_key):
			image_url=url_header+"/img/"+str(thread.cached_image_key)+".jpg"
		#if(bbs.dont_permit_app or 
		if(bbs.del_flag):	#アプリでの画像データの参照を禁止
			image_url=""

		app=0
		if(thread.applause):
			app=thread.applause
		if(bbs.disable_applause):
			app=0

		comment_cnt=0
		if(thread.comment_cnt):
			comment_cnt=thread.comment_cnt

		summary=ApiObject.truncate_html(thread.summary)

		user_id=""
		if(thread.user_id):
			user_id=thread.user_id

		tag_list=[]
		if(thread.tag_list):
			tag_list=thread.tag_list

		event_id=""
		if(thread.event_id):
			event_id=thread.event_id

		bookmark_cnt=0
		if(thread.bookmark_count):
			bookmark_cnt=thread.bookmark_count

		bbs_title=bbs.bbs_name
		bbs_url=ApiObject._get_bbs_url(req,bbs)
		bbs_key=""
		if(bbs):
			bbs_key=str(bbs.key())

		one_dic={"title":thread.title,"summary":summary,"author":thread.author,
		"user_id":user_id,"thumbnail_url":thumbnail_url,"thumbnail2_url":thumbnail2_url,
		"image_url":image_url,"create_date":create_date,"thread_url":thread_url,
		"applause":app,"bookmark":bookmark_cnt,"comment":comment_cnt,"key":str(thread.key()),
		"disable_news":disable_news,"tag":tag_list,"width":thread.width,"height":thread.height,
		"version":thread.thumbnail2_version,"violate_terms":violate_terms,"create_date_original":thread.create_date,
		"bbs_title":bbs_title,"bbs_url":bbs_url,"bbs_key":bbs_key,"adult":adult,"event_id":event_id}
		
		return one_dic