1
1
mirror of https://github.com/Yvee1/hascard.git synced 2024-10-05 19:49:16 +03:00

Add snapcraft

This commit is contained in:
Steven van den Broek 2020-07-19 18:55:48 +02:00
parent e9c6f95135
commit e251e7cb0b
4 changed files with 66 additions and 6 deletions

4
.gitignore vendored
View File

@ -1,3 +1,5 @@
.stack-work/
hascard.cabal
*~
*~
*.snap
images/

43
snap/snapcraft.yaml Normal file
View File

@ -0,0 +1,43 @@
name: hascard # you probably want to 'snapcraft register <name>'
base: core18 # the base snap is the execution environment for this snap
# version: '0.1.0.0' # just for humans, typically '1.2+git' or '1.3.2'
adopt-info: hascard
summary: A TUI for reviewing notes using 'flashcards' written with markdown-like syntax # 79 char long summary
description: |
Hascard is a text-based user interface for reviewing notes using 'flashcards'.
Cards are written in markdown-like syntax. Please see the README file on
GitHub at <https://github.com/Yvee1/hascard#readme> for more information.
grade: stable # must be 'stable' to release into candidate/stable channels
confinement: strict # use 'strict' once you have the right plugs and slots
apps:
hascard:
command: bin/hascard
plugs:
- home
parts:
hascard:
# See 'snapcraft plugins'
plugin: nil
source: .
override-pull: |
snapcraftctl pull
snapcraftctl set-version "$(grep version package.yaml | awk '{ print $NF }')"
override-build: |
if [ ! -x "$(command -v stack)" ]; then
curl -sSL https://get.haskellstack.org/ | sh
fi
stack build --copy-bins
organize:
/root/.local/bin/hascard: bin/hascard
stage-packages:
- ncurses-term
- libncurses5-dev
- libncursesw5-dev
build-packages:
- curl
- ncurses-term
- libncurses5-dev
- libncursesw5-dev

View File

@ -11,6 +11,7 @@ import Control.Monad.IO.Class
import Data.Functor (($>))
import Lens.Micro.Platform
import System.FilePath ((</>), takeBaseName)
import System.Environment (lookupEnv)
import Parser
import UI.BrickHelpers
import UI.FileBrowser (runFileBrowserUI)
@ -151,9 +152,16 @@ addRecent s = do
getRecentsFile :: IO FilePath
getRecentsFile = do
xdg <- D.getXdgDirectory D.XdgData "hascard"
D.createDirectoryIfMissing True xdg
return (xdg </> "recents")
maybeSnap <- lookupEnv "SNAP_USER_DATA"
xdg <- D.getXdgDirectory D.XdgConfig "hascard"
let dir = case maybeSnap of
Just path | not (null path) -> path
| otherwise -> xdg
Nothing -> xdg
D.createDirectoryIfMissing True dir
return (dir </> "recents")
runFileBrowser :: IO ()
runFileBrowser = do

View File

@ -8,6 +8,7 @@ import Control.Monad (void)
import Data.Functor (($>))
import Data.Map.Strict (Map, (!))
import System.FilePath ((</>))
import System.Environment (lookupEnv)
import UI.BrickHelpers
import qualified Data.Map.Strict as M
import qualified Graphics.Vty as V
@ -121,9 +122,15 @@ parseSettings = read
getSettingsFile :: IO FilePath
getSettingsFile = do
maybeSnap <- lookupEnv "SNAP_USER_DATA"
xdg <- D.getXdgDirectory D.XdgConfig "hascard"
D.createDirectoryIfMissing True xdg
return (xdg </> "settings")
let dir = case maybeSnap of
Just path | not (null path) -> path
| otherwise -> xdg
Nothing -> xdg
D.createDirectoryIfMissing True dir
return (dir </> "settings")
defaultSettings :: Settings
defaultSettings = M.fromList [(0, False), (1, True), (2, False)]