Package gi is the top-level repository for the GoGi GUI framework. All of the code is in the sub-packages within this repository: * gist: css-based styling settings, including Color * girl: rendering library, can be used standalone, SVG compliant * gi: the main 2D GUI Node, Widgets, and Window * giv: more complex Views of Go data structures, supporting Model-View paradigm. * svg: full SVG rendering framework, used for Icons in gi. * gi3d: 3D rendering of a Scene within 2D windows -- full interactive 3D scenegraph. * histyle: text syntax-based highlighting styles -- used in giv.TextView * python: access all of GoGi from within Python using GoPy system.
Package gi is the top-level repository for the GoGi GUI framework. All of the code is in the sub-packages within this repository: * gist: css-based styling settings, including Color * girl: rendering library, can be used standalone, SVG compliant * gi: the main 2D GUI Node, Widgets, and RenderWin * giv: more complex Views of Go data structures, supporting Model-View paradigm. * svg: full SVG rendering framework, used for Icons in gi. * gi3d: 3D rendering of a Scene within 2D windows -- full interactive 3D scenegraph. * histyle: text syntax-based highlighting styles -- used in textview.View * python: access all of GoGi from within Python using GoPy system.
Package web implements a basic web site serving framework. The two fundamental types in this package are Site and Page. A Site is an http.Handler that serves requests from a file system. Use NewSite(fsys) to create a new Site. The Site is defined primarily by the content of its file system fsys, which holds files to be served as well as templates for converting Markdown or HTML fragments into full HTML pages. A Page, which is a map[string]interface{}, is the raw data that a Site renders into a web page. Typically a Page is loaded from a *.html or *.md file in the file system fsys, although dynamic pages can be computed and passed to ServePage as well, as described in “Serving Dynamic Pages” below. For a Page loaded from the file system, the key-value pairs in the map are initialized from the YAML or JSON metadata block at the top of a Markdown or HTML file, which looks like (YAML): or (JSON): By convention, key-value pairs loaded from a metadata block use lower-case keys. For historical reasons, keys in JSON metadata are converted to lower-case when read, so that the two headers above both refer to a key with a lower-case k. A few keys have special meanings: The key-value pair “status: n” sets the HTTP response status to the integer code n. The key-value pair “redirect: url” causes requests for this page redirect to the given relative or absolute URL. The key-value pair “layout: name” selects the page layout template with the given name. See the next section, “Page Rendering”, for details about layout and rendering. In addition to these explicit key-value pairs, pages loaded from the file system have a few implicit key-value pairs added by the page loading process: The key “Content” is added during during the rendering process. See “Page Rendering” for details. A Page's content is rendered in two steps: conversion to content, and framing of content. To convert a page to content, the page's file body (its FileData key, a []byte) is parsed and executed as an HTML template, with the page itself passed as the template input data. The template output is then interpreted as Markdown (perhaps with embedded HTML), and converted to HTML. The result is stored in the page under the key “Content”, with type template.HTML. A page's conversion to content can be skipped entirely in dynamically-generated pages by setting the “Content” key before passing the page to ServePage. The second step is framing the content in the overall site HTML, which is done by executing the site template, again using the Page itself as the template input data. The site template is constructed from two files in the file system. The first file is the fsys's “site.tmpl”, which provides the overall HTML frame for the site. The second file is a layout-specific template file, selected by the Page's “layout: name” key-value pair. The renderer searches for “name.tmpl” in the directory containing the page's file, then in the parent of that directory, and so on up to the root. If no such template is found, the rendering fails and reports that error. As a special case, “layout: none” skips the second file entirely. If there is no “layout: name” key-value pair, then the renderer tries using an implicit “layout: default”, but if no such “default.tmpl” template file can be found, the renderer uses an implicit “layout: none” instead. By convention, the site template and the layout-specific template are connected as follows. The site template, at the point where the content should be rendered, executes: The layout-specific template overrides this block by defining its own template named “layout”. For example: The use of the “block” template construct ensures that if there is no layout-specific template, the content will still be rendered. In this web server, templates can themselves be invoked as functions. See https://pkg.go.dev/rsc.io/tmplfunc for more details about that feature. During page rendering, both when rendering a page to content and when framing the content, the following template functions are available (in addition to those provided by the template package itself and the per-template functions just mentioned). In all functions taking a file path f, if the path begins with a slash, it is interpreted relative to the fsys root. Otherwise, it is interpreted relative to the directory of the current page's URL. The “{{add x y}}”, “{{sub x y}}”, “{{mul x y}}”, and “{{div x y}}” functions provide basic math on arguments of type int. The “{{code f [start [end]]}}” function returns a template.HTML of a formatted display of code lines from the file f. If both start and end are omitted, then the display shows the entire file. If only the start line is specified, then the display shows that single line. If both start and end are specified, then the display shows a range of lines starting at start up to and including end. The arguments start and end can take two forms: a number indicates a specific line number, and a string is taken to be a regular expresion indicating the earliest matching line in the file (or, for end, the earliest matching line after the start line). Any lines ending in “OMIT” are elided from the display. For example: The “{{data f}}” function reads the file f, decodes it as YAML, and then returns the resulting data, typically a map[string]interface{}. It is effectively shorthand for “{{yaml (file f)}}”. The “{{file f}}” function reads the file f and returns its content as a string. The “{{first n slice}}” function returns a slice of the first n elements of slice, or else slice itself when slice has fewer than n elements. The “{{markdown text}}” function interprets text (a string) as Markdown and returns the equivalent HTML as a template.HTML. The “{{page f}}” function returns the page data (a Page) for the static page contained in the file f. The lookup ignores trailing slashes in f as well as the presence or absence of extensions like .md, .html, /index.md, and /index.html, making it possible for f to be a relative or absolute URL path instead of a file path. The “{{pages glob}}” function returns a slice of page data (a []Page) for all pages loaded from files or directories in fsys matching the given glob (a string), according to the usual file path rules (if the glob starts with slash, it is interpreted relative to the fsys root, and otherwise relative to the directory of the page's URL). If the glob pattern matches a directory, the page for the directory's index.md or index.html is used. For example: The “{{raw s}}” function converts s (a string) to type template.HTML without any escaping, to allow using s as raw Markdown or HTML in the final output. The “{{yaml s}}” function decodes s (a string) as YAML and returns the resulting data. It is most useful for defining templates that accept YAML-structured data as a literal argument. For example: The “path” and “strings” functions return package objects with methods for every top-level function in these packages (except path.Split, which has more than one non-error result and would not be invokable). For example, “{{strings.ToUpper "abc"}}”. A Site is an http.Handler that serves requests by consulting the underlying file system and constructing and rendering pages, as well as serving binary and text files. To serve a request for URL path /p, if fsys has a file p/index.md, p/index.html, p.md, or p.html (in that order of preference), then the Site opens that file, parses it into a Page, renders the page as described in the “Page Rendering” section above, and responds to the request with the generated HTML. If the request URL does not match the parsed page's URL, then the Site responds with a redirect to the canonical URL. Otherwise, if fsys has a directory p and the Site can find a template “dir.tmpl” in that directory or a parent, then the Site responds with the rendering of where dir is the directory contents. Otherwise, if fsys has a file p containing valid UTF-8 text (at least up to the first kilobyte of the file) and the Site can find a template “text.tmpl” in that file's directory or a parent, and the file is not named robots.txt, and the file does not have a .css, .js, .svg, or .ts extension, then the Site responds with the rendering of where texthtml is the text file as rendered by the golang.org/x/website/internal/texthtml package. In the texthtml.Config, GoComments is set to true for file names ending in .go; the h URL query parameter, if present, is passed as Highlight, and the s URL query parameter, if set to lo:hi, is passed as a single-range Selection. If the request has the URL query parameter m=text, then the text file content is not rendered or framed and is instead served directly as a plain text response. If the request is for a file with a .ts extension the file contents are transformed from TypeScript to JavaScript and then served with a Content-Type=text/javascript header. Otherwise, if none of those cases apply but the request path p does exist in the file system, then the Site passes the request to an http.FileServer serving from fsys. This last case handles binary static content as well as textual static content excluded from the text file case above. Otherwise, the Site responds with the rendering of where err is the “not exist” error returned by fs.Stat(fsys, p). (See also the “Serving Errors” section below.) Of course, a web site may wish to serve more than static content. To allow dynamically generated web pages to make use of page rendering and site templates, the Site.ServePage method can be called with a dynamically generated Page value, which will then be rendered and served as the result of the request. If an error occurs while serving a request r, the Site responds with the rendering of If that rendering itself fails, the Site responds with status 500 and the cryptic page text “error rendering error”. The Site.ServeError and Site.ServeErrorStatus methods provide a way for dynamic servers to generate similar responses.
go-start is a high level web-framework for Go, like Django for Python or Rails for Ruby. * Source: https://github.com/ungerik/go-start/ * Documentation: http://go-start.org/pkg/go-start/gostart/ Note: Don't use Go on 32 bit systems in production, it has severe memory leaks. (If the documentation URL above doesn't work, then godoc -html has has crashed because of that issue) ## Intro: Features: * HTML views can be defined in Go syntax * Optional template system * HTML5 Boilerplate page template (Mustache template, will be changed to Go v1 template) * Unified data model for forms and databases * Data models are simple Go structs * MongoDB as default database * User management/authentication out of the box * Additional packages for Planned Features: * medialib * CSRF protection * Tutorial App * Remove web.go * Controller of MVC implemented as REST service * Support for LESS CSS * Support for Twitter Bootstrap ## Views: The philosophy for creating HTML views is (unlike Rails/Django) that you should not have to learn yet another language to be able to write templates. There are several very simple template languages out there that reduce program code like logic within the template, but it’s still yet another syntax to learn. In go-start the HTML structure of a page is represented by a structure of type safe Go objects. It should feel like writing HTML but using the syntax of Go. And no, it has nothing to do with the mess of intertwined markup and code in PHP. Example of a static view: Example of a dynamic view: Beside DynamicView there is also a ModelIteratorView. It takes a model.Iterator and creates a dynamic view for every iterated data item: ## Pages and URLs: ## Models: Data is abstacted as models. The same model abstraction and data validation is used for HTML forms and for databases. So a model can be loaded from a database, displayed as an HTML form and saved back to the database after submit. This is not always a good practice, but it shows how easy things can be. A model is a simple Go struct that uses gostart/model types as struct members. Custom model wide validation is done by adding a Validate() method to the struct type: Here is how a HTML form is created that displays input fields for the SignupFormModel: MongoDB is the default database of go-start utilizing Gustavo Niemeyer's great lib mgo (http://labix.org/mgo). Mongo collections and queries are encapsulated to make them compatible with the go-start data model concept, and a little bit easier to use. Example of a collection and document struct: Example query: A new mongo.Document is always created by the corresponding collection object to initialize it with meta information about its collection. This way it is possible to implement Save() or Remove() methods for the document. Example for creating, modifying and saving a document:
go-start is a high level web-framework for Go, like Django for Python or Rails for Ruby. * Source: https://github.com/ungerik/go-start/ * Documentation: http://go-start.org/pkg/go-start/gostart/ Note: Don't use Go on 32 bit systems in production, it has severe memory leaks. (If the documentation URL above doesn't work, then godoc -html has has crashed because of that issue) ## Intro: Features: * HTML views can be defined in Go syntax * Optional template system * HTML5 Boilerplate page template (Mustache template, will be changed to Go v1 template) * Unified data model for forms and databases * Data models are simple Go structs * MongoDB as default database * User management/authentication out of the box * Additional packages for Planned Features: * medialib * CSRF protection * Tutorial App * Remove web.go * Controller of MVC implemented as REST service * Support for LESS CSS * Support for Twitter Bootstrap ## Views: The philosophy for creating HTML views is (unlike Rails/Django) that you should not have to learn yet another language to be able to write templates. There are several very simple template languages out there that reduce program code like logic within the template, but it’s still yet another syntax to learn. In go-start the HTML structure of a page is represented by a structure of type safe Go objects. It should feel like writing HTML but using the syntax of Go. And no, it has nothing to do with the mess of intertwined markup and code in PHP. Example of a static view: Example of a dynamic view: Beside DynamicView there is also a ModelIteratorView. It takes a model.Iterator and creates a dynamic view for every iterated data item: ## Pages and URLs: ## Models: Data is abstacted as models. The same model abstraction and data validation is used for HTML forms and for databases. So a model can be loaded from a database, displayed as an HTML form and saved back to the database after submit. This is not always a good practice, but it shows how easy things can be. A model is a simple Go struct that uses gostart/model types as struct members. Custom model wide validation is done by adding a Validate() method to the struct type: Here is how a HTML form is created that displays input fields for the SignupFormModel: MongoDB is the default database of go-start utilizing Gustavo Niemeyer's great lib mgo (http://labix.org/mgo). Mongo collections and queries are encapsulated to make them compatible with the go-start data model concept, and a little bit easier to use. Example of a collection and document struct: Example query: A new mongo.Document is always created by the corresponding collection object to initialize it with meta information about its collection. This way it is possible to implement Save() or Remove() methods for the document. Example for creating, modifying and saving a document:
Package temple provides an HTML rendering framework built on top of the html/template package. Temple is organized around Components and Renderables. A Component is some piece of the HTML document that you want included in the page's output. A Renderable is a Component that gets rendered itself rather than being included in another Component. The homepage of a site is probably a Renderable; the site's navbar is probably a Component, as is the base layout that all pages have in common. temple also has the concept of a Site. Each server should have a Site, which acts as a singleton for the server and provides the fs.FS containing the templates that Components are using. A Site will also be available at render time, as .Site, so it can hold configuration data used across all pages. To render a page, pass it to the Render function. The page itself will be made available as .Page within the template, and the Site will be available as .Site. Components tend to be structs, with properties for whatever data they want to pass to their templates. When a Component relies on another Component, our homepage including a navbar for example, a good practice is to make an instance of the navbar Component a property on the homepage Component struct. That allows the homepage to select, e.g., which link in the navbar is highlighted as active. It's also a good idea to include the navbar Component in the output of a UseComponents method on the homepage Component, so all its methods (the templates it uses, any CSS or JS that it embeds or links to, any Components _it_ relies on...) will all get included whenever the homepage Component is rendered.
go-start is a high level web-framework for Go, like Django for Python or Rails for Ruby. * Source: https://github.com/ungerik/go-start/ * Documentation: http://go-start.org/pkg/go-start/gostart/ Note: Don't use Go on 32 bit systems in production, it has severe memory leaks. (If the documentation URL above doesn't work, then godoc -html has has crashed because of that issue) ## Intro: Features: * HTML views can be defined in Go syntax * Optional template system * HTML5 Boilerplate page template (Mustache template, will be changed to Go v1 template) * Unified data model for forms and databases * Data models are simple Go structs * MongoDB as default database * User management/authentication out of the box * Additional packages for Planned Features: * medialib * CSRF protection * Tutorial App * Remove web.go * Controller of MVC implemented as REST service * Support for LESS CSS * Support for Twitter Bootstrap ## Views: The philosophy for creating HTML views is (unlike Rails/Django) that you should not have to learn yet another language to be able to write templates. There are several very simple template languages out there that reduce program code like logic within the template, but it’s still yet another syntax to learn. In go-start the HTML structure of a page is represented by a structure of type safe Go objects. It should feel like writing HTML but using the syntax of Go. And no, it has nothing to do with the mess of intertwined markup and code in PHP. Example of a static view: Example of a dynamic view: Beside DynamicView there is also a ModelIteratorView. It takes a model.Iterator and creates a dynamic view for every iterated data item: ## Pages and URLs: ## Models: Data is abstacted as models. The same model abstraction and data validation is used for HTML forms and for databases. So a model can be loaded from a database, displayed as an HTML form and saved back to the database after submit. This is not always a good practice, but it shows how easy things can be. A model is a simple Go struct that uses gostart/model types as struct members. Custom model wide validation is done by adding a Validate() method to the struct type: Here is how a HTML form is created that displays input fields for the SignupFormModel: MongoDB is the default database of go-start utilizing Gustavo Niemeyer's great lib mgo (http://labix.org/mgo). Mongo collections and queries are encapsulated to make them compatible with the go-start data model concept, and a little bit easier to use. Example of a collection and document struct: Example query: A new mongo.Document is always created by the corresponding collection object to initialize it with meta information about its collection. This way it is possible to implement Save() or Remove() methods for the document. Example for creating, modifying and saving a document:
go-start is a high level web-framework for Go, like Django for Python or Rails for Ruby. * Source: https://github.com/ungerik/go-start/ * Documentation: http://go-start.org/pkg/go-start/gostart/ Note: Don't use Go on 32 bit systems in production, it has severe memory leaks. (If the documentation URL above doesn't work, then godoc -html has has crashed because of that issue) ## Intro: Features: * HTML views can be defined in Go syntax * Optional template system * HTML5 Boilerplate page template (Mustache template, will be changed to Go v1 template) * Unified data model for forms and databases * Data models are simple Go structs * MongoDB as default database * User management/authentication out of the box * Additional packages for Planned Features: * medialib * CSRF protection * Tutorial App * Remove web.go * Controller of MVC implemented as REST service * Support for LESS CSS * Support for Twitter Bootstrap ## Views: The philosophy for creating HTML views is (unlike Rails/Django) that you should not have to learn yet another language to be able to write templates. There are several very simple template languages out there that reduce program code like logic within the template, but it’s still yet another syntax to learn. In go-start the HTML structure of a page is represented by a structure of type safe Go objects. It should feel like writing HTML but using the syntax of Go. And no, it has nothing to do with the mess of intertwined markup and code in PHP. Example of a static view: Example of a dynamic view: Beside DynamicView there is also a ModelIteratorView. It takes a model.Iterator and creates a dynamic view for every iterated data item: ## Pages and URLs: ## Models: Data is abstacted as models. The same model abstraction and data validation is used for HTML forms and for databases. So a model can be loaded from a database, displayed as an HTML form and saved back to the database after submit. This is not always a good practice, but it shows how easy things can be. A model is a simple Go struct that uses gostart/model types as struct members. Custom model wide validation is done by adding a Validate() method to the struct type: Here is how a HTML form is created that displays input fields for the SignupFormModel: MongoDB is the default database of go-start utilizing Gustavo Niemeyer's great lib mgo (http://labix.org/mgo). Mongo collections and queries are encapsulated to make them compatible with the go-start data model concept, and a little bit easier to use. Example of a collection and document struct: Example query: A new mongo.Document is always created by the corresponding collection object to initialize it with meta information about its collection. This way it is possible to implement Save() or Remove() methods for the document. Example for creating, modifying and saving a document:
go-start is a high level web-framework for Go, like Django for Python or Rails for Ruby. * Source: https://github.com/ungerik/go-start/ * Documentation: http://go-start.org/pkg/go-start/gostart/ Note: Don't use Go on 32 bit systems in production, it has severe memory leaks. (If the documentation URL above doesn't work, then godoc -html has has crashed because of that issue) ## Intro: Features: * HTML views can be defined in Go syntax * Optional template system * HTML5 Boilerplate page template (Mustache template, will be changed to Go v1 template) * Unified data model for forms and databases * Data models are simple Go structs * MongoDB as default database * User management/authentication out of the box * Additional packages for Planned Features: * medialib * CSRF protection * Tutorial App * Remove web.go * Controller of MVC implemented as REST service * Support for LESS CSS * Support for Twitter Bootstrap ## Views: The philosophy for creating HTML views is (unlike Rails/Django) that you should not have to learn yet another language to be able to write templates. There are several very simple template languages out there that reduce program code like logic within the template, but it’s still yet another syntax to learn. In go-start the HTML structure of a page is represented by a structure of type safe Go objects. It should feel like writing HTML but using the syntax of Go. And no, it has nothing to do with the mess of intertwined markup and code in PHP. Example of a static view: Example of a dynamic view: Beside DynamicView there is also a ModelIteratorView. It takes a model.Iterator and creates a dynamic view for every iterated data item: ## Pages and URLs: ## Models: Data is abstacted as models. The same model abstraction and data validation is used for HTML forms and for databases. So a model can be loaded from a database, displayed as an HTML form and saved back to the database after submit. This is not always a good practice, but it shows how easy things can be. A model is a simple Go struct that uses gostart/model types as struct members. Custom model wide validation is done by adding a Validate() method to the struct type: Here is how a HTML form is created that displays input fields for the SignupFormModel: MongoDB is the default database of go-start utilizing Gustavo Niemeyer's great lib mgo (http://labix.org/mgo). Mongo collections and queries are encapsulated to make them compatible with the go-start data model concept, and a little bit easier to use. Example of a collection and document struct: Example query: A new mongo.Document is always created by the corresponding collection object to initialize it with meta information about its collection. This way it is possible to implement Save() or Remove() methods for the document. Example for creating, modifying and saving a document:
Package gi is the top-level repository for the GoGi GUI framework. All of the code is in the sub-packages within this repository: * gist: css-based styling settings, including Color * girl: rendering library, can be used standalone, SVG compliant * gi: the main 2D GUI Node, Widgets, and Window * giv: more complex Views of Go data structures, supporting Model-View paradigm. * svg: full SVG rendering framework, used for Icons in gi. * gi3d: 3D rendering of a Scene within 2D windows -- full interactive 3D scenegraph. * histyle: text syntax-based highlighting styles -- used in giv.TextView * python: access all of GoGi from within Python using GoPy system.
Package xycss contains the xyrillian.css framework. Import it in your application to pull the CSS files in with `go mod vendor`.