当前位置: 首页>>代码示例>>Python>>正文


Python ContentApi.get_jpg_preview_path方法代码示例

本文整理汇总了Python中tracim_backend.lib.core.content.ContentApi.get_jpg_preview_path方法的典型用法代码示例。如果您正苦于以下问题:Python ContentApi.get_jpg_preview_path方法的具体用法?Python ContentApi.get_jpg_preview_path怎么用?Python ContentApi.get_jpg_preview_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tracim_backend.lib.core.content.ContentApi的用法示例。


在下文中一共展示了ContentApi.get_jpg_preview_path方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: sized_preview_jpg_revision

# 需要导入模块: from tracim_backend.lib.core.content import ContentApi [as 别名]
# 或者: from tracim_backend.lib.core.content.ContentApi import get_jpg_preview_path [as 别名]
 def sized_preview_jpg_revision(self, context, request: TracimRequest, hapic_data=None):  # nopep8
     """
     Obtain resized jpg preview of a specific revision of content.
     Good pratice for filename is filename is `{label}_r{revision_id}_page_{page_number}_{width}x{height}.jpg`.
     Default filename value is 'raw' (without file extension) or nothing.
     """
     app_config = request.registry.settings['CFG']
     api = ContentApi(
         show_archived=True,
         show_deleted=True,
         current_user=request.current_user,
         session=request.dbsession,
         config=app_config,
     )
     content = api.get_one(
         hapic_data.path.content_id,
         content_type=content_type_list.Any_SLUG
     )
     revision = api.get_one_revision(
         revision_id=hapic_data.path.revision_id,
         content=content
     )
     jpg_preview_path = api.get_jpg_preview_path(
         content_id=content.content_id,
         revision_id=revision.revision_id,
         page_number=hapic_data.query.page,
         height=hapic_data.path.height,
         width=hapic_data.path.width,
         file_extension=revision.file_extension,
     )
     filename = hapic_data.path.filename
     if not filename or filename == 'raw':
         filename = "{label}_r{revision_id}_page_{page_number}_{width}x{height}.jpg".format(  # nopep8
             revision_id=revision.revision_id,
             label=revision.label,
             page_number=hapic_data.query.page,
             width=hapic_data.path.width,
             height=hapic_data.path.height
         )
     return HapicFile(
         file_path=jpg_preview_path,
         filename=filename,
         as_attachment=hapic_data.query.force_download
     )
开发者ID:tracim,项目名称:tracim,代码行数:46,代码来源:file_controller.py

示例2: preview_jpg

# 需要导入模块: from tracim_backend.lib.core.content import ContentApi [as 别名]
# 或者: from tracim_backend.lib.core.content.ContentApi import get_jpg_preview_path [as 别名]
 def preview_jpg(self, context, request: TracimRequest, hapic_data=None):
     """
     Obtain normally sized jpg preview of last revision of content.
     Good pratice for filename is `filename is {label}_page_{page_number}.jpg`.
     Default filename value is 'raw' (without file extension) or nothing.
     """
     app_config = request.registry.settings['CFG']
     api = ContentApi(
         show_archived=True,
         show_deleted=True,
         current_user=request.current_user,
         session=request.dbsession,
         config=app_config,
     )
     content = api.get_one(
         hapic_data.path.content_id,
         content_type=content_type_list.Any_SLUG
     )
     allowed_dim = api.get_jpg_preview_allowed_dim()
     jpg_preview_path = api.get_jpg_preview_path(
         content_id=content.content_id,
         revision_id=content.revision_id,
         page_number=hapic_data.query.page,
         file_extension=content.file_extension,
         width=allowed_dim.dimensions[0].width,
         height=allowed_dim.dimensions[0].height,
     )
     filename = hapic_data.path.filename
     if not filename or filename == 'raw':
         filename = "{label}_page_{page_number}.jpg".format(
             label=content.label,
             page_number=hapic_data.query.page
         )
     return HapicFile(
         file_path=jpg_preview_path,
         filename=filename,
         as_attachment=hapic_data.query.force_download
     )
开发者ID:tracim,项目名称:tracim,代码行数:40,代码来源:file_controller.py


注:本文中的tracim_backend.lib.core.content.ContentApi.get_jpg_preview_path方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。