From 718674b0f3ca526b7c69bbe1d1eb196ba2622a42 Mon Sep 17 00:00:00 2001 From: Vicky Steeves Date: Sun, 28 Jul 2019 10:13:11 -0400 Subject: [PATCH] remove unused plugins, fix missing links resume --- pages/resume.html | 12 +- plugins/__init__.py | 1 - plugins/publication_list/README.md | 112 -------- .../publication_list/publication_list.plugin | 14 - plugins/publication_list/publication_list.py | 263 ------------------ plugins/publication_list/requirements.txt | 1 - .../templates/jinja/publication.tmpl | 65 ----- .../templates/mako/publication.tmpl | 65 ----- plugins/upgrade_metadata_v8/README.md | 17 -- .../upgrade_metadata_v8.plugin | 13 - .../upgrade_metadata_v8.py | 187 ------------- 11 files changed, 6 insertions(+), 744 deletions(-) delete mode 100644 plugins/__init__.py delete mode 100644 plugins/publication_list/README.md delete mode 100644 plugins/publication_list/publication_list.plugin delete mode 100644 plugins/publication_list/publication_list.py delete mode 100644 plugins/publication_list/requirements.txt delete mode 100644 plugins/publication_list/templates/jinja/publication.tmpl delete mode 100644 plugins/publication_list/templates/mako/publication.tmpl delete mode 100644 plugins/upgrade_metadata_v8/README.md delete mode 100644 plugins/upgrade_metadata_v8/upgrade_metadata_v8.plugin delete mode 100644 plugins/upgrade_metadata_v8/upgrade_metadata_v8.py diff --git a/pages/resume.html b/pages/resume.html index 1041832..5e65077 100644 --- a/pages/resume.html +++ b/pages/resume.html @@ -41,17 +41,17 @@

New York University New York, NY, USA

-

Master of Computer Science Expected 2022

+

Master of Computer Science Expected 2022

Simmons College Boston, MA, USA

-

Master of Library and Information Science August 2014

+

Master of Library and Information Science August 2014

GPA: 3.85
Research Opportunities

Small World Project. Research done accompanying Dr. Kathy Wisser, March-June 2014. I provided software analysis using Gephi, a data visualization software, on researchers' social network analysis of historical relationships between literary figures.

-

Bachelor of Science in Computer Science and Information Technology May 2013

+

Bachelor of Science in Computer Science and Information Technology May 2013

GPA: 3.75
Honours Thesis: Computational Linguistic Approach to Inflection in Human Speech and Difference in Meaning
@@ -222,12 +222,12 @@
    -
  • Partners in Reproducibility: Working with Researchers and Data Producers to Enhance Sharing, Reproducibility, and Long-term Access to Research Data. Muilenburg Jennifer & Steeves, Vicky & Zhao, Shirley & McDougall, Janet. (2019, May). IASSIST 2019.
  • -
  • Reproducibility, Preservation, and Access to Research with ReproZip and ReproServer. Steeves, Vicky & Rampin, R.. (2019, May). IASSIST 2019.
  • +
  • Panel - Partners in Reproducibility: Working with Researchers and Data Producers to Enhance Sharing, Reproducibility, and Long-term Access to Researosfch Data. Muilenburg Jennifer & Steeves, Vicky & Zhao, Shirley & McDougall, Janet. (2019, May). IASSIST 2019.
  • +
  • Reproducibility, Preservation, and Access to Research with ReproZip and ReproServer. Steeves, Vicky & Rampin, R.. (2019, May). IASSIST 2019.
  • Qualitative Research Using Open Tools. Duckles, Beth M. & Steeves, Vicky. (2019, May). csv,conf,v4.
  • The Role of Libraries in the Age of Computational Reproducibility. Steeves, Vicky, & Hayden, Gabriele. (2019, May). csv,conf,v4.
  • Taguette: Open Qualitative Research. Steeves, Vicky & DeMott, Sarah. (2019, February). Workshop for Seton Hall University.
  • -
  • Advocating for Open: Putting Ethics Into Practice. Marshall, Brianna & Steeves, Vicky & Vandegift, Micah. (2019, April). ACRL 2019. Cleveland, OH.
  • +
  • Advocating for Open: Putting Ethics Into Practice. Marshall, Brianna & Steeves, Vicky & Vandegift, Micah. (2019, April). ACRL 2019. Cleveland, OH.
  • Reproducibility Librarianship in Practice. Steeves, Vicky. (2018, December). Webinar for LIBER.
  • ReproServer: Making Reproducibility Easier and Less Intrusive. Steeves, V. & Rampin, R., Chirigati, F. & Freire, J. October 2018. Moore-Sloan Data Science Environment. Park City, Utah.
  • Best practices for reproducible research. Steeves, V. October 2018. Harvard-Smithsonian Center for Astrophysics. Cambride, Massachusetts.
  • diff --git a/plugins/__init__.py b/plugins/__init__.py deleted file mode 100644 index fd7e25d..0000000 --- a/plugins/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# Plugin modules go here. \ No newline at end of file diff --git a/plugins/publication_list/README.md b/plugins/publication_list/README.md deleted file mode 100644 index 0377eb2..0000000 --- a/plugins/publication_list/README.md +++ /dev/null @@ -1,112 +0,0 @@ -# Publication List - -A Nikola plugin to easily manage publication list. - -This plugin provides a directive `publication_list`, which reads a BibTeX file -and display the references in them on the web page. - -The publications are displayed in the following way. All publications are sorted -by year in reverse order, i.e., recent publication first. Publications in the -same year are grouped together with a year subtitle. Within the same year, -publications are sorted by order they appear in the BibTeX file. Finally, each -publication is formatted with the designated style. - -## Options - -The `publication-list` directive accepts multiple options. - -* `:bibtex_dir:` indicates the directory where the bibtex file of each - publication is generated. If empty, no bibtex file will be created for each - publication. The default is `bibtex`. - -* `:detail_page_dir:` indicates the directory where the details pages of the - publications are stored. If empty, no details page will be created. The - default is `papers`. - -* `:highlight_author:` indicates the author to highlight. Usually this is the - owner of the website. This can be a list of names separated by “;” if there are several - optional names. - -In the BibTeX file entries, the following fields have special meanings. - -* `abstract` is the abstract of the paper. If it is present, the abstract will - be available in the details page. -* `fulltext` is the URL to the full text of the paper (usually a PDF file). If - it is present, a "full text" link will be shown below the publication and the - PDF file will be embedded in the details page. -* Fields starting with `customlink` will add custom links below the publication. - For example, `customlinkslides` will add a link `[slides]` to the URL of the - value of the field. - -If you need math support, please add the following to your `EXTRA_HEAD_DATA` -option in your `conf.py` file, then every math equation surrounded by `\(` and -`\)`, e.g., the ones in the abstracts and titles, will be rendered properly. - - r'' - -## Example - -A simple example: - - Publications - ------------ - - .. publication_list:: my-publications.bib - :style: unsrt - :highlight_author: Nikola Tesla - -where `my-publications.bib` contains: - - @article{a2015, - title = {One Article in 2015}, - author = {Nikola Tesla}, - year = 2015, - journal = {Great Journal}, - volume = 1, - pages = {1--10}, - fulltext = {/pdf/a2015.pdf} - } - - @book{b2010, - title = {One Book in 2010}, - author = {Isaac Newton and Nikola Tesla}, - year = 2010, - isbn = {000-0000000000}, - publisher = {Nikola Tesla Publishing Group}, - fulltext = {http://example.org/b2010.pdf} - } - - @inproceedings{p2015, - title = {One Conference in 2015}, - booktitle = {Nikola Tesla Conference}, - author = {Nikola Tesla}, - year = 2015 - } - -If you have multiple bibtex files, you can specify them in one line, separated -by spaces. For example: - - ... publication_list:: my-novels.bib my-research-papers.bib my-collections.bib - -Live examples: - -- http://www.shudan.me/ -- https://bishesh.github.io/publications/ - -## Customize Details Pages - -You can also customize details pages. To do that, simply create files named -`publicationlist_label_after_abstract.html` or -`publicationlist_label_after_fulltext.html` in your template directory (usually -named `templates`). The contents in these files will be inserted into the -details page of the paper with that BibTeX label. For example, for a paper with -a BibTeX label `a2015`, you can create files -`publicationlist_a2015_after_abstract.html` and/or -`publicationlist_a2015_after_fulltext.html` to customize its details page. - -## Screenshot - -![publication-list screenshot](http://plugins.getnikola.com/__data__/publication-list-screenshot.png) - -[list of styles]: https://bitbucket.org/pybtex-devs/pybtex/src/master/pybtex/style/formatting/ -[Pybtex]: http://pybtex.org diff --git a/plugins/publication_list/publication_list.plugin b/plugins/publication_list/publication_list.plugin deleted file mode 100644 index df616b7..0000000 --- a/plugins/publication_list/publication_list.plugin +++ /dev/null @@ -1,14 +0,0 @@ -[Core] -Name = publication_list -Module = publication_list -Tests = test_publication_list - -[Nikola] -PluginCategory = CompilerExtension -Compiler = rest - -[Documentation] -Author = Hong Xu -Version = 0.7.1 -Website = https://www.topbug.net -Description = Easily manage publication list. diff --git a/plugins/publication_list/publication_list.py b/plugins/publication_list/publication_list.py deleted file mode 100644 index b280582..0000000 --- a/plugins/publication_list/publication_list.py +++ /dev/null @@ -1,263 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright © 2016-2017 Hong Xu . - -# Permission is hereby granted, free of charge, to any -# person obtaining a copy of this software and associated -# documentation files (the "Software"), to deal in the -# Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the -# Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice -# shall be included in all copies or substantial portions of -# the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import os -import sys - -from docutils import nodes -from docutils.parsers.rst import Directive, directives - -from nikola.plugin_categories import RestExtension -from nikola.utils import get_logger, STDERR_HANDLER - -from pybtex.database import BibliographyData, Entry -from pybtex.database.input.bibtex import Parser -from pybtex.markup import LaTeXParser -from pybtex.style.formatting.unsrt import Style as UnsrtStyle -from pybtex.style.template import href, tag - - -LOGGER = get_logger('scan_posts', STDERR_HANDLER) - - -class Style(UnsrtStyle): - """The style for publication listing. It hyperlinks the title to the detail page if user sets it. - """ - - def __init__(self, detail_page_url): - super().__init__() - self.detail_page_url = detail_page_url - - def format_title(self, e, which_field, as_sentence=True): - "Override the UnsrtStyle format_title(), so we have the title hyperlinked." - - title = tag('strong')[super().format_title(e, which_field, as_sentence)] - - if self.detail_page_url: - url = '/'.join((self.detail_page_url, e.label + '.html')) - return href[url, title] - else: - return title - - -class Plugin(RestExtension): - - name = "publication_list" - - def set_site(self, site): - self.site = site - directives.register_directive('publication_list', PublicationList) - PublicationList.site = self.site - PublicationList.output_folder = self.site.config['OUTPUT_FOLDER'] - return super(Plugin, self).set_site(site) - - -class PublicationList(Directive): - """ - Directive to list publications. - """ - has_content = False - required_arguments = 1 - optional_arguments = sys.maxsize - option_spec = { - 'bibtex_dir': directives.unchanged, - 'detail_page_dir': directives.unchanged, - 'highlight_author': directives.unchanged, - 'style': directives.unchanged - } - - def run(self): - - bibtex_dir = self.options.get('bibtex_dir', 'bibtex') - detail_page_dir = self.options.get('detail_page_dir', 'papers') - highlight_authors = self.options.get('highlight_author', None) - if highlight_authors: - highlight_authors = highlight_authors.split(';') - style = Style(self.site.config['BASE_URL'] + detail_page_dir if detail_page_dir else None) - self.state.document.settings.record_dependencies.add(self.arguments[0]) - - all_entries = [] - labels = set() - for a in self.arguments: - parser = Parser() - for item in parser.parse_file(a).entries.items(): - if item[0] in labels: # duplicated entries - LOGGER.warning( - ("publication_list: BibTeX entries with duplicated labels are found. " - "Only the first occurrence will be used.")) - continue - labels.add(item[0]) - all_entries.append(item) - # Sort the publication entries by year reversed - data = sorted(all_entries, key=lambda e: e[1].fields['year'], reverse=True) - - html = '
    \n' - cur_year = None - - if bibtex_dir: # create the bibtex dir if the option is set - try: - os.makedirs(os.path.sep.join((self.output_folder, bibtex_dir))) - except OSError: # probably because the dir already exists - pass - - if detail_page_dir: # create the detail page dir if the option is set - try: - os.makedirs(os.path.sep.join((self.output_folder, detail_page_dir))) - except OSError: # probably because the dir already exists - pass - - for label, entry in data: - # print a year title when year changes - if entry.fields['year'] != cur_year: - if cur_year is not None: # not first year group - html += '
' - cur_year = entry.fields['year'] - html += '

{}

\n
    '.format(cur_year) - - entry.label = label # Pass label to the style. - pub_html = list(style.format_entries((entry,)))[0].text.render_as('html') - if highlight_authors: # highlight one of several authors (usually oneself) - for highlight_author in highlight_authors: - # We need to replace all occurrence of space except for the last one with - #  , since pybtex does it for all authors - count = highlight_author.count(' ') - 1 - pub_html = pub_html.replace( - highlight_author.strip().replace(' ', ' ', count), - '{}'.format(highlight_author), 1) - html += '
  • ' + pub_html - - extra_links = "" - - if 'fulltext' in entry.fields: # the link to the full text, usually a link to the pdf file - extra_links += '[full text] '.format(entry.fields['fulltext']) - - bibtex_fields = dict(entry.fields) - # Collect and remove custom links (fields starting with "customlink") - custom_links = dict() - for key, value in bibtex_fields.items(): - if key.startswith('customlink'): - custom_links[key[len('customlink'):]] = value - # custom fields (custom links) - for key, value in custom_links.items(): - extra_links += '[{}] '.format(value, key) - - # Remove some fields for the publicly available BibTeX file since they are mostly only - # used by this plugin. - for field_to_remove in ('abstract', 'fulltext'): - if field_to_remove in bibtex_fields: - del bibtex_fields[field_to_remove] - # Prepare for the bib file. Note detail_page_dir may need bib_data later. - bibtex_entry = Entry(entry.type, bibtex_fields, entry.persons) - bib_data = BibliographyData(dict({label: bibtex_entry})) - bib_string = bib_data.to_string('bibtex') - extra_links += ''' - [BibTeX▼] - '''.format('bibtex-' + label) - if bibtex_dir: # write bib files to bibtex_dir for downloading - bib_link = '{}/{}.bib'.format(bibtex_dir, label) - bib_data.to_file('/'.join([self.output_folder, bib_link]), 'bibtex') - - if extra_links or detail_page_dir or 'abstract' in entry.fields: - html += '
    ' - - # Add the abstract link. - if 'abstract' in entry.fields: - html += ''' - [abstract▼] '''.format('abstract-' + label) - - display_none = '' - bibtex_display = display_none.format( - 'bibtex-' + label, bib_string) - - abstract_text = str( - LaTeXParser(entry.fields['abstract']).parse()) if 'abstract' in entry.fields else '' - if detail_page_dir: # render the details page of a paper - page_url = '/'.join((detail_page_dir, label + '.html')) - html += '[details] '.format( - self.site.config['BASE_URL'] + page_url) - context = { - 'title': str(LaTeXParser(entry.fields['title']).parse()), - 'abstract': abstract_text, - 'bibtex': bib_data.to_string('bibtex'), - 'bibtex_link': '/' + bib_link if bibtex_dir else '', - 'default_lang': self.site.config['DEFAULT_LANG'], - 'label': label, - 'lang': self.site.config['DEFAULT_LANG'], - 'permalink': self.site.config['SITE_URL'] + page_url, - 'reference': pub_html, - 'extra_links': extra_links + bibtex_display - } - - if 'fulltext' in entry.fields: - context['pdf'] = entry.fields['fulltext'] - - self.site.render_template( - 'publication.tmpl', - os.path.sep.join((self.output_folder, detail_page_dir, label + '.html')), - context, - ) - - html += extra_links - - # Add the hidden abstract and bibtex. - if 'abstract' in entry.fields: - html += ''' - - '''.format('abstract-' + label, abstract_text) - html += bibtex_display - html += '
  • ' - - if len(data) != 0: # publication list is nonempty - html += '
' - - html += '
' - - return [nodes.raw('', html, format='html'), ] diff --git a/plugins/publication_list/requirements.txt b/plugins/publication_list/requirements.txt deleted file mode 100644 index c8e7b54..0000000 --- a/plugins/publication_list/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -pybtex>=0.21 diff --git a/plugins/publication_list/templates/jinja/publication.tmpl b/plugins/publication_list/templates/jinja/publication.tmpl deleted file mode 100644 index 2b997cb..0000000 --- a/plugins/publication_list/templates/jinja/publication.tmpl +++ /dev/null @@ -1,65 +0,0 @@ -{# -*- coding: utf-8 -*- #} -{% extends 'base.tmpl' %} - -<%! -import os, mako -%> - -{% macro include_if_exists(name) %} - <% - try: - tmpl = self.get_template(name) - except mako.exceptions.TemplateLookupException as e: - pass - else: - tmpl.render_context(context) - %> -{% endmacro %} - -{% block extra_head %} - -{% endblock %} - -{% block content %} - - -
-

- {{ reference }} - {% if extra_links %} -
{{ extra_links }} - {% endif %} -

-
- - {% if abstract %} -

Abstract

-
-

{{ abstract | h }}

-
- {% endif %} - - {{ include_if_exists("publicationlist_{ }_after_abstract.html".format(label))}} - - {% if pdf %} -

Full Text

-
- -

Your browser does not support viewing the PDF file inline. Please click the link below to download the file.

-
-

[download]

-
- {% endif %} - - {{ include_if_exists("publicationlist_{ }_after_fulltext.html".format(label))}} -{% endblock %} diff --git a/plugins/publication_list/templates/mako/publication.tmpl b/plugins/publication_list/templates/mako/publication.tmpl deleted file mode 100644 index 38c5d5b..0000000 --- a/plugins/publication_list/templates/mako/publication.tmpl +++ /dev/null @@ -1,65 +0,0 @@ -## -*- coding: utf-8 -*- -<%inherit file="base.tmpl"/> - -<%! -import os, mako -%> - -<%def name="include_if_exists(name)" buffered="True"> - <% - try: - tmpl = self.get_template(name) - except mako.exceptions.TemplateLookupException as e: - pass - else: - tmpl.render_context(context) - %> - - -<%block name="extra_head"> - - - -<%block name="content"> - - -
-

- ${reference} - % if extra_links: -
${extra_links} - % endif -

-
- - % if abstract: -

Abstract

-
-

${abstract | h}

-
- % endif - - ${include_if_exists("publicationlist_{}_after_abstract.html".format(label))} - - % if pdf: -

Full Text

-
- -

Your browser does not support viewing the PDF file inline. Please click the link below to download the file.

-
-

[download]

-
- % endif - - ${include_if_exists("publicationlist_{}_after_fulltext.html".format(label))} - diff --git a/plugins/upgrade_metadata_v8/README.md b/plugins/upgrade_metadata_v8/README.md deleted file mode 100644 index f119872..0000000 --- a/plugins/upgrade_metadata_v8/README.md +++ /dev/null @@ -1,17 +0,0 @@ -Nikola Metadata Upgrade (v7 to v8) -================================== - -This plugin fulfills two purposes: - -1. It upgrades old-style tags metadata (`draft`, `private`, `mathjax`) - to new-style metadata, i.e. using the `status` and `has_math` metadata fields. - The tags were used in Nikola v7 and earlier, and are no longer used by default - in Nikola v8. If you are using them in your blog, **you will be warned** by - `nikola build` — otherwise, don’t install this plugin (it won’t do a thing - anyway and will only waste disk space and load time). - -2. It converts sections to categories. If both section and category are specified - in a post, a warning is printed and the category kept. - -The plugin adds the `nikola upgrade_metadata_v8` command. Remove the plugin -manually after the upgrade. diff --git a/plugins/upgrade_metadata_v8/upgrade_metadata_v8.plugin b/plugins/upgrade_metadata_v8/upgrade_metadata_v8.plugin deleted file mode 100644 index 49aa1e7..0000000 --- a/plugins/upgrade_metadata_v8/upgrade_metadata_v8.plugin +++ /dev/null @@ -1,13 +0,0 @@ -[Core] -Name = upgrade_metadata_v8 -Module = upgrade_metadata_v8 - -[Nikola] -PluginCategory = Command -MinVersion = 8.0.0 - -[Documentation] -Author = Chris Warrick, Felix Fontein -Version = 0.1 -website = https://getnikola.com/ -Description = Convert special tags (draft, private, mathjax) to metadata diff --git a/plugins/upgrade_metadata_v8/upgrade_metadata_v8.py b/plugins/upgrade_metadata_v8/upgrade_metadata_v8.py deleted file mode 100644 index d0bca6e..0000000 --- a/plugins/upgrade_metadata_v8/upgrade_metadata_v8.py +++ /dev/null @@ -1,187 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright © 2014–2015, Chris Warrick. -# Copyright © 2018, Felix Fontein. - -# Permission is hereby granted, free of charge, to any -# person obtaining a copy of this software and associated -# documentation files (the "Software"), to deal in the -# Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the -# Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice -# shall be included in all copies or substantial portions of -# the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -from __future__ import unicode_literals -import io -import os -import sys -from nikola.plugin_categories import Command -from nikola import utils - - -class UpgradeMetadata(Command): - """Convert special tags (draft, private, mathjax) to status and has_math metadata. Also removes sections.""" - - name = 'upgrade_metadata_v8' - doc_purpose = 'Convert special tags (draft, private, mathjax) to metadata' - cmd_options = [ - { - 'name': 'yes', - 'short': 'y', - 'long': 'yes', - 'type': bool, - 'default': False, - 'help': 'Proceed without confirmation', - }, - ] - - def _execute(self, options, args): - L = utils.get_logger('upgrade_metadata_v8', utils.STDERR_HANDLER) - - if not self.site.config['USE_TAG_METADATA']: - L.error('This plugin can only be used if USE_TAG_METADATA is set to True.') - sys.exit(-1) - self.site.config['WARN_ABOUT_TAG_METADATA'] = False - - # scan posts - self.site.scan_posts() - flagged = [] - for post in self.site.timeline: - flag = False - if post.has_oldstyle_metadata_tags: - flag = True - for lang in self.site.config['TRANSLATIONS'].keys(): - if 'section' in post.meta[lang]: - flag = True - if flag: - flagged.append(post) - if flagged: - if len(flagged) == 1: - L.info('1 post (and/or its translations) contains old-style metadata or has section metadata:') - else: - L.info('{0} posts (and/or their translations) contain old-style metadata or have section metadata:'.format(len(flagged))) - for post in flagged: - L.info(' ' + (post.metadata_path if post.is_two_file else post.source_path)) - L.warn('Please make a backup before running this plugin. It might eat your data.') - if not options['yes']: - yesno = utils.ask_yesno("Proceed with metadata upgrade?") - if options['yes'] or yesno: - number_converted = 0 - number_converted_partial = 0 - for post in flagged: - converted = False - fully_converted = True - for lang in self.site.config['TRANSLATIONS'].keys(): - # Get file names and extractor - extractor = post.used_extractor[lang] - is_two_file = post.is_two_file - if lang == post.default_lang: - fname = post.metadata_path if is_two_file else post.source_path - else: - meta_path = os.path.splitext(post.source_path)[0] + '.meta' if is_two_file else post.source_path - fname = utils.get_translation_candidate(post.config, meta_path, lang) - - # We don't handle compilers which extract metadata for now - if post.compiler is extractor: - L.warn('Cannot convert {0} (language {1}), as metadata was extracted by compiler.'.format(fname, lang)) - fully_converted = False - continue - - # Read metadata and text from post file - if not os.path.exists(fname): - L.debug("File {0} does not exist, skipping.".format(fname)) - continue - - with io.open(fname, "r", encoding="utf-8-sig") as meta_file: - source_text = meta_file.read() - if not is_two_file: - _, content_str = extractor.split_metadata_from_text(source_text) - meta = extractor.extract_text(source_text) - - # Consider metadata mappings - sources = {} - for m in ('tags', 'status', 'has_math', 'section', 'category'): - sources[m] = m - for foreign, ours in self.site.config.get('METADATA_MAPPING', {}).get(extractor.map_from, {}).items(): - if ours in sources: - sources[ours] = foreign - for meta_key, hook in self.site.config.get('METADATA_VALUE_MAPPING', {}).get(extractor.map_from, {}).items(): - if meta_key in sources.values(): - L.warn('Cannot convert {0} (language {1}): a metadata value mapping is defined for "{2}"!'.format(fname, lang, meta_key)) - - # Update metadata - updated = False - tags = meta.get(sources['tags'], []) - tags_are_string = False - if not isinstance(tags, list): - tags_are_string = True - tags = [tag.strip() for tag in tags.split(',') if tag.strip()] - - if 'draft' in [_.lower() for _ in tags]: - tags.remove('draft') - meta[sources['status']] = 'draft' - updated = True - - if 'private' in tags: - tags.remove('private') - meta[sources['status']] = 'private' - updated = True - - if 'mathjax' in tags: - tags.remove('mathjax') - meta[sources['has_math']] = 'yes' - updated = True - - if meta.get(sources['section']): - if meta.get(sources['category']): - L.warn('Cannot completely {0} (language {1}): both section and category are specified. Please determine the correct category to use yourself!'.format(fname, lang)) - fully_converted = False - else: - meta[sources['category']] = meta[sources['section']] - del meta[sources['section']] - updated = True - - if tags_are_string: - meta[sources['tags']] = ', '.join(tags) - - if not updated: - # Nothing to do (but successful)! - converted = True - continue - - # Recombine metadata with post text if necessary, and write back to file - meta_str = utils.write_metadata(meta, metadata_format=extractor.name, compiler=post.compiler, - comment_wrap=(post.compiler.name != 'rest'), site=self.site) - final_str = meta_str if is_two_file else (meta_str + content_str) - - with io.open(fname, "w", encoding="utf-8") as meta_file: - meta_file.write(final_str) - converted = True - - if converted: - if fully_converted: - number_converted += 1 - else: - number_converted_partial += 1 - - L.info('{0} out of {2} posts upgraded; {1} only converted partially ' - '(see above output).'.format(number_converted + number_converted_partial, number_converted_partial, len(flagged))) - else: - L.info('Metadata not upgraded.') - else: - L.info('No posts found with special tags or section metadata. No action is required.') - L.info('You can safely set the USE_TAG_METADATA and the WARN_ABOUT_TAG_METADATA settings to False.')