Initial edge commit.
All checks were successful
continuous-integration/drone/push Build is passing

Update page handling system.
Update Makefile and .gitignore .
This commit is contained in:
Captain ALM 2022-07-25 15:39:05 +01:00
parent 0a9775d2a1
commit 0b2ba868a3
Signed by: alfred
GPG Key ID: 4E4ADD02609997B1
13 changed files with 269 additions and 26 deletions

8
.gitignore vendored
View File

@ -7,3 +7,11 @@ dist/
# Test data and logs folders # Test data and logs folders
.data/ .data/
.idea/dataSources.xml .idea/dataSources.xml
# CDN link
cdn/
cdn
# Config Link
cnf/
cnf

View File

@ -34,4 +34,7 @@ clean:
deploy: build deploy: build
sudo systemctl stop wappcityuni sudo systemctl stop wappcityuni
sudo cp "${BIN}" /usr/local/bin sudo cp "${BIN}" /usr/local/bin
sudo cp *.go.html cnf
sudo cp *.css cdn
sudo cp *.js cdn
sudo systemctl start wappcityuni sudo systemctl start wappcityuni

112
base.css Normal file
View File

@ -0,0 +1,112 @@
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
main{
padding-top: 90px;
padding-left: 6px;
}
.no-dec{
text-decoration: none;
}
.no-lst-style{
list-style: none;
}
.header{
box-shadow: 1px 1px 5px 0px;
position: fixed;
top: 0;
width: 100%;
}
.home-button{
display: inline-block;
font-size: 60px;
padding: 7px 10px 6px;
}
.nav{
width: 100%;
height: 100%;
overflow: hidden;
max-height: 0;
}
.nav-menu{
display: none;
}
.menu a{
display: block;
padding: 32px 30px;
}
.hmb{
cursor: pointer;
float: right;
background-color: transparent;
padding: 40px 20px;
}
.hmb-line{
display: block;
height: 2px;
position: relative;
width: 24px;
}
.hmb-line::before, .hmb-line::after{
content: '';
display: block;
height: 100%;
position: absolute;
transition: all .1s ease-out;
width: 100%;
}
.hmb-line::before{
top: 5px;
}
.hmb-line::after{
top: -5px;
}
.nav-menu:checked ~ nav{
max-height: 100%;
}
.nav-menu:checked ~ .hmb .hmb-line{
background: transparent;
}
.nav-menu:checked ~ .hmb .hmb-line::before{
transform: rotate(-45deg);
top:0;
}
.nav-menu:checked ~ .hmb .hmb-line::after{
transform: rotate(45deg);
top:0;
}
.flex-main{
display: flex;
flex-direction: column;
}
.box-main{
display: table;
width: 100%;
margin: 1px;
align-self: center;
}
@media (min-width: 480px){
.nav{
max-height: none;
top: 0;
position: relative;
float: right;
width: fit-content;
}
.menu li{
float: left;
}
.menu a:hover{
background-color: transparent;
}
.hmb{
display: none;
}
.box-main{
margin: 5px 10px;
}
}

29
dark.css Normal file
View File

@ -0,0 +1,29 @@
body{
color: #f9f9f9;
background-color: #050506;
border-color: #696969;
}
.header, .nav{
background-color: #1d1d1e;
}
.home-button{
color: #e0e0e0;
}
.home-button:hover{
background-color: #606061;
}
.header{
box-shadow-color: #696969;
}
.menu a{
color: #e0e0e0;
}
.menu a:hover{
background-color: #606061;
}
.hmb:hover{
background-color: #606061;
}
.hmb-line, .hmb-line::before, .hmb-line::after{
background: #e0e0e0;
}

View File

@ -13,7 +13,6 @@
text-align: center; text-align: center;
background-color: mediumslateblue; background-color: mediumslateblue;
} }
table, th, td { table, th, td {
margin: auto; margin: auto;
text-align: left; text-align: left;
@ -21,20 +20,16 @@
border-collapse: collapse; border-collapse: collapse;
word-break: break-word; word-break: break-word;
} }
table, td { table, td {
background-color: lightgray; background-color: lightgray;
} }
table { table {
width: 80%; width: 80%;
} }
th { th {
background-color: lightsteelblue; background-color: lightsteelblue;
width: 25%; width: 25%;
} }
td { td {
width: 75%; width: 75%;
} }

32
index.go.html Normal file
View File

@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>City University Portfolio</title>
<link rel="stylesheet" href="{{ .Data.CSSBaseURL }}"/>
{{ if .Light }}
<link rel="stylesheet" href="{{ .Data.CSSLightURL }}"/>
{{ else }}
<link rel="stylesheet" href="{{ .Data.CSSDarkURL }}"/>
{{ end }}
<script src="{{ .Data.JScriptURL }}"></script>
</head>
<body>
<header class="header">
<a href="?" class="home-button no-dec"><b>&#8962;</b></a>
<input class="nav-menu" type="checkbox" id="nav-menu"/>
<label class="hmb" for="nav-menu"><span class="hmb-line"></span></label>
<nav class="nav">
<ul class="menu no-lst-style">
{{ range .Data.GetHeaderLabels }}
<li><b><a href="{{ $.Data.GetHeaderLink . }}" class="no-dec">{{ . }}</a></b></li>
{{ end }}
</ul>
</nav>
</header>
<main>
</main>
</body>
</html>

11
index.go.yml Normal file
View File

@ -0,0 +1,11 @@
cssBaseURL: "http://192.168.1.193:8081/test/base.css"
cssDarkURL: "http://192.168.1.193:8081/test/dark.css"
cssLightURL: "http://192.168.1.193:8081/test/light.css"
jScriptURL: "http://192.168.1.193:8081/test/index.js"
headerLinks:
Main Portfolio: "https://portfolio.captainalm.com/"
Root Site Home: "https://www.captainalm.com/"
Github: "https://github.com/Captain-ALM/"
about:
title: "Alfred Manville (Captain ALM)"
entries:

0
index.js Normal file
View File

View File

@ -1,12 +1,31 @@
package index package index
type DataYaml struct { type DataYaml struct {
HomeLink string `yaml:"homeLink"` HeaderLinks map[string]string `yaml:"headerLinks"`
PortfolioLink string `yaml:"portfolioLink"` CSSBaseURL string `yaml:"cssBaseURL"`
CSSBaseURL string `yaml:"cssBaseURL"` CSSLightURL string `yaml:"cssLightURL"`
CSSLightURL string `yaml:"cssLightURL"` CSSDarkURL string `yaml:"cssDarkURL"`
CSSDarkURL string `yaml:"cssDarkURL"` JScriptURL string `yaml:"jScriptURL"`
JScriptURL string `yaml:"jScriptURL"` About AboutYaml `yaml:"about"`
About AboutYaml `yaml:"about"` Entries []EntryYaml `yaml:"entries"`
Entries []EntryYaml `yaml:"entries"` }
func (dy DataYaml) GetHeaderLabels() []string {
if dy.HeaderLinks == nil {
return []string{}
}
toReturn := make([]string, len(dy.HeaderLinks))
i := 0
for key := range dy.HeaderLinks {
toReturn[i] = key
i++
}
return toReturn
}
func (dy DataYaml) GetHeaderLink(headerLabel string) string {
if dy.HeaderLinks == nil {
return ""
}
return dy.HeaderLinks[headerLabel]
} }

View File

@ -1,6 +1,7 @@
package index package index
import ( import (
"golang.captainalm.com/cityuni-webserver/utils/yaml"
"html/template" "html/template"
"time" "time"
) )
@ -8,14 +9,14 @@ import (
const dateFormat = "2006-01-02" const dateFormat = "2006-01-02"
type EntryYaml struct { type EntryYaml struct {
Name string `yaml:"name"` Name string `yaml:"name"`
Content string `yaml:"content"` Content string `yaml:"content"`
StartDate time.Time `yaml:"startDate"` StartDate yaml.DateType `yaml:"startDate"`
EndDate time.Time `yaml:"endDate"` EndDate yaml.DateType `yaml:"endDate"`
VideoLocation string `yaml:"videoLocation"` VideoLocation string `yaml:"videoLocation"`
VideoContentType string `yaml:"videoContentType"` VideoContentType string `yaml:"videoContentType"`
ThumbnailLocations []string `yaml:"thumbnailLocations"` ThumbnailLocations []string `yaml:"thumbnailLocations"`
ImageLocations []string `yaml:"imageLocations"` ImageLocations []string `yaml:"imageLocations"`
} }
func (ey EntryYaml) GetStartDate() string { func (ey EntryYaml) GetStartDate() string {
@ -34,7 +35,7 @@ func (ey EntryYaml) GetEndTime() time.Time {
if ey.EndDate.IsZero() { if ey.EndDate.IsZero() {
return time.Now() return time.Now()
} else { } else {
return ey.EndDate return ey.EndDate.Time
} }
} }
@ -43,5 +44,5 @@ func (ey EntryYaml) GetContent() template.HTML {
} }
func (ey EntryYaml) GetDuration() time.Duration { func (ey EntryYaml) GetDuration() time.Duration {
return ey.GetEndTime().Sub(ey.StartDate).Truncate(time.Second) return ey.GetEndTime().Sub(ey.StartDate.Time).Truncate(time.Second)
} }

View File

@ -17,12 +17,14 @@ const yamlName = "index.go.yml"
func NewPage(dataStore string, cacheTemplates bool) *Page { func NewPage(dataStore string, cacheTemplates bool) *Page {
var ptm *sync.Mutex var ptm *sync.Mutex
var sdm *sync.Mutex
if cacheTemplates { if cacheTemplates {
ptm = &sync.Mutex{} ptm = &sync.Mutex{}
sdm = &sync.Mutex{}
} }
pageToReturn := &Page{ pageToReturn := &Page{
DataStore: dataStore, DataStore: dataStore,
StoredDataMutex: &sync.Mutex{}, StoredDataMutex: sdm,
PageTemplateMutex: ptm, PageTemplateMutex: ptm,
} }
return pageToReturn return pageToReturn

View File

@ -15,12 +15,12 @@ func (m Marshal) GetEntries() (toReturn []EntryYaml) {
toReturn = m.Data.Entries toReturn = m.Data.Entries
if m.OrderStartDate > 0 { if m.OrderStartDate > 0 {
sort.Slice(toReturn, func(i, j int) bool { sort.Slice(toReturn, func(i, j int) bool {
return toReturn[i].StartDate.Before(toReturn[j].StartDate) return toReturn[i].StartDate.Before(toReturn[j].StartDate.Time)
}) })
} }
if m.OrderStartDate < 0 { if m.OrderStartDate < 0 {
sort.Slice(toReturn, func(i, j int) bool { sort.Slice(toReturn, func(i, j int) bool {
return toReturn[i].StartDate.After(toReturn[j].StartDate) return toReturn[i].StartDate.After(toReturn[j].StartDate.Time)
}) })
} }
if m.OrderEndDate > 0 { if m.OrderEndDate > 0 {

31
utils/yaml/date-type.go Normal file
View File

@ -0,0 +1,31 @@
package yaml
import (
"gopkg.in/yaml.v3"
"strings"
"time"
)
const dateFormat = "02/01/2006"
type DateType struct {
time.Time
}
func (dt *DateType) MarshalYAML() (interface{}, error) {
return dt.Time.Format(dateFormat), nil
}
func (dt *DateType) UnmarshalYAML(value *yaml.Node) error {
var stringIn string
err := value.Decode(&stringIn)
if err != nil {
return nil
}
pt, err := time.Parse(dateFormat, strings.TrimSpace(stringIn))
if err != nil {
return err
}
dt.Time = pt
return nil
}