-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from talis/TENT-2468-universal-extension
TENT-2468: Refactor to make work in Chrome and MS Edge
- Loading branch information
Showing
34 changed files
with
1,892 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
bower_components/ | ||
dist/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
module.exports = function(grunt) { | ||
|
||
// Project configuration. | ||
grunt.initConfig({ | ||
pkg: grunt.file.readJSON('package.json'), | ||
distdir: './dist', | ||
copy: { | ||
bower: { | ||
files: [ | ||
{ | ||
expand: true, | ||
cwd: './', | ||
src: [ | ||
'bower_components/bootstrap/dist/js/bootstrap.min.js', | ||
'bower_components/bootstrap/dist/css/bootstrap.min.css', | ||
'bower_components/jquery/dist/jquery.min.js' | ||
], | ||
dest: 'dist' | ||
} | ||
] | ||
}, | ||
common: { | ||
files: [ | ||
{ | ||
expand: true, | ||
cwd: './', | ||
src: [ | ||
'*.html', | ||
'_locales/**', | ||
'images/**', | ||
'css/**', | ||
'js/*.js', | ||
'!js/ms' | ||
], | ||
dest: 'dist' | ||
} | ||
] | ||
}, | ||
msedge: { | ||
files: [ | ||
{ | ||
expand: true, | ||
cwd: './', | ||
src: [ | ||
'js/ms/**' | ||
], | ||
dest: 'dist' | ||
} | ||
] | ||
} | ||
} | ||
}); | ||
|
||
grunt.loadNpmTasks('grunt-contrib-copy'); | ||
|
||
grunt.registerTask('create-dist-dir', 'Creates the dist directory', function () { | ||
grunt.file.delete(grunt.config('distdir')); | ||
grunt.file.mkdir(grunt.config('distdir')); | ||
}); | ||
grunt.registerTask('write-manifest', 'Writes the manifest file to dist', function (browser) { | ||
var manifest = grunt.file.readJSON('manifest.json'); | ||
manifest.version = grunt.config('pkg.version'); | ||
if (grunt.option('identifier')) { | ||
manifest.applications = { 'gecko': { 'id': grunt.option('identifier') } }; | ||
} | ||
if (browser !== 'msedge') { | ||
delete(manifest['-ms-preload']); | ||
} | ||
grunt.file.write(grunt.config('distdir') + '/manifest.json', JSON.stringify(manifest, null, 2)); | ||
}); | ||
grunt.registerTask( | ||
'dist-common', | ||
'Create distribution for Web Extension browsers', | ||
['create-dist-dir', 'write-manifest:common', 'copy:bower', 'copy:common'] | ||
); | ||
grunt.registerTask( | ||
'dist-msedge', | ||
'Create distribution for Web Extension browsers', | ||
['create-dist-dir', 'write-manifest:msedge', 'copy:bower', 'copy:common', 'copy:msedge'] | ||
); | ||
grunt.registerTask('default', ['dist-common']); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2017 Talis Education Limited | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
Talis Aspire Reading Lists Bookmarking Extension | ||
================================================ | ||
|
||
Requirements: | ||
- [npm](https://www.npmjs.com/) | ||
|
||
This project provides an alternative to the Talis Aspire Reading Lists Bookmarking Bookmarklet, | ||
which can be forked and rebranded for distribution in institutional enterprise environments. | ||
|
||
The extension should work with: | ||
- Google Chrome/Chromium | ||
- Microsoft Edge | ||
- Firefox | ||
- Opera | ||
- Vivaldi | ||
|
||
To customize for your institution: | ||
|
||
Replace images/icon*.png with appropriate images for your institution. | ||
|
||
You will need images with the following dimensions (all dimensions in pixels): | ||
- 128 x 128 | ||
- 48 x 48 | ||
- 40 x 40 | ||
- 32 x 32 | ||
- 30 x 30 | ||
- 25 x 25 | ||
- 24 x 24 | ||
- 20 x 20 | ||
- 16 x 16 | ||
|
||
The different sizes will be used by different browsers in different ways. | ||
|
||
All strings in the extension can be edited by changing the values in the language files in the `_locales` directory. | ||
|
||
To build the files for the extension, | ||
``` | ||
$ npm install # This should also run bower install | ||
# replace ./images/*.png and ./_locales with institutional preferences | ||
$ grunt # This will build a Chrome/Opera/Vivaldi extension | ||
$ grunt dist-msedge # This will build a Microsoft Edge extension | ||
$ grunt --identifier="{AMO UUID}" # This will build the extension with a Mozilla Add-on Identifier | ||
``` | ||
|
||
The `./dist` directory should then contain everything you need for a `.crx`, `.xpi`, `.zip`, etc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<html> | ||
<script type="text/javascript" src="js/allTenants.js"></script> | ||
<script type="text/javascript" src="js/tenants.js"></script> | ||
<script type="text/javascript" src="js/bookmarker.js"></script> | ||
<script type="text/javascript" src="js/background.js"></script> | ||
</html> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "talis-reading-lists-bookmarker", | ||
"homepage": "https://github.com/talis/rl-chrome-extension-spike", | ||
"authors": [ | ||
"[email protected]" | ||
], | ||
"description": "A browser extension to bookmark resources to Talis Aspire Reading Lists", | ||
"main": "manifest.json", | ||
"keywords": [ | ||
"extension" | ||
], | ||
"license": "MIT", | ||
"private": true, | ||
"ignore": [ | ||
"**/.*", | ||
"node_modules", | ||
"bower_components", | ||
"test", | ||
"tests" | ||
], | ||
"dependencies": { | ||
"bootstrap": "3.3.6" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
body { min-width: 500px; padding: 20px 0 20px 0; } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Use this to populate the list of institutions in the options menu. In order for a tenant to | ||
* appear, it *must* have an `apps.rl` value (which can be anything) | ||
* | ||
* The non-branded 'Talis' extension should use the tenant list from: | ||
* https://talis-public.s3-eu-west-1.amazonaws.com/talis.com/customers.json | ||
*/ | ||
var allTenants = { | ||
"broadminster" : { | ||
"name" : "Broadminster University", | ||
"apps" : { | ||
"rl" : true | ||
} | ||
}, | ||
"broadminster_old" : { | ||
"name" : "Old Broadminster University", | ||
"apps" : { | ||
"rl" : true | ||
} | ||
}, | ||
"cst" : { | ||
"name" : "CST | Talis Training", | ||
"apps" : { | ||
"rl" : true | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Background script. | ||
* | ||
* This only does anything when the bookmarking button is clicked | ||
*/ | ||
chrome.browserAction.onClicked.addListener(function(tab) { | ||
// If no institution has been set, go to the options page to set one | ||
getActiveTenant(function (tenantCode) { | ||
if (!tenantCode) { | ||
if (window.confirm(chrome.i18n.getMessage('noTenantAlert'))) { | ||
chrome.runtime.openOptionsPage(); | ||
} | ||
} | ||
// Edge does not support the promise-based APIs (chrome.*), but, conveniently, it also | ||
// requires the bookmarker to be injected via a content_script (whereas other browsers | ||
// seem fine as background scripts), so we'll use that to differentiate | ||
if (this.browser) { | ||
browser.tabs.executeScript( | ||
{ code: 'bookmarkPage("' + tenantCode + '")'} | ||
); | ||
} else { | ||
// This is effectively the same as bookmarker.js | ||
var bookmarkCode = 'var bookmarker = document.createElement(\'script\');' + | ||
'bookmarker.setAttribute(\'src\', ' + | ||
'\'https://bookmarking.talis.com/' + tenantCode + '/parser?bookmarkButtonVersion=1&uri=\' + ' + | ||
'encodeURIComponent(encodeURI(window.location.href)) + \'&bookmarkVersion=1&title=\' + ' + | ||
'encodeURIComponent(document.title) + \'&hasJquery=no\');document.body.appendChild(bookmarker);'; | ||
chrome.tabs.executeScript( | ||
tab.id, | ||
{ code: bookmarkCode} | ||
); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* This exists for MS Edge, and should more or less be functionally identical to `bookmarkCode` | ||
* in `background.js`. | ||
* Edge needs this to be a content_script that is injected, however. | ||
* @todo Find a way to not duplicate this. | ||
*/ | ||
/** | ||
* Injected into page to redirect to the dynamic page parser | ||
* | ||
* @param {String} tenantCode | ||
*/ | ||
function bookmarkPage(tenantCode) { | ||
var bookmarker = document.createElement('script'); | ||
bookmarker.setAttribute( | ||
'src', | ||
'https://bookmarking.talis.com/' + tenantCode + '/parser?bookmarkButtonVersion=1&uri=' + | ||
encodeURIComponent(encodeURI(window.location.href)) + '&bookmarkVersion=1&title=' + | ||
encodeURIComponent(document.title) + '&hasJquery=no' | ||
); | ||
document.body.appendChild(bookmarker); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
MS Edge Support Files | ||
===================== | ||
|
||
The files in `js/ms` were automatically generated by the Microsoft Edge Extension Toolkit. | ||
|
||
See: https://www.microsoft.com/en-US/store/p/microsoft-edge-extension-toolkit/9nblggh4txvb?rtc=1 for details. |
Oops, something went wrong.