def expand_item( asset_def, images_dct, option_script=None ): asset_name = asset_def["asset_name"] item_def = images_dct[asset_name][0] htmlid = asset_name image_path = get_item_path( asset_name, images_dct ) x = asset_def['x'] y = asset_def['y'] style = common.emit_line( "<style>" ) style += common.emit_line( "#%s {" % htmlid ) style += common.emit_line( "position: absolute;") style += common.emit_line( "left: %dpx;" % int(x) ) style += common.emit_line( "top: %dpx;" % int(y) ) style += common.emit_line( "}" ) style += common.emit_line( "</style>") on_click = False link = asset_def["link"] if link!="": ltype,parm = link.split(":") if ltype=="option": on_click = option_script[parm] if on_click: content = common.emit_line( "<img id=\"%s\" src=\"%s\" onclick=\"%s\" >" % (htmlid,image_path, on_click) ) else: content = common.emit_line( "<img id=\"%s\" src=\"%s\" >" % (htmlid,image_path ) ) return [ style, content ]
def expand_caption( accum_ids, asset_def ): print "IMAGE SET EXPAND CAPTION", asset_def # get the asset definition... asset_name = asset_def["asset_name"] + "_cap" item_def = asset_def # get id... htmlid = common.get_id(asset_name,accum_ids) accum_ids.append( htmlid ) # get cap path... cap_path = asset_def['cap_path'] capfile = asset_def['cap_file'] print "caps->", cap_path, capfile capsrc = os.path.join( cap_path, capfile ) capsrc = common.path_replace(capsrc) # compute the coord... centerx = 1067 centery = 371 capw = asset_def['cap_width'] caph = asset_def['cap_height'] x = centerx - (int)(capw*1.0/2) y = centery - (int)(caph*1.0/2) # get z... z = 3 # style... style = "" style += common.emit_line( "#%s {" % htmlid ) style += common.emit_line( "position: absolute;") style += common.emit_line( "left: %dpx;" % int(x) ) style += common.emit_line( "top: %dpx;" % int(y) ) style += common.emit_line( "z-index: %d;" % int(z) ) style += common.emit_line( "}" ) # content... content = "" content += common.emit_line( "<img id=%s src=\"%s\" alt=\"TheStudio\" >" % (htmlid, capsrc) ) scriptlet_dct = {} scriptlet_dct['on'] = "document.getElementById('%s').style.visibility = '%s';" % (htmlid, 'visible' ) scriptlet_dct['off'] = "document.getElementById('%s').style.visibility = '%s';" % (htmlid, 'hidden' ) scriptlet_dct['init'] = "document.getElementById('%s').style.visibility = '%s';" % (htmlid, 'visible' ) return [ style, content, "", scriptlet_dct ]
def expand_item( accum_ids, asset_def, embeds_dct ): # get the asset definition... asset_name = asset_def["asset_name"] print "ed->", embeds_dct item_def = embeds_dct[asset_name][0] # get id... htmlid = common.get_id(asset_name,accum_ids) accum_ids.append( htmlid ) # get basic properties... codeval = item_def['code'] if codeval.startswith("file"): idx = codeval.find(":") + 1 filename = codeval[idx:] path = os.path.join(EMBEDS_DIR, filename) f = open(path,'r') code = f.read() f.close() # insert id... print "CODEVAL-->%s<--" % code, code.startswith("<div ") if ( code.startswith("<div ") ): code = code[0:5] + " id=%s " % htmlid + code[5:] print "REPLACE 1!!", code else: print "ERROR: Invalid code value" sys.exit(1) x = get_attr( 'x', asset_name, asset_def, embeds_dct ) y = get_attr( 'y', asset_name, asset_def, embeds_dct ) z = get_attr( 'z', asset_name, asset_def, embeds_dct,'0') # style... style = "" style += common.emit_line( "#%s {" % htmlid ) style += common.emit_line( "position: absolute;") style += common.emit_line( "left: %dpx;" % int(x) ) style += common.emit_line( "top: %dpx;" % int(y) ) style += common.emit_line( "z-index: %d;" % int(z) ) # content... content = common.emit_line( code ) scriptlet_dct = {} scriptlet_dct['on'] = "document.getElementById('%s').style.visibility = '%s';" % (htmlid, 'visible' ) scriptlet_dct['off'] = "document.getElementById('%s').style.visibility = '%s';" % (htmlid, 'hidden' ) scriptlet_dct['init'] = "document.getElementById('%s').style.visibility = '%s';" % (htmlid, 'visible' ) return [ style, content, "", scriptlet_dct ]
def cpo_expand_caption_item( accum_ids, parent, asset_def, cp_dct, cpo_dct, images_dct, init_item, action_scripts ): print "CPO EXPAND CAPTION->", asset_def, cpo_dct.keys() typ = asset_def["type"] x = int(asset_def['x']) y = int(asset_def['y']) z = int(asset_def['z']) name = asset_def['asset_name'] hid = common.get_id( name, accum_ids ) # get the individual images and create ids... img_init_asset = images_dct[init_item][0] path = img_init_asset['path'] fname = img_init_asset['filename'] src = os.path.join(path,fname) src = common.path_replace( src ) src = common.create_path( src ) print "init src->", src # style... style = "" style += common.emit_line("#%s {" % hid ) style += common.emit_line(" position: absolute;") style += common.emit_line(" top: %dpx;" % y ) style += common.emit_line(" left: %dpx;" % x ) style += common.emit_line(" z-index: %d;" % (z+1) ) style += common.emit_line(" border:none;" ) style += common.emit_line(" visibility: hidden;" ) style += common.emit_line("}") # content... content = "<img id=\"%s\" src=\"%s\" alt=\"TheStudio\" />\n" % (hid, src) # scriptlet dct... scriptlet_dct = {} scriptlet_dct['on'] = "document.getElementById('%s').style.visibility='visible';" % hid scriptlet_dct['off'] = "document.getElementById('%s').style.visibility='hidden';" % hid scriptlet_dct['init'] = "document.getElementById('%s').style.visibility='visible';" % hid return [ style, content, scriptlet_dct ]
def cpo_expand_preview_item(accum_ids, parent, asset_def, cp_dct, cpo_dct, images_dct, init_item, action_scripts): print "CPO EXPAND PREVIEW->", asset_def, cpo_dct.keys() typ = asset_def["type"] x = int(asset_def["x"]) y = int(asset_def["y"]) z = int(asset_def["z"]) name = asset_def["asset_name"] hid = common.get_id(name, accum_ids) # get the individual images and create ids... img_init_asset = images_dct[init_item][0] path = img_init_asset["path"] fname = img_init_asset["filename"] src = os.path.join(path, fname) src = common.path_replace(src) src = common.create_path(src) # style... style = "" style += common.emit_line("#%s {" % hid) style += common.emit_line(" position: absolute;") style += common.emit_line(" top: %dpx;" % y) style += common.emit_line(" left: %dpx;" % x) style += common.emit_line(" z-index: %d;" % (z + 1)) style += common.emit_line(" border:none;") style += common.emit_line(" visibility: hidden;") style += common.emit_line("}") # content... content = '<img id="%s" src="%s" alt="TheStudio" />\n' % (hid, src) # scriptlet dct... scriptlet_dct = {} scriptlet_dct["on"] = "document.getElementById('%s').style.visibility='visible';" % hid scriptlet_dct["off"] = "document.getElementById('%s').style.visibility='hidden';" % hid scriptlet_dct["init"] = "document.getElementById('%s').style.visibility='visible';" % hid return [style, content, scriptlet_dct]
def expand_item( accum_ids, asset_def, images_dct, movies_dct ): print "mov->", movies_dct.keys() # get the movie asset name... asset_name = asset_def["asset_name"] # get the base def of the item... item_def = movies_dct[asset_name][0] # get type... typ = "file" if item_def.has_key("type"): typ = item_def["type"] # if video type, branch here... if typ == "vimeo": return expand_vimeo_item( accum_ids, asset_def, images_dct, movies_dct ) elif typ == "brightcove": return expand_brightcove_item( accum_ids, asset_def, images_dct, movies_dct ) # get the alt movie asset name, if any... alt_name = "" if asset_def.has_key("alt"): alt_name = asset_def["alt"] # get an html id for video element... htmlid = common.get_id( asset_name, accum_ids ) accum_ids.append(htmlid) # get the poster path, if any... poster_path = "" if item_def["poster"].strip()!="": poster = item_def["poster"].strip() poster_path = gen_images.get_item_path( poster, images_dct ) poster_path = common.create_path( poster_path ) # get the alternate movie path src, if any... alt_path = "" if alt_name != "": alt_path = get_item_path( alt_name, movies_dct ) alt_path = common.create_path( alt_path ) # finally, get the primary movie path src... movie_path = get_item_path( asset_name, movies_dct ) movie_path = common.create_path( movie_path ) # get coords for def... x = asset_def['x'] y = asset_def['y'] z = asset_def['z'] # create the style... style = "" style += common.emit_line( "#%s {" % htmlid ) style += common.emit_line( "position: absolute;") style += common.emit_line( "left: %dpx;" % int(x) ) style += common.emit_line( "top: %dpx;" % int(y) ) style += common.emit_line( "z-index: %d;" % int(z) ) style += common.emit_line( "visibility: hidden;" ) style += common.emit_line( "}" ) if poster_path == "": content = common.emit_line( "<video controls id=%s ><source src=\"%s\" />CANNOT LOAD</video>" % (htmlid, movie_path) ) else: if alt_path != "": content = common.emit_line( "<video controls id=%s poster=\"%s\" >" % ( htmlid, poster_path ) ) content += common.emit_line( "<source src=\"%s\" />" % movie_path ) content += common.emit_line( "<source src=\"%s\" />" % alt_path ) content += common.emit_line( "</video>" ) else: content = common.emit_line( "<video controls id=%s poster=\"%s\" ><source src=\"%s\" /></video>" % (htmlid, poster_path, movie_path) ) scriptlet_dct = {} scriptlet_dct['on'] = "document.getElementById('%s').style.visibility='visible';" % htmlid scriptlet_dct['off'] = "document.getElementById('%s').style.visibility='hidden';" % htmlid scriptlet_dct['init'] = "document.getElementById('%s').style.visibility='visible';" % htmlid return [ style, content, scriptlet_dct ]
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 ]
def cpo_expand_option_item( accum_ids, parent, asset_def, cpo_dct, images_dct, init_option, action_scripts ): print "CPO EXPAND->", asset_def, cpo_dct.keys() typ = asset_def["type"] x = int(asset_def['x']) y = int(asset_def['y']) z = int(asset_def['z']) name = asset_def['asset_name'] hid = common.get_id( name, accum_ids ) # get the option asset... cpo_asset = cpo_dct[ name ][0] # get the individual images and create ids... img_desel = cpo_asset['deselected'] desel_id = "%s_desel" % hid img_sel = cpo_asset['selected'] sel_id = "%s_sel" % hid img_preview = cpo_asset['preview'] # desel style... style = "" style += common.emit_line("#%s {" % desel_id ) style += common.emit_line(" position: absolute;") style += common.emit_line(" top: %dpx;" % y ) style += common.emit_line(" left: %dpx;" % x ) style += common.emit_line(" z-index: %d;" % (z+1) ) style += common.emit_line(" border:none;" ) style += common.emit_line(" visibility: hidden;" ) style += common.emit_line("}") # sel style... style += common.emit_line("#%s {" % sel_id ) style += common.emit_line(" position: absolute;") style += common.emit_line(" top: %dpx;" % y ) style += common.emit_line(" left: %dpx;" % x ) style += common.emit_line(" z-index: %d;" % z ) style += common.emit_line(" border:none;" ) style += common.emit_line(" visibility: hidden;" ) style += common.emit_line("}") # create scriptlet dcts... master_scr_dct = [] scriptlet_dct = {} scriptlet_dct['on'] = "document.getElementById('%s').style.visibility='visible';" % desel_id scriptlet_dct['off'] = "document.getElementById('%s').style.visibility='hidden';" % desel_id scriptlet_dct['init'] = "document.getElementById('%s').style.visibility='visible';" % desel_id master_scr_dct.append( scriptlet_dct ) scriptlet_dct = {} scriptlet_dct['on'] = "document.getElementById('%s').style.visibility='visible';" % sel_id scriptlet_dct['off'] = "document.getElementById('%s').style.visibility='hidden';" % sel_id scriptlet_dct['init'] = "document.getElementById('%s').style.visibility='visible';" % sel_id master_scr_dct.append( scriptlet_dct ) # create the content... content = "" # desel... img_desel_asset = images_dct[img_desel][0] path = img_desel_asset['path'] fname = img_desel_asset['filename'] src = os.path.join(path,fname) src = common.path_replace( src ) content += "<a href=\"#\" >\n" #content += "<img id=\"%s\" src=\"%s\" alt=\"TheStudio\" onclick=\"%s;\" onmouseover=\"%s;\" onmouseout=\"%s;\" />\n" % \ #(desel_id, src, "%s_click()" % desel_id, "%s_mouseover()" % desel_id, "%s_mouseout()" % desel_id ) content += "<img id=\"%s\" src=\"%s\" alt=\"TheStudio\" onclick=\"%s;\" />\n" % \ (desel_id, src, "%s_click()" % desel_id ) content += "</a>\n" # sel... img_sel_asset = images_dct[img_sel][0] path = img_sel_asset['path'] fname = img_sel_asset['filename'] src = os.path.join(path,fname) src = common.path_replace( src ) content += "<a href=\"#\" >\n" #content += "<img id=\"%s\" src=\"%s\" alt=\"TheStudio\" onclick=\"%s;\" onmouseover=\"%s;\" onmouseout=\"%s;\" />\n" % \ #(sel_id, src, "%s_click()" % sel_id, "%s_mouseover()" % sel_id, "%s_mouseout()" % sel_id ) content += "<img id=\"%s\" src=\"%s\" alt=\"TheStudio\" onclick=\"%s;\" />\n" % \ (sel_id, src, "%s_click()" % sel_id ) content += "</a>\n" return [ style, content, master_scr_dct ]
def expand_item( accum_ids, asset_def, images_dct, onclick=None, init_vis=None, ahref=None, exturl=False ): print "IMAGE EXPAND" # get the asset definition... asset_name = asset_def["asset_name"] item_def = images_dct[asset_name][0] # get id... htmlid = common.get_id(asset_name,accum_ids) accum_ids.append( htmlid ) # get basic properties... image_path = get_item_path( asset_name, images_dct ) x = get_attr( 'x', asset_name, asset_def, images_dct ) y = get_attr( 'y', asset_name, asset_def, images_dct ) z = get_attr( 'z', asset_name, asset_def, images_dct,'0') # init vis param override... #init = get_attr( 'init', asset_name, asset_def, images_dct ) #if init and not init_vis: #init_vis = init # mouseover... mouseover = get_attr( 'mouseover', asset_name, asset_def, images_dct ) onmouseover = "" if mouseover: onmouseover = mouse_script_item( htmlid, mouseover, images_dct ) # mouseout... mouseout = get_attr( 'mouseout', asset_name, asset_def, images_dct ) onmouseout = "" if mouseout: onmouseout = mouse_script_item( htmlid, mouseout, images_dct ) # onclick param override... click = get_attr('click', asset_name, asset_def, images_dct, '') if click!='' and onclick==None: onclick = click_script_items( click ) #parts = click.split(":") #onclick = click_script_item(parts[0], parts[1], parts[2], images_dct ) # style... style = "" style += common.emit_line( "#%s {" % htmlid ) style += common.emit_line( "position: absolute;") style += common.emit_line( "left: %dpx;" % int(x) ) style += common.emit_line( "top: %dpx;" % int(y) ) style += common.emit_line( "z-index: %d;" % int(z) ) style += common.emit_line( "border:none; " ) style += common.emit_line( "visibility: hidden;") #if init_vis!=None: #if init_vis: #style += common.emit_line( "visibility: %s;" % init_vis ) #else: #style += common.emit_line( "visibility: %s;" % init_vis ) style += common.emit_line( "}" ) # content... content = "" # a href... if ahref: if exturl: content += common.emit_line("<a href=%s target=\"_blank\" >\n" % ahref ) else: content += common.emit_line("<a href=%s >\n" % ahref ) else: content += common.emit_line("<a href=# >\n" ) # onclick script... if onclick: content += common.emit_line( "<img id=\"%s\" src=\"%s\" onclick=\"%s\" onmouseover=\"%s\" onmouseout=\"%s\" alt=\"TheStudio\" >" % \ (htmlid,image_path, onclick, onmouseover, onmouseout) ) else: content += common.emit_line( "<img id=\"%s\" src=\"%s\" onmouseover=\"%s\" onmouseout=\"%s\" alt=\"TheStudio\" >" % \ (htmlid,image_path, onmouseover, onmouseout ) ) # end a href... if ahref: content += common.emit_line("</a>\n" ) else: content += common.emit_line("</a>\n" ) if ( asset_name.find("caption_big") > 0 ): print "content->", content print "style->", style scriptlet_dct = {} scriptlet_dct['on'] = "document.getElementById('%s').style.visibility = '%s';" % (htmlid, 'visible' ) scriptlet_dct['off'] = "document.getElementById('%s').style.visibility = '%s';" % (htmlid, 'hidden' ) #if init_vis!=None: #scriptlet_dct['init'] = "document.getElementById('%s').style.visibility = '%s';" % (htmlid, init_vis) #else: scriptlet_dct['init'] = "document.getElementById('%s').style.visibility = 'visible';" % (htmlid) return [ style, content, "", scriptlet_dct ]