pankul

package module
v0.0.0-...-16e543d Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: MIT Imports: 15 Imported by: 0

README

pankul

A database helper.

Helps to quickly create and edit flaarum tables

Projects Used

Setup

Users Table Setup

Note that user creation and updating is not part of this project. You as the administrator is to provide this. This is to ensure that you can use any form of authentication you want eg. social auth (Facebook, google, twitter), passwords, fingerprint, keys etc.

Create a users table with the following properties:

  1. it must also have fields firstname and surname for easy recognition.
  2. it must also have field email for communications.
  3. it must also have field timezone for datetime data. Example value is 'Africa/Lagos'

You must also provide a function that would get the currently logged in users. The function is given the request object to get the cookies for its purpose. Set the pankul.GetCurrentUser to this function. The function has the following declaration func(r *http.Request) (int64, error).

The pankul.GetCurrentUser should return 0 for public.

Begin

Get the framework through the following command go get -u github.com/bankole7782/pankul

There is a sample application which details how to complete the setup. Take a look at it here

Copy the folder pankul_files from the main repo into the same path as your main.go.

Make sure you look at main.go in the sample app, copy and edit it to your own preferences.

Go to /pk/setup/ to create some tables that the project would need.

Then go to /pk/page/ to start using this project.

License

Released with the MIT License

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Admins []int64
View Source
var BaseTemplate string
View Source
var FILENAME_SEPARATOR = "____"
View Source
var GetCurrentUser func(r *http.Request) (int64, error)

Functions

func AddHandlers

func AddHandlers(r *mux.Router)

func CreateDocument

func CreateDocument(ds string, dataMap map[string]string, userId int64) (int64, error)

This function would be used for saving in your create pages.

func GetDocumentStructureList

func GetDocumentStructureList() ([]string, error)

func MakeDataMapFromRequest

func MakeDataMapFromRequest(r *http.Request) map[string]string

Gets a dataMap (map[string]string) from the request object.

func UpdateDocument

func UpdateDocument(ds string, docId int64, dataMap map[string]string, userId int64) error

This is used in your update pages. It should be called to complete an update action.

Types

type DocAndStructure

type DocAndStructure struct {
	DocData
	Data string
}

func GetDocument

func GetDocument(ds string, docId int64, userId int64) ([]DocAndStructure, map[string]string, error)

This function can be used in your update pages or view pages. This function would get the structure and data for presentation as a form with some values. The second field contains meta information: created, created_by & modified.

type DocData

type DocData struct {
	Label        string
	Name         string
	Type         string
	Required     bool
	Unique       bool
	OtherOptions []string
}

func GetDocData

func GetDocData(documentStructure string) ([]DocData, error)

This function can be used for rendering a form. You are to loop through the returned object to create a form.

type Row

type Row struct {
	Id               string
	DocAndStructures []DocAndStructure
	NeedsUpdate      bool
}

func GetDocuments

func GetDocuments(userId int64, documentStructure string, elementValues map[string]string, pageNum int64) ([]Row, int64, error)

This function is used for list pages. Sample input:

map[string]string {
  email = "jj@jj.com",
  order_by = "dt",
  order_by = "asc",
}

pageNum starts from one It returns the documents in []Row, the total pages as its second output and lastly errors.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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