Mergiate le due versioni

main-old
Antonio De Lucreziis 3 years ago
commit 9db584aab6

@ -2,6 +2,16 @@
Repo del server del nuovo sito per il PHC.
### Setup
Per clonare il progetto usare
```bash
$ git clone --recursive https://github.com/phc-dm/server-poisson
```
L'opzione `--recursive` serve a clonare anche il sottomodule relativo al blog del sito, si può anche omettere però non sarà disponibile la visualizzazione del blog in fase di development.
## Development
Copiare il file `.env.dev` in `.env` per dire al server di lavorare in modalità di development e su quale indirizzo servire il sito. Per avviare il server basta fare
@ -10,3 +20,18 @@ Copiare il file `.env.dev` in `.env` per dire al server di lavorare in modalità
go run .
```
### Environment Variables
- `MODE`
Può essere `production` (default) o `development`.
- `HOST`
Indirizzo (locale) sul quale servire il sito, di default è `localhost:8000`.
- `<SERVIZIO>_URL`
Rappresentano link ad altri servizi forniti, è comodo impostarli così in modo da poter anche provare tutto insieme in locale su varie porte (e poi in produzione i vari url diventano link a sotto-domini del sito principale).
Per ora ci sono solo `GIT_URL` e `FORUM_URL`.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 790 B

@ -5,136 +5,481 @@
/* @import url('https://fonts.googleapis.com/css2?family=Sen&family=Work+Sans:wght@700&display=swap'); */
:root {
--accent-1: royalblue;
--font-title: 'Share', cursive;
--font-text: 'Ubuntu', sans-serif;
--font-mono: 'Ubuntu Mono', monospace;
}
* {
box-sizing: border-box;
}
html {
position: relative;
}
html,
body {
position: relative;
margin: 0;
min-height: 100vh;
display: flex;
flex-direction: column;
min-height: 100%;
font-family: 'Ubuntu', sans-serif;
width: 100vw;
overflow-x: hidden;
font-family: var(--font-text);
font-weight: 300;
font-size: 17px;
line-height: 1.25;
}
html {
background: white;
height: 100%;
min-height: 100%;
}
body {
margin: 0 auto;
padding-bottom: 5rem;
max-width: 850px;
text-align: justify;
background: white;
}
/* Typography */
h1, h2, h3, h4 {
font-family: 'Share', cursive;
margin: 0;
font-family: var(--font-title);
font-weight: 700;
}
a, a:focus, a:visited {
color: #666;
text-decoration: #aaa underline;
padding: 1px 2px;
border-radius: 2px;
p {
margin: 0.75rem 0;
}
a:hover {
background: var(--accent-1);
color: white;
p:last-child {
margin-bottom: 0;
}
body {
max-width: 100%;
width: 50rem;
margin: 0 auto;
padding: 0 0.5rem;
overflow-y: scroll;
}
/* Elements */
nav {
margin-bottom: 1rem;
display: flex;
align-items: center;
border-bottom: 1px solid #ddd;
flex-wrap: wrap;
border: 4px solid;
border-top: none;
gap: 2px;
/* border-bottom: 1rem solid black; */
}
.hfill {
.nav-item {
flex-grow: 1;
display: flex;
align-items: center;
justify-content: center;
height: 2.5rem;
padding: 0 0.75rem;
margin: -2px;
font-size: 130%;
font-weight: bold;
border: 2px solid black;
}
.vfill {
.nav-dropdown {
flex-grow: 1;
margin: -2px;
max-width: 100%;
display: flex;
flex-direction: column;
position: relative;
z-index: 1;
}
.news-list {
.nav-dropdown .label {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 2.5rem;
padding: 0 0.75rem;
font-size: 130%;
font-weight: bold;
border: 2px solid black;
}
.news-list > article {
margin: 1rem;
.nav-dropdown .label .icons8 {
width: 16px;
height: 16px;
margin-left: 0.5rem;
transform: translate(0, 0.1rem);
}
.nav-item:first-child {
font-size: 25px;
.nav-dropdown .dropdown {
position: absolute;
top: 100%;
width: 100%;
/* margin-bottom: 0.5rem; */
display: flex;
flex-direction: column;
gap: 2px;
border: 2px solid black;
background: white;
}
.nav-item {
font-family: 'Share', cursive;
font-weight: 700;
.nav-dropdown:not(:hover) .dropdown {
display: none;
}
font-size: 21px;
nav a {
text-decoration: none;
}
.nav-item:hover {
background: #f0f0f0;
section {
border: 4px solid;
padding: 1rem;
margin-bottom: 1rem;
}
.nav-item a, .nav-item a:focus, .nav-item a:visited {
header {
display: flex;
align-items: center;
width: 100%;
justify-content: center;
padding: 0 0.75rem;
height: 3.25rem;
margin: 2.5rem 0;
}
color: black;
header .logo {
flex-grow: 1;
margin-right: 1rem;
object-fit: contain;
object-position: right;
}
header .title {
flex-grow: 1;
display: flex;
flex-direction: column;
justify-content: space-around;
}
header .title h1 {
font-size: 56px;
display: inline-block;
transform: translate(-0.125rem);
}
.service-list {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
.service {
flex: 1 1 calc(50% - 1rem);
min-width: 300px;
padding: 1rem 0.75rem;
/* Brutal */
border: 2px solid black;
}
.user-list {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
gap: 0.25rem;
}
.user {
display: flex;
flex-grow: 1;
width: calc(50% - 0.25rem / 2);
min-width: 250px;
align-items: center;
justify-content: space-between;
padding: 0.125rem 0.25rem;
border: 2px solid black;
}
.user h4 {
font-size: 90%;
line-height: 1;
font-family: var(--font-mono);
}
.user a {
text-decoration: none;
}
body > div:last-of-type {
margin-bottom: 20rem;
.user a:hover img {
opacity: 0.6;
}
.user img {
margin: 0.5rem;
}
footer {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 3rem;
right: 0;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
border-top: 1px solid #ddd;
background: black;
color: white;
border-bottom: none;
}
.footer-item:not(:last-child)::after {
content: '•';
margin: 0 1rem;
footer a, footer a:visited {
color: white;
}
@media screen and (max-width: 600px) {
.footer-item {
padding: 0.5rem;
font-size: 90%;
}
.search {
display: flex;
align-items: center;
max-width: 27rem;
margin: 1.5rem auto;
border: 2px solid black;
}
body {
#search-field {
width: 100%;
overflow-x: hidden;
flex-grow: 1;
height: 1.75rem;
padding: 0 0.5rem;
border: none;
border-right: 2px solid black;
}
.search img {
display: block;
transform: scale(0.8);
width: 1.75rem;
height: 1.75rem;
cursor: pointer;
}
/* Common */
img {
display: block;
}
a, a:visited {
color: black;
}
a:hover {
color: gray;
}
hr {
width: 100%;
height: 1rem;
margin: 1rem 0;
padding: 0;
background: black;
border: none;
}
ul {
list-style: square;
}
li {
margin: 0.25rem 0;
}
form {
margin: 3rem auto;
padding: 0.75rem;
max-width: 30rem;
border: 4px solid black;
}
form .row {
display: flex;
width: 100%;
}
form .row:not(:last-child) {
margin-bottom: 0.5rem;
}
form label {
width: 30%;
}
form input[type=text], form input[type=password] {
flex-grow: 1;
}
form button, form input[type=submit] {
margin-top: 0.5rem;
}
input[type=text], input[type=password] {
font-size: 15px;
padding: 0 0.2rem;
height: 1.5rem;
appearance: none;
outline: none;
border: 2px solid black;
}
input[type=text]:focus, input[type=password]:focus {
background: #e0e0e0;
}
button, input[type=submit] {
outline: none;
font-size: 17px;
font-family: var(--font-title);
padding: 0 4rem;
height: 1.6rem;
background: black;
color: white;
border: none;
/* border: 2px solid black; */
cursor: pointer;
}
button:hover, input[type=submit]:hover {
background: #444;
}
/* Utils */
.icons8 {
width: 25px;
height: 25px;
display: inline-block;
vertical-align: middle;
}
h2 .icons8 {
transform: translateY(-0.125rem);
}
.hfill {
/* min-height: 0.5rem; */
flex-grow: 1000;
}
@media screen and (max-width: 850px) {
section, nav {
border-left: none;
border-right: none;
}
}
@media screen and (max-width: 30rem) {
form {
border-left: none;
border-right: none;
}
}
/* Large screen */
@media screen and (min-width: 421px) {
.nav-dropdown .dropdown {
margin-top: -2px;
}
}
.news-list {
/* Mobile screen */
@media screen and (max-width: 420px) and (orientation: portrait) {
nav {
flex-direction: column;
}
.nav-dropdown:hover {
padding: 0 0.25rem 0.25rem;
}
.nav-dropdown, .nav-dropdown .nav-item {
margin: -2px 0;
}
.nav-item, .nav-dropdown .label {
max-width: 100%;
border-left: none;
border-right: none;
}
.nav-dropdown .dropdown {
position: relative;
border: 4px solid black;
border-top-width: 2px;
}
}

@ -1,26 +1,16 @@
package main
// User as in auth-poisson
type User struct {
Username string
UID int
Name string
Surname string
FullName string
// ...
}
// "github.com/phc-dm/auth-poisson/user"
// AuthService rappresenta un servizio di autenticazione
type AuthService interface {
GetUsers() []User
// type AuthService interface {
// GetUsers() []User
GetUser(username string) User
// GetUser(username string) User
// LoginUser if successful returns the token for this user that will be stored in an HTTP cookie.
LoginUser(username, password string) (string, error)
}
// // LoginUser if successful returns the token for this user that will be stored in an HTTP cookie.
// LoginUser(username, password string) (string, error)
// }
// LdapService ...
type LdapService struct {

@ -1,47 +0,0 @@
package main
import (
"log"
"os"
"strings"
"github.com/joho/godotenv"
)
type Config struct {
Mode string
Host string
GitUrl string
ForumUrl string
}
func stringOrDefault(value, defaultValue string) string {
if len(strings.TrimSpace(value)) == 0 {
return defaultValue
}
return value
}
func LoadConfig() *Config {
godotenv.Load()
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
Mode := stringOrDefault(os.Getenv("MODE"), "production")
log.Printf("MODE = %v", Mode)
Host := stringOrDefault(os.Getenv("HOST"), "localhost:8080")
log.Printf("HOST = %v", Host)
GitUrl := stringOrDefault(os.Getenv("GIT_URL"), "git.phc.dm.unipi.it")
log.Printf("GIT_URL = %v", GitUrl)
ForumUrl := stringOrDefault(os.Getenv("FORUM_URL"), "forum.phc.dm.unipi.it")
log.Printf("FORUM_URL = %v", ForumUrl)
return &Config{
Mode, Host, GitUrl, ForumUrl,
}
}

@ -0,0 +1,41 @@
package config
import (
"log"
"os"
"strings"
"github.com/joho/godotenv"
)
var Mode string
var Host string
var GitUrl string
var ForumUrl string
func stringOrDefault(value, defaultValue string) string {
if len(strings.TrimSpace(value)) == 0 {
return defaultValue
}
return value
}
func LoadConfig() {
godotenv.Load()
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
Mode = stringOrDefault(os.Getenv("MODE"), "production")
log.Printf("MODE = %v", Mode)
Host = stringOrDefault(os.Getenv("HOST"), "localhost:8080")
log.Printf("HOST = %v", Host)
GitUrl = stringOrDefault(os.Getenv("GIT_URL"), "git.phc.dm.unipi.it")
log.Printf("GIT_URL = %v", GitUrl)
ForumUrl = stringOrDefault(os.Getenv("FORUM_URL"), "forum.phc.dm.unipi.it")
log.Printf("FORUM_URL = %v", ForumUrl)
}

@ -1,10 +1,8 @@
module git.phc.dm.xxxxx.xx/server-poisson
module github.com/phc-dm/server-poisson
go 1.13
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-chi/chi/v5 v5.0.7 // indirect
github.com/joho/godotenv v1.4.0 // indirect
github.com/labstack/echo/v4 v4.1.16
github.com/go-chi/chi/v5 v5.0.7
github.com/joho/godotenv v1.4.0
)

@ -1,52 +1,4 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/go-chi/chi/v5 v5.0.7 h1:rDTPXLDHGATaeHvVlLcR4Qe0zftYethFucbjVQ1PxU8=
github.com/go-chi/chi/v5 v5.0.7/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg=
github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/labstack/echo/v4 v4.1.16 h1:8swiwjE5Jkai3RPfZoahp8kjVCRNq+y7Q0hPji2Kz0o=
github.com/labstack/echo/v4 v4.1.16/go.mod h1:awO+5TzAjvL8XpibdsfXxPgHr+orhtXZJZIQCVjogKI=
github.com/labstack/gommon v0.3.0 h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0=
github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE=
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
github.com/valyala/fasttemplate v1.1.0 h1:RZqt0yGBsps8NGvLSGW804QQqCUYYLsaOjTVHy1Ocw4=
github.com/valyala/fasttemplate v1.1.0/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw=
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

@ -4,15 +4,15 @@ import (
"log"
"net/http"
"git.phc.dm.xxxxx.xx/server-poisson/utils"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"github.com/phc-dm/server-poisson/utils"
)
type object map[string]interface{}
func main() {
config := LoadConfig()
config.LoadConfig()
r := chi.NewRouter()
@ -29,7 +29,7 @@ func main() {
// Routes
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
err := renderer.Render(w, "home.html", object{"Config": config})
err := renderer.Render(w, "home.html", object{})
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@ -37,7 +37,7 @@ func main() {
})
r.Get("/utenti", func(w http.ResponseWriter, r *http.Request) {
err := renderer.Render(w, "utenti.html", object{"Config": config})
err := renderer.Render(w, "utenti.html", object{})
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@ -45,7 +45,7 @@ func main() {
})
r.Get("/login", func(w http.ResponseWriter, r *http.Request) {
err := renderer.Render(w, "login.html", object{"Config": config})
err := renderer.Render(w, "login.html", object{})
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@ -53,5 +53,5 @@ func main() {
})
log.Printf(`Starting server...`)
http.ListenAndServe(config.Host, r)
http.ListenAndServe(Config.Host, r)
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

@ -2,12 +2,14 @@ package utils
import (
"io"
"os"
"text/template"
"github.com/phc-dm/server-poisson/config"
)
// TemplateRenderer holds cached templates for rendering
type TemplateRenderer struct {
baseFile string
baseTemplate *template.Template
templateMap map[string]*template.Template
}
@ -15,6 +17,7 @@ type TemplateRenderer struct {
// NewTemplateRenderer constructs a template renderer with a base file
func NewTemplateRenderer(baseFile string) *TemplateRenderer {
return &TemplateRenderer{
baseFile: baseFile,
baseTemplate: template.Must(template.ParseFiles("./views/" + baseFile)),
templateMap: make(map[string]*template.Template),
}
@ -24,8 +27,15 @@ func NewTemplateRenderer(baseFile string) *TemplateRenderer {
func (t *TemplateRenderer) Render(w io.Writer, name string, data interface{}) error {
tmpl := t.templateMap[name]
if os.Getenv("MODE") == "development" || tmpl == nil {
if config.Mode == "development" || tmpl == nil {
tmpl = template.Must(t.baseTemplate.Clone())
if config.Mode == "development" {
tmpl = template.Must(template.ParseFiles("./views/" + t.baseFile))
} else {
tmpl = template.Must(t.baseTemplate.Clone())
}
tmpl.ParseFiles("./views/" + name)
t.templateMap[name] = tmpl
}

@ -7,8 +7,28 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ template "title" . }}</title>
<!-- TODO: Da cambiare molto probabilmente -->
<link rel="icon" href="/assets/icons/icons8-electronics-100.png">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css"
integrity="sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js"
integrity="sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4"
crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.min.js"
integrity="sha384-mll67QQFJfxn0IYznZYonOWZ644AWYC+Pt2cHqMaRhXVrursRwvLnLaebdGIlYNa"
crossorigin="anonymous"></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
renderMathInElement(document.body, {
delimiters: [
{ left: "$", right: "$", display: false },
{ left: "$$", right: "$$", display: true },
{ left: "\\(", right: "\\)", display: false },
{ left: "\\[", right: "\\]", display: true }
]
});
});
</script>
<link rel="stylesheet" href="/assets/style.css">
</head>
@ -19,20 +39,46 @@
<div class="nav-item">
<a href="/">PHC</a>
</div>
<div class="nav-dropdown">
<div class="label">
Risorse
<img class="icons8" src="https://img.icons8.com/ios-filled/100/000000/expand-arrow.png"/>
</div>
<div class="dropdown">
<div class="nav-item">
<a href="/utenti">Utenti</a>
<a href="/blog/">Notizie</a>
</div>
<div class="nav-item">
<a href="/blog">Notizie</a>
<a href="/blog/categories/guide/">Guide</a>
</div>
</div>
</div>
<div class="nav-dropdown">
<div class="label">
Servizi
<img class="icons8" src="https://img.icons8.com/ios-filled/100/000000/expand-arrow.png"/>
</div>
<div class="dropdown">
<div class="nav-item">
<a href="/utenti">Utenti</a>
</div>
<div class="nav-item">
<a href="https://{{ .Config.GitUrl }}">Git</a>
</div>
<div class="nav-item">
<a href="https://{{ .Config.MatrixUrl }}">Matrix</a>
</div>
<div class="nav-item">
<a href="https://{{ .Config.ForumUrl }}">Forum</a>
</div>
</div>
</div>
<!-- Spacing -->
<div class="hfill"></div>
<!-- User -->
{{if .User}}
<div class="nav-item">
@ -49,8 +95,9 @@
<footer>
<div class="footer-item">
macchinisti@poisson.phc.dm.unipi.it
macchinisti@poisson.phc.dm.xxxxx.xx
</div>
&centerdot;
<div class="footer-item">
Icone da <a target="_blank" href="https://icons8.it">Icons8</a>
</div>

@ -3,72 +3,120 @@
{{define "title"}}PHC &bull; phc.dm.xxxxx.xx{{end}}
{{define "body"}}
<h1>PHC</h1>
<h2>Servizi</h2>
<section>
<header>
<img class="logo" src="https://img.icons8.com/ios-filled/100/000000/electronics.png" />
<div class="title">
<h1 class="huge">
PHC
</h1>
<h2>Poisson</h2>
</div>
</header>
<dl>
<dt><a href="/blog">Blog & Notizie</a></dt>
<dd>
Blog del PHC
</dd>
<p>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Asperiores quas nostrum suscipit nulla. Reiciendis
quos et
vel animi amet facere dignissimos, nemo, repudiandae suscipit esse quod obcaecati iure soluta cumque?
</p>
</section>
<dt><a href="/blog/categories/guide">Guide</a></dt>
<dd>
Nel corso del tempo abbiamo scritto alcune guide utili per utilizzare Poisson o Linux in generale.
</dd>
<section>
<h2>
<img class="icons8" src="https://img.icons8.com/ios-filled/50/000000/service.png" />
Servizi
</h2>
<dt><a href="/utenti">Utenti</a></dt>
<dd>
Lista degli utenti di Poisson e link a relativi siti.
</dd>
<p>
Questi sono tutte le risorse e i servizi offerti dal PHC.
</p>
<dt><a href="https://git.phc.dm.unipi.it">Git</a></dt>
<dd>
<div class="service-list">
<div class="service">
<h3>
<img class="icons8" src="https://img.icons8.com/ios-filled/50/000000/news.png" />
<a href="/blog">Blog & Notizie</a>
</h3>
<p>
Blog del PHC, qui sono racconte le ultime notizie sui nostri progetti recenti, informazioni su eventuali
guasti e giorni di manuntenzione.
</p>
</div>
<div class="service">
<h3>
<img class="icons8" src="https://img.icons8.com/ios-filled/50/000000/user-manual.png" />
<a href="/guides">Guide</a>
</h3>
<p>
Nel corso del tempo abbiamo scritto alcune guide utili per utilizzare Poisson o Linux in generale.
</p>
</div>
<div class="service">
<h3>
<img class="icons8" src="https://img.icons8.com/ios-filled/50/000000/find-user-male.png" />
<a href="/utenti">Utenti</a>
</h3>
<p>
Lista degli utenti di Poisson e link a relativi siti.
</p>
</div>
<div class="service">
<h3>
<img class="icons8" src="https://img.icons8.com/ios-filled/50/000000/git.png" />
<a href="https://git.phc.dm.xxxxx.xx">Git</a>
</h3>
<p>
Server Git per gli utenti di Poisson, i progetti del PHC ad un certo punto verranno tenuti qui.
</dd>
<dt><a href="https://forum.phc.dm.unipi.it">Forum</a></dt>
<dd>
Forum in stile Disocurse per parlare di Matematica, Informatica e argomenti accademici in generale.
</dd>
</dl>
</p>
</div>
<div class="service">
<h3>
<img class="icons8" src="https://img.icons8.com/ios-filled/50/000000/matrix-logo.png" />
<a href="https://element.phc.dm.xxxxx.xx">Matrix server</a>
</h3>
<p>
Server locale per chattare e fare videoconferenze con altre persone del dipartimento.
</p>
</div>
<div class="service">
<h3>
<img class="icons8" src="https://img.icons8.com/ios-filled/50/000000/road-worker.png" />
<a href="https://forum.phc.dm.xxxxx.xx">Forum</a>
</h3>
<p>
Forum per parlare di Matematica in \(\LaTeX\), Informatica e argomenti accademici in generale.
</p>
</div>
</div>
</section>
<h2>Macchinisti</h2>
<section>
<h2>
<img class="icons8" src="https://img.icons8.com/ios-filled/50/000000/work.png" />
Macchinisti
</h2>
I macchinisti sono
<p>
Al momento i macchinisti sono:
</p>
<ul>
<li><a href="https://poisson.phc.dm.unipi.it/~persona">Persona 2</a> dal 2013</li>
<ul>
<li><a href="https://poisson.phc.dm.unipi.it/~persona">Persona 1</a> dal 2018</li>
<li><a href="https://poisson.phc.dm.unipi.it/~persona">Persona 5</a> dal 2017</li>
<li><a href="https://poisson.phc.dm.unipi.it/~persona">Persona 3</a> dal 2016</li>
<li><a href="https://poisson.phc.dm.unipi.it/~persona">Persona 4</a> dal 2015</li>
<li><a href="https://poisson.phc.dm.unipi.it/~persona">Persona 6</a> dal 2014</li>
<li><a href="https://poisson.phc.dm.unipi.it/~persona">Persona 2</a> dal 2013</li>
<li><a href="https://poisson.phc.dm.unipi.it/~persona">Persona 7</a> dal 2012</li>
<li><a href="https://poisson.phc.dm.unipi.it/~persona">Persona 1</a> dal 2018</li>
<li><a href="https://poisson.phc.dm.unipi.it/~persona">Persona 3</a> dal 2016</li>
<li><a href="https://poisson.phc.dm.unipi.it/~persona">Persona 5</a> dal 2017</li>
</ul>
<!--
<div class="news-list">
<article>
<h3>Notizie 1</h3>
<div class="description">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Amet quis eligendi aut consequatur quasi
veniam animi ducimus enim consectetur a.
</div>
</article>
<article>
<h3>Notizie 2</h3>
<div class="description">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Amet quis eligendi aut consequatur quasi
veniam animi ducimus enim consectetur a.
</div>
</article>
<article>
<h3>Notizie 3</h3>
<div class="description">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Amet quis eligendi aut consequatur quasi
veniam animi ducimus enim consectetur a.
</div>
</article>
</div> -->
</ul>
<h3>Vuoi diventare un macchinista?</h3>
<p>
Ti interessa (o interesserebbe) smanettare al PC, montare e smontare i cose? Stai spesso in dipartimento? Allora
puoi venire a parlare con noi per diventare un apprendista macchinista per poi entrare nel PHC.
</p>
</section>
{{end}}

@ -3,24 +3,36 @@
{{define "title"}}PHC &bull; Accedi &bull; phc.dm.xxxxx.xx{{end}}
{{define "body"}}
<h1>Login</h1>
<p>Inserisci le tue credenziali di Poisson per accedere</p>
<form action="/login" method="post">
<h2>
<img class="icons8" src="https://img.icons8.com/ios-filled/50/000000/lock.png"/>
Accedi
</h2>
<p>
Inserisci le tue credenziali di Poisson per accedere.
</p>
<p>
Per il recupero credenziali vieni direttamente al PHC per parlarne con calma o inviaci una mail.
</p>
<div class="row">
<label for="login-username">Username:</label>
<input type="text" name="username" id="login-username">
</div>
<div class="row">
<label for="login-password">Password:</label>
<input type="text" name="password" id="login-password">
<input type="password" name="password" id="login-password">
</div>
<div class="row">
<div class="hfill"></div>
<input type="submit" value="Accedi">
<!-- <div class="hfill"></div> -->
</div>
</form>
<p title="Vieni al phc per parlarne con calma o inviaci una mail">
🛈 Recupero credenziali
</p>
{{end}}

@ -3,28 +3,62 @@
{{define "title"}}PHC &bull; Utenti &bull; phc.dm.xxxxx.xx{{end}}
{{define "body"}}
<h1>Utenti</h1>
<ul>
<li>Persona 1</li>
<li>Persona 2</li>
<li>Persona 3</li>
<li>Persona 4</li>
<li>Persona 5</li>
<li>Persona 6</li>
<li>Persona 7</li>
<li>Persona 8</li>
<li>Persona 9</li>
<li>Persona 10</li>
<li>Persona 11</li>
<li>Persona 12</li>
<li>Persona 13</li>
<li>Persona 14</li>
<li>Persona 15</li>
<li>Persona 16</li>
<li>Persona 17</li>
<li>Persona 18</li>
<li>Persona 19</li>
<li>Persona 20</li>
</ul>
<section>
<h2>
<img class="icons8" src="https://img.icons8.com/ios-filled/50/000000/find-user-male.png" />
Utenti
</h2>
<p>
Questa è la lista di tutti gli utenti con un account su Poisson. Scrivi nome, cognome o username di un utente
per filtrare la lista in tempo reale.
</p>
<div class="search">
<input type="text" id="search-field" placeholder="Cerca...">
<img class="icons8" src="https://img.icons8.com/ios-filled/50/000000/search.png" />
</div>
<div class="user-list">
<!-- Dummy data -->
</div>
</section>
<script>
document.addEventListener('DOMContentLoaded', ({ }) => {
const $userList = document.querySelector('.user-list');
const $user = document.createElement('div');
$user.innerHTML = `
<div class="user">
<div class="contact">
<h3 class="fullname"></h3>
<h4 class="username"></h4>
</div>
<div class="links">
<a href="#">
<img class="icons8" src="https://img.icons8.com/ios-filled/50/000000/web.png" />
</a>
<a href="#">
<img class="icons8" src="https://img.icons8.com/ios-filled/50/000000/git.png" />
</a>
</div>
</div>
`;
// Per mostrare che la pagina regge molti utenti senza laggare troppo
Array(1400).fill(0).map(({ }, i) => {
setTimeout(() => {
// Pare che questa riga sia la più dispendiosa
const $newUser = $user.cloneNode(true);
$newUser.querySelector('.fullname').innerHTML = `Persona ${i + 1}`;
$newUser.querySelector('.username').innerHTML = `persona${i + 1}`;
$userList.appendChild($newUser.firstElementChild);
}, 0)
});
})
</script>
{{end}}
Loading…
Cancel
Save