11#!/usr/bin/env python
22# encoding: utf-8
33
4+ """
5+ This script is modified in this PR (https://github.com/CenterForOpenScience/osf.io/pull/7595)
6+ to set the corresponding `has_bibliography` flag to `False` for all citation formats whose CSL file do not
7+ include a bibliography section. As a result, all such citation formats would not show up in OSF
8+ citation widgets for users to choose.
9+
10+ NOTE:
11+ As of August 25th, 2017, there are however THREE EXCEPTIONS:
12+ "Bluebook Law Review", "Bluebook Law Review(2)" and "Bluebook Inline" shares a
13+ special CSL file ('website/static/bluebook.cls'), in which a bibliography section is defined,
14+ for rendering bibliographies even though their official CSL files (located in assets folder)
15+ do not contain a bibliography section.
16+ The side effect is that, upon parsing all the CSL files in the assets folder, these three citation
17+ formats are marked as `has_bibliography=False`, preventing them from user selection on the front end.
18+ Therefore, intervention is needed to manually "turn on" their 'has_bibliography' flag for them to show
19+ on the citation widget.
20+ """
21+
422import os
523
624from lxml import etree
1028setup_django ()
1129from osf .models .citation import CitationStyle
1230
13-
1431def main ():
1532
1633 # drop all styles
@@ -32,6 +49,8 @@ def main():
3249 fields = {
3350 '_id' : os .path .splitext (os .path .basename (style_file ))[0 ],
3451 'title' : root .find (selector + 'title' ).text ,
52+ 'has_bibliography' : True if root .find (
53+ '{{{ns}}}{tag}' .format (ns = namespace , tag = 'bibliography' )) is not None else False
3554 }
3655
3756 # Optional
0 commit comments