{"action":"created","comment":{"url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/pulls/comments/189186768","pull_request_review_id":121308812,"id":189186768,"diff_hunk":"@@ -0,0 +1,248 @@\n+/*\\\n+title: $:/plugins/tiddlywiki/webdav/webdavadaptor.js\n+type: application/javascript\n+module-type: syncadaptor\n+\n+A sync adaptor module for synchronising with WebDAV compatible servers\n+Heavily based on WebDAV Adaptor\n+\n+Revised by Sebastian Silva <sebastian@fuentelibre.org>\n+\n+\\*/\n+(function(){\n+\n+/*jslint node: true, browser: true */\n+/*global $tw: false */\n+\"use strict\";\n+\n+var CONFIG_HOST_TIDDLER = \"$:/config/webdav/host\",\n+\tDEFAULT_HOST_TIDDLER = \"$protocol$//$host$/\";\n+\n+function dirname(path) {\n+\treturn path.replace(/\\\\/g,'/').replace(/\\/[^\\/]*$/, '');\n+}\n+\n+function WebDAVAdaptor(options) {\n+\tthis.wiki = options.wiki;\n+\tthis.host = this.getHost();\n+\tthis.tiddlersBaseURL = dirname(location.pathname) + \"/tiddlers\";\n+\tthis.hasStatus = false;\n+\tthis.logger = new $tw.utils.Logger(\"WebDAVAdaptor\");\n+}\n+\n+WebDAVAdaptor.prototype.name = \"webdav\";\n+WebDAVAdaptor.prototype.knownDirs = [];\n+\n+WebDAVAdaptor.prototype.isReady = function() {\n+\treturn this.hasStatus;\n+};\n+\n+WebDAVAdaptor.prototype.getHost = function() {\n+\tvar text = this.wiki.getTiddlerText(CONFIG_HOST_TIDDLER,DEFAULT_HOST_TIDDLER),\n+\t\tsubstitutions = [\n+\t\t\t{name: \"protocol\", value: document.location.protocol},\n+\t\t\t{name: \"host\", value: document.location.host}\n+\t\t];\n+\tfor(var t=0; t<substitutions.length; t++) {\n+\t\tvar s = substitutions[t];\n+\t\ttext = $tw.utils.replaceString(text,new RegExp(\"\\\\$\" + s.name + \"\\\\$\",\"mg\"),s.value);\n+\t}\n+\treturn text;\n+};\n+\n+/*\n+Make a directory recursively\n+*/\n+WebDAVAdaptor.prototype.mkdir_p = function (path, callback) {\n+\tvar parent = dirname(path);\n+\tvar self = this;\n+\tif (this!==undefined) {\n+\t\tif (!(this.knownDirs.includes(parent))) {\n+\t\t\tif (parent!==path) {\n+\t\t\t\tthis.mkdir_p(parent, callback);\n+\t\t\t}\n+\t\t}\n+\t\t$tw.utils.httpRequest({\n+\t\t\ttype: \"MKCOL\",\n+\t\t\turl: this.tiddlersBaseURL + \"/\" + path,\n+\t\t\treturnProp: \"responseXML\",\n+\t\t\theaders: {accept: \"text/xml; charset=UTF-8\"},\n+\t\t\tcallback: function(err, doc, request) {\n+\t\t\t\t// Check for errors\n+\t\t\t\tif(err) {\n+\t\t\t\t\treturn callback(err);\n+\t\t\t\t}\n+\t\t\t\tself.knownDirs.push ( path );\n+\t\t\t}\n+\t\t});\n+\n+\t};\n+}\n+WebDAVAdaptor.prototype.getTiddlerInfo = function(tiddler) {\n+\treturn { };\n+};\n+\n+/*\n+Get the current status of the WebDAV connection\n+*/\n+WebDAVAdaptor.prototype.getStatus = function(callback) {\n+\t// Get status\n+\tvar self = this;\n+\tthis.logger.log(\"Status is fine\");\n+\tself.hasStatus = true;\n+\tvar isLoggedIn = false;\n+\n+\tcallback(null,isLoggedIn,\"GUEST\");\n+\t// or return callback(err);\n+};\n+\n+/*\n+Get an array of skinny tiddler fields from the server\n+*/\n+WebDAVAdaptor.prototype.getSkinnyTiddlers = function(callback) {\n+\tvar self = this;\n+\t$tw.utils.httpRequest({\n+\t\ttype: \"PROPFIND\",\n+\t\turl: this.tiddlersBaseURL + \"/\",\n+\t\treturnProp: \"responseXML\",\n+\t\theaders: {accept: \"text/xml; charset=UTF-8\"},\n+\t\tcallback: function(err, doc, request) {\n+\t\t\t// Check for errors\n+\t\t\tif(err) {\n+\t\t\t\tif (err.indexOf(\"404\")>0) {\n+\t\t\t\t\t$tw.utils.httpRequest({\n+\t\t\t\t\t\ttype: \"MKCOL\",\n+\t\t\t\t\t\turl: self.tiddlersBaseURL,\n+\t\t\t\t\t\theaders: {accept: \"text/xml; charset=UTF-8\"},\n+\t\t\t\t\t\tcallback: function(err, doc, request) {\n+\t\t\t\t\t\t\t// Check for errors\n+\t\t\t\t\t\t\tif(err) {\n+\t\t\t\t\t\t\t\treturn callback(err);\n+\t\t\t\t\t\t\t}\n+\t\t\t\t\t\t}\n+\t\t\t\t\t});\n+\t\t\t\t}\n+\t\t\t\telse {\n+\t\t\t\t\treturn callback(err);\n+\t\t\t\t}\n+\t\t\t}\n+\n+\t\t\tif (doc!==undefined) {\n+\t\t\t\tconst ns = \"DAV:\";\n+\t\t\t\tvar tiddlers = [];\n+\t\t\t\tvar items = doc.children[0].children;\n+\t\t\t\t// Start at 1, because the 0th is the same as self.\n+\t\t\t\tfor(var i=1; i< items.length; i++) {\n+\t\t\t\t\tvar response\t = items[i];\n+\t\t\t\t\tvar href\t\t = response.getElementsByTagNameNS(ns, 'href')[0].firstChild.nodeValue;","path":"plugins/tiddlywiki/webdav/webdavadaptor.js","position":137,"original_position":137,"commit_id":"2b65ec6335fa406fe0cecc6a55eadfc787785eff","original_commit_id":"2b65ec6335fa406fe0cecc6a55eadfc787785eff","user":{"login":"pmario","id":374655,"avatar_url":"https://avatars2.githubusercontent.com/u/374655?v=4","gravatar_id":"","url":"https://api.github.com/users/pmario","html_url":"https://github.com/pmario","followers_url":"https://api.github.com/users/pmario/followers","following_url":"https://api.github.com/users/pmario/following{/other_user}","gists_url":"https://api.github.com/users/pmario/gists{/gist_id}","starred_url":"https://api.github.com/users/pmario/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pmario/subscriptions","organizations_url":"https://api.github.com/users/pmario/orgs","repos_url":"https://api.github.com/users/pmario/repos","events_url":"https://api.github.com/users/pmario/events{/privacy}","received_events_url":"https://api.github.com/users/pmario/received_events","type":"User","site_admin":false},"body":"coding style: not tabs in front of `=`","created_at":"2018-05-18T07:44:05Z","updated_at":"2018-05-18T07:57:00Z","html_url":"https://github.com/Jermolene/TiddlyWiki5/pull/3292#discussion_r189186768","pull_request_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/pulls/3292","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/Jermolene/TiddlyWiki5/pulls/comments/189186768"},"html":{"href":"https://github.com/Jermolene/TiddlyWiki5/pull/3292#discussion_r189186768"},"pull_request":{"href":"https://api.github.com/repos/Jermolene/TiddlyWiki5/pulls/3292"}}},"pull_request":{"url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/pulls/3292","id":188928446,"html_url":"https://github.com/Jermolene/TiddlyWiki5/pull/3292","diff_url":"https://github.com/Jermolene/TiddlyWiki5/pull/3292.diff","patch_url":"https://github.com/Jermolene/TiddlyWiki5/pull/3292.patch","issue_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/issues/3292","number":3292,"state":"open","locked":false,"title":"Webdav adaptor","user":{"login":"icarito","id":199755,"avatar_url":"https://avatars0.githubusercontent.com/u/199755?v=4","gravatar_id":"","url":"https://api.github.com/users/icarito","html_url":"https://github.com/icarito","followers_url":"https://api.github.com/users/icarito/followers","following_url":"https://api.github.com/users/icarito/following{/other_user}","gists_url":"https://api.github.com/users/icarito/gists{/gist_id}","starred_url":"https://api.github.com/users/icarito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/icarito/subscriptions","organizations_url":"https://api.github.com/users/icarito/orgs","repos_url":"https://api.github.com/users/icarito/repos","events_url":"https://api.github.com/users/icarito/events{/privacy}","received_events_url":"https://api.github.com/users/icarito/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-05-18T05:58:22Z","updated_at":"2018-05-18T07:57:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8ab877ef60cb66965ec801431d4d4149edeced8c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/pulls/3292/commits","review_comments_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/pulls/3292/comments","review_comment_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/issues/3292/comments","statuses_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/statuses/2b65ec6335fa406fe0cecc6a55eadfc787785eff","head":{"label":"icarito:webdav-adaptor","ref":"webdav-adaptor","sha":"2b65ec6335fa406fe0cecc6a55eadfc787785eff","user":{"login":"icarito","id":199755,"avatar_url":"https://avatars0.githubusercontent.com/u/199755?v=4","gravatar_id":"","url":"https://api.github.com/users/icarito","html_url":"https://github.com/icarito","followers_url":"https://api.github.com/users/icarito/followers","following_url":"https://api.github.com/users/icarito/following{/other_user}","gists_url":"https://api.github.com/users/icarito/gists{/gist_id}","starred_url":"https://api.github.com/users/icarito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/icarito/subscriptions","organizations_url":"https://api.github.com/users/icarito/orgs","repos_url":"https://api.github.com/users/icarito/repos","events_url":"https://api.github.com/users/icarito/events{/privacy}","received_events_url":"https://api.github.com/users/icarito/received_events","type":"User","site_admin":false},"repo":{"id":131253718,"name":"TiddlyWiki5","full_name":"icarito/TiddlyWiki5","owner":{"login":"icarito","id":199755,"avatar_url":"https://avatars0.githubusercontent.com/u/199755?v=4","gravatar_id":"","url":"https://api.github.com/users/icarito","html_url":"https://github.com/icarito","followers_url":"https://api.github.com/users/icarito/followers","following_url":"https://api.github.com/users/icarito/following{/other_user}","gists_url":"https://api.github.com/users/icarito/gists{/gist_id}","starred_url":"https://api.github.com/users/icarito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/icarito/subscriptions","organizations_url":"https://api.github.com/users/icarito/orgs","repos_url":"https://api.github.com/users/icarito/repos","events_url":"https://api.github.com/users/icarito/events{/privacy}","received_events_url":"https://api.github.com/users/icarito/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/icarito/TiddlyWiki5","description":"A self-contained JavaScript wiki for the browser, Node.js, AWS Lambda etc.","fork":true,"url":"https://api.github.com/repos/icarito/TiddlyWiki5","forks_url":"https://api.github.com/repos/icarito/TiddlyWiki5/forks","keys_url":"https://api.github.com/repos/icarito/TiddlyWiki5/keys{/key_id}","collaborators_url":"https://api.github.com/repos/icarito/TiddlyWiki5/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/icarito/TiddlyWiki5/teams","hooks_url":"https://api.github.com/repos/icarito/TiddlyWiki5/hooks","issue_events_url":"https://api.github.com/repos/icarito/TiddlyWiki5/issues/events{/number}","events_url":"https://api.github.com/repos/icarito/TiddlyWiki5/events","assignees_url":"https://api.github.com/repos/icarito/TiddlyWiki5/assignees{/user}","branches_url":"https://api.github.com/repos/icarito/TiddlyWiki5/branches{/branch}","tags_url":"https://api.github.com/repos/icarito/TiddlyWiki5/tags","blobs_url":"https://api.github.com/repos/icarito/TiddlyWiki5/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/icarito/TiddlyWiki5/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/icarito/TiddlyWiki5/git/refs{/sha}","trees_url":"https://api.github.com/repos/icarito/TiddlyWiki5/git/trees{/sha}","statuses_url":"https://api.github.com/repos/icarito/TiddlyWiki5/statuses/{sha}","languages_url":"https://api.github.com/repos/icarito/TiddlyWiki5/languages","stargazers_url":"https://api.github.com/repos/icarito/TiddlyWiki5/stargazers","contributors_url":"https://api.github.com/repos/icarito/TiddlyWiki5/contributors","subscribers_url":"https://api.github.com/repos/icarito/TiddlyWiki5/subscribers","subscription_url":"https://api.github.com/repos/icarito/TiddlyWiki5/subscription","commits_url":"https://api.github.com/repos/icarito/TiddlyWiki5/commits{/sha}","git_commits_url":"https://api.github.com/repos/icarito/TiddlyWiki5/git/commits{/sha}","comments_url":"https://api.github.com/repos/icarito/TiddlyWiki5/comments{/number}","issue_comment_url":"https://api.github.com/repos/icarito/TiddlyWiki5/issues/comments{/number}","contents_url":"https://api.github.com/repos/icarito/TiddlyWiki5/contents/{+path}","compare_url":"https://api.github.com/repos/icarito/TiddlyWiki5/compare/{base}...{head}","merges_url":"https://api.github.com/repos/icarito/TiddlyWiki5/merges","archive_url":"https://api.github.com/repos/icarito/TiddlyWiki5/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/icarito/TiddlyWiki5/downloads","issues_url":"https://api.github.com/repos/icarito/TiddlyWiki5/issues{/number}","pulls_url":"https://api.github.com/repos/icarito/TiddlyWiki5/pulls{/number}","milestones_url":"https://api.github.com/repos/icarito/TiddlyWiki5/milestones{/number}","notifications_url":"https://api.github.com/repos/icarito/TiddlyWiki5/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/icarito/TiddlyWiki5/labels{/name}","releases_url":"https://api.github.com/repos/icarito/TiddlyWiki5/releases{/id}","deployments_url":"https://api.github.com/repos/icarito/TiddlyWiki5/deployments","created_at":"2018-04-27T06:15:24Z","updated_at":"2018-05-12T06:47:26Z","pushed_at":"2018-05-18T06:32:56Z","git_url":"git://github.com/icarito/TiddlyWiki5.git","ssh_url":"git@github.com:icarito/TiddlyWiki5.git","clone_url":"https://github.com/icarito/TiddlyWiki5.git","svn_url":"https://github.com/icarito/TiddlyWiki5","homepage":"https://tiddlywiki.com/","size":33705,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Jermolene:master","ref":"master","sha":"f0b7c9a3d59cde969364f679bc198b33460e9dea","user":{"login":"Jermolene","id":174761,"avatar_url":"https://avatars1.githubusercontent.com/u/174761?v=4","gravatar_id":"","url":"https://api.github.com/users/Jermolene","html_url":"https://github.com/Jermolene","followers_url":"https://api.github.com/users/Jermolene/followers","following_url":"https://api.github.com/users/Jermolene/following{/other_user}","gists_url":"https://api.github.com/users/Jermolene/gists{/gist_id}","starred_url":"https://api.github.com/users/Jermolene/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jermolene/subscriptions","organizations_url":"https://api.github.com/users/Jermolene/orgs","repos_url":"https://api.github.com/users/Jermolene/repos","events_url":"https://api.github.com/users/Jermolene/events{/privacy}","received_events_url":"https://api.github.com/users/Jermolene/received_events","type":"User","site_admin":false},"repo":{"id":2828239,"name":"TiddlyWiki5","full_name":"Jermolene/TiddlyWiki5","owner":{"login":"Jermolene","id":174761,"avatar_url":"https://avatars1.githubusercontent.com/u/174761?v=4","gravatar_id":"","url":"https://api.github.com/users/Jermolene","html_url":"https://github.com/Jermolene","followers_url":"https://api.github.com/users/Jermolene/followers","following_url":"https://api.github.com/users/Jermolene/following{/other_user}","gists_url":"https://api.github.com/users/Jermolene/gists{/gist_id}","starred_url":"https://api.github.com/users/Jermolene/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jermolene/subscriptions","organizations_url":"https://api.github.com/users/Jermolene/orgs","repos_url":"https://api.github.com/users/Jermolene/repos","events_url":"https://api.github.com/users/Jermolene/events{/privacy}","received_events_url":"https://api.github.com/users/Jermolene/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Jermolene/TiddlyWiki5","description":"A self-contained JavaScript wiki for the browser, Node.js, AWS Lambda etc.","fork":false,"url":"https://api.github.com/repos/Jermolene/TiddlyWiki5","forks_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/forks","keys_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/teams","hooks_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/hooks","issue_events_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/issues/events{/number}","events_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/events","assignees_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/assignees{/user}","branches_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/branches{/branch}","tags_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/tags","blobs_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/git/refs{/sha}","trees_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/statuses/{sha}","languages_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/languages","stargazers_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/stargazers","contributors_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/contributors","subscribers_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/subscribers","subscription_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/subscription","commits_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/commits{/sha}","git_commits_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/git/commits{/sha}","comments_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/comments{/number}","issue_comment_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/issues/comments{/number}","contents_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/contents/{+path}","compare_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/merges","archive_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/downloads","issues_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/issues{/number}","pulls_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/pulls{/number}","milestones_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/milestones{/number}","notifications_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/labels{/name}","releases_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/releases{/id}","deployments_url":"https://api.github.com/repos/Jermolene/TiddlyWiki5/deployments","created_at":"2011-11-22T14:26:07Z","updated_at":"2018-05-17T17:30:47Z","pushed_at":"2018-05-18T06:32:58Z","git_url":"git://github.com/Jermolene/TiddlyWiki5.git","ssh_url":"git@github.com:Jermolene/TiddlyWiki5.git","clone_url":"https://github.com/Jermolene/TiddlyWiki5.git","svn_url":"https://github.com/Jermolene/TiddlyWiki5","homepage":"https://tiddlywiki.com/","size":33684,"stargazers_count":3184,"watchers_count":3184,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":637,"mirror_url":null,"archived":false,"open_issues_count":754,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":637,"open_issues":754,"watchers":3184,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Jermolene/TiddlyWiki5/pulls/3292"},"html":{"href":"https://github.com/Jermolene/TiddlyWiki5/pull/3292"},"issue":{"href":"https://api.github.com/repos/Jermolene/TiddlyWiki5/issues/3292"},"comments":{"href":"https://api.github.com/repos/Jermolene/TiddlyWiki5/issues/3292/comments"},"review_comments":{"href":"https://api.github.com/repos/Jermolene/TiddlyWiki5/pulls/3292/comments"},"review_comment":{"href":"https://api.github.com/repos/Jermolene/TiddlyWiki5/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Jermolene/TiddlyWiki5/pulls/3292/commits"},"statuses":{"href":"https://api.github.com/repos/Jermolene/TiddlyWiki5/statuses/2b65ec6335fa406fe0cecc6a55eadfc787785eff"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"pmario"}}