diff pics2/pics_app.py @ 56:0249782e231e

pics2: add np_keys and selected thumbnail anchoring
author paulo
date Tue, 10 Sep 2013 01:04:24 -0700
parents 496714f2fd8c
children b7966ae653f2
line diff
     1.1 --- a/pics2/pics_app.py	Thu Aug 22 23:53:56 2013 -0700
     1.2 +++ b/pics2/pics_app.py	Tue Sep 10 01:04:24 2013 -0700
     1.3 @@ -79,16 +79,12 @@
     1.4  		return (root, header, body)
     1.5  	
     1.6  	
     1.7 -	def _go_thumbnail_links_to_browse_imgs_html_body(self, body, t, b, selclass=None):
     1.8 +	def _go_thumbnail_links_to_browse_imgs_html_body(self, body, t, b, a_args={}, img_args={}):
     1.9  		thumb_img_url = self._get_pics_url(t)
    1.10  		browse_url = self._get_app_url(b)
    1.11  
    1.12 -		a = body.a(href=browse_url)
    1.13 -
    1.14 -		if selclass is not None:
    1.15 -			a.img(src=thumb_img_url, klass=selclass)
    1.16 -		else:
    1.17 -			a.img(src=thumb_img_url)
    1.18 +		a = body.a(href=browse_url, **a_args)
    1.19 +		a.img(src=thumb_img_url, **img_args)
    1.20  
    1.21  		body.text(' ')
    1.22  	
    1.23 @@ -167,7 +163,7 @@
    1.24  		html_p = html_body.p
    1.25  		for (t, b) in _get_images(d):
    1.26  			if from_img is not None and b == from_img:
    1.27 -				self._go_thumbnail_links_to_browse_imgs_html_body(html_p, t, b, "sel2")
    1.28 +				self._go_thumbnail_links_to_browse_imgs_html_body(html_p, t, b, img_args={"klass":"sel2", "id":"selected"})
    1.29  			else:
    1.30  				self._go_thumbnail_links_to_browse_imgs_html_body(html_p, t, b)
    1.31  	
    1.32 @@ -201,6 +197,8 @@
    1.33  			raise AssertionError
    1.34  	
    1.35  		(html_root, html_header, html_body) = self._get_standard_html_doc(u"%s \u2014 %s of %s" % (d, x, len(imgs)))
    1.36 +
    1.37 +		html_header.script('', type="text/javascript", src=self._get_pics_url("np_keys.js"))
    1.38  	
    1.39  		browse_img_url = self._get_pics_url(img)
    1.40  		html_body.p.img(src=browse_img_url)
    1.41 @@ -208,13 +206,21 @@
    1.42  		logging.debug("imgs_circ = %s" % imgs_circ)
    1.43  	
    1.44  		html_p = html_body.p
    1.45 -		for i in imgs_circ:
    1.46 -			if i is not None:
    1.47 -				(t, b) = i
    1.48 +		for (i, img_c) in enumerate(imgs_circ):
    1.49 +			if img_c is not None:
    1.50 +				(t, b) = img_c
    1.51 +				a_args = {}
    1.52 +				img_args = {}
    1.53  				if b == img:
    1.54 -					self._go_thumbnail_links_to_browse_imgs_html_body(html_p, t, d + "?from=" + img, "sel")
    1.55 -				else:
    1.56 -					self._go_thumbnail_links_to_browse_imgs_html_body(html_p, t, b)
    1.57 +					a_args = {"id": "up"}
    1.58 +					img_args = {"klass": "sel"}
    1.59 +					b = "%s?from=%s#selected" % (d, img)
    1.60 +				elif i == v + 1:
    1.61 +					a_args = {"id": "next"}
    1.62 +				elif i == v - 1:
    1.63 +					a_args = {"id": "prev"}
    1.64 +
    1.65 +				self._go_thumbnail_links_to_browse_imgs_html_body(html_p, t, b, a_args, img_args)
    1.66  	
    1.67  		return html_root
    1.68