Documentation ¶
Index ¶
- Constants
- func ActivateUser(email string, token string) error
- func AllPackages(opt *lib.Option, userID uint64) (*[]Package, error)
- func AllPlans() (*[]Plan, error)
- func BulkUpdatePackageSource(ids lib.StringSlice, source string) error
- func CaptureCharge(chargeID string) (*stripe.Charge, error)
- func CopyCreationParamsAndFunctions(id lib.ID, curVersion uint64, newVersion uint64) error
- func CreationInUse(creaID lib.ID) bool
- func CreationLastVersion(id lib.ID) uint64
- func DeleteCreation(uID uint64, creaID lib.ID) error
- func DeletePackage(uID uint64, id lib.ID) error
- func DeletePackageCreation(uID uint64, pkgID lib.ID, creaID lib.ID) error
- func DeleteUser(uID uint64) error
- func IsTokenExpired(err *jwt.ValidationError) bool
- func IsTokenInvalid(err *jwt.ValidationError) bool
- func IsTokenMalformed(err *jwt.ValidationError) bool
- func NewCreationVersion(crea *Creation, newVersion uint64) error
- func NewCustomer(custEmail string, plan string, token string) (*stripe.Customer, error)
- func NewOrGetTag(tag *Tag)
- func NewPackageCreation(pkgID lib.ID, creaID lib.ID, version uint64, alias string) error
- func NewPackageCreationParam(pkgID lib.ID, creaID lib.ID, version uint64) error
- func NewPlanUser(uID uint64, planLabel string, periodEnd int64) (id uint64, err error)
- func NewToken(user *User, refreshToken string) *jwt.Token
- func NewUser(user *User) (uID uint64, err error)
- func PackageNbCrea(id lib.ID) uint64
- func RefreshToken(token *jwt.Token) (*jwt.Token, error)
- func RegisterBank(email string, token string) (*stripe.Account, error)
- func RenewUserPlan(custID string, startDate int64, endDate int64) error
- func SafeDeleteCreation(uID uint64, creaID lib.ID) error
- func SafeDeleteUser(uID uint64) error
- func SendActivationEmail(name string, to string) error
- func SubCustomer(custID string, plan string, token string) (*stripe.Sub, error)
- func TokenKey() []byte
- func UnsubCustomer(custID string) error
- func UnsubUserPlan(planID uint64) error
- func UpdateCreation(crea *Creation) error
- func UpdateCreationFunctions(crea *Creation) error
- func UpdateCreationParams(crea *Creation) error
- func UpdateCreationPatch(uID uint64, creaID lib.ID, patch lib.SQLPatch) error
- func UpdateCreationTags(crea *Creation) (err error)
- func UpdateCustomerID(uID uint64, customerID string) error
- func UpdatePackage(pkg *Package) error
- func UpdatePackageCreation(pkg *Package) error
- func UpdatePackagePatch(uID uint64, pkgID lib.ID, patch lib.SQLPatch) error
- func UpdateUserAccountID(uID uint64, accID string) error
- func UpdateUserPatch(uID uint64, patch lib.SQLPatch) error
- func UserCustomerID(uID uint64) (string, error)
- func UserNbPackages(uID uint64) int64
- func UserSubFund(uID uint64, amount uint64) error
- type Creation
- func AllCreations(opt lib.Option, uID uint64) ([]Creation, error)
- func AllDraftCreations(opt lib.Option, uID uint64) ([]Creation, error)
- func AllPopularCreations(opt lib.Option, uID uint64) ([]Creation, error)
- func AllUsedCreations(opt lib.Option, uID uint64) ([]Creation, error)
- func CreationByID(id lib.ID, uID uint64, latestVersion bool) (*Creation, error)
- func CreationByIDAndVersion(id lib.ID, version uint64) (*Creation, error)
- func NewCreation(crea *Creation) (*Creation, error)
- func (c *Creation) GenerateDefaultThumb() ([]byte, string)
- func (c *Creation) PopulateFunctions()
- func (c *Creation) PopulateParams()
- func (c *Creation) PopulatePreviewPositions()
- func (c *Creation) PopulateTags() error
- func (c *Creation) RetrievePreviewURL()
- func (c *Creation) RetrieveSourceCode(version string, files ...string) error
- type CreationFunction
- type CreationParam
- type CustomClaims
- type Element
- type Email
- type Engine
- type Package
- type Plan
- type PreviewPosition
- type Tag
- type User
Constants ¶
const ( Free string = "Visitor" Woobler string = "Woobler" )
Plans label
const BaseVersion uint64 = 1
BaseVersion is creation default version
const TagSeparator string = ","
TagSeparator specifies which character delimites a tag
Variables ¶
This section is empty.
Functions ¶
func ActivateUser ¶
ActivateUser activate user's email if the token is valid
func AllPackages ¶
AllPackages returns all packages
func BulkUpdatePackageSource ¶
func BulkUpdatePackageSource(ids lib.StringSlice, source string) error
BulkUpdatePackageSource updates somes packages "ids" source
func CaptureCharge ¶
CaptureCharge applies the charge
func CopyCreationParamsAndFunctions ¶
CopyCreationParamsAndFunctions copie creation parameters and functions from current version to a new version
func CreationInUse ¶
CreationInUse returns true if the creation is used by anyone
func CreationLastVersion ¶
CreationLastVersion gets creation's last version
func DeleteCreation ¶
DeleteCreation deletes a creation
func DeletePackageCreation ¶
DeletePackageCreation delete a creation from a package
func IsTokenExpired ¶
func IsTokenExpired(err *jwt.ValidationError) bool
IsTokenExpired tells if a token has expired (claim exp)
func IsTokenInvalid ¶
func IsTokenInvalid(err *jwt.ValidationError) bool
IsTokenInvalid tells if the token signature is wrong
func IsTokenMalformed ¶
func IsTokenMalformed(err *jwt.ValidationError) bool
IsTokenMalformed tells if a token is not JWT standard
func NewCreationVersion ¶
NewCreationVersion create a new version
func NewCustomer ¶
NewCustomer creates a new customer in the payment system
func NewPackageCreation ¶
NewPackageCreation create a new relationship with package and creation
func NewPackageCreationParam ¶
NewPackageCreationParam create new package creation params
func NewPlanUser ¶
NewPlanUser logs user subscription
func PackageNbCrea ¶
PackageNbCrea returns the number of creations in the package id "id"
func RefreshToken ¶
func RefreshToken(token *jwt.Token) (*jwt.Token, error)
RefreshToken refreshes old token (depending on exp claim)
func RegisterBank ¶
RegisterBank links a bank account to a customer
func RenewUserPlan ¶
RenewUserPlan renews user (customer id) plan from start date to end date
func SafeDeleteCreation ¶
SafeDeleteCreation sets creation's state to 'Deleted'
func SafeDeleteUser ¶
SafeDeleteUser sets deleted at to current date, meaning this user is disactivated
func SendActivationEmail ¶
SendActivationEmail prepares and sends an activation email
func SubCustomer ¶
SubCustomer subscribes the customer "custID" to the plan "plan"
func UnsubCustomer ¶
UnsubCustomer unsubscribes customer from his current plan
func UnsubUserPlan ¶
UnsubUserPlan unsubscribe user from his current plan (will set to free by default)
func UpdateCreation ¶
UpdateCreation update creation's information
func UpdateCreationFunctions ¶
UpdateCreationFunctions updates creation functions
func UpdateCreationParams ¶
UpdateCreationParams update all creation params for a given version (crea.Version)
func UpdateCreationPatch ¶
UpdateCreationPatch updates a creation
func UpdateCreationTags ¶
UpdateCreationTags updates creation tags
func UpdateCustomerID ¶
UpdateCustomerID updates user's customer ID
func UpdatePackageCreation ¶
UpdatePackageCreation udpates package creation information
func UpdatePackagePatch ¶
UpdatePackagePatch updates a package
func UpdateUserAccountID ¶
UpdateUserAccountID updates user "uID" account ID
func UpdateUserPatch ¶
UpdateUserPatch updates user informations
func UserCustomerID ¶
UserCustomerID returns customerID of user "uID"
func UserNbPackages ¶
UserNbPackages returns numbers of package the user uID has
func UserSubFund ¶
UserSubFund substracts user "uID" fund by "amount"
Types ¶
type Creation ¶
type Creation struct { ID lib.ID `json:"id" db:"crea.id"` Title string `json:"title" db:"title"` Description *lib.NullString `json:"description,omitempty" db:"description"` Tags []Tag `json:"tags" db:""` ThumbPath *lib.NullString `json:"thumbPath,omitempty" db:"thumb_path"` Creator User `json:"creator,omitempty" db:""` // When a creation is in draft, the very last version is ignored by most queries Versions lib.UintSlice `json:"versions,omitempty" db:"versions"` Alias string `json:"alias,omitempty" db:"alias"` State string `json:"state,omitempty" db:"state"` IsOwner bool `json:"isOwner,omitempty" db:"is_owner"` IsFeatured bool `json:"-" db:"is_featured"` NbUse uint64 `json:"nbUse" db:"nb_use"` Params []CreationParam `json:"params,omitempty" db:""` Functions []CreationFunction `json:"functions,omitempty" db:""` PreviewURL string `json:"previewUrl,omitempty"` Version uint64 `json:"version,omitempty"` PreviewPos PreviewPosition `json:"previewPosition" db:""` PreviewPositions []PreviewPosition `json:"previewPositions,omitempty" db:""` IsThumbPreview bool `json:"isThumbPreview" db:"is_thumb_preview"` Script string `json:"script,omitempty"` ParsedScript string `json:"parsedScript,omitempty"` Document string `json:"document,omitempty"` Style string `json:"style,omitempty"` CreatorID uint64 `json:"-" db:"creator_id"` Engine Engine `json:"-" db:""` CreatedAt *lib.NullTime `json:"createdAt,omitempty" db:"crea.created_at"` UpdatedAt *lib.NullTime `json:"updatedAt,omitempty" db:"crea.updated_at"` }
Creation is a Wooble object
func AllCreations ¶
AllCreations returns all creations
func AllDraftCreations ¶
AllDraftCreations returns all creation in draft of authenticated user
func AllPopularCreations ¶
AllPopularCreations returns all popular creations
func AllUsedCreations ¶
AllUsedCreations return creations used in some packages
func CreationByID ¶
CreationByID returns a creation with the id "id"
func CreationByIDAndVersion ¶
CreationByIDAndVersion returns the creation "creaID" and check if the version "version" exists
func NewCreation ¶
NewCreation creates a creation
func (*Creation) GenerateDefaultThumb ¶
GenerateDefaultThumb generates unique thumbnail for the creation it returns the image buffer and the image path
func (*Creation) PopulateFunctions ¶
func (c *Creation) PopulateFunctions()
PopulateFunctions populates creation's functions for documentation
func (*Creation) PopulateParams ¶
func (c *Creation) PopulateParams()
PopulateParams populates creation's parameters (for previewing and building into package)
func (*Creation) PopulatePreviewPositions ¶
func (c *Creation) PopulatePreviewPositions()
PopulatePreviewPositions populates available creation's preview positions
func (*Creation) PopulateTags ¶
PopulateTags populates creation's tags
func (*Creation) RetrievePreviewURL ¶
func (c *Creation) RetrievePreviewURL()
RetrievePreviewURL construct the creation's preview URL and sets the `PreviewUrl` field It uses the current `Version` of the creation c
type CreationFunction ¶
type CreationFunction struct { Call string `json:"call" db:"call"` Detail string `json:"detail" db:"detail"` }
CreationFunction is a creation function
type CreationParam ¶
type CreationParam struct { CreationID lib.ID `json:"-" db:"creation_id"` Field string `json:"field" db:"field"` Value string `json:"value" db:"value"` }
CreationParam is a creation parameter
type CustomClaims ¶
type CustomClaims struct { Name string `json:"name"` Plan Plan `json:"plan"` RefreshToken string `json:"refresh_token"` IsActive bool `json:"isActive"` jwt.StandardClaims }
CustomClaims is wooble token claims
type Engine ¶
type Engine struct { Name string `json:"name" db:"eng.name"` ContentType string `json:"-" db:"content_type"` Extension string `json:"-" db:"extension"` }
Engine is the engine used by a creation (JSES5 is the only one available for now)
func EngineByName ¶
EngineByName returns engine with name "name"
type Package ¶
type Package struct { ID lib.ID `json:"id" db:"pkg.id"` Title string `json:"title" validate:"required" db:"pkg.title"` NbBuild uint64 `json:"nbBuild" db:"nb_build"` Referer *lib.NullString `json:"referer,omitempty" db:"referer"` UserID uint64 `json:"-" db:"pkg.user_id"` User User `json:"-" db:""` Creations []Creation `json:"creations,omitempty" db:""` Source *lib.NullString `json:"source,omitempty" db:"source"` BuildRequired bool `json:"buildRequired" db:"build_required"` NbCrea *lib.NullInt64 `json:"nbCreations" db:"nb_creations"` CreatedAt *lib.NullTime `json:"createdAt,omitempty" db:"pkg.created_at"` UpdatedAt *lib.NullTime `json:"updatedAt,omitempty" db:"pkg.updated_at"` BuiltAt *lib.NullTime `json:"builtAt,omitempty" db:"built_at"` }
Package is a bundle of creations
func PackageByID ¶
PackageByID returns package with id "id"
func (*Package) PopulateCreations ¶
PopulateCreations populates creations in the package
type Plan ¶
type Plan struct { Label *lib.NullString `json:"label,omitempty" db:"plan.label"` PriceMonth uint64 `json:"pricePerMonth,omitempty" db:"price_per_month"` PriceYear uint64 `json:"pricePerYear,omitempty" db:"price_per_year"` Level *lib.NullInt64 `json:"level,omitempty" db:"level"` NbPkg *lib.NullInt64 `json:"nbPkg,omitempty" db:"nb_pkg"` NbCrea *lib.NullInt64 `json:"nbCrea,omitempty" db:"nb_crea"` StartDate *lib.NullTime `json:"startDate,omitempty" db:"start_date"` EndDate *lib.NullTime `json:"endDate,omitempty" db:"end_date"` UnsubDate *lib.NullTime `json:"unsubDate,omitempty" db:"unsub_date"` }
Plan is a Wooble plan with some restrictions NbPkg is the number of packages allowed (0 means infinite) NbCrea is the number of creations per package (0 means infinite)
func DefaultPlan ¶
DefaultPlan gets free plan or second plan if user is VIP
func PlanByLabel ¶
PlanByLabel gets plan with label "label"
func (*Plan) HasExpired ¶
HasExpired returns true if the plan has expired
type PreviewPosition ¶
type PreviewPosition struct { Position string `json:"position" db:"position_id"` StyleSource string `json:"styleSource" db:"style_source"` }
PreviewPosition is the creation position in the preview
type Tag ¶
type Tag struct { ID uint64 `json:"id,omitempty" db:"tag.id"` Title string `json:"title" db:"tag.title"` NbUse uint64 `json:"nbUse" db:"tag_nb_use"` }
Tag is for arranging crations
type User ¶
type User struct { ID uint64 `json:"-" db:"user.id"` CustomerID string `json:"-" db:"customer_id"` AccountID lib.NullString `json:"-" db:"account_id"` Email string `json:"email,omitempty" db:"email"` Name string `json:"name,omitempty" db:"name"` PicPath *lib.NullString `json:"profilePath,omitempty" db:"pic_path"` Fullname *lib.NullString `json:"fullname,omitempty" db:"fullname"` IsVIP bool `json:"-" db:"is_vip"` IsActive bool `json:"-" db:"is_active"` Website *lib.NullString `json:"website,omitempty" db:"website"` CodepenName *lib.NullString `json:"codepenName,omitempty" db:"codepen_name"` DribbbleName *lib.NullString `json:"dribbbleName,omitempty" db:"dribbble_name"` GithubName *lib.NullString `json:"githubName,omitempty" db:"github_name"` TwitterName *lib.NullString `json:"twitterName,omitempty" db:"twitter_name"` PlanID *lib.NullInt64 `json:"-" db:"plan_user.id"` Plan *Plan `json:"plan,omitempty" db:""` Packages *[]Package `json:"packages,omitempty" db:""` IsCreator bool `json:"isCreator,omitempty" db:"is_creator"` Fund uint64 `json:"fund,omitempty" db:"fund"` Secret string `json:"-" db:"passwd"` Salt string `json:"-" db:"salt_key"` CreatedAt *lib.NullTime `json:"createdAt,omitempty" db:"user.created_at"` UpdatedAt *lib.NullTime `json:"updatedAt,omitempty" db:"user.updated_at"` DeletedAt *lib.NullTime `json:"deletedAt,omitempty" db:"user.deleted_at"` }
User is a Wooble user
func AllActiveUsers ¶
AllActiveUsers returns all public and activated users
func UserByEmail ¶
UserByEmail returns user with a specified email or name
func UserByToken ¶
UserByToken return the user whom the token belong to
func UserPrivateByID ¶
UserPrivateByID returns user with id "id" It'll select the most recent plan but ignore it if the end_date expired
func UserPublicByName ¶
UserPublicByName returns user public profile with the name "username"
func (*User) IsPasswordValid ¶
IsPasswordValid checks if a password is valid