From 6ee5998e8237a18fe85e1bae6a3155b5f5de677b Mon Sep 17 00:00:00 2001 From: Daniel Kauss Serna Date: Wed, 4 Feb 2026 23:56:21 +0100 Subject: [PATCH] Clean up, working links --- app/Main.hs | 8 ++++++-- src/Render.hs | 27 +++++++++++---------------- src/Translation.hs | 43 ++++++++++++++++++++++--------------------- 3 files changed, 39 insertions(+), 39 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index 93fc795..826b10d 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -36,7 +36,7 @@ import Options.Applicative ) import Render import Text.Printf (printf) -import Translation (Lang (EN, ES)) +import Translation (Lang (EN, ES), getLangAsString) import Web.Scotty import Web.Scotty.Cookie (defaultSetCookie, getCookie, setCookie, setCookieExpires, setCookieName, setCookieValue) @@ -62,7 +62,6 @@ data Config = Config configPort :: Int } --- Build the parser configParser :: Parser Config configParser = Config @@ -115,6 +114,11 @@ main = do liftIO $ print errors 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 timeNow <- liftIO $ getCurrentTime tmz <- liftIO $ getCurrentTimeZone diff --git a/src/Render.hs b/src/Render.hs index 30a02f9..d8bd832 100644 --- a/src/Render.hs +++ b/src/Render.hs @@ -37,7 +37,7 @@ renderHeader lang active = li_ $ a_ [href_ "/", getActive 0] (toHtml $ tr lang NavChip) li_ $ a_ [href_ "/monthView", getActive 1] (toHtml $ tr lang NavEvents) 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 getActive cur = if cur == active then class_ "active" else class_ "inactive" 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 m = toHtml $ tr lang m +trhr :: Lang -> Msg -> Html () +trhr lang m = toHtmlRaw $ tr lang m + renderFrontpage :: Lang -> [Event] -> Html () renderFrontpage lang events = do renderHead lang @@ -93,18 +96,10 @@ renderFrontpage lang events = do p_ [class_ "lead"] $ trh lang Lead p_ $ do - trh lang HomeGreeting - br_ [] - trh lang HomeP1 - br_ [] - trh lang HomeP2 - br_ [] - trh lang HomePContact - a_ [href_ "/contact"] $ trh lang HomeContactHere - "!" + trhr lang HomeIntroText - section_ [class_ "image-gallery"] $ do - renderImage "example.com" "Imagen sobre algo" "Imagen interesante" + -- section_ [class_ "image-gallery"] $ do + -- renderImage "example.com" "Imagen sobre algo" "Imagen interesante" aside_ [class_ "sidebar"] $ do section_ [class_ "events-panel"] $ do @@ -176,12 +171,12 @@ renderMonthview lang (year, month) today groupedEvents = do renderHeader lang 1 div_ [class_ "calendar-wrapper"] $ do header_ [class_ "calendar-header"] $ do - h1_ [class_ "view-title"] "Vista mensual" + h1_ [class_ "view-title"] $ trh lang NavMonthView nav_ [class_ "calendar-nav"] $ do - mkLink py pm "« Mes pasado" - mkLink cy cm "Este mes" - mkLink ny nm "Mes siguiente »" + mkLink py pm $ trh lang NavPrevMonth + mkLink cy cm $ trh lang NavThisMonth + mkLink ny nm $ trh lang NavNextMonth h2_ [class_ "month-name"] $ toHtml $ diff --git a/src/Translation.hs b/src/Translation.hs index fcff4f8..daec117 100644 --- a/src/Translation.hs +++ b/src/Translation.hs @@ -12,20 +12,16 @@ data Msg | NavChip | NavEvents | NavWiki - -- Calendar - | NavContact + | -- Calendar + NavContact + | NavContactLink | NavMonthView | NavPrevMonth | NavThisMonth | NavNextMonth - -- Home page text - | Lead - | HomeGreeting - | HomeP1 - | HomeP2 - | HomePContact - | HomeContactHere - + | -- Home page text + Lead + | HomeIntroText | SignalLink | ImgCaption | ImgAlt @@ -39,16 +35,16 @@ tr ES msg = case msg of NavEvents -> "Eventos" NavWiki -> "Wiki" NavContact -> "Contacto" + NavContactLink -> "/es/Contacto" NavMonthView -> "Vista mensual" NavPrevMonth -> "« Mes pasado" NavThisMonth -> "Este mes" NavNextMonth -> "Mes siguiente »" Lead -> "Los chips estan burning" - HomeGreeting -> "Buenos dias," - 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:" - HomeP2 -> "Creer una comunidad amigable y respetuosa de gente interesante" - HomePContact -> "Contactanos " - HomeContactHere -> "aqui!" + HomeIntroText -> + "Somos un hackerspace en formación para personas y entidades interesados en la informática y tecnologías relacionadas.

\ + \Nuestro objetivo es juntar gente con intereses similares y compartir conocimientos. Mas informacion sobre los temas y objectivos puedes encontrar en nuestra wiki.

\ + \Puedes acudir a cualquiera de los eventos programados o contactarnos en estos sitios!" SidebarEvents -> "Eventos" ImgCaption -> "Imagen sobre algo" ImgAlt -> "Imagen interesante" @@ -62,21 +58,21 @@ tr ES msg = case msg of DayName 7 -> "Domingo" DayName _ -> "" tr EN msg = case msg of - PageDesc -> "Chipbuerns home page" + PageDesc -> "Chipburners home page" NavChip -> "Chip" NavEvents -> "Events" NavWiki -> "Wiki" NavContact -> "Contact" + NavContactLink -> "/en/Contact" NavMonthView -> "Monthly View" NavPrevMonth -> "« Last Month" NavThisMonth -> "This Month" NavNextMonth -> "Next Month »" Lead -> "The chips are burning" - HomeGreeting -> "Good morning," - 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:" - HomeP2 -> "Create a friendly and respectful community of interesting people" - HomePContact -> "You can contact us " - HomeContactHere -> "here!" + HomeIntroText -> + "We are a hackerspace in the making for individuals and organizations interested in computing and related technologies.

\ + \Our goal is to bring together people with similar interests and share knowledge. You can find more information on our wiki.

\ + \You can attend any of the scheduled events or contact us at these places!" SidebarEvents -> "Events" ImgCaption -> "Image about something" ImgAlt -> "Interesting image" @@ -90,6 +86,11 @@ tr EN msg = case msg of DayName 7 -> "Sunday" DayName _ -> "" +getLangAsString :: Lang -> String +getLangAsString l = case l of + EN -> "en" + ES -> "es" + esLocale :: TimeLocale esLocale = defaultTimeLocale