fragmenta

command module
v1.5.6 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2018 License: MIT Imports: 17 Imported by: 0

README

Fragmenta

Fragmenta is a command line tool for creating, managing and deploying golang web applications. It comes with a suite of libraries which making developing web apps easier, and aims to allow managing apps without making too many assumptions about which libraries they use or their internal structure. It takes care of generating CRUD actions, handling auth, routing and rendering and leaves you to concentrate the parts of your app which are unique.

Using Fragmenta
  • fragmenta version -> display version
  • fragmenta help -> display help
  • fragmenta new [app|cms|blog|URL] path/to/app -> creates a new app from the repository at URL at the path supplied
  • fragmenta -> builds and runs a fragmenta app
  • fragmenta server -> builds and runs a fragmenta app
  • fragmenta test -> run tests
  • fragmenta backup [development|production|test] -> backup the database to db/backup
  • fragmenta restore [development|production|test] -> backup the database from latest file in db/backup
  • fragmenta deploy [development|production|test] -> build and deploy using bin/deploy
  • fragmenta migrate -> runs new sql migrations in db/migrate
  • fragmenta generate resource [name] [fieldname]:[fieldtype]* -> creates resource CRUD actions and views
  • fragmenta generate migration [name] -> creates a new named sql migration in db/migrate
App structure

The default apps are laid out with the following structure:

  • bin -> server binaries, and optional deploy script
  • db -> database backups and migrations
  • public -> files for serving publicly, including assets, uploaded files etc
  • secrets -> config files, not usually checked in
  • server.go -> your app entrypoint (required)
  • src -> app source files - structure within this folder is up to you

The pkg layout within the app is up to you - defaults are provided but are not mandatory. Within src the default are arranged in packages by resource - the generator generates a new resource with the following structure:

  • pages -> resource name
    • actions -> go actions (handling CRUD etc) for this resource
    • assets -> js,css, images for this resource
    • pages.go -> the resource model file
    • pages_test.go -> tests for this model
    • views -> views for this resource
Libraries

The following independent packages are available for use with fragmenta apps (or other go web apps).

  • assets - an asset pipeline with minification and concatenation with asset fingerprinting
  • auth - utilities for authentication and authorisation
  • fragmenta - a command line tool for generating and developing websites
  • model - a base model class for optional inclusion in models
    • file - a package for handling file uploads
    • validate - a package for handling field validation
  • query - a query builder and result wrapper for mysql, psql and optionally sqlite
  • router - a router which allows pattern matching, routes, redirects, filters and provides a handler interface
  • server - a simple server based on http.listenandserve
  • view - a library for rendering view templates using html/template
    • helpers - helpers for form fields, currencies etc

Documentation

Overview

Fragmenta provides a set of independent libraries for building golang web applications, and a command line tool for generating, developing and running apps.

To install run:

go get github.com/fragmenta/fragmenta

The following subcommands are available when using the command line fragmenta tool:

------
  fragmenta version -> display version
  fragmenta help -> display help
  fragmenta new [app|cms|URL of go gettable project] path/to/app -> creates a new app from the repository at URL at the path supplied
  fragmenta -> builds and runs a fragmenta app
  fragmenta server -> builds and runs a fragmenta app
  fragmenta test  -> run tests
  fragmenta migrate -> runs new sql migrations in db/migrate
  fragmenta backup [development|production|test] -> backup the database to db/backup
  fragmenta restore [development|production|test] -> backup the database from latest file in db/backup
  fragmenta deploy [development|production|test] -> build and deploy using bin/deploy
  fragmenta generate resource [name] [fieldname]:[fieldtype]* -> creates resource CRUD actions and views
  fragmenta generate migration [name] -> creates a new named sql migration in db/migrate
------

These let you create a new website, run the website, run tests on all packages, migrate, backup and restore the database, deploy the app to production, and generate resources (model, actions, views, migration) and migrations.

Fragmenta also provides a suite of libraries for web development, which can be used independently:

  • assets - an asset pipeline with minification and concatenation with asset fingerprinting
  • auth - utilities for authentication and authorisation
  • model - a base model class for optional inclusion in models
  • file - a package for handling file uploads
  • validate - a package for handling field validation
  • query - a query builder and result wrapper for mysql, psql and optionally sqlite
  • router - a router which allows pattern matching, routes, redirects, filters and provides a handler interface
  • server - a simple server based on http.listenandserve
  • view - a library for rendering view templates using html/template
  • helpers - helpers for form fields, currencies etc

The fragmenta tool requires the following two files to exist in a project directory:

server.go
secrets/fragmenta.json (app config)

otherwise the structure of your app is up to you. The default structure given in examples is to have a package per REST resource, so for example pages has a package under src, which contains the following folders/files

src/pages
    actions ->
    assets -> js, css, and images for pages
    views -> golang html/template files ending in .got
    pages.go -> the pages model
    pages_test.go -> tests for the pages model

These are suggested patterns and can be overridden by editing the files in lib/template in your project, which define exactly what is generated by fragmenta generate.

Jump to

Keyboard shortcuts

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