Load pjax and turbolinks on demand
This commit is contained in:
parent
28916ba301
commit
ffaf1ff2ed
|
@ -1,4 +1,5 @@
|
||||||
const gulp = require('gulp')
|
const gulp = require('gulp')
|
||||||
|
const fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const merge = require('event-stream').merge
|
const merge = require('event-stream').merge
|
||||||
const map = require('map-stream')
|
const map = require('map-stream')
|
||||||
|
@ -41,19 +42,32 @@ gulp.task('styles', () => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
gulp.task('lib:ondemand', (cb) => {
|
||||||
|
const dir = './libs/ondemand'
|
||||||
|
const code = fs.readdirSync(dir).map(file => {
|
||||||
|
return `window['${file}'] = function () {
|
||||||
|
${fs.readFileSync(path.join(dir, file))}
|
||||||
|
};\n`
|
||||||
|
}).join('')
|
||||||
|
|
||||||
|
fs.writeFileSync('./tmp/ondemand.js', code)
|
||||||
|
|
||||||
|
cb()
|
||||||
|
})
|
||||||
|
|
||||||
// Chrome
|
// Chrome
|
||||||
gulp.task('chrome:template', () => {
|
gulp.task('chrome:template', () => {
|
||||||
return buildTemplate({CHROME: true})
|
return buildTemplate({CHROME: true})
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('chrome:js', ['chrome:template'], () => {
|
gulp.task('chrome:js', ['chrome:template', 'lib:ondemand'], () => {
|
||||||
return buildJs(['./src/config/chrome/overrides.js'], {CHROME: true})
|
return buildJs(['./src/config/chrome/overrides.js'], {CHROME: true})
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('chrome', ['chrome:js'], () => {
|
gulp.task('chrome', ['chrome:js'], () => {
|
||||||
return merge(
|
return merge(
|
||||||
pipe('./icons/**/*', './tmp/chrome/icons'),
|
pipe('./icons/**/*', './tmp/chrome/icons'),
|
||||||
pipe(['./libs/**/*', './tmp/octotree.*', './src/config/chrome/manifest.json'], './tmp/chrome/'),
|
pipe(['./libs/**/*', '!./libs/ondemand{,/**}', './tmp/octotree.*', './tmp/ondemand.js', './src/config/chrome/manifest.json'], './tmp/chrome/'),
|
||||||
pipe('./src/config/chrome/background.js', $.babel(), './tmp/chrome/')
|
pipe('./src/config/chrome/background.js', $.babel(), './tmp/chrome/')
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@ -87,14 +101,14 @@ gulp.task('firefox:template', () => {
|
||||||
return buildTemplate({FIREFOX: true})
|
return buildTemplate({FIREFOX: true})
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('firefox:js', ['firefox:template'], () => {
|
gulp.task('firefox:js', ['firefox:template', 'lib:ondemand'], () => {
|
||||||
return buildJs([], {FIREFOX: true})
|
return buildJs([], {FIREFOX: true})
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('firefox', ['firefox:js'], () => {
|
gulp.task('firefox', ['firefox:js'], () => {
|
||||||
return merge(
|
return merge(
|
||||||
pipe('./icons/**/*', './tmp/firefox/data/icons'),
|
pipe('./icons/**/*', './tmp/firefox/data/icons'),
|
||||||
pipe(['./libs/**/*', './tmp/octotree.*'], './tmp/firefox/data'),
|
pipe(['./libs/**/*', '!./libs/ondemand{,/**}', './tmp/octotree.*', './tmp/ondemand.js'], './tmp/firefox/data'),
|
||||||
pipe('./src/config/firefox/firefox.js', $.babel(), './tmp/firefox/lib'),
|
pipe('./src/config/firefox/firefox.js', $.babel(), './tmp/firefox/lib'),
|
||||||
pipe('./src/config/firefox/package.json', './tmp/firefox')
|
pipe('./src/config/firefox/package.json', './tmp/firefox')
|
||||||
)
|
)
|
||||||
|
@ -109,7 +123,7 @@ gulp.task('safari:template', () => {
|
||||||
return buildTemplate({SAFARI: true})
|
return buildTemplate({SAFARI: true})
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('safari:js', ['safari:template'], () => {
|
gulp.task('safari:js', ['safari:template', 'lib:ondemand'], () => {
|
||||||
return buildJs([], {SAFARI: true})
|
return buildJs([], {SAFARI: true})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -117,7 +131,7 @@ gulp.task('safari', ['safari:js'], () => {
|
||||||
return merge(
|
return merge(
|
||||||
pipe('./icons/**/*', './tmp/safari/octotree.safariextension/icons'),
|
pipe('./icons/**/*', './tmp/safari/octotree.safariextension/icons'),
|
||||||
pipe(
|
pipe(
|
||||||
['./libs/**/*', './tmp/octotree.*', './src/config/safari/**/*'],
|
['./libs/**/*', '!./libs/ondemand{,/**}', './tmp/octotree.*', './tmp/ondemand.js', './src/config/safari/**/*'],
|
||||||
'./tmp/safari/octotree.safariextension/'
|
'./tmp/safari/octotree.safariextension/'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
class Adapter {
|
class Adapter {
|
||||||
constructor() {
|
constructor(deps) {
|
||||||
|
deps.forEach(dep => window[dep]())
|
||||||
this._defaultBranch = {}
|
this._defaultBranch = {}
|
||||||
this._observe()
|
this._observe()
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,8 @@ const GH_CONTAINERS = '.container'
|
||||||
class GitHub extends Adapter {
|
class GitHub extends Adapter {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super()
|
super(['jquery.pjax.js'])
|
||||||
|
|
||||||
$(document)
|
$(document)
|
||||||
.ready(() => this._detectLocationChange())
|
.ready(() => this._detectLocationChange())
|
||||||
.on('pjax:send', () => $(document).trigger(EVENT.REQ_START))
|
.on('pjax:send', () => $(document).trigger(EVENT.REQ_START))
|
||||||
|
|
|
@ -11,7 +11,7 @@ const GL_PROJECT_ID = '#project_id'
|
||||||
class GitLab extends Adapter {
|
class GitLab extends Adapter {
|
||||||
|
|
||||||
constructor(store) {
|
constructor(store) {
|
||||||
super()
|
super(['turbolinks.js'])
|
||||||
|
|
||||||
// GitLab (for now) embeds access token in the page of a logged-in user.
|
// GitLab (for now) embeds access token in the page of a logged-in user.
|
||||||
// Use it to set the token if one isn't available.
|
// Use it to set the token if one isn't available.
|
||||||
|
|
|
@ -17,10 +17,9 @@ chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
|
||||||
const jsFiles = [
|
const jsFiles = [
|
||||||
'jquery.js',
|
'jquery.js',
|
||||||
'jquery-ui.js',
|
'jquery-ui.js',
|
||||||
'jquery.pjax.js',
|
|
||||||
'turbolinks.js',
|
|
||||||
'jstree.js',
|
'jstree.js',
|
||||||
'keymaster.js',
|
'keymaster.js',
|
||||||
|
'ondemand.js',
|
||||||
'octotree.js'
|
'octotree.js'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,9 @@ pageMod.PageMod({
|
||||||
include: ['https://github.com/*', 'https://gitlab.com/*'],
|
include: ['https://github.com/*', 'https://gitlab.com/*'],
|
||||||
contentScriptFile : [data.url('jquery.js'),
|
contentScriptFile : [data.url('jquery.js'),
|
||||||
data.url('jquery-ui.js'),
|
data.url('jquery-ui.js'),
|
||||||
data.url('jquery.pjax.js'),
|
|
||||||
data.url('jstree.js'),
|
data.url('jstree.js'),
|
||||||
data.url('keymaster.js'),
|
data.url('keymaster.js'),
|
||||||
|
data.url('ondemand.js'),
|
||||||
data.url('octotree.js')
|
data.url('octotree.js')
|
||||||
],
|
],
|
||||||
contentStyleFile : [data.url('jstree.css'),
|
contentStyleFile : [data.url('jstree.css'),
|
||||||
|
|
|
@ -1,68 +1,68 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
|
||||||
<key>Author</key>
|
|
||||||
<string>Buu Nguyen</string>
|
|
||||||
<key>Builder Version</key>
|
|
||||||
<string>9537.75.14</string>
|
|
||||||
<key>CFBundleDisplayName</key>
|
|
||||||
<string>octotree</string>
|
|
||||||
<key>CFBundleIdentifier</key>
|
|
||||||
<string>com.buunguyen.octotree</string>
|
|
||||||
<key>CFBundleInfoDictionaryVersion</key>
|
|
||||||
<string>6.0</string>
|
|
||||||
<key>CFBundleShortVersionString</key>
|
|
||||||
<string>2.0.0</string>
|
|
||||||
<key>CFBundleVersion</key>
|
|
||||||
<string>2.0.0</string>
|
|
||||||
<key>Chrome</key>
|
|
||||||
<dict/>
|
|
||||||
<key>Content</key>
|
|
||||||
<dict>
|
<dict>
|
||||||
<key>Scripts</key>
|
<key>Author</key>
|
||||||
|
<string>Buu Nguyen</string>
|
||||||
|
<key>Builder Version</key>
|
||||||
|
<string>9537.75.14</string>
|
||||||
|
<key>CFBundleDisplayName</key>
|
||||||
|
<string>octotree</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>com.buunguyen.octotree</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>2.0.0</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>2.0.0</string>
|
||||||
|
<key>Chrome</key>
|
||||||
|
<dict/>
|
||||||
|
<key>Content</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Start</key>
|
<key>Scripts</key>
|
||||||
|
<dict>
|
||||||
|
<key>Start</key>
|
||||||
|
<array>
|
||||||
|
<string>jquery.js</string>
|
||||||
|
<string>jquery-ui.js</string>
|
||||||
|
<string>jstree.js</string>
|
||||||
|
<string>keymaster.js</string>
|
||||||
|
<string>ondemand.js</string>
|
||||||
|
<string>octotree.js</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
<key>Stylesheets</key>
|
||||||
<array>
|
<array>
|
||||||
<string>jquery.js</string>
|
<string>jstree.css</string>
|
||||||
<string>jquery-ui.js</string>
|
<string>octotree.css</string>
|
||||||
<string>jquery.pjax.js</string>
|
</array>
|
||||||
<string>jstree.js</string>
|
<key>Whitelist</key>
|
||||||
<string>keymaster.js</string>
|
<array>
|
||||||
<string>octotree.js</string>
|
<string>https://github.com/*</string>
|
||||||
|
<string>https://gitlab.com/*</string>
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Stylesheets</key>
|
<key>Description</key>
|
||||||
<array>
|
<string>Display GitHub code in tree format</string>
|
||||||
<string>jstree.css</string>
|
<key>ExtensionInfoDictionaryVersion</key>
|
||||||
<string>octotree.css</string>
|
<string>1.0</string>
|
||||||
</array>
|
<key>Permissions</key>
|
||||||
<key>Whitelist</key>
|
|
||||||
<array>
|
|
||||||
<string>https://github.com/*</string>
|
|
||||||
<string>https://gitlab.com/*</string>
|
|
||||||
</array>
|
|
||||||
</dict>
|
|
||||||
<key>Description</key>
|
|
||||||
<string>Display GitHub code in tree format</string>
|
|
||||||
<key>ExtensionInfoDictionaryVersion</key>
|
|
||||||
<string>1.0</string>
|
|
||||||
<key>Permissions</key>
|
|
||||||
<dict>
|
|
||||||
<key>Website Access</key>
|
|
||||||
<dict>
|
<dict>
|
||||||
<key>Allowed Domains</key>
|
<key>Website Access</key>
|
||||||
<array>
|
<dict>
|
||||||
<string>github.com</string>
|
<key>Allowed Domains</key>
|
||||||
<string>gitlab.com</string>
|
<array>
|
||||||
</array>
|
<string>github.com</string>
|
||||||
<key>Include Secure Pages</key>
|
<string>gitlab.com</string>
|
||||||
<true/>
|
</array>
|
||||||
<key>Level</key>
|
<key>Include Secure Pages</key>
|
||||||
<string>Some</string>
|
<true/>
|
||||||
|
<key>Level</key>
|
||||||
|
<string>Some</string>
|
||||||
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
|
<key>Website</key>
|
||||||
|
<string>https://github.com/buunguyen/octotree</string>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Website</key>
|
|
||||||
<string>https://github.com/buunguyen/octotree</string>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
</plist>
|
||||||
|
|
|
@ -24,11 +24,11 @@ const DEFAULTS = {
|
||||||
// @ifndef SAFARI
|
// @ifndef SAFARI
|
||||||
HOTKEYS : '⌘+⇧+s, ⌃+⇧+s',
|
HOTKEYS : '⌘+⇧+s, ⌃+⇧+s',
|
||||||
// @endif
|
// @endif
|
||||||
GHEURLS : '',
|
|
||||||
GLEURLS : '',
|
|
||||||
WIDTH : 232,
|
|
||||||
POPUP : false,
|
POPUP : false,
|
||||||
SHOWN : false
|
WIDTH : 232,
|
||||||
|
SHOWN : false,
|
||||||
|
GHEURLS : '',
|
||||||
|
GLEURLS : ''
|
||||||
}
|
}
|
||||||
|
|
||||||
const EVENT = {
|
const EVENT = {
|
||||||
|
|
|
@ -119,7 +119,9 @@ $(document).ready(() => {
|
||||||
currRepo = repo
|
currRepo = repo
|
||||||
treeView.show(repo, token)
|
treeView.show(repo, token)
|
||||||
}
|
}
|
||||||
else treeView.syncSelection()
|
else {
|
||||||
|
treeView.syncSelection()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue