commit b4c8dbe7003e307a79c274254af4a92ffb24dc9e
parent 30af2c89df036a98f97b973831104ef306fedd45
Author: Simon Kornblith <simon@simonster.com>
Date: Thu, 3 Aug 2006 04:54:16 +0000
closes #157, add database infrastructure for different CSL styles
CSL is stored in a new "csl" table. only metadata relevant to updates and selection (ID, date updated, and title) is stored in columns.
Diffstat:
5 files changed, 127 insertions(+), 12 deletions(-)
diff --git a/chrome/chromeFiles/content/scholar/fileInterface.js b/chrome/chromeFiles/content/scholar/fileInterface.js
@@ -80,7 +80,6 @@ Scholar_File_Interface = new function() {
// get translators again, bc now we can check against the file
translators = translation.getTranslators();
if(translators.length) {
- // TODO: display a list of available translators
translation.setTranslator(translators[0]);
// show progress indicator
translation.setHandler("itemDone", _importItemDone);
diff --git a/chrome/chromeFiles/content/scholar/xpcom/cite.js b/chrome/chromeFiles/content/scholar/xpcom/cite.js
@@ -8,13 +8,23 @@ Scholar.Cite = new function() {
this.getStyles = getStyles;
function getStyles() {
- // TODO: return key/values from database
- return {1:"American Psychological Association"};
+ // get styles
+ var sql = "SELECT cslID, title FROM csl ORDER BY title";
+ var styles = Scholar.DB.query(sql);
+
+ // convert to associative array
+ var stylesObject = new Object();
+ for each(var style in styles) {
+ stylesObject[style.cslID] = style.title;
+ }
+
+ return stylesObject;
}
- function getBibliography(style, items) {
- // TODO: retrieve style from the database
- style = '<citationstyle xmlns="http://purl.org/net/xbiblio/csl" xml:lang="en"> <info> <title>American Psychological Association</title> <title-short>APA</title-short> <edition>5</edition> <author> <name>Bruce DÕArcus</name> <email>bdarcus@sourceforge.net</email> </author> <dateCreated>2005-05-18</dateCreated> <dateModified>2006-07-09</dateModified> <source href="http://www.english.uiuc.edu/cws/wworkshop/writer_resources/citation_styles/apa/apa.htm" >Citation Styles Handbook: APA</source> <field>psychology</field> <description>Style for the American Psychological Association.</description> </info> <general> <names and="text" sort-separator=", " initialize-with="."> <original-script position="after" prefix=" "/> </names> <contributors> <label position="before-unless-first" type="verb"/> </contributors> <locators> <label position="before" form="short"/> </locators> <titles> <original-script position="after" prefix=" "/> </titles> <dates format="year, month day" month="full"> <original position="after" prefix=" [" suffix="]"/> </dates> <publishers order="address-publisher" separator=":"/> <access order="url-date" separator=", "/> </general> <citation delimiter=";" type="author-year" sort-order="author-date" prefix="(" suffix=")"> <use-et_al min-authors="6" use-first="6" position="first"/> <use-et_al min-authors="6" use-first="1" position="subsequent"/> <item-layout> <author form="short" suffix=", "/> <year/> <point-locator prefix=": " include-label="false"/> </item-layout> </citation> <bibliography author-as-sort-order="all" author-shorten-with="ÑÑÑ." sort-order="author-date"> <use-et_al min-authors="4" use-first="3"/> <list-layout> <heading label="references"/> </list-layout> <item-layout suffix="."> <reftype name="book"> <author alternate="editor"/> <year prefix=" (" suffix=")."/> <title font-style="italic" prefix=" " suffix="."/> <editor prefix=", "/> <publisher/> <access prefix=" "/> </reftype> <reftype name="chapter"> <author alternate="editor"/> <year prefix=" (" suffix=")."/> <title prefix=" "/> <group class="container"> <text idref="in"/> <editor/> <title type="container" font-style="italic" prefix=" " suffix="."/> <title type="series" prefix=" " suffix="."/> <publisher/> </group> <access prefix=" "/> <pages prefix=", "/> </reftype> <reftype name="article"> <author alternate="container-title"/> <year prefix=" (" suffix=")."/> <title prefix=" "/> <group class="container"> <editor/> <title type="container" font-style="italic" prefix=" " suffix="."/> </group> <access prefix=" "/> <volume prefix=" "/> <issue prefix="(" suffix=")"/> <pages prefix=", "/> </reftype> <reftype name="legalcase"> <title/> <year prefix=" (" suffix=")"/> <access prefix=", "/> </reftype> </item-layout> </bibliography></citationstyle>';
+ function getBibliography(cslID, items) {
+ // get style
+ var sql = "SELECT csl FROM csl WHERE cslID = ?";
+ var style = Scholar.DB.valueQuery(sql, [cslID]);
// get item arrays
var itemArrays = new Array();
diff --git a/chrome/chromeFiles/content/scholar/xpcom/schema.js b/chrome/chromeFiles/content/scholar/xpcom/schema.js
@@ -391,7 +391,7 @@ Scholar.Schema = new function(){
//
// Change this value to match the schema version
//
- var toVersion = 31;
+ var toVersion = 32;
if (toVersion != _getSchemaSQLVersion()){
throw('Schema version does not match version in _migrateSchema()');
@@ -415,7 +415,7 @@ Scholar.Schema = new function(){
}
}
- if (i==31){
+ if (i==32){
_initializeSchema();
}
}
diff --git a/schema.sql b/schema.sql
@@ -1,4 +1,4 @@
--- 31
+-- 32
DROP TABLE IF EXISTS version;
CREATE TABLE version (
@@ -232,6 +232,14 @@
FOREIGN KEY (transactionID) REFERENCES transactions(transactionID)
);
+ DROP TABLE IF EXISTS csl;
+ CREATE TABLE csl (
+ cslID TEXT PRIMARY KEY,
+ updated DATETIME,
+ title TEXT,
+ csl TEXT
+ );
+
INSERT INTO itemTypes VALUES (1,'note');
INSERT INTO itemTypes VALUES (2,'book');
diff --git a/scrapers.sql b/scrapers.sql
@@ -3916,7 +3916,6 @@ MARC_Record.prototype._associateDBField = function(item, fieldNo, part, fieldNam
value = execMe(value, arg1, arg2);
}
- // TODO: handle creators better
if(fieldName == "creator") {
item.creators.push(value);
} else {
@@ -4073,4 +4072,103 @@ function doImport(url) { // the URL is actually here for other translators
holdOver += text;
}
}
-}');
-\ No newline at end of file
+}');
+
+REPLACE INTO "csl" VALUES('id-not-yet-given', '2006-08-03 00:33:00', 'American Psychological Association',
+'<citationstyle xmlns="http://purl.org/net/xbiblio/csl" xml:lang="en">
+ <info>
+ <title>American Psychological Association</title>
+ <title-short>APA</title-short>
+ <edition>5</edition>
+ <author>
+ <name>Bruce DÕArcus</name>
+ <email>bdarcus@sourceforge.net</email>
+ </author>
+ <dateCreated>2005-05-18</dateCreated>
+ <dateModified>2006-07-09</dateModified>
+ <source
+ href="http://www.english.uiuc.edu/cws/wworkshop/writer_resources/citation_styles/apa/apa.htm"
+ >Citation Styles Handbook: APA</source>
+ <field>psychology</field>
+ <description>Style for the American Psychological
+ Association.</description>
+ </info>
+ <general>
+ <names and="text" sort-separator=", " initialize-with=".">
+ <original-script position="after" prefix=" "/>
+ </names>
+ <contributors>
+ <label position="before-unless-first" type="verb"/>
+ </contributors>
+ <locators>
+ <label position="before" form="short"/>
+ </locators>
+ <titles>
+ <original-script position="after" prefix=" "/>
+ </titles>
+ <dates format="year, month day" month="full">
+ <original position="after" prefix=" [" suffix="]"/>
+ </dates>
+ <publishers order="address-publisher" separator=":"/>
+ <access order="url-date" separator=", "/>
+ </general>
+ <citation delimiter=";" type="author-year" sort-order="author-date"
+ prefix="(" suffix=")">
+ <use-et_al min-authors="6" use-first="6" position="first"/>
+ <use-et_al min-authors="6" use-first="1" position="subsequent"/>
+ <item-layout>
+ <author form="short" suffix=", "/>
+ <year/>
+ <point-locator prefix=": " include-label="false"/>
+ </item-layout>
+ </citation>
+ <bibliography author-as-sort-order="all" author-shorten-with="ÑÑÑ."
+ sort-order="author-date">
+ <use-et_al min-authors="4" use-first="3"/>
+ <list-layout>
+ <heading label="references"/>
+ </list-layout>
+ <item-layout suffix=".">
+ <reftype name="book">
+ <author alternate="editor"/>
+ <year prefix=" (" suffix=")."/>
+ <title font-style="italic" prefix=" " suffix="."/>
+ <editor prefix=", "/>
+ <publisher/>
+ <access prefix=" "/>
+ </reftype>
+ <reftype name="chapter">
+ <author alternate="editor"/>
+ <year prefix=" (" suffix=")."/>
+ <title prefix=" "/>
+ <group class="container">
+ <text idref="in"/>
+ <editor/>
+ <title type="container" font-style="italic" prefix=" " suffix="."/>
+ <title type="series" prefix=" " suffix="."/>
+ <publisher/>
+ </group>
+ <access prefix=" "/>
+ <pages prefix=", "/>
+ </reftype>
+ <reftype name="article">
+ <author alternate="container-title"/>
+ <year prefix=" (" suffix=")."/>
+ <title prefix=" "/>
+ <group class="container">
+ <editor/>
+ <title type="container" font-style="italic" prefix=" " suffix="."/>
+ </group>
+ <access prefix=" "/>
+ <volume prefix=" "/>
+ <issue prefix="(" suffix=")"/>
+ <pages prefix=", "/>
+ </reftype>
+ <reftype name="legalcase">
+ <title/>
+ <year prefix=" (" suffix=")"/>
+ <access prefix=", "/>
+ </reftype>
+ </item-layout>
+ </bibliography>
+</citationstyle>');
+\ No newline at end of file