Permalink
Browse files

add patches from jorge ventura to complete form and link following be…

…havior for windows and forms. will be tagged 1.2.17
  • Loading branch information...
1 parent 8cc9bfa commit a46fe6b1ff59f0596c162ee01e94ff256ee47bfe thatcher committed Aug 4, 2010
View
@@ -2,7 +2,7 @@
PROJECT: env-js
BUILD_MAJOR: 1
BUILD_MINOR: 2
-BUILD_ID: 16
+BUILD_ID: 18
BUILD_VERSION: ${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID}
BUILD: ${PROJECT}.${BUILD_VERSION}
VERSION: ${BUILD} ${DSTAMP}
View
@@ -582,6 +582,7 @@
<fileset dir="${SRC_DIR}" includes="common/__setArray__.js" />
<fileset dir="${SRC_DIR}" includes="common/__trim__.js" />
<fileset dir="${SRC_DIR}" includes="xhr/document.js" />
+ <fileset dir="${SRC_DIR}" includes="xhr/a.js" />
<fileset dir="${SRC_DIR}" includes="xhr/form.js" />
<fileset dir="${SRC_DIR}" includes="xhr/location.js" />
<fileset dir="${SRC_DIR}" includes="xhr/xmlhttprequest.js" />
View
@@ -1,57 +1,10 @@
/**
* @author thatcher
*/
-load('lib/env.rhino.js');
-load('lib/jquery-1.4.2.js');
-load('local_settings.js');
-
-// All we are using to geocode the record is the item title
-// and in particular the last 4 parts of the comma separted
-// title parts
-function get_item_title(i){
- var title;
- $.ajax({
- url:XMLDB_HHH_DUMP,
- contentType:'application/xml',
- dataType:'xml',
- type:'get',
- data:{
- _query: '/collection/document/item_title',
- _howmany: 1,
- _wrap: false,
- _start: i
- },
- async: false,
- success: function(xml){
- title = $(xml).text();
- console.log('item %s title %s', i ,title);
- }
- });
- return title;
-};
+load('dist/env.rhino.js');
+load('plugins/jquery.js');
-function get_document_id(i){
- var id;
- $.ajax({
- url:XMLDB_HHH_DUMP,
- contentType:'application/xml',
- dataType:'xml',
- type:'get',
- data:{
- _query: '/collection/document/document_id',
- _howmany: 1,
- _wrap: false,
- _start: i
- },
- async: false,
- success: function(xml){
- id = $(xml).text();
- console.log('document %s id %s', i ,id);
- }
- });
- return id;
-};
function geocode_by_title(title, id){
@@ -75,8 +28,9 @@ function geocode_by_title(title, id){
async: false,
success: function(json_text){
//save it out to flat file
- var flat_file = Envjs.uri(DATADIR_HHH + id + '.json');
- Envjs.writeToFile(json_text, flat_file);
+ //var flat_file = Envjs.uri(DATADIR_HHH + id + '.json');
+ //Envjs.writeToFile(json_text, flat_file);
+ console.log('%s', json_text);
geocode = JSON.parse(json_text);
console.log('got geocodes for %s %s', title, geocode.status);
}
@@ -89,29 +43,45 @@ $(function(){
var current_item_title,
current_document_id,
current_post;
+
+ console.log('beginning geocoding of %s', PICTURES);
//create the domain just in case its not create yet
+
$.ajax({
- url:JSONDB_HHH,
+ url:GEOCODES,
contentType:'application/json',
dataType:'json',
type:'put',
async: false,
success: function(){
- console.log('created domain %s', JSONDB_HHH);
+ console.log('created domain %s', GEOCODES);
},
error: function(xhr, status, e){
- console.log('failed to create domain', JSONDB_HHH);
+ console.log('failed to create domain', GEOCODES);
},
beforeSend: function(xhr){
xhr.setRequestHeader('Content-Length', 0);
}
});
+
+ $.ajax({
+ url: PICTURES,
+ async: false,
+ dataType: 'json',
+ success: function(response){
+ RESULTS = response.results;
+ },
+ error: function(xhr, status, e){
+ console.log('failed to load pictures to geocode %s', e);
+ }
+ });
+
// now crawl our xmldb
- for(var i = GEOCODE_HHH_START; i <= GEOCODE_HHH_END; i++){
+ for(var i = 0; i < GEOCODE_COUNT; i++){
try{
- current_document_id = get_document_id(i);
- current_item_title = get_item_title(i);
+ current_document_id = RESULTS[i].pk;
+ current_item_title = RESULTS[i].title;
geocode = geocode_by_title(
current_item_title,
current_document_id
@@ -133,10 +103,10 @@ $(function(){
};
current_post = JSON.stringify(current_post, null, '');
$.ajax({
- url: JSONDB_HHH + '/' + current_document_id + '-' + index,
+ url: GEOCODES + '/' + current_document_id + '-' + index,
contentType: 'application/json',
dataType:'json',
- type:'post',
+ type:'put',
async: false,
data: current_post,
success: function(){
@@ -150,7 +120,7 @@ $(function(){
}else if(geocode.status == "OVER_QUERY_LIMIT"){
console.log(
'over query limit [start %i] [current %s]',
- GEOCODE_HHH_START,
+ GEOCODE_START,
i
);
break;
@@ -162,10 +132,10 @@ $(function(){
};
current_post = JSON.stringify(current_post, null, '');
$.ajax({
- url: JSONDB_HHH + '/' + current_document_id,
+ url: GEOCODES + '/' + current_document_id,
contentType: 'application/json',
dataType:'json',
- type:'post',
+ type:'put',
async: false,
data: current_post,
success: function(){
@@ -184,4 +154,15 @@ $(function(){
});
-window.location = 'http://localhost:8001/eup/';
+var GEOCODES = 'http://localhost:8080/rest/geocodes',
+ GEOCODE_START = 5,
+ GEOCODE_COUNT = 100,
+ RESULTS = [],
+ PICTURES = 'http://www.loc.gov/pictures/collection/hh/search?q'+
+ '&sp='+GEOCODE_START+
+ '&c='+GEOCODE_COUNT+
+ '&fo=json'+
+ '&at=results';
+
+
+window.location = 'http://www.loc.gov/pictures/';
@@ -16,13 +16,13 @@ var readStyle='style-newspaper',
readMargin='margin-medium',
start = new Date().getTime(),
docs = {
- /*'http://www.loc.gov/pictures/collection/bbc/background.html':'background.html',
+ 'http://www.loc.gov/pictures/collection/bbc/background.html':'background.html',
'http://www.loc.gov/pictures/collection/bbc/bibliographies.html':'bibliographies.html',
'http://www.loc.gov/pictures/collection/bbc/cataloging.html': 'cataloging.html',
'http://www.loc.gov/pictures/collection/bbc/digitizing.html': 'digitizing.html',
'http://www.loc.gov/pictures/collection/bbc/sets.html': 'sets.html',
- 'http://www.loc.gov/pictures/collection/bbc/tinker_evers_chance.html': 'tinkers_evers_chance.html'*/
- 'http://timesofindia.indiatimes.com/india/Railways-rot-as-Mamata-plays-politics-in-Bengal/articleshow/6193608.cms': '6193608.html'
+ 'http://www.loc.gov/pictures/collection/bbc/tinker_evers_chance.html': 'tinkers_evers_chance.html'
+ /*'http://timesofindia.indiatimes.com/india/Railways-rot-as-Mamata-plays-politics-in-Bengal/articleshow/6193608.cms': '6193608.html'*/
/*'http://www.articlesbase.com/communication-articles/difference-between-analog-and-digital-69824.html': 'article1.html'*/
};
View
@@ -9,7 +9,7 @@ function scrape(url, links){
// scrape text from current document which we will
// assign weights to in our search index
var data = {
- $id: encodeURIComponent(url),
+ $id: encodeURIComponent(url.replace('/','_')),
url: url,
full_text: $(document.body).text(),
title: document.title,
@@ -22,23 +22,27 @@ function scrape(url, links){
// already have in our link array
$('a[href]').each(function(){
var href = $(this).attr('href');
- if($.inArray(href, links) == -1 && !href.match(/^(\s)*http|#/)){
+ if($.inArray(href, links) == -1 && !href.match(/^(\s)*http|#|mailto:/)){
//we only want to crawl local links
+ console.log('adding seed %s', href);
links.push(href);
}
});
// save the record to our index
$.ajax({
- url:'http://localhost:8080/rest/index/'+data.$id,
+ url:'http://localhost:8080/rest/crawl/'+data.$id,
contentType:'application/json',
dataType:'json',
- type: 'post',
+ type: 'put',
async: false,
data: JSON.stringify(data),
processData: false,
- success: function(){
- console.log('indexed document %s', url);
+ success: function(response){
+ console.log('crawled document %s', url);
+ },
+ error: function(xhr, status, e){
+ console.log('failed to save crawled document %s', data.$id);
}
});
}
@@ -47,26 +51,26 @@ $(function(){
// delete the index to start fresh
$.ajax({
- url:'http://localhost:8080/rest/index/',
+ url:'http://localhost:8080/rest/crawl/',
contentType:'application/json',
dataType:'json',
type:'delete',
async: false,
success: function(){
- console.log('deleted search index');
+ console.log('deleted crawl domain');
}
});
// create the search index we will populate with
// our simple crawl
$.ajax({
- url:'http://localhost:8080/rest/index/',
+ url:'http://localhost:8080/rest/crawl/',
contentType:'application/json',
dataType:'json',
type:'put',
async: false,
success: function(){
- console.log('created search index');
+ console.log('created crawl domain');
}
});
@@ -92,4 +96,4 @@ $(function(){
});
-window.location = 'http://localhost:8080/';
+window.location = 'http://www.recordsofexistence.com/';
@@ -0,0 +1,17 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd">
+
+<html lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <title></title>
+ <meta name="generator" content="Studio 3 http://aptana.com/">
+ <meta name="author" content="Christopher Thatcher">
+ <!-- Date: 2010-07-28 -->
+</head>
+<body id="form_tests">
+ <form id='form_test_1' method='get' action='links.html'>
+ <input name='foo' type='text' value='abc'/>
+ </form>
+</body>
+</html>
@@ -46,6 +46,6 @@ <h2 id="qunit-userAgent"></h2>
a side effect.
-->
</div>
-
+ <iframe id='window_exchange_tests' src='forms.html'></iframe>
</body>
</html>
@@ -0,0 +1,16 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd">
+
+<html lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <title></title>
+ <meta name="generator" content="Studio 3 http://aptana.com/">
+ <meta name="author" content="Christopher Thatcher">
+ <!-- Date: 2010-07-28 -->
+</head>
+<body id="link_tests">
+ <a id="local_link" href="#foo">local link</a>
+ <a id="link_test_1" href="forms.html">forms</a>
+</body>
+</html>
View
@@ -542,6 +542,7 @@ test('window.getComputedStyle', function() {
});
+
/**
* Not sure where this goes, since it needs the parser
*/
@@ -579,3 +580,34 @@ test('Document Named Element Lookup', function(){
ok(!doc.foo, 'old named element not found via named lookup');
});
+
+test('Default Browser Events - Form method "get"', function(){
+ var windowExchangeTests = document.getElementById('window_exchange_tests');
+ ok(windowExchangeTests, 'window_exchange_tests frame available');
+
+ windowExchangeTests.onload = function(){
+ ok(windowExchangeTests.contentDocument.getElementById('link_tests'), 'new page loaded');
+ start();
+ }
+
+ var formTest1 = windowExchangeTests.contentDocument.getElementById('form_test_1');
+ formTest1.submit();
+ stop();
+
+});
+
+
+test('Default Browser Events - Remote Link 1', function(){
+ var windowExchangeTests = document.getElementById('window_exchange_tests');
+ ok(windowExchangeTests, 'window_exchange_tests frame available');
+
+ windowExchangeTests.onload = function(){
+ ok(windowExchangeTests.contentDocument.getElementById('form_tests'), 'new page loaded');
+ start();
+ }
+
+ var linkTest1 = windowExchangeTests.contentDocument.getElementById('link_test_1');
+ linkTest1.click();
+ stop();
+
+});
View
@@ -133,3 +133,5 @@ test('HTMLParser document.writeln', function(){
ok(document.getElementById('writeln'), 'document.writeln created a div during parsing');
});
+
+
@@ -35,7 +35,7 @@ __extend__(DOMParser.prototype,{
// but simpler one seems to be ok
// xmlstring = xmlstring.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, "");
//
- xmlstring = xmlstring.replace(/<\?xml.*\?>/);
+ xmlstring = xmlstring.replace(/<\?xml.*\?>/, '');
e4 = new XMLList(xmlstring);
Oops, something went wrong.

0 comments on commit a46fe6b

Please sign in to comment.