1
0
Fork 0
mirror of https://code.naskya.net/repos/ndqEd synced 2025-01-27 17:47:51 +09:00
vervis/src/Vervis
fr33domlover 0cc1e20f85 UX: Don't redirect to referer after login
It causes first login after verification to redirect to registration page,
which is weird, and the default Yesod falue is False, so, switching back to
False
2022-09-28 14:10:20 +00:00
..
Data S2S: Implement loomApplyF (remote person asking to apply bundle on local loom) 2022-09-24 15:46:02 +00:00
Federation S2S: Implement loomApplyF (remote person asking to apply bundle on local loom) 2022-09-24 15:46:02 +00:00
Field DB: Switch to more flexible collaborator model 2022-06-22 06:19:37 +00:00
Form UI: Fix and re-enable deck ticket list view 2022-09-17 10:14:27 +00:00
Handler UI: If MR is applied, don't do the canApply check and display "RESOLVED" 2022-09-27 18:11:13 +00:00
Migration C2S: offerTicketC re-enabled and supporting looms and remote origin repo 2022-09-21 12:50:26 +00:00
Model Switch to new actor layout 2022-08-15 13:57:42 +00:00
Persist S2S: Implement loomApplyF (remote person asking to apply bundle on local loom) 2022-09-24 15:46:02 +00:00
Settings Mechanism for reporting git pushes to Vervis via post-receive hooks 2019-09-05 12:02:42 +00:00
Web UI: Actor outbox view: Render URI from route instead of parsing JSON for @id 2022-09-26 14:20:21 +00:00
Widget UI: HTML version for getLoomClothsR, copied from getDeckTicketsR 2022-09-17 19:17:11 +00:00
Access.hs S2S: Invite->Accept->Grant (for Repo, Deck, Loom and Person, not for Group) 2022-09-08 12:00:14 +00:00
ActivityPub.hs S2S: Switch from Grant->Accept->Enable to Invite->Accept->Grant 2022-09-05 16:19:52 +00:00
ActorKey.hs Crypto: PersistField instance for ActorKey, preparing to support per-actor keys 2022-09-25 12:29:53 +00:00
API.hs S2S: Implement loomApplyF (remote person asking to apply bundle on local loom) 2022-09-24 15:46:02 +00:00
Application.hs UI: Tweak and re-enable UI for uploading personal SSH keys 2022-09-26 12:51:06 +00:00
Avatar.hs Stop using Vervis.Import and NoImplicitPrelude, switch to plain regular imports 2019-06-15 08:24:08 +00:00
BinaryBody.hs Stop using Vervis.Import and NoImplicitPrelude, switch to plain regular imports 2019-06-15 08:24:08 +00:00
ChangeFeed.hs Switch to new actor layout 2022-08-15 13:57:42 +00:00
Changes.hs Stop using Vervis.Import and NoImplicitPrelude, switch to plain regular imports 2019-06-15 08:24:08 +00:00
Client.hs Client, UI: "Apply" button for local MRs & PublishMergeR form for remote MRs 2022-09-24 21:15:40 +00:00
Cloth.hs DB, Web: Allow origin repo for Cloths, mention in getClothR JSON 2022-09-18 15:55:42 +00:00
Colour.hs Stop using Vervis.Import and NoImplicitPrelude, switch to plain regular imports 2019-06-15 08:24:08 +00:00
Content.hs Stop using Vervis.Import and NoImplicitPrelude, switch to plain regular imports 2019-06-15 08:24:08 +00:00
Darcs.hs Client, UI: "Apply" button for local MRs & PublishMergeR form for remote MRs 2022-09-24 21:15:40 +00:00
Delivery.hs S2S: Prepare inbox handlers for Repo, Deck and Loom 2022-09-06 10:52:14 +00:00
Discussion.hs Switch to new actor layout 2022-08-15 13:57:42 +00:00
Federation.hs S2S: Prepare inbox handlers for Repo, Deck and Loom 2022-09-06 10:52:14 +00:00
FedURI.hs New Network.FedURI with separate URI modes for dev and for fediverse 2019-07-23 13:59:48 +00:00
Fetch.hs S2S: loomOfferTicketF, open MR sent by remote author 2022-09-23 15:59:21 +00:00
Formatting.hs Stop using Vervis.Import and NoImplicitPrelude, switch to plain regular imports 2019-06-15 08:24:08 +00:00
Foundation.hs UX: Don't redirect to referer after login 2022-09-28 14:10:20 +00:00
Git.hs Client, UI: "Apply" button for local MRs & PublishMergeR form for remote MRs 2022-09-24 21:15:40 +00:00
GraphProxy.hs Prepare for ticket dependency federation 2020-06-18 10:38:04 +00:00
Hook.hs Switch to new actor layout 2022-08-15 13:57:42 +00:00
KeyFile.hs Add OAuth2 tables to database, and run their migrations 2020-03-28 14:18:00 +00:00
Migration.hs DB: Migration: When switching repos dir to new layout, remove old sharer dirs 2022-09-26 13:27:16 +00:00
Model.hs C2S: offerTicketC re-enabled and supporting looms and remote origin repo 2022-09-21 12:50:26 +00:00
Paginate.hs Stop using Vervis.Import and NoImplicitPrelude, switch to plain regular imports 2019-06-15 08:24:08 +00:00
Palette.hs Stop using Vervis.Import and NoImplicitPrelude, switch to plain regular imports 2019-06-15 08:24:08 +00:00
Path.hs Switch to new actor layout 2022-08-15 13:57:42 +00:00
Query.hs Stop using Vervis.Import and NoImplicitPrelude, switch to plain regular imports 2019-06-15 08:24:08 +00:00
Readme.hs Syntax-highlight the pretty JSON display of AP objects 2019-06-09 14:32:57 +00:00
Recipient.hs Support delivery to Group followers collection 2022-08-29 21:41:13 +00:00
RemoteActorStore.hs Add missing signature to function in Vervis.RemoteActorStore 2022-09-05 16:25:59 +00:00
Role.hs Stop using Vervis.Import and NoImplicitPrelude, switch to plain regular imports 2019-06-15 08:24:08 +00:00
Secure.hs Stop using Vervis.Import and NoImplicitPrelude, switch to plain regular imports 2019-06-15 08:24:08 +00:00
Settings.hs UI: Add settings option to change main UI color 2022-09-28 06:03:43 +00:00
SourceTree.hs Stop using Vervis.Import and NoImplicitPrelude, switch to plain regular imports 2019-06-15 08:24:08 +00:00
Ssh.hs Switch to new actor layout 2022-08-15 13:57:42 +00:00
Style.hs Stop using Vervis.Import and NoImplicitPrelude, switch to plain regular imports 2019-06-15 08:24:08 +00:00
Ticket.hs Fix query error in getTicketSummaries 2022-09-27 10:49:32 +00:00
TicketFilter.hs UI: In ticket view, display filter as 3 checkboxes, default is open tickets 2019-11-07 10:46:25 +00:00
Time.hs Stop using Vervis.Import and NoImplicitPrelude, switch to plain regular imports 2019-06-15 08:24:08 +00:00
Widget.hs UI, Doc: Update Vervis repo links, because the route structure changed 2022-09-27 04:49:17 +00:00
Wiki.hs Stop using Vervis.Import and NoImplicitPrelude, switch to plain regular imports 2019-06-15 08:24:08 +00:00
WorkItem.hs Switch to new actor layout 2022-08-15 13:57:42 +00:00

{- This file is part of Vervis.
 -
 - Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
 -
 - ♡ Copying is an act of love. Please copy, reuse and share.
 -
 - The author(s) have dedicated all copyright and related and neighboring
 - rights to this software to the public domain worldwide. This software is
 - distributed without any warranty.
 -
 - You should have received a copy of the CC0 Public Domain Dedication along
 - with this software. If not, see
 - <http://creativecommons.org/publicdomain/zero/1.0/>.
 -}

-- | Tools for rendering README files in repository tree view.
module Vervis.Readme
    ( isReadme
    , renderReadme
    )
where

import Prelude hiding (takeWhile)

import Data.ByteString.Lazy (ByteString)
import Data.Git.Harder (ObjId (..))
import Data.Git.Storage (Git, getObject_)
import Data.Git.Storage.Object (Object (..))
import Data.Git.Types (Blob (..), Tree (..))
import Data.Text (Text, toCaseFold, takeWhile, unpack)
import System.FilePath (isExtSeparator)

import Data.Git.Local (TreeRows)
import Text.FilePath.Local (breakExt)
import Vervis.Foundation (Widget)
import Data.MediaType
import Yesod.RenderSource

-- | Check if the given filename should be considered as README file. Assumes
-- a flat filename which doesn't contain a directory part.
isReadme :: Text -> Bool
isReadme file =
    let basename = takeWhile (not . isExtSeparator) file
    in  toCaseFold "readme" == toCaseFold basename

-- | Render README content into a widget for inclusion in a page.
renderReadme :: [Text] -> Text -> ByteString -> Widget
renderReadme dir name content =
    let (base, ext) = breakExt name
        mediaType = chooseMediaType dir base ext () ()
    in  renderSourceBL mediaType content