Browse files

Version 0.2 for distro

Signed-off-by: patlockley <patrick.lockley@googlemail.com>
  • Loading branch information...
1 parent cb52c34 commit 4489bf3d8c937b8399f746646b1cbee2e2e121d8 @pgogy committed Feb 6, 2011
Showing with 105 additions and 13 deletions.
  1. +9 −0 README
  2. +10 −0 background.html
  3. +3 −5 content_script.js
  4. +2 −2 manifest.json
  5. +81 −6 popup.html
View
9 README
@@ -0,0 +1,9 @@
+OpenAttribute for Chrome
+=========================
+
+OpenAttribute for Chrome adds support for displaying license and
+attribution information for works as you browse. If the page or items
+on the page are licensed, a CC icon will appear in the URL bar, which
+can be clicked to display the author and license information. This
+metadata is used to generate HTML which can be used to attribute
+reuse.
View
10 background.html
@@ -133,6 +133,16 @@
}
}
+
+ if (localStorage["firstrun_pagedisplay"]==undefined) {
+
+ localStorage["firstrun_pagedisplay"] = true;
+
+ chrome.tabs.create({
+ url: "http://openattribute.com/first-run-chrome/"
+ });
+
+ }
chrome.pageAction.show(sender.tab.id);
View
8 content_script.js
@@ -9,7 +9,7 @@ chrome.extension.sendRequest({data: "title", title: document.title});
chrome.extension.sendRequest({data: "url", url: document.location.href});
function add_triple(data_triple){
-
+
if (triple_store.length == 0) {
triple_store.push(data_triple);
@@ -238,10 +238,8 @@ while (n) {
}
-if(license_found){
+if(license_found){
chrome.extension.sendRequest({show: "icon", html: triple_store});
-}
-
-
+}
View
4 manifest.json
@@ -9,10 +9,10 @@
"icons": {
"128": "icon.png"
},
- "name": "OpenAttribute Chrome",
+ "name": "OpenAttribute",
"page_action": {
"default_icon": "icon.png",
- "default_title": "Get Attribution Info",
+ "default_title": "Get Attribution Info from a page to allow for attributing materials",
"popup": "popup.html"
},
"permissions": [ "tabs",
View
87 popup.html
@@ -1,6 +1,27 @@
<html>
<head>
<script type="text/javascript">
+
+ function toggle(obj){
+
+ if(obj.style.display=="block"){
+
+ obj.style.display="none";
+ obj.style.height="0px";
+
+ }else{
+
+ obj.style.display="block";
+ obj.style.height="auto";
+ document.getElementById("attribtext").focus();
+ document.getElementById("attribtext").select();
+ document.execCommand('copy');
+
+ }
+
+ }
+
+
function init() {
var bkg = chrome.extension.getBackgroundPage();
@@ -13,11 +34,19 @@
author = bkg.attribute_info.author;
attribution_url = bkg.attribute_info.attribution_url;
+ non_html_attrib_string = "";
+
document.getElementById("container").innerHTML = "<p style=\"font-weight:bold\">" + title + "</p>";
attrib_string = '<span property="dct:title">' + title + '</span>';
+ non_html_attrib_string = title + " taken from " + url + "\n";
+
document.getElementById("container").innerHTML += "<p style=\"font-size:80%\"> Source : " + url + "</p>";
-
+
+ document.getElementById("container").innerHTML += "<p style=\"font-size:80%\"> License: <a target=\"_blank\" href=\"" + license_link + "\">" + license + "</a></p>";
+
+ attrib_string_light = title + " : taken from - " + url;
+
if(author!=""){
if(attribution_url!=""){
@@ -32,20 +61,66 @@
}
+ attrib_string_light += "\nAuthor: " + author + " ";
+
}
- document.getElementById("container").innerHTML += "<p style=\"font-size:80%\"> License: <a target=\"_blank\" href=\"" + license_link + "\">" + license + "</a></p>";
+ document.getElementById("container").innerHTML += "<form><input type=\"button\" value=\"More Information\" onclick=\"javascript:toggle(document.getElementById('extrainfodiv'));\" /></form>";
+
+ attrib_string_light += "\n" + license_link;
+
+ l_s = license_shorthand.split(" ").join(" ");
+
+ l_s = l_s.split(" ")
- attrib_string +='<a rel="license" target=\"_blank\" href="' + license_link + '">' + license + " / " + license_shorthand + '</a>';
+ cc_l_s = l_s[1];
+
+ l_s = l_s.join(" ");
+
+ attrib_string +='<a rel="license" target=\"_blank\" href="' + license_link + '">' + license + " / " + l_s + '</a>';
attrib_string = "<div xmlns:dc=\"http://purl.org/dc/terms/\" xmlns:cc\"http://creativecommons.org/#ns\" about=\"" + url + "\">" + attrib_string + "</a>";
- document.getElementById("container").innerHTML += "<textarea rows=\"7\" cols=\"20\">" + attrib_string + "</textarea>";
+ non_html_attrib_string += license.split("\n").join("") + " / " + l_s + "\n";
+
+ switch (cc_l_s.toLowerCase()) {
+ case "by":
+ case "by-sa":
+ case "mark":
+ case "zero":
+ case "publicdomain":
+ license_color = "green";
+ break;
+
+ case "by-nc":
+ case "by-nd":
+ case "by-nc-nd":
+ case "by-nc-sa":
+ case "sampling+":
+ case "nc-sampling+":
+ license_color = "yellow";
+ break;
+
+ case "sampling":
+ case "devnations":
+ license_color = "red";
+ break;
+ }
+
+ document.getElementById("colorbar").style.backgroundColor = license_color;
+
+ document.getElementById("extrainfodiv").innerHTML += "<p style=\"font-size:80%\">Basic Attribution</p><textarea rows=\"7\" id=\"attribtext\" cols=\"70\">" + attrib_string_light + "</textarea>";
+ document.getElementById("extrainfodiv").innerHTML += "<p style=\"font-size:80%\">RDFa Attribution</p><textarea rows=\"7\" id=\"attribtextRDFA\" cols=\"70\">" + attrib_string + "</textarea>";
}
</script>
</head>
- <body onload="init();" style="font-family:arial; width:600px; height:auto">
- <div id="container"></div>
+ <body onload="init();" style="font-family:arial; width:600px;">
+ <div id="container">
+ </div>
+ <div id="extrainfodiv" style="display:none;">
+ </div>
+ <div id="colorbar" style="height:25px; background-color:red">
+ </div>
</body>
</html>

0 comments on commit 4489bf3

Please sign in to comment.