Skip to content

Commit

Permalink
The "Page Info" dialog update: added support for many predicates of h…
Browse files Browse the repository at this point in the history
  • Loading branch information
igorlukanin committed Jul 15, 2010
1 parent b28dd2d commit fea7915
Show file tree
Hide file tree
Showing 5 changed files with 218 additions and 6 deletions.
47 changes: 47 additions & 0 deletions content/pageInfo.xul
Expand Up @@ -126,6 +126,53 @@
},true);
sourceLine.appendChild(sourceValue);
var type = ccffext.objects.getType(doc,objects[i]);
if ("undefined" != typeof type)
{
const typeLine = document.createElement("hbox");
typeLine.setAttribute("class","line");
leftPanel.appendChild(typeLine);
const typeTitle = document.createElement("label");
typeTitle.setAttribute("class","line-title");
typeTitle.setAttribute("value",ccffext.l10n.get("object.type.title.label"));
typeLine.appendChild(typeTitle);
const typeValue = document.createElement("label");
var line = ccffext.l10n.get("object.type."
+ type.toLowerCase().replace(/[^a-z]/g,"") + ".label");
typeValue.setAttribute("value",line.substring(0,1).toUpperCase() + line.substring(1));
typeLine.appendChild(typeValue);
}
var author = ccffext.objects.getAuthor(doc,objects[i]);
var authorUri = ccffext.objects.getAuthorUri(doc,objects[i]);
if ("undefined" != typeof author)
{
const authorLine = document.createElement("hbox");
authorLine.setAttribute("class","line");
leftPanel.appendChild(authorLine);
const authorTitle = document.createElement("label");
authorTitle.setAttribute("class","line-title");
authorTitle.setAttribute("value",ccffext.l10n.get("object.author.title.label"));
authorLine.appendChild(authorTitle);
const authorValue = document.createElement("label");
authorValue.setAttribute("value",author);
authorLine.appendChild(authorValue);
if ("undefined" != authorUri)
{
authorValue.setAttribute("class","anchor");
authorValue.setAttribute("uri",authorUri.uri);
authorValue.addEventListener("click",function(event)
{
window.open(this.getAttribute("uri"));
},true);
}
}
var license = ccffext.objects.getLicense(doc,objects[i],window.opener.content,RDFA,XH);
const licenseLine = document.createElement("hbox");
licenseLine.setAttribute("class","line primary");
Expand Down
12 changes: 8 additions & 4 deletions doc/FUNCSPEC
Expand Up @@ -18,8 +18,8 @@ Any software is made to provide ways to solve a specific problem of its end user
+ There should be a list displaying an entry for any of licensed objects
+ The name of the object should be displayed
± Some information about the object should be shown:
- The type of the object
- The information about object`s creator
+ The type of the object
+ The information about object`s creator
- The information about object`s rights holder
+ The hyperlink to the soure
± Some licensing information should be shown:
Expand All @@ -38,7 +38,7 @@ The extension may use information defined by:
+ http://www.w3.org/1999/xhtml/vocab#
+ copyright
+ license
± http://creativecommons.org/ns#
+ http://creativecommons.org/ns#
+ Reproduction
+ Distribution
+ DerivativeWorks
Expand All @@ -51,7 +51,11 @@ The extension may use information defined by:
+ Copyleft
+ LesserCopyleft
+ CommercialUse
- http://purl.org/dc/elements/1.1/#
+ attributionName
+ attributionURL
- http://purl.org/dc/terms/
+ title
+ type
- http://xmlns.com/foaf/0.1/#

Currently the development process is focused on supporting more predcates from the list above, that would also lead to changing "-"/"±"s in the UI list to "+"s.
42 changes: 42 additions & 0 deletions locale/en-US/locale.properties
Expand Up @@ -93,6 +93,48 @@ object.button.attributionastext.label=Copy to clipboard as plain text
# Key to be used with <Alt> to copy attribution information to the clipboard as plain text
object.button.attributionastext.key=T

# The type of the object
object.type.title.label=Type:

# The Collection type of the object
object.type.collection.label=collection

# The Dataset type of the object
object.type.dataset.label=dataset

# The Event type of the object
object.type.event.label=event

# The Image type of the object
object.type.image.label=image

# The InteractiveResource type of the object
object.type.interactiveresource.label=interactive resource

# The MovingImage type of the object
object.type.movingimage.label=moving image

# The PhysicalObject type of the object
object.type.physicalobject.label=physical object

# The Service type of the object
object.type.service.label=service

# The Software type of the object
object.type.software.label=software

# The Sound type of the object
object.type.sound.label=sound

# The StillImage type of the object
object.type.stillimage.label=stillimage

# The Text type of the object
object.type.text.label=text

# The author of the object
object.author.title.label=Author:


# The location bar icon

Expand Down
55 changes: 55 additions & 0 deletions locale/ru-RU/locale.properties
Expand Up @@ -95,6 +95,61 @@ object.button.attributionastext.label=Копировать в буфер обм
# Key to be used with <Alt> to copy attribution information to the clipboard as plain text
object.button.attributionastext.key=Т

# The type of the object
# TODO
object.type.title.label=Type:

# The Collection type of the object
# TODO
object.type.collection.label=collection

# The Dataset type of the object
# TODO
object.type.dataset.label=dataset

# The Event type of the object
# TODO
object.type.event.label=event

# The Image type of the object
# TODO
object.type.image.label=image

# The InteractiveResource type of the object
# TODO
object.type.interactiveresource.label=interactive resource

# The MovingImage type of the object
# TODO
object.type.movingimage.label=moving image

# The PhysicalObject type of the object
# TODO
object.type.physicalobject.label=physical object

# The Service type of the object
# TODO
object.type.service.label=service

# The Software type of the object
# TODO
object.type.software.label=software

# The Sound type of the object
# TODO
object.type.sound.label=sound

# The StillImage type of the object
# TODO
object.type.stillimage.label=stillimage

# The Text type of the object
# TODO
object.type.text.label=text

# The author of the object
object.author.title.label=Автор:


# The location bar icon

Expand Down
68 changes: 66 additions & 2 deletions module/ccffext.js
Expand Up @@ -239,18 +239,82 @@ var ccffext =

/**
* Returns a title for a licensed object.
* For now only the case when the object refers to the current document is processed in a smart way
*
* @param document The analysed document
* @param object The object
*/
getTitle : function(document,object)
{
for (let i = 0, pairs = ccffext.objects.getPairs(document,object); i < pairs.length; ++i)
{
if (pairs[i][0].uri == "http://purl.org/dc/terms/title")
{
return pairs[i][1];
}
}

return document.location.href == object.uri
? ccffext.l10n.get("object.title.current-page.label")
: object.uri;
},

/**
* Returns a type for a licensed object
*
* @param document The analysed document
* @param object The object
*/
getType : function(document,object)
{
for (let i = 0, pairs = ccffext.objects.getPairs(document,object); i < pairs.length; ++i)
{
if (pairs[i][0].uri == "http://purl.org/dc/terms/type")
{
return pairs[i][1].uri.replace("http://purl.org/dc/dcmitype/","");
}
}

return undefined;
},

/**
* Returns an author for a licensed object
*
* @param document The analysed document
* @param object The object
*/
getAuthor : function(document,object)
{
for (let i = 0, pairs = ccffext.objects.getPairs(document,object); i < pairs.length; ++i)
{
if (pairs[i][0].uri == "http://creativecommons.org/ns#attributionName")
{
return pairs[i][1];
}
}

return undefined;
},

/**
* Returns an URI for an author for a licensed object
*
* @param document The analysed document
* @param object The object
*/
getAuthorUri : function(document,object)
{
for (let i = 0, pairs = ccffext.objects.getPairs(document,object); i < pairs.length; ++i)
{
if (pairs[i][0].uri == "http://creativecommons.org/ns#attributionURL")
{
return pairs[i][1];
}
}

return undefined;
},

/**
* Returns a source for a licensed object.
*
Expand Down Expand Up @@ -295,7 +359,7 @@ var ccffext =
if ("undefined" != typeof license.uri)
{
var xhr = new window.XMLHttpRequest();
let uri = "http://api.creativecommons.org/rest/1.5/details?license-uri=" + license.uri;
let uri = "http://api.creativecommons.org/rest/dev/details?license-uri=" + license.uri;

xhr.open("GET",uri,false);
xhr.send();
Expand Down

0 comments on commit fea7915

Please sign in to comment.