models

package
v0.0.0-...-7d79363 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2015 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Conn

func Conn() (*gorm.DB, error)

Conn provied a *gorm.DB which is ready for interacting with database

func RunMigrations

func RunMigrations()

func SanitizeTestHelper

func SanitizeTestHelper(s string) template.HTML

Types

type Account

type Account struct {
	Id              int64     `form:"-"`
	UserName        string    `toml:"-" sql:"not null;unique" form:"userName" valid:"Required"`
	Company         string    `toml:"company_name" sql:"unique" form:"company" valid:"Required"`
	Email           string    `toml:"email" sql:"unique" form:"email" valid:"Email"`
	Projects        []Project `toml:"-" form:"-"`
	Password        string    `toml:"-" form:"password" valid:"Required"`
	ConfirmPassword string    `toml:"-" sql:"-" form:"password2" valid:"Required"`
	Uploads         []Upload  `toml:"-" form:"-"`
	Profile         Profile   `toml:"-" form:"-"`
	ProfileId       int64     `toml:"-" form:"-"`
	ClearanceLevel  int       `toml:"-" form:"-"`
	CreatedAt       time.Time `toml:"-" form:"-"`
	UpdatedAt       time.Time `toml:"-" form:"-"`
	DeletedAt       time.Time `toml:"-" form:"-"`
}

Account stores user information

type Image

type Image struct {
	Id    int64
	Path  string `toml:"path"`
	Class string `toml:"class"`
}

type LoginForm

type LoginForm struct {
	Email    string `form:"email" valid:"Required;Email"`
	Password string `form:"password" valid:"Required;MinSize(6)"`
}

RegistrationForm has info strings for verification during registration process

type Lora

type Lora struct {
	Page       Page
	Project    Project
	Account    Account
	Section    Section
	SubSection SubSection
	Profile    Profile

	Pages       []Page
	Projects    []Project
	Accounts    []Account
	Sections    []Section
	SubSections []SubSection
	Profiles    []Profile

	HasPage       bool
	HasProject    bool
	HasAccount    bool
	HasSection    bool
	HasSubSection bool
	HasProfile    bool

	HasPages       bool
	HasProjects    bool
	HasAccounts    bool
	HasSections    bool
	HasSubSections bool
	HasProfiles    bool

	IsAdmin bool
}

func NewLoraObject

func NewLoraObject() *Lora

func (*Lora) Add

func (l *Lora) Add(v interface{})

type Page

type Page struct {
	Id          int64
	Title       string        `toml:"title"`
	ProjectId   int64         `toml:"-" `
	Content     string        `toml:"content" sql:"null;type:text"`
	ContentHtml template.HTML `toml:"-" sql:"-"`
	Slug        string        `toml:"slug" sql:"null"`
	Draft       bool          `toml:"draft" sql:"null"`
	Sections    []Section     `toml:"sections"`
	ContentPath string        `toml:"-" sql:"-"`
	CreatedAt   time.Time     `toml:"-"`
	UpdatedAt   time.Time     `toml:"-"`
}

Page representation of web page

func (*Page) Generate

func (p *Page) Generate(project *Project) error

Generate creates a markdown file for the given page

func (*Page) LastUpdate

func (p *Page) LastUpdate() string

func (*Page) Sanitize

func (p *Page) Sanitize()

Sanitize This prepares the ContentHtml field for rendering safe html

func (*Page) SaveDataFile

func (p *Page) SaveDataFile(dest string) error

type Param

type Param struct {
	Id              int64
	Slides          []Image `toml:"slides"`
	Author          string  `toml:"author"`
	Description     string  `toml:"description"`
	BackgroundImage string  `toml:"background"`
	Brand           string  `toml:"brand"`
	CreatedAt       time.Time
	UpdatedAt       time.Time
}

type Profile

type Profile struct {
	Id        int64
	Phone     string
	Photo     string `sql:"null"`
	Thumbnail string
	UpdatedAt time.Time
	CreatedAT time.Time
}

func (*Profile) GenerateIdenticon

func (p *Profile) GenerateIdenticon(base, s string) error

type Project

type Project struct {
	Id           int64
	Title        string    `toml:"title"`
	Name         string    `toml:"projectName" sql:"unique""`
	BaseDir      string    `toml:"-" sql:"-"`
	Template     string    `toml:"templateName"`
	Theme        string    `toml:"theme"`
	PublishDir   string    `toml:"publishDir"`
	ProjectPath  string    `toml:"projectPath"`
	TemplatePath string    `toml:"-"`
	BaseUrl      string    `toml:"baseurl"`
	HomeUrl      string    `toml:"-" sql:"-"`
	LanguageCode string    `toml:"languageCode" sql:"-"`
	Pages        []Page    `toml:"pages"`
	AccountId    int64     `toml:"-" sql:"null"`
	Param        Param     `toml:"params"`
	ParamId      int64     `toml:"-"`
	Copyright    string    `toml:"copyright"`
	CreatedAt    time.Time `toml:"-"`
	UpdatedAt    time.Time `toml:"-"`
}

Project provide an abstract representation of a hugo project with other extra important details about a website project

func NewLoraProject

func NewLoraProject(base string, name string, template string, theme string) (Project, error)

func (*Project) Build

func (p *Project) Build() error

Build run hugo on the root of project path to generate static files in public folder of the project path.

func (*Project) Clean

func (p *Project) Clean() error

Clean makes sure all project files in disc are safely removed

func (*Project) GenContent

func (p *Project) GenContent() error

GenContent generates frontmatter and contents of the pages in Markdown files, the fuction can only be called after the project configurations have been loaded

func (*Project) GenLorem

func (p *Project) GenLorem()

GenLorem populates pages with lorem ipsum for the page's content

func (*Project) GenScaffold

func (p *Project) GenScaffold() error

GenScaffold copies a directory from the templates folder into the projects folder. The template name should be provided by the user, if not default template is used

func (*Project) InitDir

func (p *Project) InitDir() error

InitiDir initializes the project directory by performing git stuffs

func (*Project) Initialize

func (p *Project) Initialize(base string, name string, template string, theme string) error

func (*Project) InstallTemplate

func (p *Project) InstallTemplate(name, theme string) error

func (*Project) InstallTheme

func (p *Project) InstallTheme(theme string) error

func (*Project) LoadConfigFile

func (p *Project) LoadConfigFile() error

LoadConfig reads the configuration file found in a project path. The file is expected to be of toml format, it unamrshall the values into the current project object.

func (*Project) SaveConfigFile

func (p *Project) SaveConfigFile() error

SaveConfigFile saves the current object to a configuration file in Toml format

func (*Project) SaveDataFiles

func (p *Project) SaveDataFiles() error

func (*Project) SetBaseUrl

func (p *Project) SetBaseUrl()

type Resource

type Resource struct {
	Name  string
	Type  string
	Image string
}

func GetAvailableTemplates

func GetAvailableTemplates(base string) (list []Resource, err error)

func GetAvailableThemes

func GetAvailableThemes(base string) (list []Resource, err error)

type Section

type Section struct {
	Id          int64
	PageId      int64
	Name        string        `toml:"name"`
	Title       string        `toml:"title"`
	Phone       string        `toml:"phone"`
	Photo       string        `toml:"photo"`
	Email       string        `toml:"email"`
	Address     string        `toml:"address"`
	Body        string        `toml:"body" sql:"null;type:text"`
	BodyHtml    template.HTML `sql:"-"`
	SubSections []SubSection  `toml:"subsections"`
	LastUpdate  string        `sql:"-" toml:"last_update"`
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

Section divides a page into small pieces

func (*Section) Sanitize

func (s *Section) Sanitize()

type SubSection

type SubSection struct {
	Id         int64
	Name       string `toml:"name"`
	Photo      string `toml:"photo"`
	SectionId  int64
	Body       string        `toml:"body"`
	BodyHtml   template.HTML `sql:"-"`
	LastUpdate string        `sql:"-" toml:"last_update"`
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

func (*SubSection) Sanitize

func (s *SubSection) Sanitize()

type Upload

type Upload struct {
	Id   int64
	Path string
}

type UserProfileForm

type UserProfileForm struct {
	Company string `valid:"Required"`
	Phone   string `valid:"Required;Phone"`
}

Jump to

Keyboard shortcuts

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