Modify

Opened 13 years ago

Closed 12 years ago

#7721 closed enhancement (fixed)

List entire bibliography

Reported by: pauld.mccarthy@… Owned by: Roman Mohr
Priority: normal Component: TracBibPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description

A new macro: [[BibList]], which renders the entire contents of a bibtex file.

  • tracbib/tracbib.py

     
    298298    tags.append(ol)
    299299
    300300    return tag.div(id='References')(*tags)
     301 
     302class BibListMacro(WikiMacroBase):
     303  implements(IWikiMacroProvider)
     304
     305  def render_macro(self, request,name,content):
     306    return self.expand_macro(request,name,content)
     307
     308  def expand_macro(self,formatter,name,content):
     309
     310    bibdb = getattr(formatter, BIBDB,{})
     311
     312    page = WikiPage(self.env,'BibTex')
     313    if page.exists:
     314      if '{{{' in page.text and '}}}' in page.text:
     315        tmp = re.compile('{{{|}}}',2).split(page.text)
     316        bibdb.update(extract_entries(tmp[1]))
     317        setattr(formatter,BIBDB,bibdb)
     318
     319    l = []
     320    for k in bibdb:
     321      print k
     322      content = ''
     323      for bibkey in BIBTEX_KEYS:
     324        if bibdb[k].has_key(bibkey):
     325          content +=bibdb[k][bibkey] + ', '
     326      if bibdb[k].has_key('url') == False:
     327        l.append(tag.li(tag.a(name=k), tag.a(href='#cite_%s' % k)('^') ,content))
     328      else:
     329        url = k['url']
     330        l.append(tag.li(tag.a(name=k), tag.a(href='#cite_%s' % k)('^') ,content, tag.br(),tag.a(href=url)(url)))
     331
     332    ol = tag.ol(*l)
     333    tags = []
     334    tags.append(tag.h1(id='Bibliography')('Bibliography'))
     335    tags.append(ol)
     336
     337    return tag.div(id='Bibliography')(*tags)

Attachments (0)

Change History (2)

comment:1 Changed 13 years ago by pauld.mccarthy@…

Type: defectenhancement

comment:2 Changed 12 years ago by Roman Mohr

Resolution: fixed
Status: newclosed

Since r11553, there exists the macro

[[BibFullRef]]

Thanks for sharing all of your code.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Roman Mohr.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.