Skip to content
This repository has been archived by the owner on Feb 17, 2018. It is now read-only.

Commit

Permalink
Fix compatibility of extensions for firefox
Browse files Browse the repository at this point in the history
Currently a bug with vue <transition> and firefox extensions which
results in

    TypeError: 'requestAnimationFrame' called on an object that does not implement interface Window.
    Stack trace:
    zt@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:6:30523
    Gt@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:7:551
    tn@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:7:1640
    d@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:6:23084
    o@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:6:22291
    xt/<@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:6:26311
    we/e.prototype._update@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:6:10301
    we/e.prototype._mount/n._watcher<@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:6:10082
    Ji.prototype.get@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:7:26477
    Ji.prototype.run@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:7:27130
    z@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:6:4802
    Ai</</<@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:7:23148
    e@resource://gre/modules/ExtensionContent.jsm -> moz-extension://3b35a7b5-6bf4-744d-900b-04c8768fdd55/js/content_script.js:7:22607

see Semantic-Org/Semantic-UI#3855
  • Loading branch information
sbdchd committed Jan 17, 2017
1 parent e7d48a5 commit e2c4f4b
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 34 deletions.
8 changes: 8 additions & 0 deletions browser-extensions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ npm run build
# or with watchexec installed
cd src/ && watchexec -- npm run build
```

Note: when debugging in

- Chrome open the `background page` located in the extensions page
- Firefox open [Tools > Web Developer > Browser Console][1] <kbd>shift + cmd + j</kbd>, also nav to `about:debugging#addons`


[1]: http://stackoverflow.com/a/24104946
17 changes: 12 additions & 5 deletions browser-extensions/src/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,15 @@ import axios from 'axios'
import { focus } from 'vue-focus'
import config from './config.js'
const baseURL = config.isDebug ? 'http:localhost:8000' : 'https://getlinky.com'
const baseURL =
config.isDebug
? 'http:localhost:8000'
: 'https://getlinky.com'
const storage =
typeof chrome.storage.sync !== 'undefined'
? chrome.storage.sync
: chrome.storage.local
export default {
directives: {
Expand All @@ -66,7 +74,7 @@ export default {
axios.post(baseURL + '/rest-auth/login/', credentials)
.then(response => {
console.info('login successful')
chrome.storage.sync.set({'token': response.data.key})
storage.set({'token': response.data.key})
this.inputErrors = false
this.authenticated = true
this.password = ''
Expand All @@ -80,7 +88,7 @@ export default {
},
logout () {
// Note: empty data payload needed for axios to send the headers as headers
chrome.storage.sync.get('token', token => {
storage.get('token', token => {
axios.post(baseURL + '/rest-auth/logout/', {}, {headers: {'Authorization': 'Token ' + token.token}})
.then(response => {
console.info('logged out')
Expand All @@ -94,8 +102,7 @@ export default {
},
mounted () {
console.log('mounted')
chrome.storage.sync.get('token', token => {
storage.get('token', token => {
axios.get(baseURL + '/api/users/me/',
{headers: {'Authorization': 'Token ' + token.token}})
.then(response => {
Expand Down
22 changes: 16 additions & 6 deletions browser-extensions/src/Notification.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
<template>
<transition name="fade">
<div v-if="show" class="linky-note linky-bottom" :class="'linky-'+level">
<span v-if="html" v-html="message"></span>
<span v-else >{{ message }}</span>
<a v-if="button" class="linky-close" @click="closed">✕</a>
</div>
<transition v-if="!isFirefox" name="fade">
<div v-if="show" class="linky-note linky-bottom" :class="'linky-'+level">
<span v-if="html" v-html="message"></span>
<span v-else >{{ message }}</span>
<a v-if="button" class="linky-close" @click="closed">✕</a>
</div>
</transition>
<div v-else>
<div v-if="show" class="linky-note linky-bottom" :class="'linky-'+level">
<span v-if="html" v-html="message"></span>
<span v-else >{{ message }}</span>
<a v-if="button" class="linky-close" @click="closed">✕</a>
</div>
</div>
</template>

<script>
Expand Down Expand Up @@ -82,6 +89,9 @@ export default {
'show': this.show,
}
},
isFirefox () {
return navigator.userAgent.indexOf('Firefox') > 0
},
},
}
</script>
Expand Down
7 changes: 6 additions & 1 deletion browser-extensions/src/content_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ const div = document.createElement('div')
div.id = 'linky-vue'
document.querySelector('body').appendChild(div)

const storage =
typeof chrome.storage.sync !== 'undefined'
? chrome.storage.sync
: chrome.storage.local

// eslint-disable-next-line no-new
const v = new Vue({
el: '#linky-vue',
Expand All @@ -28,7 +33,7 @@ const v = new Vue({
},
methods: {
addURL (URL) {
chrome.storage.sync.get('token', token => {
storage.get('token', token => {
axios.post(baseURL + '/api/links/', {'url': URL},
{headers: {'Authorization': 'Token ' + token.token}})
.then(response => {
Expand Down
3 changes: 3 additions & 0 deletions browser-extensions/src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"css": ["css/content_script.css"]
}],
"options_page": "index.html",
"options_ui": {
"page": "index.html"
},
"browser_action": {
"default_title": "Add URL to Linky"
},
Expand Down
24 changes: 2 additions & 22 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,4 @@
# frontend
> the vue.js frontend for linky
> A Vue.js project
## Build Setup

``` bash
# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build

# lint all *.js and *.vue files
npm run lint

# run unit tests
npm test
```

For more information see the [docs for vueify](https://github.com/vuejs/vueify).
See base README.md for dev setup
8 changes: 8 additions & 0 deletions frontend/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ module.exports = {
target: 'http://web:8000',
changeOrigin: true,
},
'/static/rest_framework': {
target: 'http://web:8000',
cahngeOrigin: true,
},
'/static/admin': {
target: 'http://web:8000',
cahngeOrigin: true,
},
},
// CSS Sourcemaps off by default because relative paths are "buggy"
// with this option, according to the CSS-Loader README
Expand Down

0 comments on commit e2c4f4b

Please sign in to comment.