Giter VIP home page Giter VIP logo

gapt's Introduction

gapt wip draft

gapt is a go asset packaging tool to bundle and preprocess resources before compilation, e.g. by using go generate. It is more comparable to aapt, the android asset packaging tool.

At first, this sounds very familiar to other bundle tools like vfsgen, go.rice, statik, packr or go-bindata but gapt is more dynamic and allows efficient customization and replacements of asset files at runtime using fsnotify mechanism, both while developing or in release mode. This allows to overload embedded files dynamically at runtime, either by directly using the original files from your module while developing or by placing them in a folder in release mode. This can be applied to configuration files or templates as well and is very useful for whitelabel software which must be highly customizable without forking or recompilation. You even don't need to restart the process at all.

Milestones and features

  • find a cool name and define project goals
  • embedding files into byte slices
  • parse templates at processing time and fail early
  • using non-embedded files in development mode
  • overlay resources from different origins
  • fsnotify in release and development mode
  • localized resources
  • multi-client/multi-tenant resources
  • build variants and exclude resources by compilation flag
  • basic localization using android strings format
  • android string plurals and non-translatable texts
  • generate type safe interfaces to use parameterized strings safely and let compiler do the type checks

FAQ

How does it work with modules?

Modules will contain the generated type safe accessors and will register them self at the AssetManager which provides a central fnotify infrastructure and aggregates an aggregated view over all resources. Each virtual tree may have an overlay by a local file system tree.

Resources of GAPT are organized and accessed within a single virtual filesystem of http.FileSystem. The convention is the following:

/ 
│
└───www
│   │   app.wasm
│   │   style.css
│   │   ...
│   │
│   └───js
│       │   app.js
│       │   libXY.js
│       │   ...
│   
└───tmpl
|   │   header.gohtml
|   │   footer.gohtml
│   │   ...
│   │
│   └───user
│           show.gohtml
│           list.gohtml
│           ...
└───etc
|   │   myproject-config.json
│           ...
|
└───values
│   │   hello_world
│   │   ...
|   |   
└───values-de-DE
│   │   hello_world
│   └───github.com
│   |   └─── mycompany
│   |        └─── myproject
│   |                 userName
│   |                 password
│   │                 ...
|   |   

The www-folder is always published over http as root. All other files and folders should never be made accessible through the web server. Localized values are also handled as files, however the according File implementation will provide an efficient shortcut. In general, as a convention, a module should fan out their data with their actual module name. Strings within the values folder are just plain simple utf-8 byte sequences, with optional positional placeholders. Plurals and gender variants need still to be defined but will likely be represented by a json format, e.g. indicated by .pl extension.

DSL proposal

# ADD <namespace>:<src>
# $local denotes the local module name 
ADD $local:*.gotmpl :.
ADD config/etc/colors.xml .

JSON proposal

{
  ".": {
    "add": ["*.gotmpl","config/etc/colors.xml"],
    "ignore": ["users/test.gotmpl"]
  },
  "github.com/mycompany/privateprj": {
    "remove": ["groups/layout.xml"],
    "add": ["customization/stuff/*"]
  }
}

gapt's People

Contributors

torbenschinke avatar

Stargazers

Fred Lahde avatar

Watchers

James Cloos avatar Julian Kahnert avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.