bookstackclient

package
v0.0.0-...-b5ae77a Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchPageMarkdown

func FetchPageMarkdown(app *config.Application, pageID int) ([]byte, error)

FetchPageMarkdown hits the /api/pages/<pageid>/export/markdown endpoint and returns a byte slice with APP_URL replaed by a /

Types

type Book

type Book struct {
	ID          int       `json:"id"`
	Name        string    `json:"name"`
	Slug        string    `json:"slug"`
	Description string    `json:"description"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	CreatedBy   struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
	} `json:"created_by"`
	UpdatedBy struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
	} `json:"updated_by"`
	OwnedBy struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
	} `json:"owned_by"`
	Tags []struct {
		ID    int    `json:"id"`
		Name  string `json:"name"`
		Value string `json:"value"`
		Order int    `json:"order"`
	} `json:"tags"`
	Cover struct {
		ID         int       `json:"id"`
		Name       string    `json:"name"`
		URL        string    `json:"url"`
		CreatedAt  time.Time `json:"created_at"`
		UpdatedAt  time.Time `json:"updated_at"`
		CreatedBy  int       `json:"created_by"`
		UpdatedBy  int       `json:"updated_by"`
		Path       string    `json:"path"`
		Type       string    `json:"type"`
		UploadedTo int       `json:"uploaded_to"`
	} `json:"cover"`
}

Book represents the BookStack API endpoint /api/books/{id}

type Books

type Books struct {
	Data []struct {
		ID          int       `json:"id"`
		Name        string    `json:"name"`
		Slug        string    `json:"slug"`
		Description string    `json:"description"`
		CreatedAt   time.Time `json:"created_at"`
		UpdatedAt   time.Time `json:"updated_at"`
		CreatedBy   int       `json:"created_by"`
		UpdatedBy   int       `json:"updated_by"`
		OwnedBy     int       `json:"owned_by"`
		ImageID     int       `json:"image_id"`
	} `json:"data"`
	Total int `json:"total"`
}

Books represents the BookStack API endpoint /api/books

func FetchBooks

func FetchBooks(app *config.Application) (Books, error)

FetchBooks returns all the books in the wiki sorted by name.

type Chapter

type Chapter struct {
	ID          int       `json:"id"`
	BookID      int       `json:"book_id"`
	Slug        string    `json:"slug"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	Priority    int       `json:"priority"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	CreatedBy   struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
	} `json:"created_by"`
	UpdatedBy struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
	} `json:"updated_by"`
	OwnedBy struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
	} `json:"owned_by"`
	Tags []struct {
		Name  string `json:"name"`
		Value string `json:"value"`
		Order int    `json:"order"`
	} `json:"tags"`
	Pages []struct {
		ID            int       `json:"id"`
		BookID        int       `json:"book_id"`
		ChapterID     int       `json:"chapter_id"`
		Name          string    `json:"name"`
		Slug          string    `json:"slug"`
		Priority      int       `json:"priority"`
		CreatedAt     time.Time `json:"created_at"`
		UpdatedAt     time.Time `json:"updated_at"`
		CreatedBy     int       `json:"created_by"`
		UpdatedBy     int       `json:"updated_by"`
		Draft         bool      `json:"draft"`
		RevisionCount int       `json:"revision_count"`
		Template      bool      `json:"template"`
	} `json:"pages"`
}

Chapter represents the BookStack API endpoint /api/chapters/{id}

type Chapters

type Chapters struct {
	Data []struct {
		ID          int       `json:"id"`
		BookID      int       `json:"book_id"`
		Name        string    `json:"name"`
		Slug        string    `json:"slug"`
		Description string    `json:"description"`
		Priority    int       `json:"priority"`
		CreatedAt   string    `json:"created_at"`
		UpdatedAt   time.Time `json:"updated_at"`
		CreatedBy   int       `json:"created_by"`
		UpdatedBy   int       `json:"updated_by"`
		OwnedBy     int       `json:"owned_by"`
	} `json:"data"`
	Total int `json:"total"`
}

Chapters represents the BookStack API endpoint /api/chapters

func FetchChapters

func FetchChapters(app *config.Application, bookID int) (Chapters, error)

FetchChapters returns all the chapters of a book sorted by priority.

func FetchPages

func FetchPages(app *config.Application, bookID int, chapterID int) (Chapters, error)

FetchPages returns pages sorted by priority. If chapterID = 0 then it returns independent (non chapter) pages of the book. If chapterID != 0 then it returns pages of the chapter.

type Page

type Page struct {
	ID        int       `json:"id"`
	BookID    int       `json:"book_id"`
	ChapterID int       `json:"chapter_id"`
	Name      string    `json:"name"`
	Slug      string    `json:"slug"`
	HTML      string    `json:"html"`
	Priority  int       `json:"priority"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	CreatedBy struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
	} `json:"created_by"`
	UpdatedBy struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
	} `json:"updated_by"`
	OwnedBy struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
	} `json:"owned_by"`
	Draft         bool   `json:"draft"`
	Markdown      string `json:"markdown"`
	RevisionCount int    `json:"revision_count"`
	Template      bool   `json:"template"`
	Tags          []struct {
		Name  string `json:"name"`
		Value string `json:"value"`
		Order int    `json:"order"`
	} `json:"tags"`
}

Page represents the BookStack API endpoint /api/pages/{id}

type Pages

type Pages struct {
	Data []struct {
		ID        int       `json:"id"`
		BookID    int       `json:"book_id"`
		ChapterID int       `json:"chapter_id"`
		Name      string    `json:"name"`
		Slug      string    `json:"slug"`
		Priority  int       `json:"priority"`
		Draft     bool      `json:"draft"`
		Template  bool      `json:"template"`
		CreatedAt time.Time `json:"created_at"`
		UpdatedAt time.Time `json:"updated_at"`
		CreatedBy int       `json:"created_by"`
		UpdatedBy int       `json:"updated_by"`
		OwnedBy   int       `json:"owned_by"`
	} `json:"data"`
	Total int `json:"total"`
}

Pages represents the BookStack API endpoint /api/pages

type Shelf

type Shelf struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Slug        string `json:"slug"`
	Description string `json:"description"`
	CreatedBy   struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
	} `json:"created_by"`
	UpdatedBy struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
	} `json:"updated_by"`
	OwnedBy struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
	} `json:"owned_by"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	Tags      []struct {
		ID    int    `json:"id"`
		Name  string `json:"name"`
		Value string `json:"value"`
		Order int    `json:"order"`
	} `json:"tags"`
	Cover struct {
		ID         int       `json:"id"`
		Name       string    `json:"name"`
		URL        string    `json:"url"`
		CreatedAt  time.Time `json:"created_at"`
		UpdatedAt  time.Time `json:"updated_at"`
		CreatedBy  int       `json:"created_by"`
		UpdatedBy  int       `json:"updated_by"`
		Path       string    `json:"path"`
		Type       string    `json:"type"`
		UploadedTo int       `json:"uploaded_to"`
	} `json:"cover"`
	Books []struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
		Slug string `json:"slug"`
	} `json:"books"`
}

Shelf represents the BookStack API endpoint /api/shelves/{id}

type Shelves

type Shelves struct {
	Data []struct {
		ID          int       `json:"id"`
		Name        string    `json:"name"`
		Slug        string    `json:"slug"`
		Description string    `json:"description"`
		CreatedAt   time.Time `json:"created_at"`
		UpdatedAt   time.Time `json:"updated_at"`
		CreatedBy   int       `json:"created_by"`
		UpdatedBy   int       `json:"updated_by"`
		OwnedBy     int       `json:"owned_by"`
		ImageID     int       `json:"image_id"`
	} `json:"data"`
	Total int `json:"total"`
}

Shelves represents the BookStack API endpoint /api/shelves

type Wiki

type Wiki struct {
	Name  string
	Books []WikiBook
	// one book can be on multiple shelves
	Shelves []WikiShelf
}

Wiki is the BookStack2Site representation of a Wiki

func FetchWiki

func FetchWiki(app *config.Application) (Wiki, error)

type WikiBook

type WikiBook struct {
	BookID int
	Name   string
	Slug   string
	// a book can have pages in chapters or independent pages
	Chapters   []WikiChapter
	IndiePages []WikiPage
}

type WikiChapter

type WikiChapter struct {
	ChapterID int
	Name      string
	Slug      string
	Priority  int
	Pages     []WikiPage
}

type WikiPage

type WikiPage struct {
	PageID   int
	Name     string
	Slug     string
	Priority int
	// FilePath is path of file relative to root of wiki. To be filled while downloading.
	// Should start with a '/'.
	// Should not end with a '/'.
	FilePath string
}

type WikiShelf

type WikiShelf struct {
	ShelfID int
	Name    string
	Slug    string
	BookIDs []int
}

Jump to

Keyboard shortcuts

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