diff --git a/README.md b/README.md index 4e132de..86a0840 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,12 @@ By default, Octotree only works on `github.com`. To support GitHub Enterprise on ## Changelog +### v1.7.0 +* Support direct downloading when hovering a file + +### v1.6.4 +* Fix bug detecting branch/tag due to GitHub DOM change + ### v1.6.3 * Fix bug when switching to branches with slashes in their names @@ -60,36 +66,36 @@ By default, Octotree only works on `github.com`. To support GitHub Enterprise on ### v1.6.1 * Update buttons' style to match GitHub new button style -### [v1.6](https://github.com/buunguyen/octotree/issues?q=milestone%3A1.6+is%3Aclosed) +### v1.6 * Update all dependencies to latest version * Allow navigating to commit trees https://github.com/buunguyen/octotree/issues/157 * Support keyboard navigation https://github.com/buunguyen/octotree/issues/158 * Fix bug handling back tick in paths https://github.com/buunguyen/octotree/issues/160 -### [v1.5.3](https://github.com/buunguyen/octotree/issues?q=milestone%3A1.5.3+is%3Aclosed) +### v1.5.3 * Fix bug https://github.com/buunguyen/octotree/pull/149 * Fix bug https://github.com/buunguyen/octotree/issues/151 * Fix bug https://github.com/buunguyen/octotree/issues/155 -### [v1.5.2](https://github.com/buunguyen/octotree/issues?q=milestone%3A1.5.2+is%3Aclosed) +### v1.5.2 * Fix bug https://github.com/buunguyen/octotree/issues/147 -### [v1.5](https://github.com/buunguyen/octotree/issues?q=milestone%3A1.5+is%3Aclosed) +### v1.5 * Option to show in non-code pages * Option to load tree only when sidebar is visible * Option to configure tab size * Bug fixes -### [v1.4.1](https://github.com/buunguyen/octotree/issues?q=milestone%3A1.4.1+is%3Aclosed) +### v1.4.1 * New header to match new GitHub design * Bug fixes -### [v1.4](https://github.com/buunguyen/octotree/issues?labels=&milestone=4&page=1&state=closed) +### v1.4 * Support GitHub enterprise * Change default hotkey (`cmd+b` for Safari and `cmd+shift+s` for all other browsers) * Some other minor changes -### [v1.3](https://github.com/buunguyen/octotree/issues?labels=&milestone=3&page=1&state=closed) +### v1.3 * Setting panel allowing: * Changing access token * Changing hotkeys @@ -99,7 +105,7 @@ By default, Octotree only works on `github.com`. To support GitHub Enterprise on * More responsive in big repositories * And bug fixes -### [v1.2](https://github.com/buunguyen/octotree/issues?labels=&milestone=1&page=1&state=closed) +### v1.2 * Hide sidebar by default (upon many user requests) * Hotkey (`cmd+b`, `ctrl+b`) to toggle sidebar * Sidebar is now resizable @@ -108,7 +114,7 @@ By default, Octotree only works on `github.com`. To support GitHub Enterprise on * New sidebar header and progress indicator * And bug fixes -### [v1.1](https://github.com/buunguyen/octotree/issues?labels=&milestone=2&page=1&state=closed) +### v1.1 * New UI that blends better with GitHub! * Hide Octotree on non-code pages * When asking for token, show more detailed message and not fly out automatically diff --git a/dist/chrome.crx b/dist/chrome.crx index 8338b98..6963c60 100644 Binary files a/dist/chrome.crx and b/dist/chrome.crx differ diff --git a/dist/chrome.zip b/dist/chrome.zip index c9ec93b..9e26946 100755 Binary files a/dist/chrome.zip and b/dist/chrome.zip differ diff --git a/dist/firefox.xpi b/dist/firefox.xpi index a93a8ef..4dd14c0 100644 Binary files a/dist/firefox.xpi and b/dist/firefox.xpi differ diff --git a/dist/opera.nex b/dist/opera.nex index 8338b98..6963c60 100644 Binary files a/dist/opera.nex and b/dist/opera.nex differ diff --git a/package.json b/package.json index 122f3e5..3a58c37 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "octotree", - "version": "1.6.4", + "version": "1.7.0", "description": "Display GitHub code in tree format", "main": "inject.js", "scripts": { diff --git a/src/adapter.github.js b/src/adapter.github.js index 11caa2d..d5cbb22 100644 --- a/src/adapter.github.js +++ b/src/adapter.github.js @@ -42,10 +42,20 @@ GitHub.prototype.selectSubmodule = function(path) { window.location.href = path } +/** + * Downloads the file at the given + */ +GitHub.prototype.downloadFile = function(path, fileName) { + var link = document.createElement('a') + link.setAttribute('href', path.replace(/\/blob\//, '/raw/')) + link.setAttribute('download', fileName) + link.click() +} + /** * Selects a path. */ -GitHub.prototype.selectPath = function(path, tabSize) { +GitHub.prototype.selectFile = function(path, tabSize) { var container = $(GH_PJAX_SEL) , qs = tabSize ? ('?ts=' + tabSize) : '' diff --git a/src/chrome/manifest.json b/src/chrome/manifest.json index 8d6cbc7..276d497 100755 --- a/src/chrome/manifest.json +++ b/src/chrome/manifest.json @@ -1,6 +1,6 @@ { "name": "Octotree", - "version": "1.6.4", + "version": "1.7.0", "manifest_version": 2, "author": "Buu Nguyen", "description": "Display GitHub code in tree format", diff --git a/src/firefox/package.json b/src/firefox/package.json index ecb5b1d..a0fed9b 100644 --- a/src/firefox/package.json +++ b/src/firefox/package.json @@ -11,7 +11,7 @@ "icon": "data/icons/icon48.png", "icon64": "data/icons/icon64.png", "license": "MIT", - "version": "1.6.4", + "version": "1.7.0", "permissions": { "cross-domain-content": ["https://api.github.com", "https://github.com"] } diff --git a/src/octotree.less b/src/octotree.less index 1d19809..5a919a2 100755 --- a/src/octotree.less +++ b/src/octotree.less @@ -108,6 +108,11 @@ content: '\f011'; color: #777; } + .jstree-node.jstree-leaf:hover { + .jstree-icon.blob:before { + content: '\f00b'; + } + } .jstree-icon.commit:before { content: '\f017'; color: #777; @@ -117,7 +122,7 @@ text-decoration: none; outline: none; & > span { - color: black; + color: black; } } .jstree-anchor:hover { @@ -125,21 +130,21 @@ } .jstree-default { .jstree-wholerow { - height: auto; + height: auto; } .jstree-wholerow-hovered { - background: #eee; + background: #eee; } .jstree-wholerow-clicked { - background: #dbeeff; + background: #dbeeff; } .jstree-node { - line-height: 24px; - margin-left: 12px; + line-height: 24px; + margin-left: 12px; } .jstree-icon.jstree-ocl { - margin-right: -6px; - margin-top: -1px; + margin-right: -6px; + margin-top: -1px; } } diff --git a/src/safari/Info.plist b/src/safari/Info.plist index ab0e1dc..3bcf93c 100755 --- a/src/safari/Info.plist +++ b/src/safari/Info.plist @@ -13,9 +13,9 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleShortVersionString - 1.6.4 + 1.7.0 CFBundleVersion - 1.6.4 + 1.7.0 Chrome Content diff --git a/src/view.tree.js b/src/view.tree.js index 61c05d9..1782952 100644 --- a/src/view.tree.js +++ b/src/view.tree.js @@ -12,9 +12,14 @@ function TreeView($dom, store, adapter) { }) .on('click', function(event) { var $target = $(event.target) + var self = this + var download = false // handle icon click, fix #122 - if ($target.is('i.jstree-icon')) $target = $target.parent() + if ($target.is('i.jstree-icon')) { + $target = $target.parent() + download = true + } if (!$target.is('a.jstree-anchor')) return @@ -23,13 +28,26 @@ function TreeView($dom, store, adapter) { ? $target.children(':first') : $target.siblings(':first') // handles child links in submodule - // refocus after complete so that keyboard navigation works, fix #158 - $(document).one('pjax:success', function () { - $.jstree.reference(this).get_container().focus() - }.bind(this)) + if ($icon.hasClass('commit')) { + refocusAfterCompletion() + adapter.selectSubmodule(href) + } + else if ($icon.hasClass('blob')) { + if (download) { + adapter.downloadFile(href, $target.text()) + } + else { + refocusAfterCompletion() + adapter.selectFile(href, store.get(STORE.TABSIZE)) + } + } - if ($icon.hasClass('commit')) adapter.selectSubmodule(href) - else if ($icon.hasClass('blob')) adapter.selectPath(href, store.get(STORE.TABSIZE)) + // refocus after complete so that keyboard navigation works, fix #158 + function refocusAfterCompletion() { + $(document).one('pjax:success', function () { + $.jstree.reference(self).get_container().focus() + }) + } }) .jstree({ core : { multiple: false, themes : { responsive : false } }, @@ -52,7 +70,7 @@ TreeView.prototype.showHeader = function(repo) { ) .on('click', 'a[data-pjax]', function(event) { event.preventDefault() - adapter.selectPath($(this).attr('href') /* a.href always return absolute URL, don't want that */) + adapter.selectFile($(this).attr('href') /* a.href always return absolute URL, don't want that */) }) }