blog

package
v0.0.0-...-1694169 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: MIT Imports: 16 Imported by: 0

README

Blog module

A simple blog module for darkstorm-backend.

Requests

Author info
Get author info

GET /author/{authorID}

{
  id: "authorID",
  name: "author name",
  about: "about",
  picurl: "picture URL"
}
Update author info

POST /author/{authorID}

Must have a auth token for a user with the "blog": "admin" permission.

{
  name: "author name",
  about: "about",
  picurl: "picture url"
}
Add Author info

POST /author

Must have a auth token for a user with the "blog": "admin" permission.

{
  name: "author name",
  about: "about",
  picurl: "picture URL"
}
Blog
Specific blog

GET /blog/{blogID}

Return:

{
  id: "blogID",
  staticPage: false, // static pages don't show up alongside other blog pages.
  createTime: 0, // creation time in Unix format
  updateTime: 0, // last update time in Unix format
  author: "authorID",
  favicon: "favicon url",
  title: "blog title",
  blog: "blog", // blog will have been converted to HTML
}
Create blog

Request:

POST /blog

Must have a auth token for a user with the "blog": "admin" permission.

{
  favicon: "favicon url",
  title: "blog title",
  blog: "blog", // blog will have been converted to HTML
}

Return:

{
  id: "blogID"
}
Update blog

Request:

POST /blog/{blogID}

Must have a auth token for a user with the "blog": "admin" permission.

{
  favicon: "new icon",
  title: "new title",
  blog: "new blog content"
}
Latest blogs

GET /blog?page=0

Will return up to 5 blogs. page query is optional (implies 0 if not set).

Return:

{
  num: 1, // Number of returned results, returns up to 5 results
  blogs: [
    {
      id: "blogID",
      createTime: 0, // creation time in Unix format
      updateTime: 0, // last update time in Unix format
      author: "authorID",
      favicon: "favicon url",
      title: "blog title",
      blog: "blog", // blog will have been converted to HTML
    }
    ...
  ]
}
Blog List

GET /blog/list?page=0

Will return up to 50 IDs. page query is optional (implies 0 if not set).

Return:

{
  num: 1, // Number of returned results, returns up to 50 results
  blogList: [
    {
      id: "blogID",
      createTime: 0, // Unix format
    },
    {
      id: "blogID",
      createTime: 0, // Unix format
    },
    ...
  ]
}
Portfolio
Get Projects

GET: /portfolio?lang=go

Return:

[
  {
    title: "Darkstorm Server",
    order: 0,
    repository: "https://github.com/CalebQ42/darkstorm-server",
    description: "The backend that runs runs my website and APIs",
    technologies: [ // May be empty
      "MongoDB",
      "RESTful API"
    ],
    language: [
      {
        language: "go",
        dates: "September 2021"
      }
    ]
  }
]

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Author

type Author struct {
	ID     string `json:"id" bson:"_id"`
	Name   string `json:"name" bson:"name"`
	About  string `json:"about" bson:"about"`
	PicURL string `json:"picurl" bson:"picurl"`
}

func (Author) HTML

func (a Author) HTML() string

type Blog

type Blog struct {
	ID         string `json:"id" bson:"_id"`
	Author     string `json:"author" bson:"author"`
	Favicon    string `json:"favicon" bson:"favicon"`
	Title      string `json:"title" bson:"title"`
	RawBlog    string `json:"blog" bson:"blog"`
	HTMLBlog   string `json:"-" bson:"-"`
	StaticPage bool   `json:"staticPage" bson:"staticPage"`
	Draft      bool   `json:"draft" bson:"draft"`
	CreateTime int64  `json:"createTime" bson:"createTime"`
	UpdateTime int64  `json:"updateTime" bson:"updateTime"`
}

func (*Blog) HTMX

func (b *Blog) HTMX(blogApp *BlogApp, ctx context.Context) string

type BlogApp

type BlogApp struct {
	// contains filtered or unexported fields
}

func NewBlogApp

func NewBlogApp(db *mongo.Database) *BlogApp

func (*BlogApp) AboutMe

func (b *BlogApp) AboutMe(ctx context.Context) (*Author, error)

func (*BlogApp) AddBackend

func (b *BlogApp) AddBackend(back *backend.Backend)

func (*BlogApp) AllBlogsList

func (b *BlogApp) AllBlogsList(ctx context.Context) ([]BlogListResult, error)

func (*BlogApp) AnyBlog

func (b *BlogApp) AnyBlog(ctx context.Context, ID string) (*Blog, error)

func (*BlogApp) AppID

func (b *BlogApp) AppID() string

func (*BlogApp) Blog

func (b *BlogApp) Blog(ctx context.Context, ID string) (*Blog, error)

func (*BlogApp) BlogList

func (b *BlogApp) BlogList(ctx context.Context, page int64) ([]BlogListResult, error)

func (*BlogApp) CleanCache

func (b *BlogApp) CleanCache(ID string)

func (*BlogApp) Contains

func (b *BlogApp) Contains(ctx context.Context, ID string) bool

func (*BlogApp) ConvertBlog

func (b *BlogApp) ConvertBlog(blog *Blog)

func (*BlogApp) CountTable

func (b *BlogApp) CountTable() backend.CountTable

func (*BlogApp) CrashTable

func (b *BlogApp) CrashTable() backend.CrashTable

func (*BlogApp) Extension

func (b *BlogApp) Extension(mux *http.ServeMux)

func (*BlogApp) GetAuthor

func (b *BlogApp) GetAuthor(ctx context.Context, blog *Blog) (*Author, error)

func (*BlogApp) InsertBlog

func (b *BlogApp) InsertBlog(ctx context.Context, blog Blog) error

func (*BlogApp) LatestBlogs

func (b *BlogApp) LatestBlogs(ctx context.Context, page int64) ([]*Blog, error)

func (*BlogApp) Projects

func (b *BlogApp) Projects(ctx context.Context, techFilter string) (Portfolio, error)

func (*BlogApp) RemoveBlog

func (b *BlogApp) RemoveBlog(ctx context.Context, ID string) error

func (*BlogApp) UpdateBlog

func (b *BlogApp) UpdateBlog(ctx context.Context, ID string, updates bson.M) error

type BlogListResult

type BlogListResult struct {
	ID         string `json:"id" bson:"_id"`
	Title      string `json:"title" bson:"title"`
	CreateTime int    `json:"createTime" bson:"createTime"`
}

func (BlogListResult) HTMX

func (b BlogListResult) HTMX() string

type Portfolio

type Portfolio []PortfolioProject

func (Portfolio) FullHTMX

func (p Portfolio) FullHTMX(ctx context.Context, blogApp *BlogApp, selectedTech string) string

func (Portfolio) HTMX

func (p Portfolio) HTMX() string

type PortfolioProject

type PortfolioProject struct {
	Title        string   `json:"_id" bson:"_id"`
	Order        int      `json:"order" bson:"order"`
	Repository   string   `json:"repository" bson:"repository"`
	Description  string   `json:"description" bson:"description"`
	Technologies []string `json:"technologies" bson:"technologies"`
	Languages    []struct {
		Language string `json:"language" bson:"language"`
		Dates    string `json:"dates" bson:"dates"`
	} `json:"language" bson:"language"`
}

func (PortfolioProject) HTMX

func (p PortfolioProject) HTMX() string

Jump to

Keyboard shortcuts

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