Commit 5dd90077 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

Merge branch 'dev' into dev-file-upload

parents b8b639d5 92e50de6
...@@ -5,9 +5,11 @@ MASTER_USER = gargantua ...@@ -5,9 +5,11 @@ MASTER_USER = gargantua
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = PASSWORD_TO_CHANGE SECRET_KEY = PASSWORD_TO_CHANGE
# Data path to local files # Data path to local files
DATA_FILEPATH = FILEPATH_TO_CHANGE DATA_FILEPATH = FILEPATH_TO_CHANGE
# [external]
# FRAMES # FRAMES
FRAME_WRITE_URL = URL_TO_CHANGE FRAME_WRITE_URL = URL_TO_CHANGE
FRAME_CALC_URL = URL_TO_CHANGE FRAME_CALC_URL = URL_TO_CHANGE
...@@ -15,6 +17,17 @@ FRAME_CALC_URL = URL_TO_CHANGE ...@@ -15,6 +17,17 @@ FRAME_CALC_URL = URL_TO_CHANGE
FRAME_SEARX_URL = URL_TO_CHANGE FRAME_SEARX_URL = URL_TO_CHANGE
FRAME_ISTEX_URL = URL_TO_CHANGE FRAME_ISTEX_URL = URL_TO_CHANGE
[server]
# Server config (TODO connect in ReaderMonad)
ALLOWED_ORIGIN = http://localhost
ALLOWED_ORIGIN_PORT = 8008
ALLOWED_HOST = localhost
ALLOWED_HOST_PORT = 3000
JWT_SETTINGS = TODO
[network] [network]
# Emails From address (sent by smtp) # Emails From address (sent by smtp)
MAIL = username@gargantext.org MAIL = username@gargantext.org
...@@ -33,5 +46,5 @@ DB_PASS = PASSWORD_TO_CHANGE ...@@ -33,5 +46,5 @@ DB_PASS = PASSWORD_TO_CHANGE
[logs] [logs]
LOG_FILE = /var/log/gargantext/backend.log LOG_FILE = /var/log/gargantext/backend.log
LOG_LEVEL = DEBUG LOG_LEVEL = LevelDebug
LOG_FORMATTER = verbose LOG_FORMATTER = verbose
...@@ -75,7 +75,6 @@ data Settings = Settings ...@@ -75,7 +75,6 @@ data Settings = Settings
, _cookieSettings :: CookieSettings , _cookieSettings :: CookieSettings
, _sendLoginEmails :: SendEmailType , _sendLoginEmails :: SendEmailType
, _scrapydUrl :: BaseUrl , _scrapydUrl :: BaseUrl
, _fileFolder :: FilePath
, _config :: GargConfig , _config :: GargConfig
} }
...@@ -97,7 +96,6 @@ devSettings jwkFile = do ...@@ -97,7 +96,6 @@ devSettings jwkFile = do
-- , _dbServer = "localhost" -- , _dbServer = "localhost"
, _sendLoginEmails = LogEmailToConsole , _sendLoginEmails = LogEmailToConsole
, _scrapydUrl = fromMaybe (panic "Invalid scrapy URL") $ parseBaseUrl "http://localhost:6800" , _scrapydUrl = fromMaybe (panic "Invalid scrapy URL") $ parseBaseUrl "http://localhost:6800"
, _fileFolder = "data"
, _cookieSettings = defaultCookieSettings { cookieXsrfSetting = Just xsrfCookieSetting } -- TODO-SECURITY tune , _cookieSettings = defaultCookieSettings { cookieXsrfSetting = Just xsrfCookieSetting } -- TODO-SECURITY tune
, _jwtSettings = defaultJWTSettings jwk -- TODO-SECURITY tune , _jwtSettings = defaultJWTSettings jwk -- TODO-SECURITY tune
, _config = defaultConfig , _config = defaultConfig
......
...@@ -24,7 +24,7 @@ import Control.Lens (makeLenses) ...@@ -24,7 +24,7 @@ import Control.Lens (makeLenses)
data GargConfig = GargConfig { _gc_masteruser :: !Text data GargConfig = GargConfig { _gc_masteruser :: !Text
, _gc_secretkey :: !Text , _gc_secretkey :: !Text
, _gc_datafilepath :: !Text , _gc_datafilepath :: !FilePath
, _gc_frame_write_url :: !Text , _gc_frame_write_url :: !Text
, _gc_frame_calc_url :: !Text , _gc_frame_calc_url :: !Text
...@@ -36,7 +36,6 @@ data GargConfig = GargConfig { _gc_masteruser :: !Text ...@@ -36,7 +36,6 @@ data GargConfig = GargConfig { _gc_masteruser :: !Text
makeLenses ''GargConfig makeLenses ''GargConfig
readConfig :: FilePath -> IO GargConfig readConfig :: FilePath -> IO GargConfig
readConfig fp = do readConfig fp = do
ini <- readIniFile fp ini <- readIniFile fp
...@@ -50,7 +49,7 @@ readConfig fp = do ...@@ -50,7 +49,7 @@ readConfig fp = do
pure $ GargConfig (val "MASTER_USER") pure $ GargConfig (val "MASTER_USER")
(val "SECRET_KEY") (val "SECRET_KEY")
(val "DATA_FILEPATH") (cs $ val "DATA_FILEPATH")
(val "FRAME_WRITE_URL") (val "FRAME_WRITE_URL")
(val "FRAME_CALC_URL") (val "FRAME_CALC_URL")
(val "FRAME_SEARX_URL") (val "FRAME_SEARX_URL")
......
...@@ -20,6 +20,7 @@ import Control.Monad.Reader (MonadReader) ...@@ -20,6 +20,7 @@ import Control.Monad.Reader (MonadReader)
import Control.Monad.Reader (ask) import Control.Monad.Reader (ask)
import Data.Text (Text) import Data.Text (Text)
import GHC.IO (FilePath) import GHC.IO (FilePath)
import Gargantext.Config
import Gargantext.API.Admin.Settings import Gargantext.API.Admin.Settings
import Gargantext.Database.Admin.Types.Node (NodeId, NodeType) import Gargantext.Database.Admin.Types.Node (NodeId, NodeType)
import Gargantext.Prelude import Gargantext.Prelude
...@@ -65,7 +66,7 @@ class ReadFile a where ...@@ -65,7 +66,7 @@ class ReadFile a where
writeFile :: (MonadReader env m, MonadBase IO m, HasSettings env, SaveFile a) writeFile :: (MonadReader env m, MonadBase IO m, HasSettings env, SaveFile a)
=> a -> m FilePath => a -> m FilePath
writeFile a = do writeFile a = do
dataPath <- view (settings . fileFolder) <$> ask dataPath <- view (settings . config . gc_datafilepath) <$> ask
(fp,fn) <- liftBase $ (toPath 3) . hash . show <$> newStdGen (fp,fn) <- liftBase $ (toPath 3) . hash . show <$> newStdGen
let foldPath = dataPath <> "/" <> fp let foldPath = dataPath <> "/" <> fp
...@@ -80,5 +81,5 @@ writeFile a = do ...@@ -80,5 +81,5 @@ writeFile a = do
readFile :: (MonadReader env m, MonadBase IO m, HasSettings env, ReadFile a) readFile :: (MonadReader env m, MonadBase IO m, HasSettings env, ReadFile a)
=> FilePath -> m a => FilePath -> m a
readFile fp = do readFile fp = do
dataPath <- view (settings . fileFolder) <$> ask dataPath <- view (settings . config . gc_datafilepath) <$> ask
liftBase $ readFile' $ dataPath <> "/" <> fp liftBase $ readFile' $ dataPath <> "/" <> fp
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment