model

package
Version: v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2021 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Username = `aoangc`
)

Functions

func GetKey

func GetKey() [16]byte
func Header(tag string) string

func LoadConfig

func LoadConfig()

func Pagination

func Pagination(current, total, count int64) string

func SwitchMode

func SwitchMode(mode string) string

func UpdateKey

func UpdateKey() [16]byte

Types

type Configuration

type Configuration struct {
	Database        string `json:"database"`         // pg sqlite 目前仅支持,看编译的啥,数据库地址
	Domain          string `json:"domain"`           // 域名,如果不填写,默认为监听地址
	ListenAddr      string `json:"listen_addr"`      // 监听地址,默认为 :8088
	DataFolder      string `json:"data_folder"`      // 数据文件夹 默认 /data/memo/
	LogLevel        string `json:"log_level"`        // log 等级
	TelegramID      int64  `json:"telegram_id"`      // 用户的 Telegram ID
	TelegramToken   string `json:"telegram_token"`   // telegram bot token
	TelegramWebhook string `json:"telegram_webhook"` // 默认地址 /api/v1/telegram/bot/webhook

	Token struct {
		AutoUpdate uint32 `json:"auto_update"` // 自动更新 key 的时间,单位 分钟。为零不自动更新
		Preview    uint32 `json:"preview"`     // 预览的有效时间。为零不过期
		View       uint32 `json:"view"`        // 阅读的有效时间
		Share      uint32 `json:"share"`       // 分享的有效时间
	} `json:"token"`
}
var Conf Configuration

func (Configuration) DSN

func (c Configuration) DSN() string

func (Configuration) IsPostgreSQL

func (c Configuration) IsPostgreSQL() bool

func (Configuration) IsSQLite

func (c Configuration) IsSQLite() bool

func (Configuration) IsWebhook

func (c Configuration) IsWebhook() bool

func (Configuration) LogFolder

func (c Configuration) LogFolder() string

func (Configuration) StaticFolder

func (c Configuration) StaticFolder() string

func (Configuration) TemplatesFolder

func (c Configuration) TemplatesFolder() string

func (Configuration) Webhook

func (c Configuration) Webhook() string

type Input

type Input struct {
	ID        uint64         `gorm:"primaryKey" json:"id" `
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`

	MessageID int
	Content   string `json:"content"` // 内容
}

type Mode

type Mode string
const (
	ModeInput  Mode = "输入模式"
	ModeSearch Mode = "搜索模式"
)

func (Mode) String

func (m Mode) String() string

type Note

type Note struct {
	ID        uint64         `gorm:"primaryKey" json:"id" `
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
	Title     string         `json:"title"`   // 标题
	Content   string         `json:"content"` // 内容
}

func NewNote

func NewNote(text string) *Note

NewNote 标题规则 如果设置了标题,默认为第一行作为标题,超过 32 个字符的,认定为无标题

func (*Note) Description

func (n *Note) Description() string

func (*Note) HTML

func (n *Note) HTML() template.HTML

func (*Note) InlineQueryResultArticle

func (n *Note) InlineQueryResultArticle() dandelion.InlineQueryResultArticle

func (*Note) List

func (n *Note) List() string
func (n *Note) MarkdownLink() string

func (*Note) ParticipleContent

func (n *Note) ParticipleContent() string

func (*Note) ParticipleTitle

func (n *Note) ParticipleTitle() string
func (n *Note) PreviewLink() string
func (n *Note) ShareLink() string
func (n *Note) ViewLink() string

type Token

type Token struct {
	Type   Type // 预览草稿箱,阅读文章,分享
	NoteID uint64
	Time   time.Time
}

func NewToken

func NewToken(t Type, noteID uint64) Token

func ParseToken

func ParseToken(s string) *Token

func (Token) String

func (t Token) String() string

func (Token) Valid

func (t Token) Valid() bool

type Type

type Type uint8
const (
	None Type = iota
	Preview
	View
	Share
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL