mdnotify

package module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

README

md-notify(开发中)

按照文件夹监控markdown文档变化,提供列表,检索,markdown文档内容接口 因为要写一个博客系统替换之前的wordpress博客,原因是wordpress太重。 目标是需要一个不依赖数据库,简单运行即可,前后端分离,复制即迁移的轻量级博客系统。wordpress显然无法满足需求。要实现markdown文件变更实时更新前台浏览必须有一个对markdown文档统一管理的组件。也就是本项目的最终目标。

预计支持的特性
  • 提供文档列表接口(按序号)
  • 提供文档列表接口(按类型)
  • 提供分类列表
  • 提供文档内容接口
  • 按照标签筛选接口
预计支持的markdown标签

markdown标签和内容使用[content]进行分隔,类似section,比如下面的结构

title=1
sub_title=副标题
image=1.jpg
other=3
[content]
这里开始是markdown文档开始部分

默认支持的标签如下,尽量简短

标签 说明
title 标题
class 分类
sort 排序号
class 分类

默认标签是必填的,当然标签允许自定义,所有自定义标签都会使用倒排索引优化。标签数量不做限制

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MarkDown

type MarkDown struct {
	Id         string
	FileName   string
	LastUpdate int64
	Content    inter_struct.Content
}

func (*MarkDown) Load

func (md *MarkDown) Load(file *os.File) *MarkDown

读取markdown

func (*MarkDown) MarkdownContent

func (md *MarkDown) MarkdownContent() []byte

func (*MarkDown) ParseContent

func (md *MarkDown) ParseContent(bytes []byte) inter_struct.Content

type MdManager

type MdManager struct {
	Papers     map[string]*MarkDown        // 使用文件名md5作为key
	SortIndex  []string                    // 排序号对应文件名md5,可能多个
	TitleIndex map[string]string           // 标题倒排索引
	ClassIndex map[string]map[string]uint8 // 类别倒排索引
	// contains filtered or unexported fields
}

func (*MdManager) AllMarkdownFile

func (mdm *MdManager) AllMarkdownFile() ([]os.FileInfo, error)

func (*MdManager) InitAllMarkdown

func (mdm *MdManager) InitAllMarkdown() (*MdManager, error)

func (*MdManager) ListByClass

func (mdm *MdManager) ListByClass(value string, start int, len int) []MarkDown

func (*MdManager) ListMarkDown

func (mdm *MdManager) ListMarkDown() []MarkDown

func (*MdManager) MarkdownContent

func (mdm *MdManager) MarkdownContent(id string) string

func (MdManager) New

func (mdm MdManager) New(folder string) *MdManager

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL