photogallery plugin patch

Ryan Barrett <pyblosxom-6sb6M7qyT/[email protected]>
Newsgroups gmane.comp.web.pyblosxom.devel
Message-ID <[email protected]>
hi magnus, pyblosxom-devel. (pyblosxom-devel, are you sick of me yet? :P)

magnus, i've attached a patch for your wonderful photogallery pyblosxom
plugin. the big change is that galleries can now have text headers and
footers. the plugin pulls head.txt and/or foot.txt from the gallery directory
(depending on whether they exist), runs the standard entry parser and
preformatter on them, and displays them before and after the thumbnails.

you can see this in action here:

http://snarfed.org/gallery/Vegas+2006

the patch also adds config.py options for the number of columns and whether or
not to display captions.

-Ryan

p.s. this is the last patch from me for this week...erm, probably. :P

--
http://snarfed.org/

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________
Pyblosxom-devel mailing list
Pyblosxom-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/pyblosxom-devel
photogallery_header_and_footer.patch (text/plain, 5 KB)
*** photogallery/photogallery.py	Wed Apr 28 08:43:57 2004
--- pyblosxom/plugins/photogallery.py	Wed Aug 23 04:16:22 2006
***************
*** 1,3 ****
--- 1,4 ----
+ # -*- mode: python; indent-tabs-mode: t, tab-width: 8 -*-
  """
  This plugin kicks up a photo gallery when accessed with the set trigger.
  
***************
*** 48,54 ****
      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  """
  import os, string
! from Pyblosxom import tools, entries
  
  __author__ = "Magnus Nordlander magnus (at) nordlander (dot) tk"
  __version__ = "0.3 (27 April, 2004)"
--- 49,55 ----
      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  """
  import os, string
! from Pyblosxom import tools, entries, pyblosxom
  
  __author__ = "Magnus Nordlander magnus (at) nordlander (dot) tk"
  __version__ = "0.3 (27 April, 2004)"
***************
*** 83,88 ****
--- 84,91 ----
  
      baseurl = config['base_url']
      trigger = config['gallerytrigger']
+     captions = config.get('gallerycaptions', True)
+     columns = config.get('gallerycolumns', 4)
      imagepath = config['imagedata'] + trigger
      gallery = pyhttp["PATH_INFO"][len(trigger) + 1:]
  
***************
*** 97,103 ****
  	nicelist = []
  	#Generate list of galleries
  	for x in dirlist:
! 	    nicelist.append("<a href=\"" + baseurl + trigger + "/" + x + "\">" + x + "</a><br>")
  	contents = string.join(nicelist)
  	#Generate entry and return it
  	absolute_path = ""
--- 100,106 ----
  	nicelist = []
  	#Generate list of galleries
  	for x in dirlist:
! 	    nicelist.append("<a href=\"" + baseurl + trigger + "/" + x + "\">" + x + "</a><br />")
  	contents = string.join(nicelist)
  	#Generate entry and return it
  	absolute_path = ""
***************
*** 107,113 ****
  	return [fe]	
      elif string.find(gallery, "/") == -1:
  	#find out what images we have
!     	abspath = imagepath + "/" + gallery + "/thumbs"
  	list = os.listdir(abspath)
  	i = str(len(list))
  	#generate table with thumbnails and 
--- 110,118 ----
  	return [fe]	
      elif string.find(gallery, "/") == -1:
  	#find out what images we have
! 	abspath = imagepath + "/" + gallery + "/thumbs"
! 	if not os.path.isdir(abspath):
! 	    return
  	list = os.listdir(abspath)
  	i = str(len(list))
  	#generate table with thumbnails and 
***************
*** 116,124 ****
  	j = 1
  	stringlist.append("<tr>")
  	for x in list:
! 	    stringlist.append("<td><a href=\"" + baseurl + trigger + "/" + gallery + "/" + x + "\"><img src=\"" + baseurl + "/images/" + trigger + "/" + gallery + "/thumbs/" + x + "\" alt=\"" + x + "\" /></a><br />" + x + "</td>")
  	    j = 1 + j
! 	    if j % 4 == 1:
  		stringlist.append("</tr>")
  		stringlist.append("<tr>")
  	stringlist.append("</tr></table>")
--- 121,132 ----
  	j = 1
  	stringlist.append("<tr>")
  	for x in list:
! 	    stringlist.append("<td><a href=\"" + baseurl + trigger + "/" + gallery + "/" + x + "\"><img src=\"" + baseurl + trigger + "/" + gallery + "/thumbs/" + x + "\" alt=\"" + x + "\" /></a><br />")
! 	    if captions:
! 		stringlist.append(x)
! 	    stringlist.append("</td>")
  	    j = 1 + j
! 	    if j % columns == 1:
  		stringlist.append("</tr>")
  		stringlist.append("<tr>")
  	stringlist.append("</tr></table>")
***************
*** 126,140 ****
  	absolute_path = trigger[1:]
  	fn = gallery
  	file_path = absolute_path + "/" + fn
! 	#generate entry and return it	
! 	fe = entries.base.generate_entry(request, {"title": gallery + " gallery", "absolute_path": absolute_path, "file_path": file_path, "fn": fn }, contents, None)
  	return [fe]
  
      else:
  	l = string.find(gallery, "/")
  	image = gallery[l+1:]
  	#generate entry and return it
! 	contents = "<br /><img src=\"" + baseurl +"/images/" + trigger + "/" + gallery + "\" alt=\"" + image + "\" /><br />"
  	i = string.find(gallery, "/") 
  	absolute_path = trigger[1:] + "/" + gallery[:i]
  	fn = image
--- 134,162 ----
  	absolute_path = trigger[1:]
  	fn = gallery
  	file_path = absolute_path + "/" + fn
! 	#generate entry and return it
! 	data = {"title": gallery, "absolute_path": absolute_path,
! 		"file_path": file_path, "fn": fn}
! 
! 	# parse the header and footer
! 	for filename in ['foot.txt', 'head.txt']:
! 	    path = os.path.join(config['datadir'], file_path, filename)
! 	    if os.path.isfile(path):
! 		data.update(pyblosxom.blosxom_entry_parser(path, request))
! 		data[filename] = data['body']
! 	    else:
! 		data[filename] = ''
! 
! 	contents = '\n\n'.join([data['head.txt'], contents, data['foot.txt']])
! 
! 	fe = entries.base.generate_entry(request, data, contents, None)
  	return [fe]
  
      else:
  	l = string.find(gallery, "/")
  	image = gallery[l+1:]
  	#generate entry and return it
! 	contents = "<br /><img src=\"" + baseurl + trigger + "/" + gallery + "\" alt=\"" + image + "\" /><br />"
  	i = string.find(gallery, "/") 
  	absolute_path = trigger[1:] + "/" + gallery[:i]
  	fn = image
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.