Modify

Opened 4 years ago

Closed 2 years ago

#7721 closed enhancement (fixed)

List entire bibliography

Reported by: pauld.mccarthy@… Owned by: Amfortas
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 4 years ago by pauld.mccarthy@…

  • Type changed from defect to enhancement

comment:2 Changed 2 years ago by Amfortas

  • Resolution set to fixed
  • Status changed from new to closed

Since r11553, there exists the macro

[[BibFullRef]]

Thanks for sharing all of your code.

Add Comment

Modify Ticket

Action
as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from Amfortas. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.