{-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE ScopedTypeVariables #-} module OpenlabTools where import Control.DeepSeq (NFData, deepseq) import Control.Monad.Logger qualified as Logger import Control.Monad.Logger.CallStack import Control.Monad.Reader import Data.Aeson.BetterErrors qualified as Json import Data.Error.Tree import Data.HashMap.Strict qualified as HashMap import Data.List qualified as List import Data.Maybe (listToMaybe) import Data.Text qualified as Text import Data.Time (UTCTime, getCurrentTime) import Data.Time.Clock (addUTCTime) import Debug.Trace import GHC.Records (HasField (..)) import GHC.Stack qualified import IHP.HSX.QQ (hsx) import Json qualified import Label import Network.HTTP.Client.Conduit qualified as Http import Network.HTTP.Simple qualified as Http import Network.HTTP.Types import Network.HTTP.Types qualified as Http import Network.Wai qualified as Wai import Network.Wai.Handler.Warp qualified as Warp import Network.Wai.Parse qualified as Wai import OpenTelemetry.Trace qualified as Otel hiding (getTracer, inSpan, inSpan') import OpenTelemetry.Trace.Core qualified as Otel hiding (inSpan, inSpan') import OpenTelemetry.Trace.Monad qualified as Otel import PossehlAnalyticsPrelude import Pretty import System.Environment qualified as Env import System.IO qualified as IO import Text.Blaze.Html.Renderer.Pretty qualified as Html.Pretty import Text.Blaze.Html.Renderer.Utf8 qualified as Html import Text.Blaze.Html5 qualified as Html import Text.HTML.TagSoup qualified as Soup import UnliftIO import Prelude hiding (span, until) mapallSpaceOla :: Text mapallSpaceOla = "https://mapall.space/heatmap/show.php?id=OpenLab+Augsburg" mainPage :: Html.Html mainPage = Html.docTypeHtml [hsx|
Welcome to the OpenLab Augsburg tools thingy. The idea is to provide some services that can be embedded into our other pages.
The source code can be found in my user dir in the tvl repo.
To build the server, clone the repository from https://code.tvl.fyi/depot.git.
Then cd
into users/Profpatsch
, run nix-shell
.
You can now run the server with cabal repl openlab-tools/`
by executing the main
function inside the GHC repl. It starts on port 9099
.
To try out changes to the code, stop the server with Ctrl+z and type :reload
, then main
again.
Finally, from within users/Profpatsch
you can start a working development environment by installing vscode or vscodium and the Haskell extension. Then run code .
from within the directory.
Once you have a patch, contact me on Matrix or DM me at irc/libera
, nick Profpatsch
.
Uh oh! could not fetch the table from {mapallSpaceOla}
|]) <&> Soup.renderTags where firstSection f t = t & Soup.sections f & listToMaybe match :: Soup.Tag ByteString -> Soup.Tag ByteString -> Bool match x (t :: Soup.Tag ByteString) = (Soup.~==) @ByteString t x findHeatmap t = t & firstSection (match (Soup.TagOpen ("") [("class", "heatmap")])) >>= firstSection (match (Soup.TagOpen "table" [])) <&> getTable <&> (<> htmlToTags [hsx|