1
0
Fork 0
mirror of https://code.naskya.net/repos/ndqEd synced 2025-01-28 12:47:49 +09:00
vervis/src/Vervis
2019-10-19 08:15:48 +00:00
..
ActivityPub Fix handling of forwarded activities from local repos 2019-10-18 23:20:48 +00:00
Federation Default actor name display is now its URL, not the string "(?)" 2019-10-19 04:10:33 +00:00
Field UI: Take SSH public key in 1 field, then split into key type and content 2019-10-17 09:57:46 +00:00
Form Display SSH key example as a placeholder, not a default value (thanks zPlus!) 2019-10-19 06:35:28 +00:00
Handler Provide 'following' collections and link in page header 2019-10-19 08:15:48 +00:00
Migration Implement remote following, disable automatic following 2019-09-25 10:43:05 +00:00
Model Stop using Vervis.Import and NoImplicitPrelude, switch to plain regular imports 2019-06-15 08:24:08 +00:00
Settings Mechanism for reporting git pushes to Vervis via post-receive hooks 2019-09-05 12:02:42 +00:00
Widget Default actor name display is now its URL, not the string "(?)" 2019-10-19 04:10:33 +00:00
Access.hs Stop using Vervis.Import and NoImplicitPrelude, switch to plain regular imports 2019-06-15 08:24:08 +00:00
ActivityPub.hs Implement C2S unfollowing, using Undo{Follow} 2019-10-05 14:10:29 +00:00
ActorKey.hs Stop using Vervis.Import and NoImplicitPrelude, switch to plain regular imports 2019-06-15 08:24:08 +00:00
API.hs List repo in Push recipients, it was accidentally not listed 2019-10-12 19:38:29 +00:00
Application.hs Install darcs post-apply hooks in darcs repos, no-op hook for now 2019-10-07 14:05:52 +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 Stop using Vervis.Import and NoImplicitPrelude, switch to plain regular imports 2019-06-15 08:24:08 +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 Implement C2S unfollowing, using Undo{Follow} 2019-10-05 14:10:29 +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 Install darcs post-apply hooks in darcs repos, no-op hook for now 2019-10-07 14:05:52 +00:00
Discussion.hs New Network.FedURI with separate URI modes for dev and for fediverse 2019-07-23 13:59:48 +00:00
Federation.hs Fix missing logs of fixRunningDeliveries 2019-10-18 23:51:55 +00:00
FedURI.hs New Network.FedURI with separate URI modes for dev and for fediverse 2019-07-23 13:59:48 +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 C2S: Process the HTML forms in postPublishR, not postSharerOutboxR 2019-10-19 02:41:36 +00:00
Git.hs If Git repo is empty (no branches), don't 404, just show basic repo page 2019-10-19 06:01:14 +00:00
GraphProxy.hs Stop using Vervis.Import and NoImplicitPrelude, switch to plain regular imports 2019-06-15 08:24:08 +00:00
Hook.hs In darcs post-apply hook, send a Push object to Vervis 2019-10-10 16:41:34 +00:00
KeyFile.hs Stop using Vervis.Import and NoImplicitPrelude, switch to plain regular imports 2019-06-15 08:24:08 +00:00
Migration.hs Implement remote following, disable automatic following 2019-09-25 10:43:05 +00:00
Model.hs New Network.FedURI with separate URI modes for dev and for fediverse 2019-07-23 13:59:48 +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
Patch.hs Provide AP representation of commits, and support committer field 2019-08-06 13:23:11 +00:00
Path.hs Mechanism for reporting git pushes to Vervis via post-receive hooks 2019-09-05 12:02: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
RemoteActorStore.hs New Network.FedURI with separate URI modes for dev and for fediverse 2019-07-23 13:59:48 +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 Install darcs post-apply hooks in darcs repos, no-op hook for now 2019-10-07 14:05:52 +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 In darcs post-apply hook, send a Push object to Vervis 2019-10-10 16:41:34 +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 SQL query that selects ticket summary data, was making getTicketsR fail 2019-06-27 11:47:23 +00:00
TicketFilter.hs Stop using Vervis.Import and NoImplicitPrelude, switch to plain regular imports 2019-06-15 08:24:08 +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 Add "Follow" button to person, repo, project and ticket pages 2019-10-02 08:07:26 +00:00
Wiki.hs Stop using Vervis.Import and NoImplicitPrelude, switch to plain regular imports 2019-06-15 08:24:08 +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