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
.data/
.idea/dataSources.xml
# CDN link
cdn/
cdn
# Config Link
cnf/
cnf

View File

@ -34,4 +34,7 @@ clean:
deploy: build
sudo systemctl stop wappcityuni
sudo cp "${BIN}" /usr/local/bin
sudo cp *.go.html cnf
sudo cp *.css cdn
sudo cp *.js cdn
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;
background-color: mediumslateblue;
}
table, th, td {
margin: auto;
text-align: left;
@ -21,20 +20,16 @@
border-collapse: collapse;
word-break: break-word;
}
table, td {
background-color: lightgray;
}
table {
width: 80%;
}
th {
background-color: lightsteelblue;
width: 25%;
}
td {
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
type DataYaml struct {
HomeLink string `yaml:"homeLink"`
PortfolioLink string `yaml:"portfolioLink"`
CSSBaseURL string `yaml:"cssBaseURL"`
CSSLightURL string `yaml:"cssLightURL"`
CSSDarkURL string `yaml:"cssDarkURL"`
JScriptURL string `yaml:"jScriptURL"`
About AboutYaml `yaml:"about"`
Entries []EntryYaml `yaml:"entries"`
HeaderLinks map[string]string `yaml:"headerLinks"`
CSSBaseURL string `yaml:"cssBaseURL"`
CSSLightURL string `yaml:"cssLightURL"`
CSSDarkURL string `yaml:"cssDarkURL"`
JScriptURL string `yaml:"jScriptURL"`
About AboutYaml `yaml:"about"`
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
import (
"golang.captainalm.com/cityuni-webserver/utils/yaml"
"html/template"
"time"
)
@ -8,14 +9,14 @@ import (
const dateFormat = "2006-01-02"
type EntryYaml struct {
Name string `yaml:"name"`
Content string `yaml:"content"`
StartDate time.Time `yaml:"startDate"`
EndDate time.Time `yaml:"endDate"`
VideoLocation string `yaml:"videoLocation"`
VideoContentType string `yaml:"videoContentType"`
ThumbnailLocations []string `yaml:"thumbnailLocations"`
ImageLocations []string `yaml:"imageLocations"`
Name string `yaml:"name"`
Content string `yaml:"content"`
StartDate yaml.DateType `yaml:"startDate"`
EndDate yaml.DateType `yaml:"endDate"`
VideoLocation string `yaml:"videoLocation"`
VideoContentType string `yaml:"videoContentType"`
ThumbnailLocations []string `yaml:"thumbnailLocations"`
ImageLocations []string `yaml:"imageLocations"`
}
func (ey EntryYaml) GetStartDate() string {
@ -34,7 +35,7 @@ func (ey EntryYaml) GetEndTime() time.Time {
if ey.EndDate.IsZero() {
return time.Now()
} else {
return ey.EndDate
return ey.EndDate.Time
}
}
@ -43,5 +44,5 @@ func (ey EntryYaml) GetContent() template.HTML {
}
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 {
var ptm *sync.Mutex
var sdm *sync.Mutex
if cacheTemplates {
ptm = &sync.Mutex{}
sdm = &sync.Mutex{}
}
pageToReturn := &Page{
DataStore: dataStore,
StoredDataMutex: &sync.Mutex{},
StoredDataMutex: sdm,
PageTemplateMutex: ptm,
}
return pageToReturn

View File

@ -15,12 +15,12 @@ func (m Marshal) GetEntries() (toReturn []EntryYaml) {
toReturn = m.Data.Entries
if m.OrderStartDate > 0 {
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 {
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 {

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
}