Modify ↓
Opened 14 years ago
Closed 13 years ago
#7713 closed enhancement (fixed)
Allow loading of .bib file from htdocs
Reported by: | Owned by: | Roman Mohr | |
---|---|---|---|
Priority: | normal | Component: | TracBibPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 0.11 |
Description
Being able to store and load a .bib file as a static resource from the htdocs/ directory is useful for me. I have a single .bib file, containing all the references for my work, which is under independent version control. With the patch below, I can simply create a symlink from htdocs to my .bib file, so I don't need to maintain a separate .bib file.
Using the patch as-is, to add a .bib file stored in $TRAC_ENV/htdocs/library.bib, you would type [[BibAdd(static:library.bib)]]
.
-
trunk/tracbib/tracbib.py
56 56 from trac.wiki.formatter import WikiProcessor 57 57 from trac.util.text import to_unicode 58 58 59 import os 59 60 import re 60 61 import bibtexparse 61 62 … … 186 187 raise TracError('No code block on page \'' + whom[1] + '\' found.') 187 188 else: 188 189 raise TracError('No wiki page named \'' + whom[1] + '\' found.') 190 191 elif whom[0] == 'static': 192 193 if (len(whom) != 2): 194 raise TracError('Wrong syntax for environment \'static\'; Usage BibAdd(static:/path/to/static/file)') 195 196 htdir = self.env.get_htdocs_dir() 197 fdir = os.path.join(htdir,whom[1]) 198 199 if not os.path.exists(fdir): 200 raise TracError('Static resource %s does not exist') 201 if not os.path.isfile(fdir): 202 raise TracError('Static resource %s is not a file') 203 204 fd = open(fdir, 'rt') 205 string = fd.read() 206 fd.close() 207 189 208 else: 190 209 raise TracError('Unknown location \''+ whom[0] +'\'') 191 210 try:
Attachments (0)
Note: See
TracTickets for help on using
tickets.
Since r11553, as part of a full rewrite its now possible to load bibtex files from everywhere in the web.
Example:
Its not exactly what you wanted, because I don't like the idea of hardcoding something for the symlink, but you can have the same effect by using the 'http' prefix and securing your file via your webserver.