Support direct file downloading
This commit is contained in:
parent
5a2d03cce3
commit
ac77ac9c5d
24
README.md
24
README.md
|
@ -51,6 +51,12 @@ By default, Octotree only works on `github.com`. To support GitHub Enterprise on
|
||||||
|
|
||||||
## Changelog
|
## 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
|
### v1.6.3
|
||||||
* Fix bug when switching to branches with slashes in their names
|
* 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
|
### v1.6.1
|
||||||
* Update buttons' style to match GitHub new button style
|
* 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
|
* Update all dependencies to latest version
|
||||||
* Allow navigating to commit trees https://github.com/buunguyen/octotree/issues/157
|
* Allow navigating to commit trees https://github.com/buunguyen/octotree/issues/157
|
||||||
* Support keyboard navigation https://github.com/buunguyen/octotree/issues/158
|
* Support keyboard navigation https://github.com/buunguyen/octotree/issues/158
|
||||||
* Fix bug handling back tick in paths https://github.com/buunguyen/octotree/issues/160
|
* 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/pull/149
|
||||||
* Fix bug https://github.com/buunguyen/octotree/issues/151
|
* Fix bug https://github.com/buunguyen/octotree/issues/151
|
||||||
* Fix bug https://github.com/buunguyen/octotree/issues/155
|
* 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
|
* 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 show in non-code pages
|
||||||
* Option to load tree only when sidebar is visible
|
* Option to load tree only when sidebar is visible
|
||||||
* Option to configure tab size
|
* Option to configure tab size
|
||||||
* Bug fixes
|
* 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
|
* New header to match new GitHub design
|
||||||
* Bug fixes
|
* Bug fixes
|
||||||
|
|
||||||
### [v1.4](https://github.com/buunguyen/octotree/issues?labels=&milestone=4&page=1&state=closed)
|
### v1.4
|
||||||
* Support GitHub enterprise
|
* Support GitHub enterprise
|
||||||
* Change default hotkey (`cmd+b` for Safari and `cmd+shift+s` for all other browsers)
|
* Change default hotkey (`cmd+b` for Safari and `cmd+shift+s` for all other browsers)
|
||||||
* Some other minor changes
|
* Some other minor changes
|
||||||
|
|
||||||
### [v1.3](https://github.com/buunguyen/octotree/issues?labels=&milestone=3&page=1&state=closed)
|
### v1.3
|
||||||
* Setting panel allowing:
|
* Setting panel allowing:
|
||||||
* Changing access token
|
* Changing access token
|
||||||
* Changing hotkeys
|
* Changing hotkeys
|
||||||
|
@ -99,7 +105,7 @@ By default, Octotree only works on `github.com`. To support GitHub Enterprise on
|
||||||
* More responsive in big repositories
|
* More responsive in big repositories
|
||||||
* And bug fixes
|
* 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)
|
* Hide sidebar by default (upon many user requests)
|
||||||
* Hotkey (`cmd+b`, `ctrl+b`) to toggle sidebar
|
* Hotkey (`cmd+b`, `ctrl+b`) to toggle sidebar
|
||||||
* Sidebar is now resizable
|
* 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
|
* New sidebar header and progress indicator
|
||||||
* And bug fixes
|
* 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!
|
* New UI that blends better with GitHub!
|
||||||
* Hide Octotree on non-code pages
|
* Hide Octotree on non-code pages
|
||||||
* When asking for token, show more detailed message and not fly out automatically
|
* When asking for token, show more detailed message and not fly out automatically
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "octotree",
|
"name": "octotree",
|
||||||
"version": "1.6.4",
|
"version": "1.7.0",
|
||||||
"description": "Display GitHub code in tree format",
|
"description": "Display GitHub code in tree format",
|
||||||
"main": "inject.js",
|
"main": "inject.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -42,10 +42,20 @@ GitHub.prototype.selectSubmodule = function(path) {
|
||||||
window.location.href = 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.
|
* Selects a path.
|
||||||
*/
|
*/
|
||||||
GitHub.prototype.selectPath = function(path, tabSize) {
|
GitHub.prototype.selectFile = function(path, tabSize) {
|
||||||
var container = $(GH_PJAX_SEL)
|
var container = $(GH_PJAX_SEL)
|
||||||
, qs = tabSize ? ('?ts=' + tabSize) : ''
|
, qs = tabSize ? ('?ts=' + tabSize) : ''
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "Octotree",
|
"name": "Octotree",
|
||||||
"version": "1.6.4",
|
"version": "1.7.0",
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"author": "Buu Nguyen",
|
"author": "Buu Nguyen",
|
||||||
"description": "Display GitHub code in tree format",
|
"description": "Display GitHub code in tree format",
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
"icon": "data/icons/icon48.png",
|
"icon": "data/icons/icon48.png",
|
||||||
"icon64": "data/icons/icon64.png",
|
"icon64": "data/icons/icon64.png",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "1.6.4",
|
"version": "1.7.0",
|
||||||
"permissions": {
|
"permissions": {
|
||||||
"cross-domain-content": ["https://api.github.com", "https://github.com"]
|
"cross-domain-content": ["https://api.github.com", "https://github.com"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,6 +108,11 @@
|
||||||
content: '\f011';
|
content: '\f011';
|
||||||
color: #777;
|
color: #777;
|
||||||
}
|
}
|
||||||
|
.jstree-node.jstree-leaf:hover {
|
||||||
|
.jstree-icon.blob:before {
|
||||||
|
content: '\f00b';
|
||||||
|
}
|
||||||
|
}
|
||||||
.jstree-icon.commit:before {
|
.jstree-icon.commit:before {
|
||||||
content: '\f017';
|
content: '\f017';
|
||||||
color: #777;
|
color: #777;
|
||||||
|
@ -117,7 +122,7 @@
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
& > span {
|
& > span {
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.jstree-anchor:hover {
|
.jstree-anchor:hover {
|
||||||
|
@ -125,21 +130,21 @@
|
||||||
}
|
}
|
||||||
.jstree-default {
|
.jstree-default {
|
||||||
.jstree-wholerow {
|
.jstree-wholerow {
|
||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
.jstree-wholerow-hovered {
|
.jstree-wholerow-hovered {
|
||||||
background: #eee;
|
background: #eee;
|
||||||
}
|
}
|
||||||
.jstree-wholerow-clicked {
|
.jstree-wholerow-clicked {
|
||||||
background: #dbeeff;
|
background: #dbeeff;
|
||||||
}
|
}
|
||||||
.jstree-node {
|
.jstree-node {
|
||||||
line-height: 24px;
|
line-height: 24px;
|
||||||
margin-left: 12px;
|
margin-left: 12px;
|
||||||
}
|
}
|
||||||
.jstree-icon.jstree-ocl {
|
.jstree-icon.jstree-ocl {
|
||||||
margin-right: -6px;
|
margin-right: -6px;
|
||||||
margin-top: -1px;
|
margin-top: -1px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
<key>CFBundleInfoDictionaryVersion</key>
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
<string>6.0</string>
|
<string>6.0</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.6.4</string>
|
<string>1.7.0</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1.6.4</string>
|
<string>1.7.0</string>
|
||||||
<key>Chrome</key>
|
<key>Chrome</key>
|
||||||
<dict/>
|
<dict/>
|
||||||
<key>Content</key>
|
<key>Content</key>
|
||||||
|
|
|
@ -12,9 +12,14 @@ function TreeView($dom, store, adapter) {
|
||||||
})
|
})
|
||||||
.on('click', function(event) {
|
.on('click', function(event) {
|
||||||
var $target = $(event.target)
|
var $target = $(event.target)
|
||||||
|
var self = this
|
||||||
|
var download = false
|
||||||
|
|
||||||
// handle icon click, fix #122
|
// 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
|
if (!$target.is('a.jstree-anchor')) return
|
||||||
|
|
||||||
|
@ -23,13 +28,26 @@ function TreeView($dom, store, adapter) {
|
||||||
? $target.children(':first')
|
? $target.children(':first')
|
||||||
: $target.siblings(':first') // handles child links in submodule
|
: $target.siblings(':first') // handles child links in submodule
|
||||||
|
|
||||||
// refocus after complete so that keyboard navigation works, fix #158
|
if ($icon.hasClass('commit')) {
|
||||||
$(document).one('pjax:success', function () {
|
refocusAfterCompletion()
|
||||||
$.jstree.reference(this).get_container().focus()
|
adapter.selectSubmodule(href)
|
||||||
}.bind(this))
|
}
|
||||||
|
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)
|
// refocus after complete so that keyboard navigation works, fix #158
|
||||||
else if ($icon.hasClass('blob')) adapter.selectPath(href, store.get(STORE.TABSIZE))
|
function refocusAfterCompletion() {
|
||||||
|
$(document).one('pjax:success', function () {
|
||||||
|
$.jstree.reference(self).get_container().focus()
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.jstree({
|
.jstree({
|
||||||
core : { multiple: false, themes : { responsive : false } },
|
core : { multiple: false, themes : { responsive : false } },
|
||||||
|
@ -52,7 +70,7 @@ TreeView.prototype.showHeader = function(repo) {
|
||||||
)
|
)
|
||||||
.on('click', 'a[data-pjax]', function(event) {
|
.on('click', 'a[data-pjax]', function(event) {
|
||||||
event.preventDefault()
|
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 */)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue