From 15a0543ab38f1fcbc29dc058b8d02fcfe376ee8f Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Sun, 18 Jun 2023 14:10:59 +0200 Subject: [PATCH] proper index --- assets/static/emoji/1f4dd.svg | 1 + assets/static/emoji/1f5a5.svg | 1 + assets/static/emoji/1f5c2.svg | 1 + assets/static/emoji/1f9ea.svg | 1 + assets/style.css | 102 ++++++++++++++++++++++++++++++---- cards/404.md | 15 +++++ cards/index.md | 6 +- cards/search.md | 1 + site.hs | 29 ++++++---- templates/bigcards.html | 34 ++++++++++++ templates/index.html | 1 + templates/searchresults.html | 2 +- 12 files changed, 171 insertions(+), 23 deletions(-) create mode 100644 assets/static/emoji/1f4dd.svg create mode 100644 assets/static/emoji/1f5a5.svg create mode 100644 assets/static/emoji/1f5c2.svg create mode 100644 assets/static/emoji/1f9ea.svg create mode 100644 cards/404.md create mode 100644 templates/bigcards.html diff --git a/assets/static/emoji/1f4dd.svg b/assets/static/emoji/1f4dd.svg new file mode 100644 index 0000000..1697ffb --- /dev/null +++ b/assets/static/emoji/1f4dd.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/static/emoji/1f5a5.svg b/assets/static/emoji/1f5a5.svg new file mode 100644 index 0000000..e1a0633 --- /dev/null +++ b/assets/static/emoji/1f5a5.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/static/emoji/1f5c2.svg b/assets/static/emoji/1f5c2.svg new file mode 100644 index 0000000..822a927 --- /dev/null +++ b/assets/static/emoji/1f5c2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/static/emoji/1f9ea.svg b/assets/static/emoji/1f9ea.svg new file mode 100644 index 0000000..8116cfa --- /dev/null +++ b/assets/static/emoji/1f9ea.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/style.css b/assets/style.css index a2116ff..93218a0 100644 --- a/assets/style.css +++ b/assets/style.css @@ -95,6 +95,26 @@ h6 { font-weight: 300; } +tbody tr.even { + background: #f8f8f8; +} + +table td { + padding: 0.3em; +} + +table th { + padding: 0.5em; + border-bottom: 1pt solid #777; +} + +blockquote { + border-left: 0.5em solid #eee; + padding-left: 1em; +} + +/* the "side" infobox */ + .sidebox ol { padding-left: 1em; margin: 0; @@ -112,6 +132,8 @@ h6 { text-align: right; } +/* search form and related stuff */ + .search-form-wrap { text-align: center; font-size: 120%; @@ -140,25 +162,68 @@ input.search { input, button { font-size: inherit; font-family: inherit; + height: 2em; +} + +/* front page */ + +.index-cards { + display:flex; + justify-content: center; + flex-wrap: wrap; + align-items: flex-start; +} + +.index-card { + border: 1pt solid #777; + box-shadow: 5pt 5pt 10pt #aaa; + border-radius: 1rem; + padding: 0.5rem; + margin: 0.5rem; + width: 6rem; + height: 10rem; + text-align: center; +} + +.index-card a { + text-decoration: inherit; + color: #777; +} + +.index-card a:hover { + text-decoration: inherit; + color: #0ad; } -tbody tr.even { - background: #f8f8f8; +.index-card-icon { + width: 4rem; + height: 4rem; + margin: 0.5rem; + display: inline-block; + background-size: contain; + background-repeat: no-repeat; } -table td { - padding: 0.3em; +.index-icon-admin { + background-image: url('static/emoji/1f5c2.svg'); } -table th { - padding: 0.5em; - border-bottom: 1pt solid #777; +.index-icon-it { + background-image: url('static/emoji/1f5a5.svg'); } -blockquote { - border-left: 0.5em solid #eee; - padding-left: 1em; +.index-icon-lab { + background-image: url('static/emoji/1f9ea.svg'); +} + +.index-icon-pub { + background-image: url('static/emoji/1f4dd.svg'); +} + +.index-card-title { + font-family: 'Barlow Condensed', sans-serif; + font-size: 80%; } /* layout */ @@ -398,6 +463,23 @@ main { flex-grow: 0; } + .index-card { + border-radius: 2rem; + padding: 1rem; + margin: 1rem; + width: 9rem; + height: 15rem; + } + + .index-card-icon { + width:6rem; + height:6rem; + } + + .index-card-title { + font-size: 120%; + } + /* header stuff */ .topbar-unilu { diff --git a/cards/404.md b/cards/404.md new file mode 100644 index 0000000..60148b7 --- /dev/null +++ b/cards/404.md @@ -0,0 +1,15 @@ +--- +mount: /404 +title: Page not found +search: off +--- + +# Page not found! + +You may have clicked a bad link, or the links between the how-to cards are +broken. If you believe the page should be here, try [searching for +it](/search), or [let us know](/contribute) about the issue. + +**If you are not connected to the university network**, the card you are trying +to access may be internal-only, and thus hidden from you. You may [connect to +the VPN](/it/vpn) to fix that. diff --git a/cards/index.md b/cards/index.md index a318fbb..d59a5e2 100644 --- a/cards/index.md +++ b/cards/index.md @@ -4,4 +4,8 @@ title: How-To Cards main page template: index.html --- -# How-To Cards +#### What are How-To Cards? + +How-To Cards are a self-documentation resource for the main processes, rules and tasks at LCSB. Everyone can [contribute their knowledge](/about/contribute) to the cards, or publish updates of the existing cards. All information about the how-to cards is [categorized here](/tag/about). + +If you need help with the service functionality, please create a request for support by creating a ticket on [ServiceNow](https://service.uni.lu/) using the catalog item *LCSB/BioCore: Application Services*. diff --git a/cards/search.md b/cards/search.md index 50e44be..957d83a 100644 --- a/cards/search.md +++ b/cards/search.md @@ -2,6 +2,7 @@ mount: /search title: Search template: search.html +search: off --- # Search diff --git a/site.hs b/site.hs index c5ff809..6c6e895 100644 --- a/site.hs +++ b/site.hs @@ -134,7 +134,8 @@ rootUrl fp = ( unAbsolute fp) <$> use urlBase -- | Process a single link pointing out from a page. processLink :: FilePath -> FilePath -> Site String processLink base l = - if any (l `hasUriScheme`) ["http", "https", "ftp", "mailto"] || take 1 l == "#" + if any (l `hasUriScheme`) ["http", "https", "ftp", "mailto"] || take 1 l == + "#" then pure l else if isAbsolute l then rootUrl l @@ -346,20 +347,26 @@ renderTags :: Site () renderTags = use (htags . to M.keys) >>= traverse_ renderTag -- | Transform one mounted PageInfo to the base search data -mkSearchData :: FilePath -> PageInfo -> Site Y.Value +mkSearchData :: FilePath -> PageInfo -> Site [Y.Value] mkSearchData mount pi = do link <- rootUrl mount text <- io . runIOorExplode $ writePlain plainWriteOpts (pi ^. pageDoc) let title = pi ^? pageMeta . key "title" . _String -- TODO: unify retrieval of tags - let tags = sort $ pi ^.. pageMeta . key "tags" . values . _String . to T.unpack - pure $ - Y.object - [ ("link", fromString link) - , ("title", maybe (fromString mount) Y.String title) - , ("tags", Y.array $ map (Y.array . map fromString . splitDirectories) tags) - , ("text", Y.String text) - ] + let tags = + sort $ pi ^.. pageMeta . key "tags" . values . _String . to T.unpack + if pi ^? pageMeta . key "search" . _Bool == Just False -- `off` gets parsed as bool + then pure [] + else pure $ + [ Y.object + [ ("link", fromString link) + , ("title", maybe (fromString mount) Y.String title) + , ( "tags" + , Y.array $ + map (Y.array . map fromString . splitDirectories) tags) + , ("text", Y.String text) + ] + ] -- | Collect all pages' search data to the file renderSearchData :: Site () @@ -369,7 +376,7 @@ renderSearchData = use searchDataOut >>= traverse_ go ps <- use (pages . to M.assocs) >>= traverse (uncurry mkSearchData) io $ do putStrLn $ "S -> " ++ out - AE.encodeFile out $ Y.array ps + AE.encodeFile out $ Y.array (concat ps) -- | Build the whole site. main = do diff --git a/templates/bigcards.html b/templates/bigcards.html new file mode 100644 index 0000000..93aa6a7 --- /dev/null +++ b/templates/bigcards.html @@ -0,0 +1,34 @@ +
+ + + + +
diff --git a/templates/index.html b/templates/index.html index 7a686b7..d7eaba0 100644 --- a/templates/index.html +++ b/templates/index.html @@ -3,6 +3,7 @@ {{> header.html}} {{> searchform.html}} +{{> bigcards.html}} {{{body}}} {{> footer.html}} diff --git a/templates/searchresults.html b/templates/searchresults.html index 4afb6f7..b0dc750 100644 --- a/templates/searchresults.html +++ b/templates/searchresults.html @@ -8,7 +8,7 @@

Enter a few words into the box above to start the search.

You may use * for wildcard search, and prefixes + for required terms and - for unwanted terms.

-

Example: laboratory noteb* +red -code will find information about laboratory notebooks that must also describe something red, but do not contain any mention of code.

+

Example: laboratory noteb* +red -code will find cards about laboratory notebooks that must also describe something red, but do not contain any mention of code.