必要说明:
- 主题开发好了,需要放在 下,系统启动会自动读取主题目录,然后在后台就可以选择你想要的主题了
- 如果你不是开发环境,那需要将开发好的或者下载的主题文件夹放在
pybbs.jar
所在目录下的templates/theme
文件夹下,如果这两个文件夹没有,需要你创建好 - 开发主题肯定需要引入样式,建议使用
cdnjs.com
的外链,但也有一些对系统内的样式,这个样式文件需要放在pybbs.jar
目录所在文件夹下的templates/static/theme/css
文件夹下,js同理
主题必备目录有以下几个
必备的文件有如下
simple
├── comment
│ └── edit.ftl
├── error.ftl
├── index.ftl
├── login.ftl
├── notifications.ftl
├── register.ftl
├── search.ftl
├── tag
│ ├── tag.ftl
│ └── tags.ftl
├── top100.ftl
├── topic
│ ├── create.ftl
│ ├── detail.ftl
│ └── edit.ftl
└── user
├── collects.ftl
├── profile.ftl
├── settings.ftl
└── topics.ftl
注意,上面列出来的文件夹和文件都是必备的
全局对象
通俗点说就是在所有页面里都能取到的数据的对象,有如下几个
String formatContent(String content);
Set<String> getUpIds(String upIds);
boolean isEmpty(String txt);
site对象中的属性
在页面里取site里的属性方法 ${site.name!}
属性的类型全都是 String,可根据自己需要将值转成 int 或者 boolean
i18n对象中的属性
在页面中获取的方法是 ${i18n.getMessage("index")}
在标签返回对象里有一些不是定义的model里的对象,而是Map封装的对象,这些map里都有啥呢?
标签 tag_topics 对象中的Map包含的字段
- Topic t.*: Topic对象里的所有字段
- username: 用户名
- avatar: 用户头像
标签 tag_notifications 对象中的Map包含的字段
- Notification n.*: Notification对象里的所有字段
- username: 用户名
- avatar: 用户头像
- title: 话题标题
- topicId: 话题ID
- id: 话题ID
- title: 话题标题
- content: 话题内容
标签 tag_user_topics 对象中的Map包含的字段
- Topic t.*: Topic对象里的所有字段
- username: 用户名
- avatar: 用户头像
标签 tag_user_comments 对象中的Map包含的字段
- Comment c.*: Comment对象里的所有字段
- topicUsername: 话题的用户名
- commentUsername: 话题的用户名
- title: 话题标题
- topicId: 话题ID
标签 tag_user_collects 对象中的Map包含的字段
- Topic t.*: Topic对象里的所有字段
- username: 用户名
- avatar: 用户头像
自定义标签使用
自定义标签用法很简单,不会用的话,可以参考已经存在的主题里的用法,下面说一下首页的 tag_topics 标签的用法
至于标签里返回的对象都是什么东西,下面介绍,先说说每个路由渲染的页面里都能取出什么东西吧
对象包含的字段
分页对象 Page
这个对象是Mybatis-Plus里封装的,常用字段有以下几个
- List records: 查询出来的列表放在这个里面,类型是个List
- long current: 当前是第几页,从1开始
- long total: 总条数
- long pages: 总页数
- long size: 每页显示条数
private Integer id;
private String username;
private String telegramName;
private String avatar;
private String password;
private String email;
// 个人网站
private String website;
// 个人简介
private Integer score;
private Date inTime;
private String token;
// 有消息通知是否通过邮箱收取
private Boolean emailNotification;
// 帐号的激活状态
private Boolean active;
话题对象 Topic
private Integer id;
private String title;
private String content;
private Date inTime;
private Date modifyTime;
private Integer userId;
private Integer commentCount;
// 收藏数
private Integer collectCount;
// 浏览数
private Integer view;
// 置顶
private Boolean top;
// 加精
private Boolean good;
// 点赞用户的id英文,隔开的,要计算被多少人点赞过,可以通过英文,分隔这个字符串计算数量
private String upIds;
评论对象 Comment
评论(盖楼)对象 CommentsByTopic
// 话题下面的评论列表单个对象的数据结构
public class CommentsByTopic extends Comment implements Serializable {
private String username;
private String avatar;
// 评论的层级,直接评论话题的,layer即为0,如果回复了评论的,则当前回复的layer为评论对象的layer+1
private Integer layer;
}
通知对象 Notification
private Integer id;
private Integer topicId;
private Integer userId;
// 通知对象ID
private Integer targetUserId;
// 动作: REPLY, COMMENT, COLLECT, TOPIC_UP, COMMENT_UP
private String action;
private Date inTime;
private String content;