mirror of
https://code.naskya.net/repos/ndqEd
synced 2025-03-20 15:14:54 +09:00
61 lines
1.7 KiB
Haskell
61 lines
1.7 KiB
Haskell
{- 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/>.
|
|
-}
|
|
|
|
module Vervis.Path
|
|
( askRepoRootDir
|
|
, personDir
|
|
, askPersonDir
|
|
, projectDir
|
|
, askProjectDir
|
|
, repoDir
|
|
, askRepoDir
|
|
)
|
|
where
|
|
|
|
import Prelude
|
|
|
|
import Data.Text (Text, unpack)
|
|
import System.FilePath ((</>))
|
|
import Yesod.Core.Handler (getYesod)
|
|
|
|
import Vervis.Foundation
|
|
import Vervis.Settings
|
|
|
|
askRepoRootDir :: Handler FilePath
|
|
askRepoRootDir = appRepoDir . appSettings <$> getYesod
|
|
|
|
personDir :: FilePath -> Text -> FilePath
|
|
personDir root user = root </> unpack user
|
|
|
|
askPersonDir :: Text -> Handler FilePath
|
|
askPersonDir user = do
|
|
root <- askRepoRootDir
|
|
return $ personDir root user
|
|
|
|
projectDir :: FilePath -> Text -> Text -> FilePath
|
|
projectDir root user proj = root </> unpack user </> unpack proj
|
|
|
|
askProjectDir :: Text -> Text -> Handler FilePath
|
|
askProjectDir user proj = do
|
|
root <- askRepoRootDir
|
|
return $ projectDir root user proj
|
|
|
|
repoDir :: FilePath -> Text -> Text -> Text -> FilePath
|
|
repoDir root user proj repo = projectDir root user proj </> unpack repo
|
|
|
|
askRepoDir :: Text -> Text -> Text -> Handler FilePath
|
|
askRepoDir user proj repo = do
|
|
root <- askRepoRootDir
|
|
return $ repoDir root user proj repo
|