Beispiel #1
0
def get_link( item, is_dct, directive, page_name=None):
	global mpgs_dct

	print "GET LINK->", item, is_dct.keys()

	if mpgs_dct == None:
        	mpgs_dct = get_dct()
	print "MPGS DCT->", mpgs_dct.keys()
		
	link_name = item['link'].split(":")[0]
	print "LINK->",  link_name, mpgs_dct.keys()

	multipage_def = mpgs_dct[link_name]

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

        # expand the IS...
        asset_defs = gen_image_set.expand_def( is_dct, is_def )

	pages = [  asset['page_name'] for asset in asset_defs ]
	pages.sort()

	if directive == "first":
		return pages[0] + ".html"
	elif directive == "previous":
		print "ITEM->", item.keys(), page_name
		idx = pages.index( page_name ) -1
		if idx<0: idx = len(pages)-1
		return pages[idx] + ".html"
	elif directive == "next":
		print "ITEM->", item.keys(), page_name
		idx = pages.index( page_name ) + 1
		if idx>=len(pages): idx = 0
		return pages[idx] + ".html"
	else:
		print "ERROR: invalid directive->", directive
		sys.exit(1)
Beispiel #2
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 )