1 //base remote search obj
4 "mwe-imported_from" : "$1 imported from [$2 $3]. See the original [$4 resource page] for more information."
6 // @key is name of rObj variable
7 // @value is where to find the value in the item xml
10 // . indicates multiple tags @ seperates the tag from attribute list
11 // {.}tag_name@{attribute1|attribute12}
12 // @@todo should probably switch this over to something like Xpath if we end up parsing a lot of rss formats
13 var rsd_default_rss_item_mapping = {
14 'poster' : 'media:thumbnail@url',
15 'roe_url' : 'media:roe_embed@url',
16 'person' : 'media:person@label|url',
17 'parent_clip':'media:parent_clip@url',
18 'bill' : 'media:bill@label|url',
21 'desc' : 'description',
23 'category' : '.media:category@label|url'
26 var baseRemoteSearch = function(iObj) {
27 return this.init(iObj);
29 baseRemoteSearch.prototype = {
36 //default search result values for paging:
43 init: function( iObj ){
44 js_log('mvBaseRemoteSearch:init');
50 getSearchResults:function(){
51 //empty out the current results before issuing a request
53 //do global getSearchResults bindings
54 this.last_query = $j('#rsd_q').val();
55 this.last_offset = this.cp.offset;
56 //@@todo its possible that video rss is the "default" format we could put that logic here:
59 * Parses and adds video rss based input format
60 * @param $data XML data to parse
61 * @param provider_url the source url (used to generate absolute links)
63 addRSSData:function( data , provider_url ){
64 js_log('f:addRSSData');
69 pUrl = parseUri( provider_url );
70 http_host = pUrl.protocol +'://'+ pUrl.authority;
71 http_path = pUrl.directory;
73 var items = data.getElementsByTagName('item');
74 //js_log('found ' + items.length );
75 $j.each(items, function(inx, item){
77 for(var i in rsd_default_rss_item_mapping){
78 var selector = rsd_default_rss_item_mapping[i].split('@');
80 var flag_multiple = ( selector[0].substr(0,1) == '.' ) ? true : false;
82 rObj[i] = new Array();
83 var tag_name = selector[0].substr(1);
85 var tag_name = selector[0];
89 if( typeof selector[1] != 'undefined'){
90 attr_name = selector[1];
91 if( attr_name.indexOf('|') != -1 )
92 attr_name = attr_name.split('|');
95 $j.each( item.getElementsByTagName( tag_name ), function ( inx, node ){
97 if( node!=null && attr_name == null ){
98 if( node.childNodes[0] != null){
99 //trim and strip html:
100 tag_val = $j.trim( node.firstChild.nodeValue ).replace(/(<([^>]+)>)/ig,"");
103 if( node!=null && attr_name != null){
104 if( typeof attr_name == 'string' ){
105 tag_val = $j.trim( $j( node ).attr( attr_name ) );
108 for( var j in attr_name ){
109 if( $j(node).attr( attr_name[j] ).length != 0)
110 attr_vals[ attr_name[j] ] = $j.trim( $j(node).attr( attr_name[j]) ).replace(/(<([^>]+)>)/ig,"");
112 tag_val = attr_vals ;
116 rObj[i].push( tag_val)
123 } // done with property loop
126 //make relative urls absolute:
127 var url_param = new Array('src', 'poster');
128 for(var j=0; j < url_param.length; j++){
129 var p = url_param[j];
130 if(typeof rObj[p] != 'undefined'){
131 if( rObj[p].substr(0,1)=='/' ){
132 rObj[p] = http_host + rObj[p];
134 if( parseUri( rObj[i] ).host == rObj[p]){
135 rObj[p] = http_host + http_path + rObj[p];
139 //force a mime type for now.. in the future generalize for other RSS feeds and conversions
140 rObj['mime'] = 'video/ogg';
141 //add pointer to parent search obj:( this.cp.limit )? this.cp.limit : this.limit,
143 rObj['pSobj'] = _this;
144 //add the result to the result set:
145 _this.resultsObj[ inx ] = rObj;
149 //by default just return the existing image with callback
150 getImageObj:function( rObj, size, callback){
151 callback( {'url':rObj.poster} );
153 //by default just return the rObj.desc
154 getInlineDescWiki:function( rObj ){
155 //return striped html & trim white space
157 return $j.trim( rObj.desc.replace(/(<([^>]+)>)/ig,"") );
161 //default license permission wiki text is cc based template mapping (does not confirm the templates actually exist)
162 getPermissionWikiTag: function( rObj ){
164 return '';//no license info
165 //check that its a defined creative commons licnese key:
166 if( this.rsd.licenses.cc.licenses[ rObj.license.key ] != 'undefined' ){
167 return '{{Cc-' + rObj.license.key + '}}';
168 }else if( rObj.license.lurl ) {
169 return '{{Template:External_License|' + rObj.license.lurl + '}}';
173 getImportResourceDescWiki:function(rObj){
174 return gM('mwe-imported_from', [rObj.title, this.cp.homepage, this.cp.title, rObj.link]);
176 //for thigns like categories and the like
177 getExtraResourceDescWiki:function( rObj ){
180 //by default just return the poster (clients can overide)
181 getImageTransform:function(rObj, opt){
184 getEmbedObjParsedInfo:function(rObj, eb_id){
187 getEmbedTimeMeta:function(rObj, callback){
190 getEmbedWikiCode:function(rObj){
191 var layout = ( rObj.layout)? rObj.layout:"right"
192 var o= '[[' + this.rsd.cFileNS + ':' + rObj.target_resource_title + '|thumb|'+layout;
194 if(!rObj.target_width && rObj.width){
195 rObj.target_width = (rObj.width < 640)? rObj.width: '640';
198 if(rObj.target_width)
199 o+='|' + rObj.target_width + 'px';
201 if( rObj.inlineDesc )
202 o+='|' + rObj.inlineDesc;
207 updateTargetResourceTitle:function(rObj){
208 rObj.target_resource_title = rObj.titleKey.replace(/File:|Image:/,'');
209 rObj.target_resource_title = this.cp.resource_prefix + rObj.target_resource_title;
211 updateDataForImport:function( rObj ){