提供多种文本资源格式的高亮预览
项目描述
ckanext-pygments
此扩展提供了多种文本资源格式的高亮预览。
缓存
此扩展中实现了一种缓存机制。默认情况下它是禁用的。要启用它,将ckanext.pygments.cache.enable
设置为True
。您还可以使用ckanext.pygments.cache.ttl
设置缓存的时间生存周期(以秒为单位)。默认值为7200秒(2小时)。您还可以使用ckanext.pygments.cache.resource_max_size
设置要缓存的资源的最大大小(以字节为单位)。默认值为20MB。
为什么默认禁用缓存?
我们使用Redis进行缓存,它使用内存。如果您有很多资源并且它们很大,可能会耗尽内存。这就是为什么它默认禁用。我们还在讨论是否真的需要缓存。经过pygments处理的大资源将会更大。因此,我们可能会有大量的内存使用。但是,如果有很多资源和许多用户访问它们,我们可以在处理上节省很多时间。
管理员配置页面
如果您使用的是ckanext-admin-panel扩展,您可以从管理员面板配置pygments设置。
否则,您可以在ckan.ini
文件中配置它。
配置设置
支持的配置选项
- key: ckanext.pygments.supported_formats
type: list
description: Specify a list of supported formats
default: sql html xhtml htm xslt py pyw pyi jy sage sc rs rs.in rst rest md markdown xml xsl rss xslt xsd wsdl wsf json jsonld yaml yml dtd php inc rdf ttl js
- key: ckanext.pygments.max_size
type: int
description: Specify how many bytes we are going to render from file. Default to 1MB
default: 1048576
- key: ckanext.pygments.include_htmx_asset
description: Include HTMX asset
default: true
type: bool
- key: ckanext.pygments.default_theme
description: Default theme for preview
default: default
- key: ckanext.pygments.cache.enable
description: Enable cache
default: false
type: bool
- key: ckanext.pygments.cache.preview_max_size
description: Specify what is the maximum size of a preview we are going to cache
default: 20971520 # 20MB
type: int
- key: ckanext.pygments.cache.ttl
description: Specify the time to live of the cache
default: 7200 # 2 hours
type: int
测试
要运行测试,请执行
pytest --ckan-ini=test.ini
许可协议
项目详情
下载文件
下载适用于您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。
源分发
ckanext_pygments-1.2.0.tar.gz (42.4 kB 查看哈希值)
构建分发
ckanext_pygments-1.2.0-py3-none-any.whl (46.7 kB 查看哈希值)
关闭
ckanext_pygments-1.2.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | ea68fbd5fdd8bb6f3c6f81f127b1e5b47f3e2869cb60683647ed8766be857ada |
|
MD5 | aac782201a884d85489700035c7c140c |
|
BLAKE2b-256 | 34abf5d4ed4a95061bac8d55d561e78daf478d7b8d3d68275cad3413a162f3e4 |
关闭
ckanext_pygments-1.2.0-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 219656362d3a76286666699bda069c28edf86b869b12dd1a919671a20b762c05 |
|
MD5 | a1f7b0cfb5d36ff1aaae2459e7d564b9 |
|
BLAKE2b-256 | 0bf635a4e59cf92c3be2c034fdd1491984066033fc933f2dbbd310e211a223fc |