packages feed

boomange 0.1.0.0 → 0.1.0.1

raw patch · 2 files changed

+97/−125 lines, 2 files

Files

Main.hs view
@@ -35,41 +35,36 @@  appName = "boomange" -- header to be used on the sample config file-configHeader = 	-	"# This is the configuration file for " ++ appName ++ "\n" ++-	"# For a full description of its syntax, see the haddock documentation of DescriLo\n" ++-	"# In the config description:\n" ++-	"# output - where should the resulting html file be placed\n" ++-	"# header - file to be prepended to output\n" ++-	"# footer - file to be appended to output\n" ++-	"# there are no other values for config\n\n" ++-	"# In the watch description, there may be an unlimited amount of values and the left part is always ignored by the program and may be used for organization.\n" ++-	"# The right part indicates which file will be read to create the output. It will behave as if all of the files were concatenated.\n\n"+configHeader =+  "# This is the configuration file for " ++ appName ++ "\n" +++  "# For a full description of its syntax, see the haddock documentation of DescriLo\n" +++  "# In the config description:\n" +++  "# output - where should the resulting html file be placed\n" +++  "# header - file to be prepended to output\n" +++  "# footer - file to be appended to output\n" +++  "# there are no other values for config\n\n" +++  "# In the watch description, there may be an unlimited amount of values and the left part is always ignored by the program and may be used for organization.\n" +++  "# The right part indicates which file will be read to create the output. It will behave as if all of the files were concatenated.\n\n" 	 -- header to be used on the sample bookmarks file bookmarksHeader =-	"# This is a sample bookmarks file for " ++ appName ++ "\n" ++-	"# For a full description of its syntax, see the haddock documentation of DescriLo\n" ++-	"# Every description has at least two values:\n" ++-	"# type - may be either 'folder' or 'url'\n" ++-	"# father - creates an hierarchy. May be the name of any folder description or 'root'\n" ++-	"# Additionally, descriptions where type=url have the following value:\n" ++-	"# url - where it links to\n" ++-	"# there are no other possible values\n\n"-	+  "#" +++  "# This is a sample bookmarks file for " ++ appName ++ "\n" +++  "# For a full description of its syntax, see the haddock documentation for SimtreeLo\n" +++  "# The first line indicates the comment pattern" +++  "# Leaves represent the URI of their direct parents"	  generateBookmarks config = do-	header <- readFile $ headerFile config-	footer <- readFile $ footerFile config-	final <- openFile (outputFile config) WriteMode-	-	bookmarks <- loadBookmarks $ watch config-	let body = htmlBookmarks bookmarks-	-	hPutStr final header-	hPutStr final body-	hPutStr final footer-	hClose final+  header <- readFile $ headerFile config+  footer <- readFile $ footerFile config+  final <- openFile (outputFile config) WriteMode+                               +  bookmarks <- loadBookmarks $ watch config+  let body = htmlBookmarks bookmarks+  hPutStr final header+  hPutStr final body+  hPutStr final footer+  hClose final  -- | gets the directory where configuration files should be placed --@@ -77,104 +72,81 @@ -- if it does not, the checks if HOME does, producing $HOME/.config/appName if it does -- if it still fails, returns getAppUserDataDirectory appName getConfigDirectory appName =-	let failXDG e = do-		dir <- getEnv "HOME"-		return $ dir ++ [pathSeparator] ++ ".config" ++ [pathSeparator] ++ appName-	in-	let failHOME e = getAppUserDataDirectory appName in-	do-	handle-		(failHOME::SomeException -> IO FilePath) $-		handle (failXDG::SomeException -> IO FilePath) $ do-			dir <- getEnv "XDG_CONFIG_HOME"-			return $ dir ++ [pathSeparator] ++ appName--+  let failXDG e = do+        dir <- getEnv "HOME"+        return $ dir ++ [pathSeparator] ++ ".config" ++ [pathSeparator] ++ appName  +      failHOME e = getAppUserDataDirectory appName+  in+   do+     handle (failHOME::SomeException -> IO FilePath) $+       handle (failXDG::SomeException -> IO FilePath) $ do+         dir <- getEnv "XDG_CONFIG_HOME"+         return $ dir ++ [pathSeparator] ++ appName  -- | installs a basic configuration installConfig cDir =-	let htmlDir = cDir ++ [pathSeparator] ++ "html" in-	let bookFile = cDir ++ [pathSeparator] ++ "bookmarks" in-	let outFile = cDir ++ [pathSeparator] ++ "bookmarks.html" in-	let config =-		Description-		{-			name = "config"-		, values = [-		             ("output",outFile)-								,("header",htmlDir ++ [pathSeparator] ++ "header.html")-								,("footer", htmlDir ++ [pathSeparator] ++ "footer.html")-							 ]-		}-	in-	let watch =-		Description-		{-			  name = "watch"-			, values = [-			("default",bookFile)-			           ]-		}-	in-	let sampleFolder =-		Description-		{-			  name = "Sample Folder"-			, values = [-			           ("type","folder")-			          ,("father","root")-			         ]-		}	-	in-	let sampleUrl =-		Description-		{-			name = "Sample Url"-		,	values = [-			           ("type","url")-			          ,("father","Sample Folder")-			          ,("url","file://" ++ outFile)-			         ]-		}	-	in-	let cFile = cDir ++ [pathSeparator] ++ "config" in-	do-	-- creates the base config file-	hcFile <- openFile cFile WriteMode-	hPutStr hcFile configHeader-	hPutStr hcFile $ show config-	-- hPutStr hcFile $ "\n\n"-	hPutStr hcFile $ show watch-	hClose hcFile-	-	-- copies the default html files-	headerFile <- getDataFileName "html/header.html"-	footerFile <- getDataFileName "html/footer.html"-	cssFile <- getDataFileName "style.css"-	-- creates the html folder-	createDirectoryIfMissing True htmlDir-	-- copies html files-	copyFile headerFile $ htmlDir ++ [pathSeparator] ++ "header.html"-	copyFile footerFile $ htmlDir ++ [pathSeparator] ++ "footer.html"-	-- copies css file-	copyFile cssFile $ cDir ++ [pathSeparator] ++ "style.css"	-	-	-- creates a sample bookmarks file-	hBookmarks <- openFile bookFile WriteMode-	hPutStr hBookmarks bookmarksHeader-	hPutStr hBookmarks $ show sampleFolder-	hPutStr hBookmarks $ show sampleUrl-	hClose hBookmarks+  let htmlDir = cDir ++ [pathSeparator] ++ "html"+      bookFile = cDir ++ [pathSeparator] ++ "bookmarks"      +      outFile = cDir ++ [pathSeparator] ++ "bookmarks.html"+      config =+        Description+        {+          name = "config"+	, values = [+            ("output",outFile)+          , ("header",htmlDir ++ [pathSeparator] ++ "header.html")+          , ("footer", htmlDir ++ [pathSeparator] ++ "footer.html")+          ]+	} 	+      watch =+        Description+                   {+                     name = "watch"+                   , values = [+                     ("default",bookFile)+                     ]+                   }	+      sampleBookmarks =+        "Boomange\n\tDocumentation\n" +++        "\t\tDescriLo\n\t\t\thttp://hackage.haskell.org/package/descrilo-0.1.0.0/docs/Data-DescriLo.html\n" +++        "\t\tSimtreeLo\n\t\t\thttp://hackage.haskell.org/package/simtreelo-0.1.0.0/docs/Data-Simtreelo.html\n"+        +      cFile = cDir ++ [pathSeparator] ++ "config"+  in+   do+     -- creates the base config file+     hcFile <- openFile cFile WriteMode+     hPutStr hcFile configHeader+     hPutStr hcFile $ show config+     hPutStr hcFile $ show watch+     hClose hcFile 	+     -- copies the default html files+     headerFile <- getDataFileName "html/header.html"+     footerFile <- getDataFileName "html/footer.html"+     cssFile <- getDataFileName "style.css"+     -- creates the html folder+     createDirectoryIfMissing True htmlDir+     -- copies html files+     copyFile headerFile $ htmlDir ++ [pathSeparator] ++ "header.html"+     copyFile footerFile $ htmlDir ++ [pathSeparator] ++ "footer.html"+     -- copies css file+     copyFile cssFile $ cDir ++ [pathSeparator] ++ "style.css"	++     -- creates a sample bookmarks file+     hBookmarks <- openFile bookFile WriteMode+     hPutStr hBookmarks bookmarksHeader+     hPutStr hBookmarks $ sampleBookmarks+     hClose hBookmarks 	 main = do-	cDir <- getConfigDirectory appName-	-- if the configuration directory does not exists, sets it up-	confExists <- doesDirectoryExist cDir-	when (not confExists) $ do-		createDirectoryIfMissing True cDir-		installConfig cDir-	let cFile = cDir ++ "/config"-	config <- loadConfig cFile-	generateBookmarks config+  cDir <- getConfigDirectory appName+  -- if the configuration directory does not exists, sets it up+  confExists <- doesDirectoryExist cDir+  when (not confExists) $ do+    createDirectoryIfMissing True cDir+    installConfig cDir+    let cFile = cDir ++ "/config"+    config <- loadConfig cFile+    generateBookmarks config
boomange.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                boomange-version:             0.1.0.0+version:             0.1.0.1 synopsis:            A Bookmarks manager with a HTML generator description:         In order to allow a unified and customized bookmarks file, boomange generates a HTML file with an user's bookmarks. license:             GPL-3