Skip to content

Commit 1114bd8

Browse files
committed
sub-packages, quotation marking and environment variables implemented
1 parent 4ca96eb commit 1114bd8

102 files changed

Lines changed: 1229 additions & 944 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

assets/fonts.css

Lines changed: 0 additions & 83 deletions
This file was deleted.

build-release.cmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
cd internal\config
2+
go generate
3+
cd ..\..
14
go generate
25
go build -ldflags "-H=windowsgui -s -w" -trimpath

build-release.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/bin/bash
2+
cd internal/config
3+
go generate
4+
cd ../..
25
go generate
36
go build -ldflags "-s -w" -trimpath
47
#chmod +x ./edm

companies.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"database/sql"
5+
"edm/pkg/accs"
56
"encoding/json"
67
"log"
78
"net/http"
@@ -13,6 +14,7 @@ import (
1314
// CompaniesPage is passed into template
1415
type CompaniesPage struct {
1516
AppTitle string
17+
AppVersion string
1618
PageTitle string
1719
LoggedinID int
1820
LoggedinAdmin bool
@@ -39,6 +41,7 @@ func (bs *BaseStruct) companiesHandler(w http.ResponseWriter, r *http.Request) {
3941

4042
var Page = CompaniesPage{
4143
AppTitle: bs.text.AppTitle,
44+
AppVersion: AppVersion,
4245
PageTitle: bs.text.CompaniesPageTitle,
4346
LoggedinID: id,
4447
}
@@ -137,7 +140,7 @@ ORDER BY c.ShortName ASC, c.FullName ASC, c.ForeignName ASC`)
137140
}()
138141

139142
if err != nil {
140-
log.Println(currentFunction()+":", err)
143+
log.Println(accs.CurrentFunction()+":", err)
141144
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
142145
//http.Error(w, err.Error(), http.StatusInternalServerError) //Commented to not displayng error details to end user
143146
return
@@ -155,7 +158,7 @@ ORDER BY c.ShortName ASC, c.FullName ASC, c.ForeignName ASC`)
155158
// HTML output
156159
err = bs.templates.ExecuteTemplate(w, "companies.tmpl", Page)
157160
if err != nil {
158-
log.Println(currentFunction()+":", err)
161+
log.Println(accs.CurrentFunction()+":", err)
159162
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
160163
//http.Error(w, err.Error(), http.StatusInternalServerError) //Commented to not displayng error details to end user
161164
return

company.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"database/sql"
5+
"edm/pkg/accs"
56
"encoding/json"
67
"fmt"
78
"log"
@@ -40,7 +41,7 @@ func unmarshalNonEmptyCompanyContacts(c string) (res CompanyContacts) {
4041
if c != "" {
4142
err := json.Unmarshal([]byte(c), &res)
4243
if err != nil {
43-
log.Println(currentFunction()+":", err)
44+
log.Println(accs.CurrentFunction()+":", err)
4445
}
4546
}
4647
return res
@@ -255,6 +256,7 @@ func (u Unit) GiveHeadNameJob() (head string) {
255256
// CompanyPage is passed into template
256257
type CompanyPage struct {
257258
AppTitle string
259+
AppVersion string
258260
PageTitle string
259261
LoggedinID int
260262
UserConfig UserConfig
@@ -282,6 +284,7 @@ func (bs *BaseStruct) companyHandler(w http.ResponseWriter, r *http.Request) {
282284

283285
var Page = CompanyPage{
284286
AppTitle: bs.text.AppTitle,
287+
AppVersion: AppVersion,
285288
LoggedinID: id,
286289
Editable: false,
287290
New: false,
@@ -293,7 +296,7 @@ func (bs *BaseStruct) companyHandler(w http.ResponseWriter, r *http.Request) {
293296
Page.Editable = true
294297
}
295298

296-
TextID := getTextIDfromURL(r.URL.Path)
299+
TextID := accs.GetTextIDfromURL(r.URL.Path)
297300
IntID, _ := strconv.Atoi(TextID)
298301

299302
var created int
@@ -302,7 +305,7 @@ func (bs *BaseStruct) companyHandler(w http.ResponseWriter, r *http.Request) {
302305
// Create or update code ==========================================================================
303306
if r.Method == "POST" && (r.FormValue("createButton") != "" || r.FormValue("updateButton") != "") {
304307
if Page.Editable == false {
305-
throwAccessDenied(w, "writing company", Page.LoggedinID, IntID)
308+
accs.ThrowAccessDenied(w, "writing company", Page.LoggedinID, IntID)
306309
return
307310
}
308311
c := Company{
@@ -358,7 +361,7 @@ func (bs *BaseStruct) companyHandler(w http.ResponseWriter, r *http.Request) {
358361
// Create or update Units =====================================================================
359362
if r.Method == "POST" && (r.FormValue("createUnit") != "" || r.FormValue("updateUnit") != "") {
360363
if Page.Editable == false {
361-
throwAccessDenied(w, "writing unit", Page.LoggedinID, IntID)
364+
accs.ThrowAccessDenied(w, "writing unit", Page.LoggedinID, IntID)
362365
return
363366
}
364367
UnitIntID, _ := strconv.Atoi(r.FormValue("unitID"))
@@ -389,7 +392,7 @@ func (bs *BaseStruct) companyHandler(w http.ResponseWriter, r *http.Request) {
389392
// Delete Unit ================+==========================
390393
if r.Method == "POST" && r.FormValue("deleteUnit") != "" {
391394
if Page.Editable == false {
392-
throwAccessDenied(w, "writing unit", Page.LoggedinID, IntID)
395+
accs.ThrowAccessDenied(w, "writing unit", Page.LoggedinID, IntID)
393396
return
394397
}
395398
UnitIntID, _ := strconv.Atoi(r.FormValue("unitID"))
@@ -414,13 +417,13 @@ func (bs *BaseStruct) companyHandler(w http.ResponseWriter, r *http.Request) {
414417
Page.Company.ID = IntID
415418
err = Page.Company.load(bs.db, bs.dbt)
416419
if err != nil {
417-
log.Println(currentFunction()+":", err)
420+
log.Println(accs.CurrentFunction()+":", err)
418421
http.NotFound(w, r)
419422
return
420423
}
421424
Page.Units, err = Page.Company.loadUnits(bs.db, bs.dbt)
422425
if err != nil {
423-
log.Println(currentFunction()+":", err)
426+
log.Println(accs.CurrentFunction()+":", err)
424427
http.NotFound(w, r)
425428
return
426429
}
@@ -448,8 +451,8 @@ func (bs *BaseStruct) companyHandler(w http.ResponseWriter, r *http.Request) {
448451
// HTML output
449452
err = bs.templates.ExecuteTemplate(w, "company.tmpl", Page)
450453
if err != nil {
451-
log.Println(currentFunction()+":", err)
452-
throwServerError(w, "executing company template", Page.LoggedinID, Page.Company.ID)
454+
log.Println(accs.CurrentFunction()+":", err)
455+
accs.ThrowServerError(w, "executing company template", Page.LoggedinID, Page.Company.ID)
453456
return
454457
}
455458

edm_test.go renamed to date_test.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
11
package main
22

33
import (
4-
"strings"
54
"testing"
65
)
76

8-
func TestReadiniForComments(t *testing.T) {
9-
testmap, err := readini("./testfiles/testini.cfg")
10-
if err != nil {
11-
t.Errorf("Expected map of settings, received:%v", err)
12-
}
13-
for k, v := range testmap {
14-
t.Log("pair:" + k + ":" + v)
15-
if strings.Contains(k, "#commented") {
16-
t.Errorf("Expected omit comments, received:%s:%s", k, v)
17-
}
18-
}
19-
}
20-
217
func TestDateToInt64(t *testing.T) {
228
var d, rev Date
239
var res int64

docs.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"database/sql"
5+
"edm/pkg/accs"
56
"encoding/json"
67
"log"
78
"net/http"
@@ -14,6 +15,7 @@ import (
1415
// DocsPage is passed into template
1516
type DocsPage struct {
1617
AppTitle string
18+
AppVersion string
1719
PageTitle string
1820
LoggedinID int
1921
LoggedinAdmin bool
@@ -50,6 +52,7 @@ func (bs *BaseStruct) docsHandler(w http.ResponseWriter, r *http.Request) {
5052

5153
var Page = DocsPage{
5254
AppTitle: bs.text.AppTitle,
55+
AppVersion: AppVersion,
5356
PageTitle: bs.text.DocsPageTitle,
5457
Categories: bs.text.Categories,
5558
DocTypes: bs.text.DocTypes,
@@ -264,7 +267,7 @@ func (bs *BaseStruct) docsHandler(w http.ResponseWriter, r *http.Request) {
264267
}()
265268

266269
if err != nil {
267-
log.Println(currentFunction()+":", err)
270+
log.Println(accs.CurrentFunction()+":", err)
268271
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
269272
//http.Error(w, err.Error(), http.StatusInternalServerError) //Commented to not displayng error details to end user
270273
return
@@ -286,7 +289,7 @@ func (bs *BaseStruct) docsHandler(w http.ResponseWriter, r *http.Request) {
286289
// HTML output
287290
err = bs.templates.ExecuteTemplate(w, "docs.tmpl", Page)
288291
if err != nil {
289-
log.Println(currentFunction()+":", err)
292+
log.Println(accs.CurrentFunction()+":", err)
290293
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
291294
//http.Error(w, err.Error(), http.StatusInternalServerError) //Commented to not displayng error details to end user
292295
return

0 commit comments

Comments
 (0)