Define the 'Home' and 'About Me' pages

This commit is contained in:
Feufochmar 2019-11-07 19:39:50 +01:00
parent 3f4f49832a
commit c323e1f1f5
4 changed files with 367 additions and 26 deletions

View File

@ -7,40 +7,33 @@
(module+ main
(require
"src/webcontainer/webcontainer.rkt")
(require
"src/webcontainer/weblets.rkt"
"src/webcontainer/weblet-parameter.rkt"
"src/webcontainer/website.rkt")
;; Main entry point, executed when run with the `racket` executable or DrRacket.
(define *home-page*
(html-page-weblet
#:body '(html (body (h1 "Hello World")))))
(define *hello-page*
(html-page-weblet
#:body (lambda (param)
`(html (body (h1 "Hello " ,(hash-ref (weblet-parameter-match param) 'name)))))))
"src/webcontainer/webcontainer.rkt"
"src/webcontainer/website.rkt"
"src/pages/sitemap.rkt"
"src/pages/home.rkt")
; Website
(define *website*
(website
"" weblet *home-page* "Home" #t
("hello/{name}" matching-weblet *hello-page* "Hello" #f)))
"" weblet pages:home
("AboutMe" weblet pages:about-me)))
; Sitemap
(sitemap
("Home" "/" #f
("About Me" "/AboutMe" #f))
)
; Webcontainer
(define *webcontainer* (make-webcontainer))
(webcontainer-add-website! *webcontainer* *website*)
(webcontainer-set-404-weblet!
*webcontainer*
(html-page-weblet
#:body '(html (body (h1 "Sorry") (p "Nothing found here")))))
(webcontainer-set-404-weblet! *webcontainer* pages:not-found)
(display "Starting server...")(newline)
(webcontainer-start *webcontainer*))
;(website
; "" weblet home-page "Home" #t
; ("ToyCatCreator" redirection "http://beleth.pink" "Toy Cat Creator" #f)
; ("About" weblet about-me-page "About me" #t)
; ("Fonts" weblet fonts-page "Fonts" #t)
; ("FlagGenerator" weblet flag-generator-page "Flag Generator" #t
; ("RawFlag" weblet flag-generator-raw-page "Flag Generator (Raw SVG)" #t)
; ("About" weblet about-flag-generator-page "About the Flag Generator" #t))
; "" weblet home-page
; ("ToyCatCreator" redirection "http://beleth.pink")
; ("About" weblet about-me-page)
; ("Fonts" weblet fonts-page)
; ("FlagGenerator" weblet flag-generator-page
; ("RawFlag" weblet flag-generator-raw-page)
; ("About" weblet about-flag-generator-page))
; )

115
src/pages/home.rkt Normal file
View File

@ -0,0 +1,115 @@
#lang racket/base
(require
"../webcontainer/weblets.rkt"
"../webcontainer/weblet-parameter.rkt"
"sitemap.rkt"
racket/date
racket/string
)
(provide
pages:not-found
pages:home
pages:about-me)
; Make the header
(define (make-header param)
(define path (weblet-parameter-path param))
`(header
; Current page
(nav ,@(build-main-headers path))
; Child pages of current page
(nav ,@(build-secondary-headers path))))
; Main template for pages
(define (pages:template
#:title title
#:content content
#:author author
#:date [date #f]
#:stylesheets [stylesheets (list "/css/feuforeve.css")]
#:scripts [scripts (list)]
#:on-load [on-load #f]
#:error-code [error-code 200]
)
(html-page-weblet
#:error-code error-code
#:body
(lambda (param)
`(html
(head
(title ,title)
(meta ((charset "UTF-8")))
(link ((href "/css/feuforeve.css")(rel "stylesheet")(type "text/css")(media "all")))
,@(map
(lambda (x)
`(link ((href ,x)(rel "stylesheet")(type "text/css")(media "all"))))
stylesheets)
,@(map
(lambda (x)
`(script ((src ,x)) " "))
scripts)
)
(body (,@(if on-load `((onload ,on-load)) '()))
,(make-header param)
(main
(div ((class "author-date"))
(span ((class "author")) ,author) " "
,(if date date ""))
(h1 ,title)
,content)
(footer ,(string-append "©2015-" (number->string (date-year (current-date))) " Feufochmar"))
)))))
; Not found page
(define pages:not-found
(pages:template
#:title "Not found"
#:content '(article (p "Sorry, there is nothing here."))
#:author "404"
#:error-code 404))
; Home page and other minor pages
(define pages:home
(pages:template
#:title "Feuforêve: Home"
#:author "Feufochmar"
#:date "2019-11-07"
#:content
'(article
(p "I'm " (a ((href "/AboutMe")) "Feufochmar") " and this is my personnal website. ")
; various links to my other accounts - not displayed, only for checking purpose for those websites
(p ((style "display: none;"))
"You can find me on "
(ul ((style "display: none;"))
(li (a ((href "https://social.surfnet.space/@Feufochmar")(rel "me")) "Social.surfnet.space"))
(li (a ((href "https://functional.cafe/@Feufochmar")(rel "me")) "Functional.cafe"))
(li (a ((href "https://donphan.social/@Feufochmar")(rel "me")) "Donphan.social"))
))
)
))
(define pages:about-me
(pages:template
#:title "About: Feufochmar"
#:author "Feufochmar"
#:date "2019-11-07"
#:content
'(article
(h2 "Myself")
(p "I'm a ghost haunting the labyrinth named Internet, and I like to write code and play video games. ")
(p "You can also find me on "
(a ((href "http://feufochmar.deviantart.com/")) "deviantArt") ", "
(a ((href "https://twitter.com/Feufochmar")) "Twitter") ", "
(a ((href "https://social.surfnet.space/@Feufochmar")) "Mastodon") "."
(br)
"You can also contact me at " (code "contact [at] feuforeve [dot] fr") ".")
(h2 "Website name")
(p "The website name, "
(a ((href "http://www.pokemon.com/fr/pokedex/feuforêve")) "Feuforêve")
", comes from the french name of the "
(a ((href "http://www.pokemon.com")) "Pokémon") " "
(a ((href "http://www.pokemon.com/us/pokedex/misdreavus")) "Misdreavus") ". ")
)
))

76
src/pages/sitemap.rkt Normal file
View File

@ -0,0 +1,76 @@
#lang racket/base
; Utility to build a sitemap and provide links in headers
(require
racket/string)
(provide
sitemap
build-main-headers
build-secondary-headers)
(define *sitemap* (make-hash)) ; sitemap: path->level1
(define *links-to-level1* (make-hash)) ; path->path
; Site structure
(struct sitepage
(name ; Name displayed in headers
path ; Absolute path to the page
link? ; Indicate if the link is clickable when on the same page
children ; Children of the node
))
(define (make-sitepage name path link? children path-level1)
(hash-set! *links-to-level1* path path-level1)
(sitepage name path link? children))
; Syntax to build the sitemap tree
(define-syntax sitemap
(syntax-rules ()
( (sitemap (level1-name level1-path level1-link? (level2-name level2-path level2-link?) ...) ...)
(begin
(hash-set!
*sitemap*
level1-path
(make-sitepage
level1-name
level1-path
level1-link?
(list
(make-sitepage
level2-name
level2-path
level2-link?
(list)
level1-path)
...)
level1-path))
...)
)))
; Build the navigation header of level 1
(define (build-main-headers current-path)
(let ((str-path (string-join current-path "/" #:before-first "/")))
(map
(lambda (x)
`(section ((class "nav-item"))
,(if (or (not (equal? str-path (sitepage-path x)))
(sitepage-link? x))
`(a ((href ,(sitepage-path x))) ,(sitepage-name x))
(sitepage-name x))))
(hash-values *sitemap*))))
; Build the navigation header of level 2
(define (build-secondary-headers current-path)
(define str-path (string-join current-path "/" #:before-first "/"))
(define level-1 (hash-ref *sitemap* (hash-ref *links-to-level1* str-path #f) #f))
(if level-1
(map
(lambda (x)
`(section ((class "nav-item"))
,(if (or (not (equal? str-path (sitepage-path x)))
(sitepage-link? x))
`(a ((href ,(sitepage-path x))) ,(sitepage-name x))
(sitepage-name x))))
(sitepage-children level-1))
`((section ((class "nav-item")) "*"))))

157
static/css/feuforeve.css Normal file
View File

@ -0,0 +1,157 @@
body {
background: url('/images/background.png');
margin-left: 15%;
margin-right: 15%;
color: hsla(230, 10%, 15%, 1.0);
border-color: hsla(230, 10%, 15%, 1.0);
}
h1 {
margin: 1px;
padding: 1px;
}
h2 {
margin: 1px;
padding: 1px;
}
h3 {
margin: 1px;
padding: 1px;
}
h4 {
margin: 1px;
padding: 1px;
}
h5 {
margin: 1px;
padding: 1px;
}
h6 {
margin: 1px;
padding: 1px;
}
hr {
border-style: solid;
border-width: thin;
}
footer {
background-color: hsla(230, 10%, 90%, 0.60);
border-style: solid;
border-width: thin;
border-radius: 5px;
margin: 2px;
padding: 5px;
text-align: center;
}
main {
background-color: hsla(230, 10%, 90%, 0.60);
border-style: solid;
border-width: thin;
border-radius: 5px;
margin: 2px;
padding: 10px;
height: auto;
}
main::after {
content: "";
display: block;
clear: both;
}
nav {
background-color: hsla(230, 10%, 90%, 0.60);
border-style: solid;
border-width: thin;
border-radius: 5px;
margin: 2px;
padding: 3px;
}
article {
}
section {
margin-left: 5px;
}
p {
margin-left: 7px;
}
.nav-item {
display: inline-block;
padding-left: 10px;
padding-right: 10px;
}
.author-date {
text-align: right;
font-style: italic;
float: right;
background-color: hsla(230, 10%, 90%, 0.60);
border-style: solid;
border-width: thin;
border-radius: 5px;
padding: 5px;
}
.author-date img {
border-style: solid;
border-width: thin;
border-radius: 5px;
}
.author {
font-variant: small-caps;
}
.banner {
text-align: center;
opacity: 1.0;
}
a:link {
color: hsla(230, 90%, 35%, 1.0);
text-decoration: none;
}
a:visited {
color: hsla(280, 90%, 35%, 1.0);
text-decoration: none;
}
a:hover {
color: hsla(230, 90%, 90%, 1.0);
text-shadow: 1px 0px 2px hsla(230, 90%, 15%, 1.0), -1px 0px 2px hsla(230, 90%, 15%, 1.0), 0px 1px 2px hsla(230, 90%, 15%, 1.0), 0px -1px 2px hsla(230, 90%, 15%, 1.0), 0px 0px 0.2em hsla(230, 90%, 25%, 1.0)
}
table {
border-style: solid;
border-width: thin;
border-collapse: collapse;
}
th {
background-color: hsla(230, 10%, 90%, 1.0);
border-style: solid;
border-width: thin;
border-collapse: collapse;
padding: 5px;
text-align: center;
}
td {
border-style: solid;
border-width: thin;
border-collapse: collapse;
padding: 5px;
text-align: center;
}