主题适配

目前此插件为主题端提供了 /douban 路由,模板为 douban.html,也提供了 Finder API,可以将瞬间列表渲染到任何地方。

主题模板编写

在主题中创建一个名为 douban.html 的模板,最基础的示例如下:

<th:block th:replace="~{plugin:plugin-douban:modules/style}"></th:block>
<main class="main">
    <div class="layoutSingleColumn layoutSingleColumn--wide u-paddingTop50">
        <th:block th:replace="~{plugin:plugin-douban:modules/douban}"></th:block>
    </div>
</main>
<th:block th:replace="~{plugin:plugin-douban:modules/script}"></th:block>
</main>

模板变量

路由信息

  • 模板路径:/templates/douban.html
  • 访问路径:/douban

变量

  • douban
  • genres
  • types

变量类型

Finder API

listAllGenres()

描述

获取全部种类。

参数

返回值

DoubanGenresVo

示例

<div>
  <div th:each="genres : ${doubanFinder.listAllGenres()}">
    <a th:href="${genres}" target="_blank" th:text="${genres}"></a>
  </div>
</div>

listAllType()

描述

获取全部类型。

参数

返回值

DoubanTypeVo

示例

<div>
  <div th:each="type : ${doubanFinder.listAllType()}">
    <a th:href="|/douban?type=${type.key}|" target="_blank" th:text="${type.name}"></a>
  </div>
</div>

list({...})

doubanFinder.list({
  page: 1,
  size: 10,
  type: 'type',
  dataType: 'dataType',
  status: 'status',
  genre: 'genre',
});

描述

统一参数的豆瓣列表查询方法,支持分页、类型、数据类型、状态、种类等参数,且均为可选参数。

可以使用此方法来代替 list(page, size)、listByType(page, size, type)、list(page, size, type, status) 方法。

参数

page:int - 分页页码,从 1 开始 size:int - 分页条数 type:string - 类型 dataType:string - 数据类型 status:string - 状态 genre:string - 种类

返回值

ListResult

示例

<th:block th:with="doubans = ${doubanFinder.list({
  page: 1,
  size: 10,
  type: 'type',
  dataType: 'dataType',
  status: 'status',
  genre: 'genre',
})}">
    <div th:each="douban : ${doubans.items}">
        <a th:href="${douban.link}" target="_blank" th:text="${douban.name}"></a>
        <div>
            <img th:src="${douban.poster}"
                alt="avatar">
            <span th:text="${douban.type}"></span>
            <span th:text="${douban.score}"></span>
        </div>
    </div>
</th:block>

list(page, size)

描述

根据分页参数获取豆瓣内容。

参数

  • page: int - 分页页码,从 1 开始
  • size: int - 分页条数

返回值

ListResult

示例

<th:block th:with="doubans = ${doubanFinder.list(1, 10)}">
    <div th:each="douban : ${doubans.items}">
        <a th:href="${douban.link}" target="_blank" th:text="${douban.name}"></a>
        <div>
            <img th:src="${douban.poster}"
                alt="avatar">
            <span th:text="${douban.type}"></span>
            <span th:text="${douban.score}"></span>
        </div>
    </div>
</th:block>

listByType(page, size, type)

描述

根据类型和分页参数获取豆瓣内容。

参数

  • page: int - 分页页码,从 1 开始
  • size: int - 分页条数
  • type: string - 类型

返回值

ListResult

示例

<th:block th:with="doubans = ${doubanFinder.listByType(1, 10,'movie')}">
    <div th:each="douban : ${doubans.items}">
        <a th:href="${douban.link}" target="_blank" th:text="${douban.name}"></a>
        <div>
            <img th:src="${douban.poster}"
                alt="avatar">
            <span th:text="${douban.type}"></span>
            <span th:text="${douban.score}"></span>
        </div>
    </div>
</th:block>

list(page, size, type, status)

描述

根据类型和状态和分页参数获取豆瓣内容。

参数

  • page: int - 分页页码,从 1 开始
  • size: int - 分页条数
  • type: string - 类型
  • status: string - 状态

返回值

ListResult

示例

<th:block th:with="doubans = ${doubanFinder.list(1, 10,'movie','done')}">
    <div th:each="douban : ${doubans.items}">
        <a th:href="${douban.link}" target="_blank" th:text="${douban.name}"></a>
        <div>
            <img th:src="${douban.poster}"
                alt="avatar">
            <span th:text="${douban.type}"></span>
            <span th:text="${douban.score}"></span>
        </div>
    </div>
</th:block>

list(type, status)

描述

根据类型和状态获取豆瓣内容。

参数

  • type: string - 类型
  • status: string - 状态

返回值

DoubanMovieData

示例

<th:block th:with="doubans = ${doubanFinder.list('movie','done')}">
    <div th:each="douban : ${doubans}">
        <a th:href="${douban.link}" target="_blank" th:text="${douban.name}"></a>
        <div>
            <img th:src="${douban.poster}"
                alt="avatar">
            <span th:text="${douban.type}"></span>
            <span th:text="${douban.score}"></span>
        </div>
    </div>
</th:block>

类型定义

DoubanMovieData

{
  "id": "string",                    // 唯一标识
  "creationTimestamp": "Instant",    // 创建时间
  "name": "string",                  // 标题
  "poster": "string",                // 封面
  "link": "string",                  // 链接
  "doubanId": "string",              // 豆瓣 ID
  "score": "string",                 // 评分
  "year": "string",                  // 年份
  "type": "string",                  // 类型
  "pubdate": "string",               // 发布时间
  "cardSubtitle": "string",          // 描述
  "dataType": "string",              // 数据类型
  "genres": "Set<string>",           // 种类
  "favesRemark": "string",           // 我的短评
  "favesCreateTime": "Instant",      // 观看时间
  "favesScore": "string",            // 我的评分
  "favesStatus": "string"            // 状态
}

DoubanTypeVo

{
  "name": "string",                                     // 名称
  "key": "string",                                      // 类型
  "doubanCount": "Integer",                             // 豆瓣数
}

DoubanGenresVo

{
  "name": "string",                                      // 种类
  "doubanCount": "Integer",                              // 豆瓣数
}