{"action":"created","comment":{"url":"https://api.github.com/repos/Courseography/courseography/pulls/comments/24938061","id":24938061,"diff_hunk":"@@ -0,0 +1,130 @@\n+module ParserUtil where\n+\n+import Text.XML.HaXml\n+import Text.XML.HaXml.ByteStringPP\n+import Text.XML.HaXml.Wrappers\n+import Text.XML.HaXml.Types\n+import Text.XML.HaXml.Combinators\n+import Control.Monad.IO.Class  (liftIO)\n+import Text.XML.HaXml.Util\n+import Text.XML.HaXml.XmlContent.Parser\n+import qualified Data.Conduit.List as CL\n+import Database.Persist\n+import Database.Persist.Sqlite\n+import Text.XML.HaXml.Namespaces\n+import Data.Conduit\n+import Data.List.Split\n+import Data.List\n+import Data.Text as T (pack, unpack)\n+import Tables\n+import JsonParser\n+import SVGTypes\n+\n+-- | Gets the root element of the document.\n+getRoot :: Document i -> Content i\n+getRoot doc = head $ parseDocument (tag \"svg\") doc\n+\n+-- | Gets a style attribute from a style String.\n+getStyleAttr :: String -> String -> String\n+getStyleAttr attr style =\n+    drop (length attr + 1) $\n+    head $ filter\n+            (\\x -> take (length attr + 1) x == (attr ++ \":\"))\n+            (splitOn \";\" style) ++ [\"\"]\n+\n+-- | Gets a style attribute from a style String. If the style attribute is \"\",\n+-- then this function defaults to the previous style attribute, 'parent'.\n+getNewStyleAttr :: String -> String -> String -> String\n+getNewStyleAttr newStyle attr parent =\n+    if null (getStyleAttr attr newStyle)\n+    then parent\n+    else getStyleAttr attr newStyle\n+\n+-- | Converts a tuple of Float to a tuple of Rational.\n+convertFloatTupToRationalTup :: (Float, Float) -> (Rational, Rational)\n+convertFloatTupToRationalTup tup = (toRational (fst tup), toRational (snd tup))\n+\n+-- | Applys a CFilter to a Document and produces a list of Content filtered\n+-- by the CFilter.\n+parseDocument :: CFilter i -> Document i -> [Content i]\n+parseDocument filter (Document _ _ e _) = filter (CElem e undefined)\n+\n+-- | Gets the tag name of an Element.\n+getName :: Content i -> String\n+getName (CElem (Elem a _ _) _) = printableName a\n+getName _ = \"\"\n+\n+-- | Gets the list of Attributes of an Element.\n+getAttrs :: Element s -> [Attribute]\n+getAttrs (Elem _ b _) = b\n+\n+-- | Gets an Attribute's name.\n+getAttrName :: Attribute -> String\n+getAttrName ((a,_)) = printableName a\n+\n+-- | Gets an Attribute's value.\n+getAttrVal :: Attribute -> String\n+getAttrVal ((_,b)) = show b\n+\n+-- | Converts an Attribute into a more parsable form.\n+convertAttributeToTuple :: Attribute -> (String, String)\n+convertAttributeToTuple at = (getAttrName at, getAttrVal at)\n+\n+-- | Gets the children of the current node.\n+getChildren :: Content i -> [Content i]\n+getChildren = (path [children])","path":"hs/ParserUtil.hs","position":75,"original_position":75,"commit_id":"4e7bcc44da5d11910ea38432524b2a29de0508af","original_commit_id":"4e7bcc44da5d11910ea38432524b2a29de0508af","user":{"login":"david-yz-liu","id":3333115,"avatar_url":"https://avatars.githubusercontent.com/u/3333115?v=3","gravatar_id":"","url":"https://api.github.com/users/david-yz-liu","html_url":"https://github.com/david-yz-liu","followers_url":"https://api.github.com/users/david-yz-liu/followers","following_url":"https://api.github.com/users/david-yz-liu/following{/other_user}","gists_url":"https://api.github.com/users/david-yz-liu/gists{/gist_id}","starred_url":"https://api.github.com/users/david-yz-liu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/david-yz-liu/subscriptions","organizations_url":"https://api.github.com/users/david-yz-liu/orgs","repos_url":"https://api.github.com/users/david-yz-liu/repos","events_url":"https://api.github.com/users/david-yz-liu/events{/privacy}","received_events_url":"https://api.github.com/users/david-yz-liu/received_events","type":"User","site_admin":false},"body":"()","created_at":"2015-02-18T20:36:28Z","updated_at":"2015-02-18T20:36:28Z","html_url":"https://github.com/Courseography/courseography/pull/343#discussion_r24938061","pull_request_url":"https://api.github.com/repos/Courseography/courseography/pulls/343","_links":{"self":{"href":"https://api.github.com/repos/Courseography/courseography/pulls/comments/24938061"},"html":{"href":"https://github.com/Courseography/courseography/pull/343#discussion_r24938061"},"pull_request":{"href":"https://api.github.com/repos/Courseography/courseography/pulls/343"}}},"pull_request":{"url":"https://api.github.com/repos/Courseography/courseography/pulls/343","id":29344680,"html_url":"https://github.com/Courseography/courseography/pull/343","diff_url":"https://github.com/Courseography/courseography/pull/343.diff","patch_url":"https://github.com/Courseography/courseography/pull/343.patch","issue_url":"https://api.github.com/repos/Courseography/courseography/issues/343","number":343,"state":"open","locked":false,"title":"Svg Parser: Interactivity","user":{"login":"Ian-Stewart-Binks","id":6301000,"avatar_url":"https://avatars.githubusercontent.com/u/6301000?v=3","gravatar_id":"","url":"https://api.github.com/users/Ian-Stewart-Binks","html_url":"https://github.com/Ian-Stewart-Binks","followers_url":"https://api.github.com/users/Ian-Stewart-Binks/followers","following_url":"https://api.github.com/users/Ian-Stewart-Binks/following{/other_user}","gists_url":"https://api.github.com/users/Ian-Stewart-Binks/gists{/gist_id}","starred_url":"https://api.github.com/users/Ian-Stewart-Binks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ian-Stewart-Binks/subscriptions","organizations_url":"https://api.github.com/users/Ian-Stewart-Binks/orgs","repos_url":"https://api.github.com/users/Ian-Stewart-Binks/repos","events_url":"https://api.github.com/users/Ian-Stewart-Binks/events{/privacy}","received_events_url":"https://api.github.com/users/Ian-Stewart-Binks/received_events","type":"User","site_admin":false},"body":"This pull request accomplishes the following tasks:\r\n* Issue #342 : The graph is now parsed on the server.\r\n* The SVG output is now nicer.\r\n* SVG graph is now retrieved dynamically.\r\n\r\nThere are still a few kinks to work out: \r\n* Fill for courses 120 and 104 have not been fixed yet.\r\n* Region text has been taken out in this pull request. It should not be too difficult to add it back in. It was taken out to support text to rect assignment (for IDs and text/rect nesting in group elements).\r\n* SVG path curve-to has not been tackled yet. This is the cause of the wonky theory region.\r\n* The graph ID currently has nothing to do with graph retrieval.\r\n\r\nNote: Text elements are currently using their native x and y positions. I think that this is acceptable, and it works perfectly fine.\r\n\r\nNote: This code could most likely use more refactoring. If you see anything that can be refactored further, please leave a line note.","created_at":"2015-02-16T00:48:23Z","updated_at":"2015-02-18T20:36:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a9fad72924a923dfd55ddc7d02c1f114fed589c9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Courseography/courseography/pulls/343/commits","review_comments_url":"https://api.github.com/repos/Courseography/courseography/pulls/343/comments","review_comment_url":"https://api.github.com/repos/Courseography/courseography/pulls/comments/{number}","comments_url":"https://api.github.com/repos/Courseography/courseography/issues/343/comments","statuses_url":"https://api.github.com/repos/Courseography/courseography/statuses/4e7bcc44da5d11910ea38432524b2a29de0508af","head":{"label":"Ian-Stewart-Binks:svg-parser-interactive","ref":"svg-parser-interactive","sha":"4e7bcc44da5d11910ea38432524b2a29de0508af","user":{"login":"Ian-Stewart-Binks","id":6301000,"avatar_url":"https://avatars.githubusercontent.com/u/6301000?v=3","gravatar_id":"","url":"https://api.github.com/users/Ian-Stewart-Binks","html_url":"https://github.com/Ian-Stewart-Binks","followers_url":"https://api.github.com/users/Ian-Stewart-Binks/followers","following_url":"https://api.github.com/users/Ian-Stewart-Binks/following{/other_user}","gists_url":"https://api.github.com/users/Ian-Stewart-Binks/gists{/gist_id}","starred_url":"https://api.github.com/users/Ian-Stewart-Binks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ian-Stewart-Binks/subscriptions","organizations_url":"https://api.github.com/users/Ian-Stewart-Binks/orgs","repos_url":"https://api.github.com/users/Ian-Stewart-Binks/repos","events_url":"https://api.github.com/users/Ian-Stewart-Binks/events{/privacy}","received_events_url":"https://api.github.com/users/Ian-Stewart-Binks/received_events","type":"User","site_admin":false},"repo":{"id":26987808,"name":"courseography","full_name":"Ian-Stewart-Binks/courseography","owner":{"login":"Ian-Stewart-Binks","id":6301000,"avatar_url":"https://avatars.githubusercontent.com/u/6301000?v=3","gravatar_id":"","url":"https://api.github.com/users/Ian-Stewart-Binks","html_url":"https://github.com/Ian-Stewart-Binks","followers_url":"https://api.github.com/users/Ian-Stewart-Binks/followers","following_url":"https://api.github.com/users/Ian-Stewart-Binks/following{/other_user}","gists_url":"https://api.github.com/users/Ian-Stewart-Binks/gists{/gist_id}","starred_url":"https://api.github.com/users/Ian-Stewart-Binks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ian-Stewart-Binks/subscriptions","organizations_url":"https://api.github.com/users/Ian-Stewart-Binks/orgs","repos_url":"https://api.github.com/users/Ian-Stewart-Binks/repos","events_url":"https://api.github.com/users/Ian-Stewart-Binks/events{/privacy}","received_events_url":"https://api.github.com/users/Ian-Stewart-Binks/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Ian-Stewart-Binks/courseography","description":"Courseography is a tool created by David Liu and Ian Stewart-Binks to guide students through their undergraduate careers.","fork":true,"url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography","forks_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/forks","keys_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/teams","hooks_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/hooks","issue_events_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/issues/events{/number}","events_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/events","assignees_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/assignees{/user}","branches_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/branches{/branch}","tags_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/tags","blobs_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/git/refs{/sha}","trees_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/statuses/{sha}","languages_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/languages","stargazers_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/stargazers","contributors_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/contributors","subscribers_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/subscribers","subscription_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/subscription","commits_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/commits{/sha}","git_commits_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/git/commits{/sha}","comments_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/comments{/number}","issue_comment_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/issues/comments/{number}","contents_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/contents/{+path}","compare_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/merges","archive_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/downloads","issues_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/issues{/number}","pulls_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/pulls{/number}","milestones_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/milestones{/number}","notifications_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/labels{/name}","releases_url":"https://api.github.com/repos/Ian-Stewart-Binks/courseography/releases{/id}","created_at":"2014-11-22T03:49:56Z","updated_at":"2015-01-14T04:52:54Z","pushed_at":"2015-02-18T19:44:19Z","git_url":"git://github.com/Ian-Stewart-Binks/courseography.git","ssh_url":"git@github.com:Ian-Stewart-Binks/courseography.git","clone_url":"https://github.com/Ian-Stewart-Binks/courseography.git","svn_url":"https://github.com/Ian-Stewart-Binks/courseography","homepage":"","size":3747,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"Courseography:svg-schema","ref":"svg-schema","sha":"a431611695bfae2e8b3a1dcd25c45644e350c7e4","user":{"login":"Courseography","id":9721671,"avatar_url":"https://avatars.githubusercontent.com/u/9721671?v=3","gravatar_id":"","url":"https://api.github.com/users/Courseography","html_url":"https://github.com/Courseography","followers_url":"https://api.github.com/users/Courseography/followers","following_url":"https://api.github.com/users/Courseography/following{/other_user}","gists_url":"https://api.github.com/users/Courseography/gists{/gist_id}","starred_url":"https://api.github.com/users/Courseography/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Courseography/subscriptions","organizations_url":"https://api.github.com/users/Courseography/orgs","repos_url":"https://api.github.com/users/Courseography/repos","events_url":"https://api.github.com/users/Courseography/events{/privacy}","received_events_url":"https://api.github.com/users/Courseography/received_events","type":"Organization","site_admin":false},"repo":{"id":16873349,"name":"courseography","full_name":"Courseography/courseography","owner":{"login":"Courseography","id":9721671,"avatar_url":"https://avatars.githubusercontent.com/u/9721671?v=3","gravatar_id":"","url":"https://api.github.com/users/Courseography","html_url":"https://github.com/Courseography","followers_url":"https://api.github.com/users/Courseography/followers","following_url":"https://api.github.com/users/Courseography/following{/other_user}","gists_url":"https://api.github.com/users/Courseography/gists{/gist_id}","starred_url":"https://api.github.com/users/Courseography/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Courseography/subscriptions","organizations_url":"https://api.github.com/users/Courseography/orgs","repos_url":"https://api.github.com/users/Courseography/repos","events_url":"https://api.github.com/users/Courseography/events{/privacy}","received_events_url":"https://api.github.com/users/Courseography/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Courseography/courseography","description":"Courseography is a tool created by David Liu and Ian Stewart-Binks to guide students through their undergraduate careers.","fork":false,"url":"https://api.github.com/repos/Courseography/courseography","forks_url":"https://api.github.com/repos/Courseography/courseography/forks","keys_url":"https://api.github.com/repos/Courseography/courseography/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Courseography/courseography/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Courseography/courseography/teams","hooks_url":"https://api.github.com/repos/Courseography/courseography/hooks","issue_events_url":"https://api.github.com/repos/Courseography/courseography/issues/events{/number}","events_url":"https://api.github.com/repos/Courseography/courseography/events","assignees_url":"https://api.github.com/repos/Courseography/courseography/assignees{/user}","branches_url":"https://api.github.com/repos/Courseography/courseography/branches{/branch}","tags_url":"https://api.github.com/repos/Courseography/courseography/tags","blobs_url":"https://api.github.com/repos/Courseography/courseography/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Courseography/courseography/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Courseography/courseography/git/refs{/sha}","trees_url":"https://api.github.com/repos/Courseography/courseography/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Courseography/courseography/statuses/{sha}","languages_url":"https://api.github.com/repos/Courseography/courseography/languages","stargazers_url":"https://api.github.com/repos/Courseography/courseography/stargazers","contributors_url":"https://api.github.com/repos/Courseography/courseography/contributors","subscribers_url":"https://api.github.com/repos/Courseography/courseography/subscribers","subscription_url":"https://api.github.com/repos/Courseography/courseography/subscription","commits_url":"https://api.github.com/repos/Courseography/courseography/commits{/sha}","git_commits_url":"https://api.github.com/repos/Courseography/courseography/git/commits{/sha}","comments_url":"https://api.github.com/repos/Courseography/courseography/comments{/number}","issue_comment_url":"https://api.github.com/repos/Courseography/courseography/issues/comments/{number}","contents_url":"https://api.github.com/repos/Courseography/courseography/contents/{+path}","compare_url":"https://api.github.com/repos/Courseography/courseography/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Courseography/courseography/merges","archive_url":"https://api.github.com/repos/Courseography/courseography/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Courseography/courseography/downloads","issues_url":"https://api.github.com/repos/Courseography/courseography/issues{/number}","pulls_url":"https://api.github.com/repos/Courseography/courseography/pulls{/number}","milestones_url":"https://api.github.com/repos/Courseography/courseography/milestones{/number}","notifications_url":"https://api.github.com/repos/Courseography/courseography/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Courseography/courseography/labels{/name}","releases_url":"https://api.github.com/repos/Courseography/courseography/releases{/id}","created_at":"2014-02-15T22:32:22Z","updated_at":"2015-02-17T05:01:34Z","pushed_at":"2015-02-18T20:20:36Z","git_url":"git://github.com/Courseography/courseography.git","ssh_url":"git@github.com:Courseography/courseography.git","clone_url":"https://github.com/Courseography/courseography.git","svn_url":"https://github.com/Courseography/courseography","homepage":"","size":8499,"stargazers_count":7,"watchers_count":7,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"open_issues_count":45,"forks":13,"open_issues":45,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Courseography/courseography/pulls/343"},"html":{"href":"https://github.com/Courseography/courseography/pull/343"},"issue":{"href":"https://api.github.com/repos/Courseography/courseography/issues/343"},"comments":{"href":"https://api.github.com/repos/Courseography/courseography/issues/343/comments"},"review_comments":{"href":"https://api.github.com/repos/Courseography/courseography/pulls/343/comments"},"review_comment":{"href":"https://api.github.com/repos/Courseography/courseography/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/Courseography/courseography/pulls/343/commits"},"statuses":{"href":"https://api.github.com/repos/Courseography/courseography/statuses/4e7bcc44da5d11910ea38432524b2a29de0508af"}}}}