Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * footer_generator.cpp - Generator of page footer 00004 * 00005 * Created: Sun Aug 30 14:40:26 2009 00006 * Copyright 2006-2009 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * Read the full text in the LICENSE.GPL file in the doc directory. 00021 */ 00022 00023 #include "footer_generator.h" 00024 00025 #include <core/version.h> 00026 #include <utils/misc/string_conversions.h> 00027 00028 /** @class WebviewFooterGenerator "footer_generator.h" 00029 * Webview page footer. 00030 * Custom page header that shows other webview instances found on the net 00031 * via mDNS-SD. 00032 * @author Tim Niemueller 00033 */ 00034 00035 /** Constructor. 00036 * @param service_browser service browser used to add links to other Webview 00037 * instances. 00038 */ 00039 WebviewFooterGenerator::WebviewFooterGenerator(WebviewServiceBrowseHandler *service_browser) 00040 { 00041 __service_browser = service_browser; 00042 } 00043 00044 00045 std::string 00046 WebviewFooterGenerator::html_footer() 00047 { 00048 std::string f = std::string("\n <div id=\"footer\">\n") 00049 + " <hr />\n"; 00050 00051 f += " <div id=\"version\"><a href=\"http://www.fawkesrobotics.org\" " 00052 "rel=\"external\">Fawkes "; 00053 f += FAWKES_VERSION_STRING; 00054 f += "</a></div>\n"; 00055 WebviewServiceBrowseHandler::ServiceList sl = __service_browser->service_list(); 00056 if (! sl.empty()) { 00057 f += " <div class=\"instances\"><ul>"; 00058 WebviewServiceBrowseHandler::ServiceList &sl = __service_browser->service_list(); 00059 WebviewServiceBrowseHandler::ServiceList::iterator i; 00060 for (i = sl.begin(); i != sl.end(); ++i) { 00061 std::string short_host = i->second->host(); 00062 std::string::size_type s = short_host.find("."); 00063 if (s != std::string::npos) short_host = short_host.substr(0, s); 00064 00065 f += std::string("<li><a href=\"http://") + i->second->host() + ":" 00066 + fawkes::StringConversions::to_string(i->second->port()) + "/\"" 00067 + " title=\"" + i->first + "\">" 00068 + short_host + "</a></li>"; 00069 } 00070 f += "</ul></div>\n"; 00071 } 00072 f += " </div>"; 00073 f += "\n </body>\n"; 00074 f += "</html>\n"; 00075 00076 return f; 00077 }