From af90ba0a6c3cdb3239470893a0f5a4ba4e7d1e0e Mon Sep 17 00:00:00 2001 From: Cheikh Seck Date: Wed, 23 Aug 2017 01:08:46 +0000 Subject: [PATCH] Update readme.md --- readme.md | 730 +----------------------------------------------------- 1 file changed, 3 insertions(+), 727 deletions(-) diff --git a/readme.md b/readme.md index 6ddf543..bd98536 100644 --- a/readme.md +++ b/readme.md @@ -1,729 +1,5 @@ -## Updates : -- 1.14.2016 : Leverage your hardware now with [Hardware kit](hardwarekit.md) --12.18.2015 : Mobile Support added. Create IOS applications from Go lang templates and functions. [Tutorial](tutorial.md) -- 6.10.2017: Update to .gxml file extension. Automatic support with Sublime syntax correction. -- 8.06.2017 : Debug with GoS compiler directly, Cloudflare ready. +Visit The Gopher Sauce wiki : [Link](https://github.com/cheikhshift/Gopher-Sauce/wiki) +## Bugs -# Gopher Sauce Markup language -![Implies that Gopher sauce uses Go to write go programs.](https://lh3.googleusercontent.com/-vnw4NhuJKQY/VmuZgzodIPI/AAAAAAAAAAM/mbm7EfWjfsY/s0/xlarge.png "xlarge.png") - -Gopher Sauce is is a command line tool used for compiling GoS projects. A GoS project uses XML sources and Go lang packages to create a web server. It uses xml to build onto Go lang's [template](https://golang.org/pkg/html/template/) processing functionality, making it easier to define custom objects,methods and structs that are accessible to your templates as well as any Go lang declarations within your GoS project. -Gopher Sauce makes web server application distribution easy by compiling your entire Gopher Sauce application's sources and misc. file resources into one binary. - -### How to install GoS - go get github.com/cheikhshift/gos - go install github.com/cheikhshift/gos - gos deps - -### Generate project -GoS can be used to generated package folders with the option `make` -For Example : - - $GOPATH/bin/gos make some/pkg/name - -## OR - - -![](https://orkiv.com/sapphire/gs-intro.gif) - -### Handle GoS Dependencies -The application generated by Gopher Sauce has certain dependencies. Please run the command below to download them before attempting to run or export your application. (Assuming $GOPATH is set) - - $GOPATH/bin/gos dependencies - -# Table of Content - - 1. [GoS XML template](#gos-xml-template) - 2. [GoS project layout](#gos-project-layout) - 3. [Core Usage](#core-usage) - 1. [Using GoS command without parameters](#using-gos-command-without-parameters) - 2. [GoS running application](#gos-running-application) - 3. [GoS export application](#gos-export-application) - 4. [GoS Bind to Xcode Project](#gos-ios-application) - 4. [Configuring GoS xml file](#configuring-gos-xml-file) - 1. [Deploy](#deploy) - 2. [Web](#web-tag) - 3. [Tmpl](#tmpl-tag) - 2. [Port](#port) - 3. [Output](#output) - 4. [Key](#key) - 5. [Init](#init) - 6. [Main](#main) - 7. [Var](#var) - 8. [Header](#header) - 1. [Structs](#struct) - 2. [Objects](#objects) -9. [Methods](#methods) -10. [Timers](#timers) -11. [Templates](#templates) -12. [API Generation](#api-generation) -13. [Imports](#imports) - 5. [GoS builtin template functions](#gos-builtin-template-functions) - 6. [GoS page](#gos-page) - 7. [Mobile Sessions](#mobile-session) - 8. [Mobile Views](#mobile-views) - 8. [Bug tracking](#bug-tracking) - -# GoS XML template -The GoS XML template is where your application's imports, structs,objects,methods,timers,templates and end point hooks. Here is a fully documented project template [file](https://github.com/cheikhshift/Gopher-Sauce/blob/master/src/github.com/cheikhshift/gosapphire/server.xml) - - Below is an example of a very minimal GoS XML source : -This Example will save a file named server_out.go to the package package in the gos cmd tool. It will create one struct called DemoChild in the native go manner. - - - - webapp - 8080 - - server_out.go - - something-secretive-is-what-a-gorrilla-needs -
- - - SomeOtherAttr string - -
-
- -# GoS project layout -This section covers the integration of GoS with your current Go configuration. GoS project minimally requires a GoS XML template, a web root folder and a template root folder. - - - Template folder is the root folder for all templates declared within your application - - Web root can contain both usual server resource data and template pages as well. Template pages within the web root folder have access to user sessions. - - *webroot/dist/ is initialized as a fileserver to correct issues when serving css files. It will not compile templates and handle api end points with the `/dist/` prefix. - -Your GoS project should look like this - - $GOPATH/src/ - |- your/package/name - |- gos_xml_template.gxml - |- web_root/ - |- index.html - template_root/ - |- email.tmpl - - -# Core Usage -This section covers how to use the command line tool - -## Using GoS command without parameters -It is possible to invoke gos directly without commands. Simply answer the questions and watch your application compile. The program will guide you through the process. - - $GOPATH/bin/gos - -## GoS running application -To compile and run your GoS application invoke `gos` with the run parameter. -The example below will compile a package called `sample/test` with configuration file `server.gxml`, a web root folder called `web` as well as a templates directory called `tmpl` , - -*Command of process described - $GOPATH/bin/gos run sample/test server.gxml web tmpl - -The command above should compile and execute your program. Invoking the `gos` with the run parameter will put go-bindata in -debug mode so that you can edit your server resources and templates while your application is in running. -## GoS export application -Exporting your application will wrap up all of your GoS project resources as one binary ready for distribution (Zips require too much work). To compile and export your GoS application invoke `gos` with the export parameter. -For example to export a package called `sample/test` with configuration file `server.gxml`, a web root folder called `web` as well as a templates directory called `tmpl`, the command below will be ran : - - $GOPATH/bin/gos export - *Command of process described - $GOPATH/bin/gos export sample/test server.gxml web tmpl - -Unlike running the GoS application, this build will have static copies of its resources at the time of compilation. The executable will be placed in your GoS project root (package root). This copy can be ran anywhere without the need of resources within your package. - -## Gos IOS application -Bind your IOS project with your GoS project. Please make sure that this packages GoS configuration file has its deploy set to `bind`. - - $GOPATH/bin/gos export - //ios_project_path = the folder with your Xcode project's .xcodeproj file as a child element - - -# Configuring GoS XML file -This section covers documentation of GoS XML template tags. Here is how to export your application, and to simplify the command line entry process, we recommend creating your new Xcode project in the same folder as your package. Read this [Tutorial](tutorial.md) to make your first GoS Mobile application - - -## Deploy -Application deploy specifies the manner that GoS should compile your application. Use `webapp` to have GoS generate a webserver for you. To link this package to an app use `bind` instead of `webapp`. This tag should always be within the root of the `` tag. - -### Available Deploy types - - - webapp : Will add Go's default Http Listener to your package's `main()` function. - - bind : Will create the framework files needed to use your GoS config as an HTML5 based application for mobile. - - package : Make your package's template's and web resources exportable. - -*This tag is required - - - ... - webapp - ... - - -## Web tag -Specifies the name of the folder that contains your web resources within your GoS exportable package. - - - ... - foldername - ... - - -## Tmpl tag -Specifies the name of the folder containing your template files within your Gos exportable package. - - - ... - foldername - ... - - -## Session -Custom variables append to the `session` Struct. Useful for setting custom Exported fields for the session struct. More information on mobile sessions [here](#mobile-session) with templates - - - ... - - Theme Color // assuming the struct Color exists - Other,userid string - - ... - - -## Package -This is only applicable to applications of type `bind` (mobile) and `package`. It specifies the package name to use in generation of your IOS FrameWork. It specifies the web and template folder prefix for your exportable GoS package. - - - ... - packageName - ... - - -## Port -(if applicable) Specifies the port your application should listen on. - - - ... - 8080 - ... - -## Output -The name of the file that GoS will save. -*This tag is required - - - ... - server_out.go - ... - -## Key - -(if applicable) used as cookie store key within your web app - - - ... - my-key-braah - ... - -## Init -GoS will wrap the data within this tag into the usual Go `init()` function -For example : - - - ... - - fmt.Println("Logging from init function") - - ... - -Will translate into - - func init(){ - fmt.Println("Logging from init function") - } -This can be useful for registering custom declared structs for Session use. - -## Main -GoS will wrap the data within this tag into the go `main()` function. -For example : - - - ... -
- fmt.Println("Logging from main function") -
- ... -
-Will translate into - - func main(){ - ... - fmt.Println("Logging from Main function") - ... - } - - -## Variables -To declare public variables that are accessible to your program use the `var` tag. Use the type parameter to specify the variable type. Use the `*` qualifier as appropriate. -For example - - FreeServer -Will become (within your Go program) - - var FreeServer string -## Header -Think of the `
` tag as the interface of your application. It holds structure and object declarations. -### Structs -The `` tag will declare a new Go structure within within your generated Go src. -#### Attributes -name - The name of this structure -** Innerxml Struct parameter declarations. - -The example below declares a Go struct named DemoGos with a sub structure called DemoChild. The struct DemoGos has attributes SomeAttr and Child. - -These structs are available everywhere within your application. - -Whenever this struct is initialized within a template, these variables are accessible as that object's properties. - - - ... -
- - SomeOtherAttr string - - - SomeAttr string - Child *DemoChild - -
- ... -
-### Objects -The `` tag declares a GoS object. It needs struct name to have a parameter map, which is used whenever this object is initialized within a template. Please keep in mind that the struct specified for this object must be returned all the time. -#### Attributes - struct - the name of a struct available to the application - name - name of object -The example below will declare an object called `myDemoObject`. The inner content of this tag is where object methods are declared. (remember to jumpline after each declaration!!!) -These functions also need to be declared within your GoS application xml template or another imported xml template. - - - - ... -
- - Hackfmt(save string) - WhatsMyAttr(save string,end string) string - WhatsMyAttrLength() string - -
- ... -
-By declaring an object : - - GoS will create a Go lang `type` with the object's name linked to its respective struct - - GoS will create a local and template accessible method to initialize this object. Local method : `net_myDemoObject(args ...interface{}) (d DemoGos)`. Template method : {{$emptyObject := myDemoObject}}. - -- Invoking object with static parameters : `{{$object := myDemoObject /{`\`SomeAttr\`:\`ValueIn\`}/ }}`. To pass initialization variables we can use a static json escape holders `/{` and `}/`. To initialize your variable with other objects create a method that returns this object by using the desired input initialization objects to use. - -- Each function specified within this tag, will be generated to accept this object as a mutable parameter within templates as well as your application's local scope. Local function generated : - ` func (object DemoGos) Hackfmt(save string) ` - You can access this function via templates by invoking these calls within any template in this application : `{{$object | Hackfmt "data"}}` or `{{$error := $object | Hackfmt "data" }}`. The return type declared will be returned, so please make sure that type is returned within the linked method. - -*If an Object and a template share a struct you can initialize the template and compile it to html with this call `{{b