seed

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2020 License: AGPL-3.0 Imports: 4 Imported by: 0

README

logo Godoc Go Report Card Build Status

The cross-platform Go module for building apps.

Usecases

As a lightweight alternative to Electron
Write your frontend and native code in Go, distribute native binaries of your app. Supported on Windows, Mac & Linux. Mobile support planned.

Full-stack progressive webapp
Write the complete app in Go, place binaries on public-facing web servers. Access these apps on Windows, Mac, Linux, IOS & Android.

As a lightweight alternative to Phonegap (WIP linux-only)
Write your app in Go, export the frontend as a native app. Android-only. IOS support planned.

Examples

showcase

Getting started

Create HelloWorld.go file and paste in the following contents:

package main

import (
	"qlova.org/seed/new/app"
	"qlova.org/seed/new/text"
)

func main() {
	app.New("Hello World",
		text.Set("Hello World"),
	).Launch()
}

In the same folder, run 'go mod init .' to initialise the project and then 'go build' to create an executable for the app, run this to launch the app. By default, Qlovaseed will start a WebServer and open a browser window displaying your app.

Core Concepts

Qlovaseed is a full-stack cross-platform application-development framework.
This means that Apps created with Qlovaseed under the hood feature both a client and server component.

Qlovaseed aims to blur the client-server distinction, the app is written as a whole, in Go. Then communication is achieved with 'client' and 'clientside' packages.

Javascript and http.Handlers are managed by the framework.

This is a clientside pattern that changes the text of the button on the client-side.

    var Text = new(clientside.String)

    button.New(
        text.SetTo(Text),

        client.OnClick(Text.Set("You Clicked me")),
    )

This is client handler that changes the text of the button from the server.

	var Text = new(clientside.String)

    button.New(
        text.SetTo(Text),

        client.OnClick(client.Go(func() client.Script {
            return Text.Set("You Clicked me")
        }),
    )

Given an App, by default Qlovaseed will create a web server, manage the handlers, HTML, JS & CSS. All these resources are pre-rendered by Qlovaseed. Then the app will be launched on the local web browser in kiosk mode (if available).
Alternatively, the app can be placed on a remote server and proxied through a webserver with automatic HTTPS (such as Caddy).
This will serve the app as a Lighthouse-compliant progressive WebApp.

Full App example.

package main

import (
	"image/color"

	"qlova.org/seed/client"
	"qlova.org/seed/client/clientside"

	//Import a seed to use it, a list of seeds can be found [here](https://github.com/qlova/seed/tree/master/new).
	"qlova.org/seed/new/app"
	"qlova.org/seed/new/button"
	"qlova.org/seed/new/text"

	"qlova.org/seed/set"
)

func main() {
	var Text1 = &clientside.String{Value: "My callback runs on the client"}
	var Text2 = &clientside.String{Value: "My callback runs on the server"}

	app.New("My App",
		button.New(
			text.SetStringTo(Text1),

			client.OnClick(Text1.Set("You Clicked me")),
		),

		button.New(
			text.SetStringTo(Text2),

			set.Color(color.RGBA{100, 100, 0, 255}),

			client.OnClick(client.Go(func() client.Script {
				return Text2.Set("You Clicked me")
			})),
		),
	).Launch()
}

This example shows a quick glimpse on how powerful Qlovaseed is.

Project folder structure

For larger apps, it is a good idea to seperate the ui from the business logic. The recomended folder structure is:

    domain (business logic)
    |
    ├───── main (main package that launches the app)
    |      └─── main.go
    |
    ├───── ui (pages & popups)
    |      ├─ new (place custom seed packages in here)
    |      |  └─── customseed
    |      |        └──────── customseed.go
    |      |
    |      ├─ user (global clientside state)
    |      |  └─── user.go
    |      |
    |      ├─ style (styles for your seeds)
    |      |  └─── styles.go
    |      |
    |      └─ page.Home.go
    |
    └───── domain.go

Styles

All seeds can be styled with methods from the set package.

import "color"
import "qlova.org/seed/set"
import "qlova.org/seed/new/text"
import "qlova.org/seed/use/css/units/rem"

text.New(set.Color(color.RGBA{100, 0, 0, 255}),
    set.Margin(rem.One, rem.One),

    text.Set("Some stylable text"),
)

HTML/CSS/JS

The use of raw HTML, CSS and Javascript to build apps is discouraged. However, there may be good reasons to use these technologies to extend functionality or to create new seeds.

  • Seeds have a html.Set option for setting raw HTML.
  • When in doubt, css.Set can be used to set css styles with strings,
  • js.Bundle is useful for embedding Javascript and CSS files. Checkout the gallery seed.

Community

There is a reddit community: /r/Qlovaseed.

Please don't hesitate to ask questions here. I haven't invested a lot of time into documentation yet.

Please remember, this framework is in development, it does not have a stable API and features are currently implemented as needed.

License
This work is subject to the terms of the Qlova Public License, Version 2.0. If a copy of the QPL was not distributed with this work, You can obtain one at https://license.qlova.org/v2

The QPL is compatible with the AGPL which is why both licenses are provided within this repository.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Dir = filepath.Dir(os.Args[0])

Dir is the working directory of the seed.

Functions

This section is empty.

Types

type Builder

type Builder func(...Option) Seed

Builder is a function that takes one or more options and returns a seed.

type NewOption

type NewOption = OptionFunc

NewOption can be used to create options.

type Option

type Option interface {
	AddTo(Seed)
}

Option can be used to modify a seed.

func And

func And(o Option, more ...Option) Option

And implements Option.And

func If

func If(condition bool, options ...Option) Option

If applies the options if the condition is true.

func Mutate

func Mutate(f interface{}) Option

Mutate a seed with the given data. panics on illegal arguments.

type OptionFunc

type OptionFunc func(c Seed)

OptionFunc can be used to create an Option.

func (OptionFunc) AddTo

func (o OptionFunc) AddTo(c Seed)

AddTo implements Option.AddTo

func (OptionFunc) And

func (o OptionFunc) And(more ...Option) Option

And implements Option.And

type Options

type Options []Option

Options is a multiple of Option.

func (Options) AddTo

func (options Options) AddTo(c Seed)

AddTo implements Option, Options are a type of Option.

type Seed

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

Seed is an extendable entity type. Other packages can associate data with a seed. Seeds can have options applied to them and are also options themselves (seeds can be added to seeds).

func New

func New(options ...Option) Seed

New returns a new seed with the applied options.

func (Seed) AddTo

func (c Seed) AddTo(other Seed)

AddTo implements Option.

func (Seed) Children

func (c Seed) Children() []Seed

Children returns the seeds children.

func (Seed) ID

func (c Seed) ID() int

ID returns the Seed's ID.

func (Seed) Load

func (c Seed) Load(data interface{}) bool

Load loads the associated data of data's type into data and then returns true. If no data is found, data is set to the empty value and false is returned instead.

func (Seed) Parent

func (c Seed) Parent() Seed

Parent returns the seeds parent.

func (Seed) Save

func (c Seed) Save(data interface{})

Save saves data of the given type to the seed.

func (Seed) Use

func (c Seed) Use()

Use marks the seed as used.

func (Seed) Used

func (c Seed) Used() bool

Used reports whether or not the seed has been used.

func (Seed) With

func (c Seed) With(options ...Option) Seed

With is depreciated.

type Set

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

Set returns an unordered set of seeds.

func NewSet

func NewSet(seeds ...Seed) Set

NewSet creates a new unordered set of seeds out of the given seed arguments.

func (*Set) Add

func (s *Set) Add(seeds ...Seed)

Add adds seeds to the set.

func (*Set) Remove

func (s *Set) Remove(c Seed)

Remove removes a seed from the set.

func (*Set) Slice

func (s *Set) Slice() []Seed

Slice returns a slice of all the seeds in this set, ordered by id.

Directories

Path Synopsis
clientsafe
Package clientsafe provides an error type that is safe to show to clients.
Package clientsafe provides an error type that is safe to show to clients.
clientzip
Package clientzip provides clientside zipping functionality.
Package clientzip provides clientside zipping functionality.
examples
new
api
Package api provides a structure for designing an API for your app.
Package api provides a structure for designing an API for your app.
app
choices
Package choices provides a more feature-full dropdown.
Package choices provides a more feature-full dropdown.
dropdown
Package dropdown provides an input widget for selecting from an array of preset values.
Package dropdown provides an input widget for selecting from an array of preset values.
dropzone
Package dropzone provides functionality for file dropzones.
Package dropzone provides functionality for file dropzones.
page
Package page provides global pages that can be swapped in and out.
Package page provides global pages that can be swapped in and out.
paymentbox
Package paymentbox provides a (stripe) secured input that accepts payment details.
Package paymentbox provides a (stripe) secured input that accepts payment details.
row
view
Package view provides local view that can be swapped in and out.
Package view provides local view that can be swapped in and out.
set
use
css
This file is computer-generated This file is computer-generated
This file is computer-generated This file is computer-generated
js

Jump to

Keyboard shortcuts

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