News

October 2009 : a new release (bibus 1.5.0)

  • OOo3.1 compatibility
  • Infinite number of file/http links
  • Clever capitalization (lord of war => Lord of War ...)
  • Better handling of journal abbreviations
  • Import/Export filters can be added easily (plugin)
  • journal abbreviations and shortcuts can be easily edited (simple csv file that can be edited in OOo/excel or a text editor)
  • Lot of bug fixes
  • Requires python2.5 (not a problem anymore under Windows since OOo3.1 includes 2.6)
  • Requires wxpython-2.8

Create a html formated reference list

From Bibus

Jump to: navigation, search

darbas Here's a python script that creates a reference list in html format. I use it to generate a list for our groups homepage. The script queries the db for refs which have a key named 'MyGroupsPapers'. The refs are listed in blocks for each year. The 'custom1' field is used for a DOI type url to the document. If the custom1 DOI url exists, it is used to link the document title to the document. The script creates a html file named 'index_en.html'. Maybe this script helps to get started on similar projects. The present script is for MySQL, but it shouldnt be hard to change it to work with SQLite.


# -*- coding: utf-8 -*-
import sys,os
import MySQLdb


bibusdb = "bibus41"
mysqlhost = "myhost"
mysqluser = "root"
mysqlpasswd = "mypw"

years = ['2006','2005','2004','2003','2002','2001','2000','1999','1998']



htmlstart = """
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>Publications (Our Department)</TITLE>
<meta name="keywords" content="solar cell,III-V,multijunction,femtosecond,RAS,DSSC">
</HEAD>
<BODY BGCOLOR="#ffffff" TEXT="#000000" LINK="#000080" VLINK="#000080" ALINK="#cc0000">
"""


htmlend = """
</td></tr> </table>
</BODY>
</HTML>
"""

refhtml =''


print "connecting to MySQL db..."
try:
	conn1 = MySQLdb.connect(host = mysqlhost,user =mysqluser,passwd = mysqlpasswd,db = bibusdb,use_unicode=True)
except MySQLdb.Error, e:
       print "Error %d: %s" % (e.args[0], e.args[1])
       sys.exit (1)			
       
c1 = conn1.cursor()
c1.execute ("USE " + bibusdb)



refhtml =""

for year in years:
	refhtml +="""
<table width="650" border="0" cellspacing="0" cellpadding="0">
"""
	refhtml += "<tr><th><b>Publications in %s</b></th><td><br><br></td></tr>\n" % (year)
	query = """
	SELECT b.author,b.title,b.journal,b.year,b.volume,b.number,b.pages,b.custom1,b.BibliographicType,b.school,b.booktitle,b.editor,b.publisher,b.isbn 
	from bibref b,bibreflink blk,bibrefkey bk 
	where b.id=blk.ref_id  AND bk.key_name='MyGroupsPapers' AND blk.key_id=bk.key_id
	"""
	query +=" AND b.year=" + year	
	c1.execute(query)
	res = c1.fetchall()

	for r in res :
		ref = u''	
		if r[8] == 11 : #PHD Thesis
			#format authors:
			ref += '<font color="#000099">'
			ref += r[0].replace(',',' ')
			ref += '</font><br>'		
			#title:
			if r[7].find('http')>=0: #print title as url if available				
				ref += "<A HREF=\"%s\">\"%s\"</a>" % (r[7],r[1]+ '.')
			else:
				ref += r[1] + '.'
			ref += '<br>'		
			#year:
			ref += ' (' + r[3] + '), '
			#school:
			ref +=  r[9] + ', PHD-thesis'
			#add row:
			refhtml += '<tr><td>' + ref.encode('iso-8859-1', 'replace') + '<br></td></tr><tr><td> <br></td></tr>\n' 
		elif r[8] == 12 or r[8] == 4  : #conference proc, inbook etc
			#format authors:
			ref += '<font color="#000099">'
			ref += r[0].replace(',',' ')
			ref += '</font><br>'		
			#title:
			if r[7].find('http')>=0: #print title as url if available				
				ref += "<A HREF=\"%s\">\"%s\"</a>" % (r[7],r[1]+ '.')
			else:
				ref += r[1] + '.'
			ref += '<br>'		
			#booktitle:
			ref += 'in:' + r[10]
			#publisher:
			ref += ', ' + r[12]
			#year:
			ref += ' (' + r[3] + ')'
			#pages:
			ref += ' p.' + r[6]
			if len(r[13]) > 1: #isbn
				ref += ' (ISBN:' + r[13] + ')'
			#add row:
			refhtml += '<tr><td>' + ref.encode('iso-8859-1', 'replace') + '</td></tr><tr><td> <br></td></tr>\n' 
		else : #journal and unkwown:
			#format authors:
			ref += '<font color="#000099">'
			ref += r[0].replace(',',' ')
			ref += '</font><br>'		
			#title:
			if r[7].find('http')>=0: #print title as url if available				
				ref += "<A HREF=\"%s\">\"%s\"</a>" % (r[7],r[1]+ '.')
			else:
				ref += r[1] + '.'
			ref += '<br>'		
			#journal:
			ref += ' ' + r[2]
			#volume:
			ref += ' ' + r[4]
			#year:
			ref += ' (' + r[3] + ')'
			#pages:
			ref += ' p.' + r[6]
			#add row:
			refhtml += '<tr><td>' + ref.encode('iso-8859-1', 'replace') + '</td></tr><tr><td> <br></td></tr>\n' 
		
		
	refhtml +="""
<tr> <br><br></tr>	

</table>
"""


refhtml = htmlstart + refhtml + htmlend

print refhtml

f = open('index_en.html','w')
f.write(refhtml)
f.close()
	



#close connection:
c1.close()
conn1.close()

Personal tools