thestrukture/IDE

View on GitHub
api/templates/templates.go

Summary

Maintainability
A
2 hrs
Test Coverage
F
4%
// File generated by Gopher Sauce
// DO NOT EDIT!!
package templates

import (
    "fmt"
    "html/template"
    "strings"

    gosweb "github.com/cheikhshift/gos/web"

    "github.com/thestrukture/IDE/api/assets"
    methods "github.com/thestrukture/IDE/api/methods"
    "github.com/thestrukture/IDE/types"
)

var TemplateFuncStore template.FuncMap

var templateCache = gosweb.NewTemplateCache()
var WebCache = gosweb.NewCache()

func StoreNetfn() int {
    // List of pipelines linked to each template.
    TemplateFuncStore = template.FuncMap{"a": gosweb.Netadd, "s": gosweb.Netsubs, "m": gosweb.Netmultiply, "d": gosweb.Netdivided, "js": gosweb.Netimportjs, "css": gosweb.Netimportcss, "sd": gosweb.NetsessionDelete, "sr": gosweb.NetsessionRemove, "sc": gosweb.NetsessionKey, "ss": gosweb.NetsessionSet, "sso": gosweb.NetsessionSetInt, "sgo": gosweb.NetsessionGetInt, "sg": gosweb.NetsessionGet, "form": gosweb.Formval, "eq": gosweb.Equalz, "neq": gosweb.Nequalz, "lte": gosweb.Netlt, "BindMisc": methods.BindMisc, "ListPlugins": methods.ListPlugins, "BindID": methods.BindID, "RandTen": methods.RandTen, "Fragmentize": methods.Fragmentize, "ParseLog": methods.ParseLog, "AnyBugs": methods.AnyBugs, "PluginJS": methods.PluginJS, "FindmyBugs": methods.FindmyBugs, "IsExpired": methods.IsExpired, "GetTemplate": methods.GetTemplate, "MConsole": methods.MConsole, "MPut": methods.MPut, "UpdateApp": methods.UpdateApp, "GetApp": methods.GetApp, "Css": netCss, "bCss": netbCss, "cCss": netcCss, "JS": netJS, "bJS": netbJS, "cJS": netcJS, "FA": netFA, "bFA": netbFA, "cFA": netcFA, "PluginList": netPluginList, "bPluginList": netbPluginList, "cPluginList": netcPluginList, "Login": netLogin, "bLogin": netbLogin, "cLogin": netcLogin, "Modal": netModal, "bModal": netbModal, "cModal": netcModal, "xButton": netxButton, "bxButton": netbxButton, "cxButton": netcxButton, "jButton": netjButton, "bjButton": netbjButton, "cjButton": netcjButton, "PUT": netPUT, "bPUT": netbPUT, "cPUT": netcPUT, "Group": netGroup, "bGroup": netbGroup, "cGroup": netcGroup, "Register": netRegister, "bRegister": netbRegister, "cRegister": netcRegister, "Alert": netAlert, "bAlert": netbAlert, "cAlert": netcAlert, "StructEditor": netStructEditor, "bStructEditor": netbStructEditor, "cStructEditor": netcStructEditor, "MethodEditor": netMethodEditor, "bMethodEditor": netbMethodEditor, "cMethodEditor": netcMethodEditor, "ObjectEditor": netObjectEditor, "bObjectEditor": netbObjectEditor, "cObjectEditor": netcObjectEditor, "EndpointEditor": netEndpointEditor, "bEndpointEditor": netbEndpointEditor, "cEndpointEditor": netcEndpointEditor, "TimerEditor": netTimerEditor, "bTimerEditor": netbTimerEditor, "cTimerEditor": netcTimerEditor, "FSC": netFSC, "bFSC": netbFSC, "cFSC": netcFSC, "MV": netMV, "bMV": netbMV, "cMV": netcMV, "RM": netRM, "bRM": netbRM, "cRM": netcRM, "WebRootEdit": netWebRootEdit, "bWebRootEdit": netbWebRootEdit, "cWebRootEdit": netcWebRootEdit, "WebRootEdittwo": netWebRootEdittwo, "bWebRootEdittwo": netbWebRootEdittwo, "cWebRootEdittwo": netcWebRootEdittwo, "uSettings": netuSettings, "buSettings": netbuSettings, "cuSettings": netcuSettings, "Form": netForm, "bForm": netbForm, "cForm": netcForm, "SWAL": netSWAL, "bSWAL": netbSWAL, "cSWAL": netcSWAL, "ROC": netROC, "bROC": netbROC, "cROC": netcROC, "RPUT": netRPUT, "bRPUT": netbRPUT, "cRPUT": netcRPUT, "PackageEdit": netPackageEdit, "bPackageEdit": netbPackageEdit, "cPackageEdit": netcPackageEdit, "Delete": netDelete, "bDelete": netbDelete, "cDelete": netcDelete, "Welcome": netWelcome, "bWelcome": netbWelcome, "cWelcome": netcWelcome, "Stripe": netStripe, "bStripe": netbStripe, "cStripe": netcStripe, "Debugger": netDebugger, "bDebugger": netbDebugger, "cDebugger": netcDebugger, "TemplateEdit": netTemplateEdit, "bTemplateEdit": netbTemplateEdit, "cTemplateEdit": netcTemplateEdit, "TemplateEditTwo": netTemplateEditTwo, "bTemplateEditTwo": netbTemplateEditTwo, "cTemplateEditTwo": netcTemplateEditTwo, "Input": netInput, "bInput": netbInput, "cInput": netcInput, "DebuggerNode": netDebuggerNode, "bDebuggerNode": netbDebuggerNode, "cDebuggerNode": netcDebuggerNode, "Button": netButton, "bButton": netbButton, "cButton": netcButton, "Submit": netSubmit, "bSubmit": netbSubmit, "cSubmit": netcSubmit, "Logo": netLogo, "bLogo": netbLogo, "cLogo": netcLogo, "Navbar": netNavbar, "bNavbar": netbNavbar, "cNavbar": netcNavbar, "NavCustom": netNavCustom, "bNavCustom": netbNavCustom, "cNavCustom": netcNavCustom, "NavMain": netNavMain, "bNavMain": netbNavMain, "cNavMain": netcNavMain, "NavPKG": netNavPKG, "bNavPKG": netbNavPKG, "cNavPKG": netcNavPKG, "CrashedPage": netCrashedPage, "bCrashedPage": netbCrashedPage, "cCrashedPage": netcCrashedPage, "EndpointTesting": netEndpointTesting, "bEndpointTesting": netbEndpointTesting, "cEndpointTesting": netcEndpointTesting, "KanBan": netKanBan, "bKanBan": netbKanBan, "cKanBan": netcKanBan, "Docker": netDocker, "bDocker": netbDocker, "cDocker": netcDocker, "SearchProject": netSearchProject, "bSearchProject": netbSearchProject, "cSearchProject": netcSearchProject, "NavPromo": netNavPromo, "bNavPromo": netbNavPromo, "cNavPromo": netcNavPromo, "FSCs": types.NewFSCs, "isFSCs": types.CastFSCs, "SearchResult": types.NewSearchResult, "isSearchResult": types.CastSearchResult, "Dex": types.NewDex, "isDex": types.CastDex, "SoftUser": types.NewSoftUser, "isSoftUser": types.CastSoftUser, "USettings": types.NewUSettings, "isUSettings": types.CastUSettings, "App": types.NewApp, "isApp": types.CastApp, "TemplateEdits": types.NewTemplateEdits, "isTemplateEdits": types.CastTemplateEdits, "WebRootEdits": types.NewWebRootEdits, "isWebRootEdits": types.CastWebRootEdits, "TEditor": types.NewTEditor, "isTEditor": types.CastTEditor, "Navbars": types.NewNavbars, "isNavbars": types.CastNavbars, "SModal": types.NewSModal, "isSModal": types.CastSModal, "Forms": types.NewForms, "isForms": types.CastForms, "SButton": types.NewSButton, "isSButton": types.CastSButton, "STab": types.NewSTab, "isSTab": types.CastSTab, "DForm": types.NewDForm, "isDForm": types.CastDForm, "Alertbs": types.NewAlertbs, "isAlertbs": types.CastAlertbs, "Inputs": types.NewInputs, "isInputs": types.CastInputs, "Aput": types.NewAput, "isAput": types.CastAput, "RPut": types.NewRPut, "isRPut": types.CastRPut, "SSWAL": types.NewSSWAL, "isSSWAL": types.CastSSWAL, "SPackageEdit": types.NewSPackageEdit, "isSPackageEdit": types.CastSPackageEdit, "DebugObj": types.NewDebugObj, "isDebugObj": types.CastDebugObj, "DebugNode": types.NewDebugNode, "isDebugNode": types.CastDebugNode, "PkgItem": types.NewPkgItem, "isPkgItem": types.CastPkgItem, "SROC": types.NewSROC, "isSROC": types.CastSROC, "VHuf": types.NewVHuf, "isVHuf": types.CastVHuf}
    return 0
}

var FuncStored = StoreNetfn()

// load a page from your web root by passing the
// path, relative to your web root.
func LoadPage(title string) (*gosweb.Page, error) {

    if lPage, ok := WebCache.Get(title); ok {
        return &lPage, nil
    }

    var nPage = gosweb.Page{}
    if roottitle := (title == "/"); roottitle {
        webbase := "web/"
        fname := fmt.Sprintf("%s%s", webbase, "index.html")
        body, err := assets.Asset(fname)
        if err != nil {
            fname = fmt.Sprintf("%s%s", webbase, "index.tmpl")
            body, err = assets.Asset(fname)
            if err != nil {
                return nil, err
            }
            nPage.Body = body
            WebCache.Put(title, nPage)
            body = nil
            return &nPage, nil
        }
        nPage.Body = body
        nPage.IsResource = true
        WebCache.Put(title, nPage)
        body = nil
        return &nPage, nil

    }

    filename := fmt.Sprintf("web%s.tmpl", title)

    if body, err := assets.Asset(filename); err != nil {
        filename = fmt.Sprintf("web%s.html", title)

        if body, err = assets.Asset(filename); err != nil {
            filename = fmt.Sprintf("web%s", title)

            if body, err = assets.Asset(filename); err != nil {
                return nil, err
            } else {
                if strings.Contains(title, ".tmpl") {
                    return nil, nil
                }
                nPage.Body = body
                nPage.IsResource = true
                WebCache.Put(title, nPage)
                body = nil
                return &nPage, nil
            }
        } else {
            nPage.Body = body
            nPage.IsResource = true
            WebCache.Put(title, nPage)
            body = nil
            return &nPage, nil
        }
    } else {
        nPage.Body = body
        WebCache.Put(title, nPage)
        body = nil
        return &nPage, nil
    }

}