mathgenealogy 1.0.0 → 1.1.0
raw patch · 4 files changed
+54/−41 lines, 4 files
Files
- Entry.hs +1/−1
- Extract.hs +6/−3
- Main.hs +32/−21
- mathgenealogy.cabal +15/−16
Entry.hs view
@@ -51,7 +51,7 @@ maybeShow Nothing = "" removeThesis :: Entry -> Entry-removeThesis e = e{ entryGraduationInfo = case (entryGraduationInfo e) of+removeThesis e = e{ entryGraduationInfo = case entryGraduationInfo e of Nothing -> Nothing Just g -> Just g{gradThesis = Nothing}}
Extract.hs view
@@ -80,9 +80,12 @@ getLink _ [] = Nothing getLink i off = maybeLink $ flip (!!) (i-1) $ head off in - if null offset2 - then catMaybes' [(getTag 1 offset,getLink 1 offset)]- else catMaybes' [ (getTag i offset2,getLink i offset2) | i <- [3,8] ]+ (catMaybes'+ (if null offset2 then [(getTag 1 offset, getLink 1 offset)] else+ [(getTag i offset2, getLink i offset2) | i <- [3, 8]]))+-- if null offset2 +-- then catMaybes' [(getTag 1 offset,getLink 1 offset)]+-- else catMaybes' [ (getTag i offset2,getLink i offset2) | i <- [3,8] ] where -- TODO: rewrite catMaybes' :: [(Maybe a,Maybe b)] -> [(a,b)]
Main.hs view
@@ -20,7 +20,7 @@ import qualified Data.ByteString.Lazy.Char8 as B import qualified Data.List as L import System.Cmd(system)--- import System.IO.Error+import System.IO(hFlush,stdout) import System.Exit import System.Directory import Data.Maybe@@ -34,20 +34,22 @@ import Entry import Graph -data OutputType = PDF | PNG+data OutputFile = FilePDF | FilePNG | FileSVG deriving(Eq,Data,Typeable) -instance Show OutputType where- show PDF = ".pdf"- show PNG = ".png"+instance Show OutputFile where+ show FilePDF = ".pdf"+ show FilePNG = ".png"+ show FileSVG = ".svg" -outputTypeToGraphviz :: OutputType -> String-outputTypeToGraphviz PDF = " -Tpdf "-outputTypeToGraphviz PNG = " -Tpng "+outputFileToGraphviz :: OutputFile -> String+outputFileToGraphviz FilePDF = " -Tpdf "+outputFileToGraphviz FilePNG = " -Tpng "+outputFileToGraphviz FileSVG = " -Tsvg " -instance Default OutputType where- def = PNG+instance Default OutputFile where+ def = FilePDF -- command line arguments: data MathGenealogy = MathGenealogy @@ -58,7 +60,7 @@ , verbose :: Bool , includeTheses:: Bool , startURL :: String- , outputType :: OutputType+ , outputFile :: OutputFile } deriving(Eq,Data,Typeable,Show) @@ -71,7 +73,10 @@ , onlyDotFile = False &= help "Only create .dot file" , verbose = False &= help "Print data to terminal." , includeTheses= False &= help "Include PhD thesis in output"- , outputType = enum [PNG &= help "create PNG file",PDF &= help "create PDF file"]+ , outputFile = enum [ FilePDF &= help "create PDF file"+ , FilePNG &= help "create PNG file"+ , FileSVG &= help "create SVG file"+ ] } &= summary "Mathematics Genealogy Visualizer" &= details[ "Run the program with a start-URL, for example:", "# mathgenealogy http://genealogy.math.ndsu.nodak.edu/id.php?id=18231"]@@ -86,7 +91,7 @@ nodeAtt (num,e) = [ textLabel (T.pack (show e)) , Shape BoxShape- , if num == 1 then FontSize 18 else FontSize 14+ , FontSize (if num == 1 then 18 else 14) , styles [rounded,filled,bold] , color LightYellow1 , FontName (T.pack "ZapfChancery-MediumItalic") -- "Helvetica")@@ -105,18 +110,24 @@ else return (fromJust m)) let traverseEntries :: [Text] -> IO [Entry]- traverseEntries = traverseEntries' [] []+ traverseEntries = traverseEntries' 0 [] [] where- traverseEntries' acc _ [] = return $ L.nub acc- traverseEntries' acc prevUrls (url:urls) = do+ traverseEntries' _ acc _ [] = return $ L.nub acc+ traverseEntries' c acc prevUrls (url:urls) = do e <- (if includeTheses args then id else removeThesis) `liftM` downloadEntry url threadDelay 1000000- when (verbose args) $ print e+ if verbose args + then print e+ else do + putStr $ show c ++ " "+ hFlush stdout let newUrls = urlAdvisors e- traverseEntries' (e:acc) (url:prevUrls) ((newUrls L.\\ prevUrls) ++ urls)+ traverseEntries' (c+1) (e:acc) (url:prevUrls) + ((newUrls L.\\ prevUrls) ++ urls) - putStrLn "Downloading data..."+ putStrLn "Downloading entries from http://genealogy.math.ndsu.nodak.edu..."+ putStrLn "(this might take a few minutes)" theGraph <- entryGraph <$> traverseEntries [T.pack $ startURL args] putStrLn "done. :)" let dotFileName = filePrefix args ++ ".dot" @@ -131,9 +142,9 @@ unless (onlyDotFile args) $ do putStr "Generating graphics file..."- let command = gvExecutable ++ " " ++ outputTypeToGraphviz (outputType args) ++ graphvizArgs args+ let command = gvExecutable ++ " " ++ outputFileToGraphviz (outputFile args) ++ graphvizArgs args ++ " " ++ dotFileName ++ " > " - ++ filePrefix args ++ show (outputType args)+ ++ filePrefix args ++ show (outputFile args) print command result <- system command when (isExitFailure result) $ do
mathgenealogy.cabal view
@@ -1,22 +1,14 @@--- mathgenealogy.cabal auto-generated by cabal init. For additional--- options, see--- http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#pkg-descr.--- The name of the package. Name: mathgenealogy --- The package version. See the Haskell package versioning policy--- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for--- standards guiding when and how versions should be incremented.-Version: 1.0.0+Version: 1.1.0 Synopsis: Discover your (academic) ancestors! --- A longer description of the package.-Description: A command line program for extracting data from the+Description: A simple command line program for extracting data from the Mathematics Genealogy Project (<http://genealogy.math.ndsu.nodak.edu/index.php>). .- Find your entry at <http://genealogy.math.ndsu.nodak.edu/index.php> and- then use the URL as argument to mathgenealogy. + Lookup your entry at <http://genealogy.math.ndsu.nodak.edu/index.php> and+ then use that URL as a command line argument. For example, if Carl Gauss wanted to explore his academic ancestors, he would type .@@ -27,14 +19,20 @@ . > mathgenealogy --help .- for details. Requires GraphViz to run.+ for more options. Requires GraphViz (in particular the /dot/ program) to run. . + /Changes in 1.1.0:/+ .+ * documentation and code cleanup+ . /Changes in 1.0.0:/- * updated for GHC 7.6.1+ . * choice between PDF and PNG output+ . * optional inclusion of PhD theses in output- /Changes in 0.1.0:/ .+ /Changes in 0.0.2:/+ . * fixed bug regarding trailing commas (thanks to A. Koessler) -- Homepage: http://darcs.monoid.at/mathgenealogy@@ -81,4 +79,5 @@ , Entry extensions: ScopedTypeVariables , DeriveDataTypeable--- ghc-options: -O2+-- ghc-options: -O+-- ld-options: -static -pthread