Load pjax and turbolinks on demand
This commit is contained in:
parent
28916ba301
commit
ffaf1ff2ed
|
@ -1,4 +1,5 @@
|
|||
const gulp = require('gulp')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const merge = require('event-stream').merge
|
||||
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
|
||||
gulp.task('chrome:template', () => {
|
||||
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})
|
||||
})
|
||||
|
||||
gulp.task('chrome', ['chrome:js'], () => {
|
||||
return merge(
|
||||
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/')
|
||||
)
|
||||
})
|
||||
|
@ -87,14 +101,14 @@ gulp.task('firefox:template', () => {
|
|||
return buildTemplate({FIREFOX: true})
|
||||
})
|
||||
|
||||
gulp.task('firefox:js', ['firefox:template'], () => {
|
||||
gulp.task('firefox:js', ['firefox:template', 'lib:ondemand'], () => {
|
||||
return buildJs([], {FIREFOX: true})
|
||||
})
|
||||
|
||||
gulp.task('firefox', ['firefox:js'], () => {
|
||||
return merge(
|
||||
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/package.json', './tmp/firefox')
|
||||
)
|
||||
|
@ -109,7 +123,7 @@ gulp.task('safari:template', () => {
|
|||
return buildTemplate({SAFARI: true})
|
||||
})
|
||||
|
||||
gulp.task('safari:js', ['safari:template'], () => {
|
||||
gulp.task('safari:js', ['safari:template', 'lib:ondemand'], () => {
|
||||
return buildJs([], {SAFARI: true})
|
||||
})
|
||||
|
||||
|
@ -117,7 +131,7 @@ gulp.task('safari', ['safari:js'], () => {
|
|||
return merge(
|
||||
pipe('./icons/**/*', './tmp/safari/octotree.safariextension/icons'),
|
||||
pipe(
|
||||
['./libs/**/*', './tmp/octotree.*', './src/config/safari/**/*'],
|
||||
['./libs/**/*', '!./libs/ondemand{,/**}', './tmp/octotree.*', './tmp/ondemand.js', './src/config/safari/**/*'],
|
||||
'./tmp/safari/octotree.safariextension/'
|
||||
)
|
||||
)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
class Adapter {
|
||||
constructor() {
|
||||
constructor(deps) {
|
||||
deps.forEach(dep => window[dep]())
|
||||
this._defaultBranch = {}
|
||||
this._observe()
|
||||
}
|
||||
|
|
|
@ -16,7 +16,8 @@ const GH_CONTAINERS = '.container'
|
|||
class GitHub extends Adapter {
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
super(['jquery.pjax.js'])
|
||||
|
||||
$(document)
|
||||
.ready(() => this._detectLocationChange())
|
||||
.on('pjax:send', () => $(document).trigger(EVENT.REQ_START))
|
||||
|
|
|
@ -11,7 +11,7 @@ const GL_PROJECT_ID = '#project_id'
|
|||
class GitLab extends Adapter {
|
||||
|
||||
constructor(store) {
|
||||
super()
|
||||
super(['turbolinks.js'])
|
||||
|
||||
// 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.
|
||||
|
|
|
@ -17,10 +17,9 @@ chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
|
|||
const jsFiles = [
|
||||
'jquery.js',
|
||||
'jquery-ui.js',
|
||||
'jquery.pjax.js',
|
||||
'turbolinks.js',
|
||||
'jstree.js',
|
||||
'keymaster.js',
|
||||
'ondemand.js',
|
||||
'octotree.js'
|
||||
]
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@ pageMod.PageMod({
|
|||
include: ['https://github.com/*', 'https://gitlab.com/*'],
|
||||
contentScriptFile : [data.url('jquery.js'),
|
||||
data.url('jquery-ui.js'),
|
||||
data.url('jquery.pjax.js'),
|
||||
data.url('jstree.js'),
|
||||
data.url('keymaster.js'),
|
||||
data.url('ondemand.js'),
|
||||
data.url('octotree.js')
|
||||
],
|
||||
contentStyleFile : [data.url('jstree.css'),
|
||||
|
|
|
@ -1,68 +1,68 @@
|
|||
<?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">
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<string>jquery.js</string>
|
||||
<string>jquery-ui.js</string>
|
||||
<string>jquery.pjax.js</string>
|
||||
<string>jstree.js</string>
|
||||
<string>keymaster.js</string>
|
||||
<string>octotree.js</string>
|
||||
<string>jstree.css</string>
|
||||
<string>octotree.css</string>
|
||||
</array>
|
||||
<key>Whitelist</key>
|
||||
<array>
|
||||
<string>https://github.com/*</string>
|
||||
<string>https://gitlab.com/*</string>
|
||||
</array>
|
||||
</dict>
|
||||
<key>Stylesheets</key>
|
||||
<array>
|
||||
<string>jstree.css</string>
|
||||
<string>octotree.css</string>
|
||||
</array>
|
||||
<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>
|
||||
<key>Description</key>
|
||||
<string>Display GitHub code in tree format</string>
|
||||
<key>ExtensionInfoDictionaryVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>Permissions</key>
|
||||
<dict>
|
||||
<key>Allowed Domains</key>
|
||||
<array>
|
||||
<string>github.com</string>
|
||||
<string>gitlab.com</string>
|
||||
</array>
|
||||
<key>Include Secure Pages</key>
|
||||
<true/>
|
||||
<key>Level</key>
|
||||
<string>Some</string>
|
||||
<key>Website Access</key>
|
||||
<dict>
|
||||
<key>Allowed Domains</key>
|
||||
<array>
|
||||
<string>github.com</string>
|
||||
<string>gitlab.com</string>
|
||||
</array>
|
||||
<key>Include Secure Pages</key>
|
||||
<true/>
|
||||
<key>Level</key>
|
||||
<string>Some</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>Website</key>
|
||||
<string>https://github.com/buunguyen/octotree</string>
|
||||
</dict>
|
||||
<key>Website</key>
|
||||
<string>https://github.com/buunguyen/octotree</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
@ -24,11 +24,11 @@ const DEFAULTS = {
|
|||
// @ifndef SAFARI
|
||||
HOTKEYS : '⌘+⇧+s, ⌃+⇧+s',
|
||||
// @endif
|
||||
GHEURLS : '',
|
||||
GLEURLS : '',
|
||||
WIDTH : 232,
|
||||
POPUP : false,
|
||||
SHOWN : false
|
||||
WIDTH : 232,
|
||||
SHOWN : false,
|
||||
GHEURLS : '',
|
||||
GLEURLS : ''
|
||||
}
|
||||
|
||||
const EVENT = {
|
||||
|
|
|
@ -119,7 +119,9 @@ $(document).ready(() => {
|
|||
currRepo = repo
|
||||
treeView.show(repo, token)
|
||||
}
|
||||
else treeView.syncSelection()
|
||||
else {
|
||||
treeView.syncSelection()
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue