1
0
Fork 0
mirror of https://code.naskya.net/repos/ndqEd synced 2025-01-11 11:06:46 +09:00
vervis/src/Vervis
fr33domlover bec9290783 Complete DB migration list, allowing to upgrade 2016-08-04 running instance
Until now the list of DB migration actions was incomplete, containing only
changes made since I added the migration system itself. It now contains the
2016-08-04 model, and then every change made since then.

IMPORTANT: The 2016-08-04 instance doesn't have a schema version entity at all,
so it is assigned version 0, while the actual version of its schema is 1. I'm
going to patch persistent-migration to allow it to be 1, making the migration
path smooth.
2018-03-27 14:28:56 +00:00
..
Field Field enums aren't useful if you can't define values 2016-08-08 17:05:09 +00:00
Form Workflow scope field, minimal support 2016-09-01 17:40:02 +00:00
Handler getPersonR respond with minimal ActivityPub actor 2018-03-25 19:26:30 +00:00
Import Build with LTS-5.13 2016-04-19 06:38:52 +00:00
Migration Complete DB migration list, allowing to upgrade 2016-08-04 running instance 2018-03-27 14:28:56 +00:00
Model Complete DB migration list, allowing to upgrade 2016-08-04 running instance 2018-03-27 14:28:56 +00:00
Settings Put all modules under a new Vervis module 2016-02-23 08:45:03 +00:00
Widget Turn boolean ticketDone into TicketStatus enum 2016-08-11 00:44:11 +00:00
ActivityStreams.hs getPersonR respond with minimal ActivityPub actor 2018-03-25 19:26:30 +00:00
Application.hs Switch to yesod-auth-account and make the mail code independent of Vervis 2018-03-03 21:33:59 +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
Changes.hs Explore friendly rendering of event time 2016-05-05 22:20:11 +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 Move DarcsRev and code we're sharing with it into a separate library 2018-03-20 23:45:09 +00:00
Discussion.hs Pass AppDB action instead of DiscussionId 2016-05-19 22:40:54 +00:00
Formatting.hs Finish route change, it builds now 2016-05-23 20:46:54 +00:00
Foundation.hs Resend POST and verify GET require unverified login 2018-03-18 00:13:22 +00:00
Git.hs Minimal pagination for git and darcs change log 2016-05-13 08:49:19 +00:00
GitOld.hs Refactor git source view code and implement the same for Darcs 2016-05-05 07:29: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 Put all modules under a new Vervis module 2016-02-23 08:45:03 +00:00
MediaType.hs Use Pandoc for document rendering, for now just Markdown 2016-04-17 17:55:23 +00:00
Migration.hs Complete DB migration list, allowing to upgrade 2016-08-04 running instance 2018-03-27 14:28:56 +00:00
Model.hs Complete DB migration list, allowing to upgrade 2016-08-04 running instance 2018-03-27 14:28:56 +00:00
Paginate.hs Pagination: Define page number request param name in one place 2016-06-07 11:10:24 +00:00
Palette.hs Define colors in dedicated Vervis.Palette module 2016-06-22 20:58:42 +00:00
Path.hs Start big route change, doesn't build yet 2016-05-23 12:24:14 +00:00
Query.hs Ticket dependency add/remove and some fixes to recursive SQL 2016-07-28 16:40:10 +00:00
Readme.hs Refactor git source view code and implement the same for Darcs 2016-05-05 07:29:19 +00:00
Render.hs Render ticket description as Markdown 2016-05-02 21:20:25 +00:00
Role.hs Replace project role HTML flat list with an SVG diagram 2016-07-02 09:45:29 +00:00
Secure.hs Use HTTPS for avatar URL if approot in settings is https:// 2018-03-06 00:55:52 +00:00
Settings.hs Switch to yesod-auth-account and make the mail code independent of Vervis 2018-03-03 21:33:59 +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 Specify default role for repo and project visitors 2016-07-03 07:52:11 +00:00
Style.hs Define colors in dedicated Vervis.Palette module 2016-06-22 20:58:42 +00:00
Ticket.hs Custom ticket field relevance filter by ticket status 2016-08-11 09:27:30 +00:00
TicketFilter.hs Turn boolean ticketDone into TicketStatus enum 2016-08-11 00:44:11 +00:00
Time.hs Show creation date in group page 2016-05-25 07:50:10 +00:00
Widget.hs Move DarcsRev and code we're sharing with it into a separate library 2018-03-20 23:45:09 +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