Biblary是一个基于bibtex库的提供参考文献的Django应用程序。
项目描述
Biblary
安装
推荐的安装方法是使用pip
pip install biblary
开始使用
首先,确保应用程序已添加到您的项目设置中的INSTALLED_APPS
# settings.py
INSTALLED_APPS = (
...
'biblary',
)
接下来,将URL添加到您的项目中
# urls.py
from django.urls import path, include
urlpatterns = [
path('biblary/', include('biblary.urls', namespace='biblary')),
]
最后,需要配置参考文献后端适配器。例如,要服务包含BibTeX条目的文件的内容,请使用BibtexBibliography
适配器
# settings.py
import pathlib
BIBLARY_BIBLIOGRAPHY_ADAPTER = 'biblary.bibliography.adapter.bibtex.BibtexBibliography'
BIBLARY_BIBLIOGRAPHY_ADAPTER_CONFIGURATION = {
'filepath': pathlib.Path('/some/path/to/bibliography.bib')
}
filepath
是配置的唯一必需键,应是一个指向BibTeX文件的pathlib.Path
对象。
可用的适配器
BibtexBibliography
此适配器旨在服务包含BibTeX条目的文件的内容。
配置参数
filepath
:指向包含参考文献条目的BibTeX文件的pathlib.Path
对象。
编写自定义适配器
要提供一个自定义参考文献后端适配器,应实现biblary.bibliography.adapter.abstract.BibliographyAdapter
类
# -*- coding: utf-8 -*-
import typing as t
from biblary.bibliography.adapter import BibliographyAdapter
from biblary.bibliography.entry import BibliographyEntry
class CustomBibliographyAdapter(BibliographyAdapter):
"""Implementation of a ``BibliographyAdapter``."""
def __init__(self, *args, **kwargs):
"""Construct a new instance and configure the adapter."""
super().__init__(*args, **kwargs)
def get_entries(self) -> t.List[BibliographyEntry]:
"""Return the list of bibliography entries."""
构造函数应定义它应接受哪些关键字参数来配置适配器。为 BIBLARY_BIBLIOGRAPHY_ADAPTER_CONFIGURATION
指定的关键字参数将在加载参考文献时传递给适配器的构造函数。最后,应实现 get_entries
方法。该方法应返回一个包含 biblary.bibliography.entry.BiliographyEntry
实例的列表,每个实例对应参考文献中的一个条目。
配置
BIBLARY_BIBLIOGRAPHY_MAIN_AUTHOR_PATTERNS
此设置接受一个正则表达式模式元组,例如
BIBLARY_BIBLIOGRAPHY_MAIN_AUTHOR_PATTERNS = ('Paul Dirac', r'.*Dirac')
模板标签 main_author_class
将使用此设置来确定传递给它的作者是否被视为主要作者。如果是这种情况,将返回由 BIBLARY_BIBLIOGRAPHY_MAIN_AUTHOR_CLASS
设置定义的字符串。这可以在 index
模板中如下使用
{% for entry in entries %}
<div class="biblary-entry-authors">
{% for author in entry.author %}
<span class="biblary-entry-author {% main_author_class author %}">{{ author }}</span>
{% endfor %}
</div>
{% endfor %}
任何与设置中指定的任何模式匹配的作者都将获得额外的类。
BIBLARY_BIBLIOGRAPHY_MAIN_AUTHOR_CLASS
当指定的作者与 BIBLARY_BIBLIOGRAPHY_MAIN_AUTHOR_PATTERNS
设置中定义的任何模式匹配时,由 main_author_class
标签返回。默认为 biblary-entry-author-main
。
项目详情
下载文件
下载适用于您的平台文件。如果您不确定要选择哪个,请了解更多关于 安装包 的信息。
源分发
构建分发
biblary-0.2.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 6d0c6e60fdc9c32ce9c7464a63a43db52139fffdae5facb729ef9bc0c4853405 |
|
MD5 | dfc3ae2f01f6b1f12de97b7e497f73ea |
|
BLAKE2b-256 | 7203036305272f3fccc18a71a906a1e9514adc72b6df8a74a45b1e7b0f279492 |
biblary-0.2.0-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 0f9070e47e2b3e409619ab7574c51d926203e002f235d9d815803a4af60bec74 |
|
MD5 | 262e6f9358527a6d4e4c1c158f6c75fe |
|
BLAKE2b-256 | bcf6b6382662cae4797262aea0c4db64aef296824dbaaa4c09582876c19ff92e |