# # Copyright (C) 2007 Mobio Networks, Inc. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # =begin note that we require use of the new Mobio config yml schema created by Lars and documented at http://opssrv01/wiki/index.php/Mobio_Rails_Application_Framework_2.0#Use_Config_Manager =end if MOBIO_CONFIG['ad_network'] adlib="rmobio/ads/" + MOBIO_CONFIG['ad_network'] else adlib='rmobio/ads/' + 'no_network' end require adlib eval("include " + adlib.camelize) # above included functions do get_ad to just retrieve an ad from a backend network # call below gets an ad from the hosted ads service for a specified page and app # # Parameters: # * :service - the URL of the service, defaults to the URL specified in MOBIO_CONFIG # * :app - the name of the application # * :page - the specified page in the application # # Returns def get_ad_from_service service=params[:service] service||=MOBIO_CONFIG['ad_service'] service||='http://homer.qa.mobiolabs.com/hub/ads/pages' service=service + "?" adurl=service+"app=" + params[:app] if params[:app] adurl=adurl+"&" if params[:app] and params[:page] adurl=service+"page="+params[:page] if params[:page] text=nil begin text=open(adurl).read rescue logger.info "Failed to open ad url: " + $! end if text doc=XmlSimple.xml_in(adtext) @linktext=doc["linktext"][0] @linkurl=doc["linkurl"][0] @phonetext=doc["calltext"][0] @phone=doc["callurl"][0] @moretext=doc["moretext"][0] logger.info("Ad Url: " + @urltext + "(" + @adurl + "): " + @extratext) if @urltext logger.info("Ad phone: " + @phonetext + "(" + @phone + ")") if @phonetext and @phone end end