コード例 #1
0
def expand_item( accum_ids, asset_def, images_dct, movies_dct, movie_panels_dct, click_panels_dct ):
	print "CLICK PANEL OPTIONS EXPAND->", asset_def["asset_name"], click_panels_dct.keys()

	asset_name = asset_def["asset_name"]
	item_def = click_panels_dct[asset_name]

	tot_style = ""
	tot_content = ""
	for item in item_def:
		asn = item["asset_name"]

		if asn.startswith("img"):
			style, content = gen_images.expand_item( accum_ids, item, images_dct )
			tot_style += style
			tot_content += content

		elif asn.startswith("mp"):
			style, content = gen_movie_panels.expand_item( accum_ids, item, images_dct )
			tot_style += style
			tot_content += content

		else:
			print "ERROR: Cannot process asset->", item
			sys.exit(0)

	return [ tot_style, tot_content ]
コード例 #2
0
def expand_item( accum_ids, asset_def, images_dct, movies_dct, movie_panels_dct, click_panels_dct, slide_shows_dct, cpo_dct ):

        asset_name = asset_def["asset_name"]
	item_def = slide_shows_dct[asset_name]

	# prep some global action functions...
	action_scripts = {}	
	action_dct = {}
	for pagekey2 in item_def.keys():
		funcname = "func_%s_%s" % ( asset_name, pagekey2 )
		action_scripts[funcname] = None;
		action_dct[funcname] = pagekey2
	funcname = "func_%s_off " % ( asset_name )
	action_scripts[funcname] = None

	# accumulate the child elements...
	tot_style = ""
	tot_content = ""
	tot_top_script = ""
	all_on = ""
	all_off = ""
	init_script = False

	# NOTE: WE DONT DO SCRIPTS TIL END...

	# insert parent div...
	tot_style += common.emit_line("#%s {" % asset_name)
	tot_style += common.emit_line(" visibility:inherit;")
	tot_style += common.emit_line("}")
	tot_content += common.emit_line("<div id=%s >" % asset_name )

	dopage=1
	while (True):
		if not item_def.has_key( str(dopage) ):
			#print "WARNING: breaking at ", dopage
			break

		# Create a div for each slide in slide show...	
		divname = "%s_%d" % ( asset_name, dopage )
		accum_ids.append(divname)
		style  = ""
		style += common.emit_line("#%s {" % divname )
		style += common.emit_line(" top:0px;")
		style += common.emit_line(" left:0px;")
		if dopage==1:
			style += common.emit_line(" visibility:inherit;")
		else:
			style += common.emit_line(" visibility:inherit;")
		style += common.emit_line("}")
		tot_style += style
		tot_content  += common.emit_line("<div id=%s >" % divname)
	
		# Accumulate the scriptlet to turn each slide item on/off for this page...
		tot_onscrl = "document.getElementById('%s').style.visibility='visible';" % divname
		tot_offscrl = "document.getElementById('%s').style.visibility='hidden';" % divname
		cp_init = ""
	
		pagedef = item_def[str(dopage)]
		for page_item in pagedef:
			page_asset_name = page_item["asset_name"]
		
			print "SLIDE SHOW name=%s page=%d asset_name=%s" % (asset_name, dopage, page_asset_name )
	
			if ( page_asset_name.startswith("img") ):

				# determine script, ahref, if any...
				script = None
				ahref = None
				exturl = None
				if page_item.has_key("link") and page_item["link"]!="":
					link = page_item["link"]
					if link.startswith("page"):
						ltype,parm = link.split(":")
						funcname = "func_%s_%s" % ( asset_name, parm )
						test = action_scripts[funcname]
						script = "%s ();" % funcname
					elif link.startswith("url"):
						idx = link.find(":")+1
						url = link[idx:]
						ahref = url
		                        elif link.startswith("nurl:"):
                                        	idx = link.find(":") + 1
                                        	ahref = link[idx:]
                                        	exturl = True
					else:
						print "ERROR: gen_slide_show: unknown link type", ltype
						sys.exit(1)

				# determine init vis, if any...
                        	init_vis = None
                        	if page_item.has_key("init") and page_item["init"]!="":
                                	init_vis = page_item["init"]
	
				style, content, top_script, scriptlet_dct = gen_images.expand_item( \
					accum_ids, page_item, images_dct, script, init_vis, ahref, exturl )
				tot_style += style
				tot_content += content
				tot_top_script += top_script
				tot_onscrl += scriptlet_dct["on"]
				tot_offscrl += scriptlet_dct["off"]

			elif page_asset_name.startswith("cp"):
	
                        	print "GEN SLIDE SHOW - CALLING GEN CLICK PANEL", page_asset_name, page_item, "cp->", str(click_panels_dct.keys()), \
					len(click_panels_dct.keys()), len(cpo_dct.keys())
                        	style, content, top_script, scriptlet_dct  = \
					gen_click_panels.expand_item( accum_ids, page_item, images_dct, movies_dct, movie_panels_dct, click_panels_dct, cpo_dct )
			
				print "cp on->", scriptlet_dct['on']
	
				tot_style += style
				tot_content += content
				tot_onscrl += scriptlet_dct["on"]
				tot_offscrl += scriptlet_dct["off"]
				tot_top_script += top_script
			
				# total hack...
				if page_asset_name == "cp_char_dev_1":
					cp_init += "cpo1_11_desel_click();"
				else:
					cp_init += "cpo2_11_desel_click();"

			elif ( page_asset_name.startswith("mp") ):
				
				style, content,scriptlet_dct = gen_movie_panels.expand_item( accum_ids, page_item, images_dct, \
					movies_dct, movie_panels_dct )
				tot_style += style
				tot_content += content
				tot_onscrl += scriptlet_dct["on"]
				tot_offscrl += scriptlet_dct["off"]
			
			#elif ( page_asset_name.startswith("ss") ):
			#style, content = gen_slide_show.expand_item( accum_ids, page_item, images_dct, movies_dct, movie_panels_dct ) 
			#tot_style += style
			#tot_content += content

			else:
				print "ERROR: gen_slide_shows: Cannot process->", page_item
				sys.exit(1)

		tot_content  += common.emit_line("</div>")

		# deal with action scripts for this page...
        	funcname = "func_%s_%d" % ( asset_name, dopage )
		#THISISHERE !action_scripts[funcname] = tot_onscrl
		action_scripts[funcname] = tot_offscrl + tot_onscrl + cp_init
		
		all_on += tot_onscrl
		all_off+= tot_offscrl

		# the init script is first page...
		if init_script == False:
			init_script = "%s ();" % funcname 

		dopage += 1

	# end parent div...
	tot_content += common.emit_line("</div>")

	# accumulate the scriptlet dct for this control...
	scriptlet_dct = {}
	scriptlet_dct['on'] = all_off + init_script
	scriptlet_dct['off'] = all_off

	# we do this in query respond func below...
	#scriptlet_dct['init'] = all_off + init_script;
	default_init = all_off + init_script

	# finalize the global action script dct for this control...
	# create an all off...
        funcname = "func_%s_off " % ( asset_name )
        action_scripts[funcname] = all_off

	# add to header scripts...	
	for item in action_scripts.keys():
		#funcdef = "function %s () { %s; }" % (item, "alert('s');" + all_off + action_scripts[item] + "alert('e');")
		funcdef = "function %s () { %s; }" % (item, all_off + action_scripts[item] )
		tot_top_script += "\n\n" + funcdef

	# create an if else ladder to query param responder...
	ifelse = ""
	for item in action_scripts.keys():
		if not action_dct.has_key(item): continue
		pg = action_dct[item]
		ifelse += \
			"var opt = keyValuePair[1];\n" + \
			"if ( opt == '%s' )\n" % pg + \
			"{\n" + \
				" %s();\n" % item + \
			"}\n" 
	detect_query_func = \
		"function %s_respond()\n{\n" % asset_name + \
		"var querystring = unescape(location.search);\n" + \
		"if (querystring)\n" + \
		"{\n" + \
        		"querystring = querystring.substring(1);\n" + \
        		"var pairs = querystring.split('&');\n" + \
        		"if ( pairs.length>0 )\n" + \
        		"{\n" + \
                		"var keyValuePair = pairs[0].split('=');\n" + \
                		"if (( keyValuePair[0]=='page'))\n" + \
				"{\n" + \
                        		ifelse + \
				"}\n" + \
			"}\n" + \
		"}\n" + \
		"else\n" + \
		"{\n" + \
			default_init + \
		"}\n" + \
		"}"
	tot_top_script += detect_query_func

	scriptlet_dct['init'] = "%s_respond();" % asset_name

        return [ tot_style, tot_content, tot_top_script, scriptlet_dct ]
コード例 #3
0
ファイル: gen_menus.py プロジェクト: gosha1128/Studio2
def expand_option( accum_ids, menu_name, menu_def, option_name, images_dct, action_scripts, init_hidden, \
	slide_shows_dct, movies_dct, mp_dct, is_dct, click_panels_dct, cpo_dct, embeds_dct ):

	option_def = menu_def[option_name]

	tot_style = ""
	tot_content = ""
	top_scripts = ""
	off_scriptlet = ""
	on_scriptlet= ""
	init_scriptlet = ""

	for item in option_def:
		asset_name = item["asset_name"]

		if asset_name.startswith("img"):
			# determine the script, if any...
			script = None
			ahref = None
			exturl = None
			if item.has_key("link") and item["link"]!="":
        			link = item["link"]
                		if link.startswith("option:"):
                			ltype,parm = link.split(":")
					funcname = "func_%s_%s" % (menu_name, parm)
                        		test = action_scripts[funcname]
					script = "%s ();" % funcname
				elif link.startswith("url:"):
					idx = link.find(":") + 1
					ahref = link[idx:]
                                elif link.startswith("nurl:"):
                                        idx = link.find(":") + 1
                                        ahref = link[idx:]
                                        exturl = True
				elif link.startswith("mss"):
					idx = link.find(":") + 1
					page_name = gen_multipage_slideshow.get_link( item, is_dct,"first")
					#print "PAGEN->", page_name
					ahref = page_name
				else:
					print "ERROR: gen_menus: Unknown link type", asset_name, item
					sys.exit(1)	

			# determine initial css visibility, if any...
			init_vis = None
			if item.has_key("init") and item["init"]!="":
				init_vis = item["init"] 
			style, content, script, scriptlet_dct = gen_images.expand_item( accum_ids, item, images_dct, script, init_vis, ahref, exturl )

			tot_style += style
			tot_content += content
			top_scripts += script

			# accumulate on/off scriptlet...
			off_scriptlet += scriptlet_dct['off']	
			on_scriptlet += scriptlet_dct['on']	
			init_scriptlet += scriptlet_dct['init']

		elif asset_name.startswith("ss"):
			print "MENU - CALLING GEN SLIDE SHOWS EXPAND", asset_name, "cp->", click_panels_dct.keys()

			style, content, top_script, scriptlet_dct = gen_slide_shows.expand_item( accum_ids, item, images_dct, movies_dct, \
				mp_dct, click_panels_dct, slide_shows_dct, cpo_dct, embeds_dct )

			tot_style += style
			tot_content += content
			top_scripts += top_script

			# accumulate on/off scriptlet...
                        off_scriptlet += scriptlet_dct['off']
                        on_scriptlet += scriptlet_dct['on']
			init_scriptlet += scriptlet_dct['init']
			print "ss init->", init_scriptlet

                elif asset_name.startswith("mov"):
                        style, content, scr_dct = gen_movies.expand_item( accum_ids, item, images_dct, movies_dct )
                        tot_style += style
                        tot_content += content
               
			off_scriptlet += scr_dct['off']
                        on_scriptlet += scr_dct['on']
			init_scriptlet += scr_dct['init']


		elif asset_name.startswith("mp"):
			style, content, scr_dct = gen_movie_panels.expand_item( accum_ids, item, images_dct, movies_dct, mp_dct, embeds_dct )
			tot_style += style
			tot_content += content

			off_scriptlet += scr_dct['off']
			on_scriptlet += scr_dct['on']
			init_scriptlet += scr_dct['init']

		elif asset_name.startswith("embed"):
			style, content, foo, scr_dct = gen_embeds.expand_item( accum_ids, item, embeds_dct, images_dct, None, None )
			tot_style += style
			tot_content += content

			off_scriptlet += scr_dct['off']
			on_scriptlet += scr_dct['on']
			init_scriptlet += scr_dct['init']
		

		else:
			print "ERROR: gen_menus: Can't process asset->", asset_name, item
			sys.exit(1)



	scriptlet_dct = {}
	scriptlet_dct['on'] = on_scriptlet
	scriptlet_dct['off'] = off_scriptlet
	scriptlet_dct['init'] = init_scriptlet

	return [ tot_style, tot_content, top_scripts, scriptlet_dct ]
コード例 #4
0
def gen_page( accum_ids, page_name, page_def, movies_dct, images_dct, menus_dct, movie_panels_dct, click_panels_dct, slide_shows_dct, embeds_dct, cpo_dct ):
	
	print "MAIN - GEN PAGE ITEMS->", page_def, [ a["asset_name"] for a in page_def ]

	accum_body = ""
	accum_style = ""
	accum_top_script = ""
	accum_load_script = ""

	# create a master subpage div...
	#accum_body += "<div id=\"dmaster\" style=\"visibility:hidden;\" >"

	for item in page_def:

		scriptlet_dct = {}
		top_script = ""
		style = ""
		content = ""

		asset_name = item["asset_name"]

		if asset_name.startswith("mov"):

			print "MAIN - CALLING GEN MOV", asset_name, item
			style, content, scriptlet_dct = gen_movies.expand_item( accum_ids, item, images_dct, movies_dct )

		elif asset_name.startswith("img"):
			
			print "MAIN - CALLING GEN IMG", asset_name, item

                        # determine the script, if any...
                        script = None
                        ahref = None
			exturl = False
                        if item.has_key("link") and item["link"]!="":
                                link = item["link"]
                                if link.startswith("option:"):
                                        ltype,parm = link.split(":")
                                        funcname = "func_%s_%s" % (menu_name, parm)
                                        test = action_scripts[funcname]
                                        script = "%s ();" % funcname
                                elif link.startswith("url:"):
                                        idx = link.find(":") + 1
                                        ahref = link[idx:]
				elif link.startswith("nurl:"):
					idx = link.find(":") + 1
					ahref = link[idx:]
					exturl = True
                                elif link.startswith("mss"):
                                        idx = link.find(":") + 1
                                        page_name = gen_multipage_slideshow.get_link( item, is_dct,"first")
                                        print "PAGEN->", page_name
                                        ahref = page_name
                                else:
                                        print "ERROR: gen_menus: Unknown link type", asset_name, item
                                        sys.exit(1)

			style, content, top_script, scriptlet_dct = gen_images.expand_item( accum_ids, item, images_dct, script, None, \
				ahref, exturl )
 
		elif asset_name.startswith("embed"):

			print "MAIN - CALLING GEN EMBED", asset_name, item
			style, content, top_script, scriptlet_dct = gen_embeds.expand_item( accum_ids, item, embeds_dct )

		elif asset_name.startswith("menu"):

			print "MAIN - CALLING GEN MENUS EXPAND", asset_name, item
			style, content, top_script, scriptlet_dct  = gen_menus.expand_item( accum_ids, item, images_dct, menus_dct, \
				slide_shows_dct, movies_dct, movie_panels_dct, image_sets_dct, click_panels_dct, cpo_dct )
 
		elif asset_name.startswith("cp"):

			print "MAIN - CALLING GEN CLICK PANEL", asset_name, item, len(click_panels_dct.keys()), len(cpo_dct.keys())
			style, content, top_script, scriptlet_dct  = gen_click_panels.expand_item( accum_ids, item, images_dct, \
				movies_dct, movie_panels_dct, click_panels_dct, cpo_dct )

			print "CP SCRIPTLET INIT->", scriptlet_dct['init']

		elif asset_name.startswith("ss"):

			print "MAIN - CALLING GEN SS", asset_name, item
			style, content, top_script, scriptlet_dct = \
				gen_slide_shows.expand_item( accum_ids, item, images_dct, movies_dct, movie_panels_dct, \
				click_panels_dct, slide_shows_dct, cpo_dct )

			print "SS SCRIPTLET INIT->",scriptlet_dct['init']
		else:

			print "ERROR: gen_page: Unknown asset type->", asset_name
			sys.exit(1)

		accum_style += style
		accum_body += content
		accum_top_script += top_script
		accum_load_script += scriptlet_dct["init"]

        #accum_body += "</div>"

	return accum_style, accum_body, accum_top_script, accum_load_script
コード例 #5
0
def gen_page_set( multipage_def, multipage_style, multipage_content, mp_dct, movies_dct, img_dct, is_dct ):

	# find the is and the rest...
	is_def = None
	remaining_defs = []
	for page_def in multipage_def:
                if page_def['asset_name'].startswith("is"):
                        is_def = page_def
		else:
			remaining_defs.append( page_def )

	# expand the IS...
	asset_defs = gen_image_set.expand_def( is_dct, is_def )
	for asset in asset_defs:
			
		accum_ids = []

		# intialize page style and content from template...
		tot_style = multipage_style
		tot_content = multipage_content
		tot_on = ""
		tot_off = ""

		cur_page_name = asset['page_name']
	
		alldefs = remaining_defs + [ asset ]
		for page_def in alldefs:

                	# expand each asset...
                	if page_def['asset_name'].startswith("img"):
				# determine the script, if any...
                        	script = None
                        	ahref = None
				exturl = None

				print "MSS IMG DEF->", page_def
                        	if page_def.has_key("link") and page_def["link"]!="":
                                	link = page_def["link"]
					print "LINK PAGE DEF->", link, page_def.keys(), page_def['asset_name'], page_def['link']
                                	if link.startswith("option:"):
                                        	ltype,parm = link.split(":")
                                        	funcname = "func_%s_%s" % (menu_name, parm)
                                        	test = action_scripts[funcname]
                                        	script = "%s ();" % funcname
                                	elif link.startswith("url:"):
                                        	idx = link.find(":") + 1
                                        	ahref = link[idx:]
                                	elif link.startswith("nurl:"):
                                        	idx = link.find(":") + 1
                                        	ahref = link[idx:]
                                        	exturl = True
					elif link.startswith("mss"):
                                        	idx = link.find(":") + 1
						directive = link[idx:]
						ahref = get_link( page_def, is_dct, directive, cur_page_name )
						print "MS LINK->", ahref
                                	else:
                                        	print "ERROR: multipage_slide_show: Unknown link type", page_def
						sys.exit(1)

                        	style, content, foo, scriptlet_dct = gen_images.expand_item( accum_ids, page_def, img_dct, script, None, ahref, exturl )

                        	tot_style += style
                        	tot_content += content
				tot_on += scriptlet_dct["on"]
				tot_off += scriptlet_dct["off"]

			elif page_def.has_key('type') and page_def['type'] == "image_set":

				# Note, we are requiring a valid cap file...
                                if page_def.has_key('cap_file') and page_def['cap_file']!=None:
					print "WARNING: Got cap file->", page_def['cap_file']	
				else:	
					print "WARNING: No cap file->", page_def
					time.sleep(2)
					continue

				style, content, foo, scriptlet_dct = gen_image_set.expand_item( accum_ids, page_def, is_dct, None, None, None )
                        	tot_style += style
                        	tot_content += content
				tot_on += scriptlet_dct["on"]
				tot_off += scriptlet_dct["off"]

				# expand the caption too...
                                if page_def.has_key('cap_path'):
					style, content, foo, scriptlet_dct = \
						gen_image_set.expand_caption( accum_ids, page_def )
                                	tot_style += style
                                	tot_content += content
                                	tot_on += scriptlet_dct["on"]
                                	tot_off += scriptlet_dct["off"]

			else:
				print "ERROR: Cannot process this asset type->", page_def
				sys.exit(1)

		# create all the html content...
		style = "%s" % (tot_style)
		content = tot_content
		head_script = "" #subpage_head_script
		load_script  = tot_on #subpage_load_script

		# get the page name...
		page_name = asset['page_name']

		# write the file...
		common.gen_page( "%s.html" % page_name, style, content, head_script, load_script )
コード例 #6
0
ファイル: gen_movie_panels.py プロジェクト: gosha1128/Studio2
def expand_item( accum_ids, page_item, images_dct, movies_dct, movie_panels_dct, embeds_dct ):
	asset_name = page_item["asset_name"]
	item_def = movie_panels_dct[asset_name]

	tot_style = ""
	tot_content = ""
	scriptlet_dct = {}
	scriptlet_dct['on'] = ''
	scriptlet_dct['off'] = ''
	scriptlet_dct['init'] = ''

	htmlid = common.get_id( asset_name, accum_ids )
	accum_ids.append( htmlid )

	for item in item_def:

		asn = item["asset_name"]
		if asn.startswith("mov"):
			style, content, scr_dct = gen_movies.expand_item( accum_ids, item, images_dct, movies_dct )
			tot_style += style
			tot_content += content

			scriptlet_dct['on'] += scr_dct['on']
			scriptlet_dct['off'] += scr_dct['off']
			scriptlet_dct['init'] += scr_dct['init']
		
		elif asn.startswith("img"):
			# determine the script, if any...
                        script = None
                        ahref = None
			exturl = None
                        if item.has_key("link") and item["link"]!="":
                                link = item["link"]
                                if link.startswith("option:"):
                                        ltype,parm = link.split(":")
                                        funcname = "func_%s_%s" % (menu_name, parm)
                                        test = action_scripts[funcname]
                                        script = "%s ();" % funcname
                                elif link.startswith("url:"):
                                        idx = link.find(":") + 1
                                        ahref = link[idx:]
                                        print "MENUS AHREF->", ahref
                               	elif link.startswith("nurl:"):
                                        idx = link.find(":") + 1
                                        ahref = link[idx:]
                                        exturl = True
                                else:
                                        print "ERROR: gen_movie_panels: Unknown link type", asset_name, item
                                        sys.exit(1)    

			style, content, foo, scr_dct = gen_images.expand_item( accum_ids, item, images_dct, script, None, ahref, exturl )
			tot_style += style
			tot_content += content
	
			scriptlet_dct['on'] += scr_dct['on']
			scriptlet_dct['off'] += scr_dct['off']
			scriptlet_dct['init'] += scr_dct['init']

		elif asn.startswith("embed"):
			
			style, content, foo, scr_dct = gen_embeds.expand_item( accum_ids, item, embeds_dct, images_dct, None, None)
			tot_style += style
			tot_content += content
	
			scriptlet_dct['on'] += scr_dct['on']
			scriptlet_dct['off'] += scr_dct['off']
			scriptlet_dct['init'] += scr_dct['init']


		else:
			print "ERROR: gen_movie_panels: Cannot process->", item
			sys.exit(1)			


	
	return [ tot_style, tot_content, scriptlet_dct ]