Versions in this module Expand all Collapse all v1 v1.0.0 Mar 19, 2024 Changes in this version + const PublicAuthKey + var ErrPermission = os.ErrPermission + var ErrTimeout = errors.New("timeout") + var FaceBook = "facebook" + var Twitter = "twitter" + var WeChat = "wechat" + func CasdoorConfigInit() + type Account struct + type AppConfig struct + Debug bool + EndPoint string type Article + Trans bool + VttId string type ArticleEntry + Abstract string + Cover string + Label string + LikeCount int + PlatformCount []PlatformCount + Tags string + UId string + User User + ViewCount int + type ArticleLike struct + ArticleId int + Id int + UserId int + type CasdoorConfig struct + ApplicationName string + Certificate string + ClientId string + ClientSecret string + EndPoint string + OrganizationName string + type CasdoorSDKService interface + GetApplication func(name string) (*casdoorsdk.Application, error) + GetOAuthToken func(code string, state string) (token *oauth2.Token, err error) + GetUser func(name string) (user *casdoorsdk.User, err error) + GetUserById func(uid string) (user *casdoorsdk.User, err error) + GetUserByUserId func(uid string) (user *casdoorsdk.User, err error) + GetUserClaim func(uid string) (claim *casdoorsdk.User, err error) + GetUsers func() ([]*casdoorsdk.User, error) + ParseJwtToken func(token string) (claims *casdoorsdk.Claims, err error) + UpdateCasdoorUserById func(uid string, user *casdoorsdk.User) (res bool, err error) + UpdateUser func(user *UserInfo) (res bool, err error) + UpdateUserById func(uid string, user *UserInfo) (res bool, err error) + type CasdoorSDKServiceAdapter struct + func (c *CasdoorSDKServiceAdapter) GetApplication(name string) (*casdoorsdk.Application, error) + func (c *CasdoorSDKServiceAdapter) GetOAuthToken(code string, state string) (token *oauth2.Token, err error) + func (c *CasdoorSDKServiceAdapter) GetUser(name string) (user *casdoorsdk.User, err error) + func (c *CasdoorSDKServiceAdapter) GetUserById(uid string) (user *casdoorsdk.User, err error) + func (c *CasdoorSDKServiceAdapter) GetUserByUserId(uid string) (user *casdoorsdk.User, err error) + func (c *CasdoorSDKServiceAdapter) GetUserClaim(uid string) (claim *casdoorsdk.User, err error) + func (c *CasdoorSDKServiceAdapter) GetUsers() ([]*casdoorsdk.User, error) + func (c *CasdoorSDKServiceAdapter) ParseJwtToken(token string) (claims *casdoorsdk.Claims, err error) + func (c *CasdoorSDKServiceAdapter) UpdateCasdoorUserById(uid string, user *casdoorsdk.User) (res bool, err error) + func (c *CasdoorSDKServiceAdapter) UpdateUser(user *UserInfo) (res bool, err error) + func (c *CasdoorSDKServiceAdapter) UpdateUserById(uid string, user *UserInfo) (res bool, err error) type Community + CasdoorSDKService CasdoorSDKService + S3Service S3Service + func (a *Community) ArticleLView(ctx context.Context, articleId, ip, userId, platform string) + func (c *Community) DelMedia(ctx context.Context, userId, mediaId string) error + func (c *Community) DelMedias(ctx context.Context, userId string, ids []string) error + func (c *Community) GetMediaType(ctx context.Context, mediaId string) (string, error) + func (c *Community) GetMediaUrl(ctx context.Context, mediaId string) (string, error) + func (c *Community) GetVideoDuration(url string) (duration string, err error) + func (c *Community) GetVideoSubtitle(ctx context.Context, mediaId string) (string, string, error) + func (c *Community) ListMediaByUserId(ctx context.Context, userId string, format string, page, limitInt int) ([]File, int, error) + func (c *Community) NewVideoTask(ctx context.Context, userId, resourceId string) error + func (c *Community) RetryCaptionGenerate(ctx context.Context, userId, videoId string) error + func (c *Community) SaveMedia(ctx context.Context, userId string, data []byte, fileExt string) (int64, error) + func (c *Community) SetVideoTaskCache(key string, value VideoTaskTimestamp) + func (c *Community) SetVideoTaskFailed(ctx context.Context, resourceId string) error + func (c *Community) SetVideoTaskOutput(ctx context.Context, resourceId string, output string) error + func (c *Community) SetVideoTaskSuccess(ctx context.Context, resourceId string) error + func (c *Community) TimedCheckVideoTask(ctx context.Context, timeout time.Duration) + func (p *Community) ArticleLike(ctx context.Context, articleId int, userId string) (bool, error) + func (p *Community) ArticleLikeState(ctx context.Context, userId, articleId string) (bool, error) + func (p *Community) GetAccessToken(code, state string) (token *oauth2.Token, err error) + func (p *Community) GetApplicationInfo() (*casdoorsdk.Application, error) + func (p *Community) GetArticlesByUid(ctx context.Context, uid string, page string, limit int) (items []*ArticleEntry, next string, err error) + func (p *Community) GetClientIP(r *http.Request) string + func (p *Community) GetOAuthToken(code string, state string) (token *oauth2.Token, err error) + func (p *Community) GetTranslateArticle(ctx context.Context, id string) (article *Article, err error) + func (p *Community) GetUser(token string) (user *User, err error) + func (p *Community) GetUserAuthById(uid string) (user *UserAuth, err error) + func (p *Community) GetUserById(uid string) (user *User, err error) + func (p *Community) GetUserClaim(uid string) (claim *casdoorsdk.User, err error) + func (p *Community) IsAdmin(uid string) (res bool, err error) + func (p *Community) ListPageUsers(from, limit int) (users []*UserAuth, next int, err error) + func (p *Community) ParseJwtToken(token string) (userId string, err error) + func (p *Community) RedirectToCasdoor(redirect string) (loginURL string) + func (p *Community) Share(ip, platform, userId, articleId string) + func (p *Community) TranslateArticle(ctx context.Context, inputArticle *Article) (translatedArticle *Article, err error) + func (p *Community) TranslateMarkdownText(ctx context.Context, src string, from string, to language.Tag) (string, error) + func (p *Community) UpdateUser(user *UserInfo) (res bool, err error) + func (p *Community) UpdateUserById(uid string, user *UserInfo) (res bool, err error) + func (p *Community) UpdateUserPublicAuth(uid string, publicAuth bool) (res bool, err error) type Config + AppConfig AppConfig + CasdoorConfig CasdoorConfig + DBConfig DBConfig + QiNiuConfig QiNiuConfig + func NewConfigFromEnv() *Config + type DBConfig struct + DSN string + Driver string + type File struct + CreateAt time.Time + Duration *string + FileKey string + Format string + Id int + Size int64 + UpdateAt time.Time + UserId string + Vtt string + type PlatformCount struct + ArticleId string + Platform string + ViewCount string + type QiNiuConfig struct + AccessKey string + BlobUS string + Domain string + SecretKey string + TranslationKey string + type S3Reader interface + Close func() error + ContentType func() string + Read func(p []byte) (int, error) + Size func() int64 + type S3Service interface + Delete func(ctx context.Context, key string) (err error) + NewReader func(ctx context.Context, key string, opts *blob.ReaderOptions) (_ S3Reader, err error) + NewWriter func(ctx context.Context, key string, opts *blob.WriterOptions) (_ S3Writer, err error) + type S3ServiceAdapter struct + func (s *S3ServiceAdapter) Delete(ctx context.Context, key string) (err error) + func (s *S3ServiceAdapter) NewReader(ctx context.Context, key string, opts *blob.ReaderOptions) (_ S3Reader, err error) + func (s *S3ServiceAdapter) NewWriter(ctx context.Context, key string, opts *blob.WriterOptions) (_ S3Writer, err error) + type S3Writer interface + Close func() error + Write func(p []byte) (n int, err error) + type Translation struct + Engine *translation.Engine + VideoTaskCache *VideoTaskCache + type User struct + Avatar string + Id string + Name string + Password string + type UserAuth struct + Avatar string + Id string + Name string + Owner string + Status bool + type UserClaim casdoorsdk.Claims + type UserInfo casdoorsdk.User + type VideoSubtitle struct + Language string + SubtitleId int + UserId int + VideoId int + type VideoTask struct + CreateAt time.Time + Id int + Output string + ResourceId string + Status int + TaskId string + UpdateAt time.Time + UserId string + type VideoTaskCache struct + func NewVideoTaskCache() *VideoTaskCache + func (c *VideoTaskCache) Clear() + func (c *VideoTaskCache) Delete(key string) + func (c *VideoTaskCache) Get(key string) (VideoTaskTimestamp, bool) + func (c *VideoTaskCache) Set(key string, value VideoTaskTimestamp) + type VideoTaskMap map[string]VideoTaskTimestamp + type VideoTaskTimestamp int64 v1.0.0-beta.2 Mar 14, 2024 v1.0.0-beta.1 Mar 14, 2024 v1.0.0-beta Mar 14, 2024 v0 v0.2.0 Jan 18, 2024 Changes in this version + const MarkBegin + const MarkEnd + var ErrNotExist = os.ErrNotExist + type Article struct + Content string + type ArticleEntry struct + Ctime time.Time + ID string + Mtime time.Time + Title string + type Community struct + func New(ctx context.Context, conf *Config) (ret *Community, err error) + func (p *Community) Article(ctx context.Context, id string) (article *Article, err error) + func (p *Community) CanEditable(ctx context.Context, uid, id string) (editable bool, err error) + func (p *Community) DeleteArticle(ctx context.Context, uid, id string) (err error) + func (p *Community) DeleteMedia(ctx context.Context, uid, id string) (err error) + func (p *Community) ListArticle(ctx context.Context, from string, limit int) (items []*ArticleEntry, next string, err error) + func (p *Community) MediaURL(id string) (url string) + func (p *Community) PutArticle(ctx context.Context, uid string, article *Article) (id string, err error) + func (p *Community) PutMedia(ctx context.Context, uid string, media []byte) (id string, err error) + type Config struct + BlobUS string + DSN string + Driver string