import from firefox #1
@ -40,6 +40,7 @@ library
|
||||
, Operations.Insert
|
||||
, Operations.List
|
||||
, Operations.Query
|
||||
, Operations.Import.Firefox
|
||||
, Operations
|
||||
, Data.Environment
|
||||
, Data.Buuka
|
||||
@ -61,6 +62,9 @@ library
|
||||
, lens
|
||||
, hashable
|
||||
, regex-tdfa
|
||||
, sqlite-simple
|
||||
, conduit
|
||||
, conduit-extra
|
||||
hs-source-dirs: src
|
||||
|
||||
executable buuka
|
||||
|
16
default.nix
16
default.nix
@ -1,8 +1,9 @@
|
||||
{ mkDerivation, aeson, base, bytestring, containers
|
||||
, deriving-compat, exceptions, filepath, hashable, hashids
|
||||
, hedgehog, hedgehog-corpus, lens, mtl, optparse-applicative
|
||||
, regex-tdfa, stdenv, tasty, tasty-hedgehog, tasty-hunit, text
|
||||
, transformers, unliftio, vector, yaml
|
||||
{ mkDerivation, aeson, base, bytestring, conduit, conduit-extra
|
||||
, containers, deriving-compat, exceptions, filepath, hashable
|
||||
, hashids, hedgehog, hedgehog-corpus, lens, mtl
|
||||
, optparse-applicative, regex-tdfa, sqlite-simple, stdenv, tasty
|
||||
, tasty-hedgehog, tasty-hunit, text, transformers, unliftio, vector
|
||||
, yaml
|
||||
}:
|
||||
mkDerivation {
|
||||
pname = "buuka";
|
||||
@ -11,8 +12,9 @@ mkDerivation {
|
||||
isLibrary = true;
|
||||
isExecutable = true;
|
||||
libraryHaskellDepends = [
|
||||
aeson base bytestring containers exceptions filepath hashable
|
||||
hashids lens mtl regex-tdfa text transformers unliftio vector yaml
|
||||
aeson base bytestring conduit conduit-extra containers exceptions
|
||||
filepath hashable hashids lens mtl regex-tdfa sqlite-simple text
|
||||
transformers unliftio vector yaml
|
||||
];
|
||||
executableHaskellDepends = [ base optparse-applicative unliftio ];
|
||||
testHaskellDepends = [
|
||||
|
47
src/Operations/Import/Firefox.hs
Normal file
47
src/Operations/Import/Firefox.hs
Normal file
@ -0,0 +1,47 @@
|
||||
{-|
|
||||
Module : Operations.Import.Firefox
|
||||
Description : Imports from firefox
|
||||
Copyright : (c) Mats Rauhala, 2020
|
||||
License : BSD-3-Clause
|
||||
Maintainer : mats.rauhala@iki.fi
|
||||
Stability : experimental
|
||||
Portability : POSIX
|
||||
|
||||
Imports from firefox. Firefox needs to be closed when doing the import
|
||||
-}
|
||||
module Operations.Import.Firefox where
|
||||
|
||||
import Conduit
|
||||
import qualified Data.Conduit.Combinators as C
|
||||
|
||||
import System.FilePath
|
||||
(takeFileName, (</>))
|
||||
|
||||
import Control.Exception
|
||||
(Exception)
|
||||
|
||||
import System.Environment
|
||||
(lookupEnv)
|
||||
|
||||
import GHC.Stack
|
||||
|
||||
-- select p.title, p.url from moz_bookmarks b join moz_places p on b.fk = p.id
|
||||
--
|
||||
-- select keyword from moz_keywords where place_id = ?
|
||||
|
||||
newtype ImportException
|
||||
= HomeNotFound CallStack
|
||||
deriving stock (Show)
|
||||
deriving anyclass (Exception)
|
||||
|
||||
stores
|
||||
:: MonadResource m
|
||||
=> MonadThrow m
|
||||
=> MonadIO m
|
||||
=> HasCallStack
|
||||
=> ConduitT i FilePath m ()
|
||||
stores = liftIO (lookupEnv "HOME") >>= maybe (throwM (HomeNotFound callStack)) listStores
|
||||
where
|
||||
listStores home =
|
||||
sourceDirectoryDeep False (home </> ".mozilla/firefox")
|
||||
.| C.filter (\p -> takeFileName p == "places.sqlite")
|
Loading…
Reference in New Issue
Block a user