Clean up, working links

This commit is contained in:
Daniel Kauss Serna 2026-02-04 23:56:21 +01:00
parent e382150986
commit 6ee5998e82
3 changed files with 39 additions and 39 deletions

View file

@ -36,7 +36,7 @@ import Options.Applicative
) )
import Render import Render
import Text.Printf (printf) import Text.Printf (printf)
import Translation (Lang (EN, ES)) import Translation (Lang (EN, ES), getLangAsString)
import Web.Scotty import Web.Scotty
import Web.Scotty.Cookie (defaultSetCookie, getCookie, setCookie, setCookieExpires, setCookieName, setCookieValue) import Web.Scotty.Cookie (defaultSetCookie, getCookie, setCookie, setCookieExpires, setCookieName, setCookieValue)
@ -62,7 +62,6 @@ data Config = Config
configPort :: Int configPort :: Int
} }
-- Build the parser
configParser :: Parser Config configParser :: Parser Config
configParser = configParser =
Config Config
@ -115,6 +114,11 @@ main = do
liftIO $ print errors liftIO $ print errors
html $ renderText $ renderFrontpage lang validEvents html $ renderText $ renderFrontpage lang validEvents
get "/wiki" $ do
langHeader <- header "Accept-Language"
let lang = getLanguageHeader langHeader
langString = getLangAsString lang
redirect $ TL.pack $ printf "/%s/" langString
get "/monthView/" $ do get "/monthView/" $ do
timeNow <- liftIO $ getCurrentTime timeNow <- liftIO $ getCurrentTime
tmz <- liftIO $ getCurrentTimeZone tmz <- liftIO $ getCurrentTimeZone

View file

@ -37,7 +37,7 @@ renderHeader lang active =
li_ $ a_ [href_ "/", getActive 0] (toHtml $ tr lang NavChip) li_ $ a_ [href_ "/", getActive 0] (toHtml $ tr lang NavChip)
li_ $ a_ [href_ "/monthView", getActive 1] (toHtml $ tr lang NavEvents) li_ $ a_ [href_ "/monthView", getActive 1] (toHtml $ tr lang NavEvents)
li_ $ a_ [href_ "/wiki", getActive 2] (toHtml $ tr lang NavWiki) li_ $ a_ [href_ "/wiki", getActive 2] (toHtml $ tr lang NavWiki)
li_ $ a_ [href_ "/wiki/contact", getActive 3] (toHtml $ tr lang NavContact) li_ $ a_ [href_ $ tr lang NavContactLink, getActive 3] (toHtml $ tr lang NavContact)
where where
getActive cur = if cur == active then class_ "active" else class_ "inactive" getActive cur = if cur == active then class_ "active" else class_ "inactive"
renderImage :: T.Text -> T.Text -> T.Text -> Html () renderImage :: T.Text -> T.Text -> T.Text -> Html ()
@ -80,6 +80,9 @@ renderEventList lang events = mapM_ (renderDayGroup lang) (groupEvents events)
trh :: Lang -> Msg -> Html () trh :: Lang -> Msg -> Html ()
trh lang m = toHtml $ tr lang m trh lang m = toHtml $ tr lang m
trhr :: Lang -> Msg -> Html ()
trhr lang m = toHtmlRaw $ tr lang m
renderFrontpage :: Lang -> [Event] -> Html () renderFrontpage :: Lang -> [Event] -> Html ()
renderFrontpage lang events = do renderFrontpage lang events = do
renderHead lang renderHead lang
@ -93,18 +96,10 @@ renderFrontpage lang events = do
p_ [class_ "lead"] $ p_ [class_ "lead"] $
trh lang Lead trh lang Lead
p_ $ do p_ $ do
trh lang HomeGreeting trhr lang HomeIntroText
br_ []
trh lang HomeP1
br_ []
trh lang HomeP2
br_ []
trh lang HomePContact
a_ [href_ "/contact"] $ trh lang HomeContactHere
"!"
section_ [class_ "image-gallery"] $ do -- section_ [class_ "image-gallery"] $ do
renderImage "example.com" "Imagen sobre algo" "Imagen interesante" -- renderImage "example.com" "Imagen sobre algo" "Imagen interesante"
aside_ [class_ "sidebar"] $ do aside_ [class_ "sidebar"] $ do
section_ [class_ "events-panel"] $ do section_ [class_ "events-panel"] $ do
@ -176,12 +171,12 @@ renderMonthview lang (year, month) today groupedEvents = do
renderHeader lang 1 renderHeader lang 1
div_ [class_ "calendar-wrapper"] $ do div_ [class_ "calendar-wrapper"] $ do
header_ [class_ "calendar-header"] $ do header_ [class_ "calendar-header"] $ do
h1_ [class_ "view-title"] "Vista mensual" h1_ [class_ "view-title"] $ trh lang NavMonthView
nav_ [class_ "calendar-nav"] $ do nav_ [class_ "calendar-nav"] $ do
mkLink py pm "« Mes pasado" mkLink py pm $ trh lang NavPrevMonth
mkLink cy cm "Este mes" mkLink cy cm $ trh lang NavThisMonth
mkLink ny nm "Mes siguiente »" mkLink ny nm $ trh lang NavNextMonth
h2_ [class_ "month-name"] $ h2_ [class_ "month-name"] $
toHtml $ toHtml $

View file

@ -12,20 +12,16 @@ data Msg
| NavChip | NavChip
| NavEvents | NavEvents
| NavWiki | NavWiki
-- Calendar | -- Calendar
| NavContact NavContact
| NavContactLink
| NavMonthView | NavMonthView
| NavPrevMonth | NavPrevMonth
| NavThisMonth | NavThisMonth
| NavNextMonth | NavNextMonth
-- Home page text | -- Home page text
| Lead Lead
| HomeGreeting | HomeIntroText
| HomeP1
| HomeP2
| HomePContact
| HomeContactHere
| SignalLink | SignalLink
| ImgCaption | ImgCaption
| ImgAlt | ImgAlt
@ -39,16 +35,16 @@ tr ES msg = case msg of
NavEvents -> "Eventos" NavEvents -> "Eventos"
NavWiki -> "Wiki" NavWiki -> "Wiki"
NavContact -> "Contacto" NavContact -> "Contacto"
NavContactLink -> "/es/Contacto"
NavMonthView -> "Vista mensual" NavMonthView -> "Vista mensual"
NavPrevMonth -> "« Mes pasado" NavPrevMonth -> "« Mes pasado"
NavThisMonth -> "Este mes" NavThisMonth -> "Este mes"
NavNextMonth -> "Mes siguiente »" NavNextMonth -> "Mes siguiente »"
Lead -> "Los chips estan burning" Lead -> "Los chips estan burning"
HomeGreeting -> "Buenos dias," HomeIntroText ->
HomeP1 -> "Somos un grupo de personas y entidades interesados en infromatica y las technologias relacionadas. Este hackerspace ha sido creado como manera d juntar gente con intereses similares y compartir conocimientos. Mas que nada intentamos hacer una variedad de charlas y talleres sobre temas mas profundos, organizar espacios de trabajo colaborativo, ayudar con projectos personales y lo mas importnate:" "Somos un <a href=https://es.wikipedia.org/wiki/Hacklab>hackerspace</a> en formación para personas y entidades interesados en la informática y tecnologías relacionadas.<br><br>\
HomeP2 -> "Creer una comunidad amigable y respetuosa de gente interesante" \Nuestro objetivo es juntar gente con intereses similares y compartir conocimientos. Mas informacion sobre los temas y objectivos puedes encontrar en <a href=/es/>nuestra wiki.</a><br><br>\
HomePContact -> "Contactanos " \Puedes acudir a cualquiera de los eventos programados o contactarnos en <a href=/es/Contacto>estos sitios!</a>"
HomeContactHere -> "aqui!"
SidebarEvents -> "Eventos" SidebarEvents -> "Eventos"
ImgCaption -> "Imagen sobre algo" ImgCaption -> "Imagen sobre algo"
ImgAlt -> "Imagen interesante" ImgAlt -> "Imagen interesante"
@ -62,21 +58,21 @@ tr ES msg = case msg of
DayName 7 -> "Domingo" DayName 7 -> "Domingo"
DayName _ -> "" DayName _ -> ""
tr EN msg = case msg of tr EN msg = case msg of
PageDesc -> "Chipbuerns home page" PageDesc -> "Chipburners home page"
NavChip -> "Chip" NavChip -> "Chip"
NavEvents -> "Events" NavEvents -> "Events"
NavWiki -> "Wiki" NavWiki -> "Wiki"
NavContact -> "Contact" NavContact -> "Contact"
NavContactLink -> "/en/Contact"
NavMonthView -> "Monthly View" NavMonthView -> "Monthly View"
NavPrevMonth -> "« Last Month" NavPrevMonth -> "« Last Month"
NavThisMonth -> "This Month" NavThisMonth -> "This Month"
NavNextMonth -> "Next Month »" NavNextMonth -> "Next Month »"
Lead -> "The chips are burning" Lead -> "The chips are burning"
HomeGreeting -> "Good morning," HomeIntroText ->
HomeP1 -> "We are a group of people and entities interested in computer science and related technologies. This hacerpsace was created as a way to meet individuals with similar interests and share knowledge. We host a variety of workshops and talks about, goind in-depth into more obscure topics. Apart from that we facilitate community work spaces to share and help with personal projects. Hoever, most importantly we want to:" "We are a <a href=https://en.wikipedia.org/wiki/Hackerspace>hackerspace</a> in the making for individuals and organizations interested in computing and related technologies.<br><br>\
HomeP2 -> "Create a friendly and respectful community of interesting people" \Our goal is to bring together people with similar interests and share knowledge. You can find more information on <a href=/en/> our wiki.</a><br><br>\
HomePContact -> "You can contact us " \You can attend any of the scheduled events or contact us at <a href=/en/contact>these places!</a>"
HomeContactHere -> "here!"
SidebarEvents -> "Events" SidebarEvents -> "Events"
ImgCaption -> "Image about something" ImgCaption -> "Image about something"
ImgAlt -> "Interesting image" ImgAlt -> "Interesting image"
@ -90,6 +86,11 @@ tr EN msg = case msg of
DayName 7 -> "Sunday" DayName 7 -> "Sunday"
DayName _ -> "" DayName _ -> ""
getLangAsString :: Lang -> String
getLangAsString l = case l of
EN -> "en"
ES -> "es"
esLocale :: TimeLocale esLocale :: TimeLocale
esLocale = esLocale =
defaultTimeLocale defaultTimeLocale