Ejemplo n.º 1
0
def gen_page_set( multipage_def, multipage_style, multipage_content, mp_dct, movies_dct, img_dct, embeds_dct ):

	# iterate over pages...
	for page_def in multipage_def:

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

		# expand each asset...
		if page_def['asset_name'].startswith("mp"):
			style, content, scriptlet_dct = gen_movie_panels.expand_item( accum_ids, page_def, img_dct, movies_dct, mp_dct, embeds_dct )

			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

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

                # write the file...
                common.gen_page( "%s.html" % page_name, style, "", content, head_script, load_script )
Ejemplo n.º 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 ]
Ejemplo n.º 3
0
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 ]