Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jörg Schlötterer
committed
May 28, 2015
1 parent
f27f83f
commit 2bade91
Showing
15 changed files
with
274 additions
and
0 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,6 @@ | ||
{ | ||
"directory":"js/lib/", | ||
"scripts": { | ||
"postinstall": "grunt bowerRequirejs" | ||
} | ||
} |
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,31 @@ | ||
/*global module:false*/ | ||
module.exports = function(grunt) { | ||
|
||
// Project configuration. | ||
grunt.initConfig({ | ||
// Metadata. | ||
pkg: grunt.file.readJSON('package.json'), | ||
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' + | ||
'<%= grunt.template.today("yyyy-mm-dd") %>\n' + | ||
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' + | ||
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' + | ||
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n', | ||
// Task configuration. | ||
bowerRequirejs: { | ||
target: { | ||
rjsConfig: 'js/common.js', | ||
options: { | ||
baseUrl: './js/lib', | ||
transitive: true | ||
} | ||
} | ||
} | ||
}); | ||
|
||
// These plugins provide necessary tasks. | ||
grunt.loadNpmTasks('grunt-bower-requirejs'); | ||
|
||
// Default task. | ||
grunt.registerTask('default', ['bowerRequirejs']); | ||
|
||
}; |
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,31 @@ | ||
{ | ||
"name": "eexcess", | ||
"version": "0.0.1", | ||
"authors": [ | ||
"eexcess consortium <eexcess@joanneum.at>" | ||
], | ||
"description": "Enhancing Euroupe's eXchange in Cultural, Educational and Scientific reSources", | ||
"moduleType": [ | ||
"amd", | ||
"globals" | ||
], | ||
"license": "MIT", | ||
"ignore": [ | ||
"**/.*", | ||
"node_modules", | ||
"bower_components", | ||
"lib/", | ||
"test", | ||
"tests" | ||
], | ||
"dependencies": { | ||
"requirejs": "~2.1.17", | ||
"jquery": "~2.1.4", | ||
"c4": "https://github.com/EEXCESS/c4.git" | ||
}, | ||
"devDependencies": { | ||
"requirejs": "~2.1.17", | ||
"jquery": "~2.1.4", | ||
"c4": "https://github.com/EEXCESS/c4.git" | ||
} | ||
} |
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,15 @@ | ||
<!-- | ||
To change this template, choose Tools | Templates | ||
and open the template in the editor. | ||
--> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title></title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
</head> | ||
<body> | ||
<div>TODO write content</div> | ||
<script type="text/javascript" data-main="../js/background" src="../js/lib/requirejs/require.js"></script> | ||
</body> | ||
</html> |
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,40 @@ | ||
require(['./common'], function(common) { | ||
require(['c4/APIconnector'], function(APIconnector) { | ||
var msgAllTabs = function(msg) { | ||
chrome.tabs.query({}, function(tabs) { | ||
for (var i = 0, len = tabs.length; i < len; i++) { | ||
chrome.tabs.sendMessage(tabs[i].id, msg); | ||
} | ||
}); | ||
}; | ||
|
||
|
||
chrome.runtime.onMessage.addListener(function(msg, sender, sendResponse) { | ||
if (typeof msg.method !== 'undefined') { | ||
switch (msg.method) { | ||
case 'triggerQuery': | ||
console.log(msg.data); | ||
APIconnector.query(msg.data, function(response) { | ||
if (response.status === 'success') { | ||
msgAllTabs({ | ||
method: 'newResults', | ||
data: {profile: msg.data, results: {results: response.data.result}} | ||
}); | ||
} else { | ||
msgAllTabs({method: 'error', data: response.data}); | ||
} | ||
console.log(response.status); | ||
console.log(response.data); | ||
}); | ||
break; | ||
default: | ||
console.log('unknown method: ' + msg.method); | ||
break; | ||
} | ||
} else { | ||
console.log('method not specified'); | ||
} | ||
}); | ||
}); | ||
}); | ||
|
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,11 @@ | ||
require.config({ | ||
shim: { | ||
|
||
}, | ||
baseUrl: "/js/lib", | ||
paths: { | ||
}, | ||
packages: [ | ||
|
||
] | ||
}); |
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,84 @@ | ||
require(['c4/searchBar', 'c4/paragraphDetection', 'c4/namedEntityRecognition', 'c4/iframes'], function(searchBar, paragraphDetection, ner, iframes) { | ||
searchBar.init(function(profile) { | ||
chrome.runtime.sendMessage({method: 'triggerQuery', data: profile}); | ||
iframes.sendMsgAll({event: 'eexcess.queryTriggered'}); | ||
searchBar.show(); | ||
}); | ||
window.onmessage = function(e) { | ||
console.log(e.data); | ||
// do something | ||
}; | ||
|
||
// detect paragraphs | ||
var p = paragraphDetection.getParagraphs(); | ||
|
||
// enrich paragraphs with entities | ||
ner.entitiesAndCategories(p.map(function(par) { | ||
return { | ||
id: par.id, | ||
headline: par.headline, | ||
content: par.content | ||
}; | ||
}), function(result) { | ||
if (result.status && result.status === 'success') { | ||
paragraphDetection.enrichParagraphs(p, result.data.paragraphs); | ||
console.log(p); | ||
} | ||
}); | ||
|
||
// selection listener | ||
$(document).mouseup(function() { | ||
var selection = paragraphDetection.getSelection(p); | ||
if(selection.selection.length > 0) { | ||
var profile = { | ||
// TODO: split terms | ||
contextKeywords: [{ | ||
text:selection.selection, | ||
weight:1.0 | ||
}] | ||
}; | ||
if(selection.entities) { | ||
profile.contextNamedEntities = selection.entities; | ||
} | ||
// TODO: provide reason | ||
chrome.runtime.sendMessage({method: 'triggerQuery', data: profile}); | ||
iframes.sendMsgAll({event: 'eexcess.queryTriggered'}); | ||
searchBar.show(); | ||
} | ||
console.log(selection); | ||
}); | ||
|
||
// augment links | ||
$(function() { | ||
paragraphDetection.augmentLinks( | ||
$('.' + paragraphDetection.getSettings().classname), | ||
chrome.extension.getURL('media/icons/19.png'), | ||
function(profile) { | ||
// TODO: provide reason | ||
chrome.runtime.sendMessage({method: 'triggerQuery', data: profile}); | ||
iframes.sendMsgAll({event: 'eexcess.queryTriggered'}); | ||
searchBar.show(); | ||
}, | ||
paragraphDetection.getSettings().classname, p | ||
); | ||
}); | ||
|
||
chrome.runtime.onMessage.addListener(function(msg, sender, sendResponse) { | ||
console.log(msg); | ||
if (msg.method) { | ||
switch (msg.method) { | ||
case 'newResults': | ||
iframes.sendMsgAll({event: 'eexcess.newResults', data: msg.data}); | ||
break; | ||
case 'error': | ||
iframes.sendMsgAll({event: 'eexcess.error', data: msg.data}); | ||
break; | ||
default: | ||
console.log('unknown method'); | ||
break; | ||
} | ||
} else { | ||
console.log('method not specified'); | ||
} | ||
}); | ||
}); |
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,12 @@ | ||
require.load = function(context, moduleName, url) { | ||
var xhr; | ||
xhr = new XMLHttpRequest(); | ||
xhr.open('GET', chrome.extension.getURL(url) + '?=' + (new Date()).getTime(), true); | ||
xhr.onreadystatechange = function(e) { | ||
if(xhr.readyState === 4 && xhr.status === 200) { | ||
eval(xhr.responseText); | ||
context.completeLoad(moduleName); | ||
} | ||
}; | ||
xhr.send(null); | ||
}; |
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 @@ | ||
{ | ||
"name": "EEXCESS_DEV", | ||
"version": "0.11", | ||
"background": { | ||
"page": "html/background.html" | ||
}, | ||
"content_scripts": [ | ||
{ | ||
"matches": ["<all_urls>"], | ||
"run_at":"document_end", | ||
"js": ["js/lib/requirejs/require.js","js/requireContent.js","js/common.js","js/content.js"], | ||
"css": [] | ||
} | ||
], | ||
|
||
"web_accessible_resources": [ | ||
"js/*", | ||
"external/*", | ||
"media/*" | ||
], | ||
"manifest_version": 2, | ||
"permissions": [ | ||
"tabs", | ||
"<all_urls>", | ||
"geolocation", | ||
"history", | ||
"background", | ||
"storage" | ||
], | ||
"icons": {"16": "media/icons/16.png", | ||
"48": "media/icons/48.png", | ||
"128": "media/icons/128.png"} | ||
} | ||
|
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,10 @@ | ||
{ | ||
"engines": { | ||
"node": ">= 0.10.0" | ||
}, | ||
"devDependencies": { | ||
"bower": "^1.4.1", | ||
"grunt": "^0.4.5", | ||
"grunt-bower-requirejs": "^2.0.0" | ||
} | ||
} |