Federated forge server
Clone
HTTPS:
git clone https://vervis.peers.community/repos/rjQ3E
SSH:
git clone USERNAME@vervis.peers.community:rjQ3E
Branches
Tags
MediaType.hs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | {- This file is part of Vervis.
-
- Written in 2016, 2022 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/>.
-}
-- | File content types and tools for detecting them. The focus is on content
-- that gets special treatment in Vervis, and not general MIME type modeling or
-- detection (although that could be done in the future).
module Data.MediaType
( MediaType (..)
, FileName
, FileBaseName
, FileExtension
, WorkType
, SourceViewOptions
, chooseMediaType
)
where
import Data.Text (Text)
data MediaType
= PlainText
| XML
| JSON
| YAML
| HTML
| CSS
| Markdown
| CSource
| CHeader
| Haskell
| LiterateHaskell
| CabalPackageDescription
| PersistentTemplate
| YesodRouteTemplate
| Hamlet
| Cassius
| Diff
| DarcsPatch
deriving Show
type FileName = Text
type FileBaseName = Text
type FileExtension = Text
type WorkType = ()
type SourceViewOptions = ()
chooseMediaType
:: [FileName]
-> FileBaseName
-> FileExtension
-> WorkType -- project type
-> SourceViewOptions -- e.g. whether to see rendered pages or their sources
-> MediaType
chooseMediaType dir base ext wt opts =
case (dir, base, ext, wt) of
-- * Data interchange
(_, _, "xml" , _) -> PlainText
(_, _, "json" , _) -> PlainText
(_, _, "yml" , _) -> PlainText
(_, _, "yaml" , _) -> PlainText
-- * Documents
(_, _, "txt" , _) -> PlainText
(_, _, "md" , _) -> Markdown
(_, _, "mdwn" , _) -> Markdown
(_, _, "mkdn" , _) -> Markdown
(_, _, "markdown", _) -> Markdown
-- * Web page basics
(_, _, "html" , _) -> PlainText
(_, _, "xhtml" , _) -> PlainText
(_, _, "css" , _) -> PlainText
(_, _, "js" , _) -> PlainText
-- * Programming languages
-- ** C
(_, _, "c" , _) -> PlainText
(_, _, "h" , _) -> PlainText
-- ** C++
(_, _, "cc" , _) -> PlainText
(_, _, "cpp" , _) -> PlainText
(_, _, "cxx" , _) -> PlainText
(_, _, "hh" , _) -> PlainText
(_, _, "hpp" , _) -> PlainText
-- ** Haskell
(_, _, "hs" , _) -> Haskell
(_, _, "lhs" , _) -> PlainText
(_, _, "cabal" , _) -> PlainText
(_, _, "hamlet" , _) -> PlainText
(_, _, "cassius" , _) -> PlainText
-- ** Java
(_, _, "java" , _) -> PlainText
-- ** Lisp
(_, _, "cl" , _) -> PlainText
(_, _, "el" , _) -> PlainText
-- ** Lua
(_, _, "lua" , _) -> PlainText
-- ** Perl
(_, _, "pl" , _) -> PlainText
-- ** PHP
(_, _, "php" , _) -> PlainText
-- ** Python
(_, _, "py" , _) -> PlainText
-- ** Ruby
(_, _, "rb" , _) -> PlainText
-- ** Scheme
(_, _, "scm" , _) -> PlainText
-- * Development
(_, _, "diff" , _) -> Diff
(_, _, "patch" , _) -> Diff
(_, _, "dpatch" , _) -> DarcsPatch
(_, _, _ , _) -> PlainText
|