1
0
Fork 0
mirror of https://code.sup39.dev/repos/Wqawg synced 2024-12-31 06:44:51 +09:00
vervis/src/Vervis
fr33domlover b0da8747a2 In ActorFetchShare, use insertBy' to allow non-shared insertions
Before this patch, the shared fetch used plain insert, because it relied on
being the only place in the codebase where new RemoteActors get inserted. I was
hoping for that to be the case, but while I tweak things and handle fetching
URIs that can be an actor or a public key (for which ActorFetchShare isn't
sufficient without some smart modification), I'd like concurrent insertions to
be safe, without getting in the way of ActorFetchShare.

With this patch, it now uses insertBy', which doesn't mind concurrent
insertions.
2019-04-16 16:33:08 +00:00
..
Field Default roles for repos and turn user/anon collab tables into proj/repo fields 2019-01-29 22:24:32 +00:00
Form Make the DB migrations not depend on current model 2019-04-11 13:26:57 +00:00
Handler postOutboxR: Use ResultShare for fetching recipient actor 2019-04-16 14:34:17 +00:00
Import Use MVars to protect concurrenct access to instance/actor/key DB records 2019-03-02 19:13:51 +00:00
Migration Implement outbox remote delivery, in handler and periodic, not used yet 2019-04-16 14:27:50 +00:00
Model Unfinished updated outbox handler 2019-04-11 13:44:44 +00:00
Settings Put all modules under a new Vervis module 2016-02-23 08:45:03 +00:00
Widget In ticket comment tree, support mixing local and remote (federated) comments 2019-03-20 08:07:37 +00:00
Access.hs Fix typo in comment 2019-03-09 15:44:31 +00:00
ActivityStreams.hs Switch actor ID URIs to be /s/ACTOR instead of /p and /g 2019-02-14 22:13:58 +00:00
ActorKey.hs HTTP Signature verification: RSA-SHA256 and PEM/ASN1 support 2019-03-10 23:15:42 +00:00
Application.hs Implement outbox remote delivery, in handler and periodic, not used yet 2019-04-16 14:27:50 +00:00
Avatar.hs Use HTTPS for avatar URL if approot in settings is https:// 2018-03-06 00:55:52 +00:00
BinaryBody.hs Binary request body decoder 2016-04-24 18:48:07 +00:00
ChangeFeed.hs In repo change feed, entry ID is now the URL of patch page 2018-12-12 08:37:01 +00:00
Changes.hs Atom and RSS feeds for repo history 2018-03-31 22:04:33 +00:00
Colour.hs Define colors for use with 'diagrams' 2016-06-26 08:03:18 +00:00
Content.hs Send raw pack as git-upload-pack-result 2016-04-29 04:32:32 +00:00
Darcs.hs Darcs patch parser: Make sure we read the whole patch successfully 2018-07-10 16:00:01 +00:00
Discussion.hs Rename RemoteSharer entity to RemoteActor 2019-04-12 00:56:27 +00:00
Federation.hs Implement outbox remote delivery, in handler and periodic, not used yet 2019-04-16 14:27:50 +00:00
Formatting.hs Finish route change, it builds now 2016-05-23 20:46:54 +00:00
Foundation.hs Implement outbox remote delivery, in handler and periodic, not used yet 2019-04-16 14:27:50 +00:00
Git.hs Upgrade to GHC 8.4 and LTS 12 2018-12-05 03:41:19 +00:00
GraphProxy.hs Ticket dependency add/remove and some fixes to recursive SQL 2016-07-28 16:40:10 +00:00
Import.hs Upgrade to GHC 8 and LTS 10.10 2018-05-16 00:02:54 +00:00
KeyFile.hs Generate and keep permanent salt for generating hashids for URIs 2019-02-08 21:54:22 +00:00
MediaType.hs Use Pandoc for document rendering, for now just Markdown 2016-04-17 17:55:23 +00:00
Migration.hs Implement outbox remote delivery, in handler and periodic, not used yet 2019-04-16 14:27:50 +00:00
Model.hs Create Note outbox handler, not in use yet 2019-03-28 21:08:30 +00:00
Paginate.hs Pagination: Define page number request param name in one place 2016-06-07 11:10:24 +00:00
Palette.hs Palette: Make the dark blue lighter, it's too dark against the #111 background 2019-01-03 10:18:09 +00:00
Patch.hs Display commit diff for Git repos 2018-05-21 20:32:34 +00:00
Path.hs Start big route change, doesn't build yet 2016-05-23 12:24:14 +00:00
Query.hs Default roles for repos and turn user/anon collab tables into proj/repo fields 2019-01-29 22:24:32 +00:00
Readme.hs Refactor git source view code and implement the same for Darcs 2016-05-05 07:29:19 +00:00
RemoteActorStore.hs In ActorFetchShare, use insertBy' to allow non-shared insertions 2019-04-16 16:33:08 +00:00
Render.hs Upgrade to GHC 8 and LTS 10.10 2018-05-16 00:02:54 +00:00
Role.hs Default roles for repos and turn user/anon collab tables into proj/repo fields 2019-01-29 22:24:32 +00:00
Secure.hs Automatically set approot to https://HOST and require Host header to match 2019-03-16 17:15:31 +00:00
Settings.hs Add setting that says how much time to keep retrying activity delivery 2019-04-01 23:38:44 +00:00
SourceTree.hs Refactor git source view code and implement the same for Darcs 2016-05-05 07:29:19 +00:00
Ssh.hs Default roles for repos and turn user/anon collab tables into proj/repo fields 2019-01-29 22:24:32 +00:00
Style.hs Define colors in dedicated Vervis.Palette module 2016-06-22 20:58:42 +00:00
Ticket.hs Remove Discussion's nextMessage field, it's not being used anymore 2019-03-18 20:18:25 +00:00
TicketFilter.hs Display tickets in list view the same as in tree view 2018-06-17 10:29:51 +00:00
Time.hs Show creation date in group page 2016-05-25 07:50:10 +00:00
Widget.hs Add CSRF token to all buttons through a new buttonW widget 2018-07-11 08:15:19 +00:00
Wiki.hs Initial minimal optional per-project wiki 2016-06-04 06:57:54 +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 Vervis.MediaType (chooseMediaType)
import Vervis.Render (renderSourceBL)

-- | 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