[yast-commit] r67552 - in /trunk/ncurses-pkg/src: NCPackageSelector.cc NCPackageSelector.h NCPkgPackageDetails.cc
Author: gs Date: Tue Feb 28 13:02:12 2012 New Revision: 67552 URL: http://svn.opensuse.org/viewcvs/yast?rev=67552&view=rev Log: improve createHtmlParagraphs (check for doctype tag, escape html), don't show authors label for empty list Modified: trunk/ncurses-pkg/src/NCPackageSelector.cc trunk/ncurses-pkg/src/NCPackageSelector.h trunk/ncurses-pkg/src/NCPkgPackageDetails.cc Modified: trunk/ncurses-pkg/src/NCPackageSelector.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses-pkg/src/NCPackageSelector.cc?rev=67552&r1=67551&r2=67552&view=diff ============================================================================== --- trunk/ncurses-pkg/src/NCPackageSelector.cc (original) +++ trunk/ncurses-pkg/src/NCPackageSelector.cc Tue Feb 28 13:02:12 2012 @@ -1326,9 +1326,6 @@ // // createLicenseText // - -#define DOCTYPETAG "<!-- DT:Rich -->" // Special doctype for preformatted HTML - bool NCPackageSelector::showLicensePopup( string pkgName, string license ) { string html_text = ""; Modified: trunk/ncurses-pkg/src/NCPackageSelector.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses-pkg/src/NCPackageSelector.h?rev=67552&r1=67551&r2=67552&view=diff ============================================================================== --- trunk/ncurses-pkg/src/NCPackageSelector.h (original) +++ trunk/ncurses-pkg/src/NCPackageSelector.h Tue Feb 28 13:02:12 2012 @@ -102,6 +102,8 @@ return ( toupper( c1 ) == toupper( c2 ) ); } +#define DOCTYPETAG "<!-- DT:Rich -->" // Special doctype for preformatted HTML + /////////////////////////////////////////////////////////////////// // // CLASS NAME : NCPackageSelector Modified: trunk/ncurses-pkg/src/NCPkgPackageDetails.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses-pkg/src/NCPkgPackageDetails.cc?rev=67552&r1=67551&r2=67552&view=diff ============================================================================== --- trunk/ncurses-pkg/src/NCPkgPackageDetails.cc (original) +++ trunk/ncurses-pkg/src/NCPkgPackageDetails.cc Tue Feb 28 13:02:12 2012 @@ -43,6 +43,8 @@ #include "NCPkgPackageDetails.h" #include "NCPackageSelector.h" +# include <boost/algorithm/string.hpp> + using namespace zypp; /* @@ -133,9 +135,6 @@ string text = ""; text += commonHeader( pkgPtr ); - //text += " - "; - - //text += pkgPtr->summary(); if ( slbPtr->hasBothObjects () ) { @@ -197,12 +196,15 @@ text += package->sourcePkgName(); text += "-"; text += package->sourcePkgEdition().asString(); - text += "<br>"; + //text += "<br>"; - //authors, in one line - text += NCPkgStrings::Authors(); list<string> authors = package->authors(); // zypp::Package - text += createText( authors, true ); + if ( !authors.empty() ) + { + text += NCPkgStrings::Authors(); + //authors, in one line + text += createText( authors, true ); + } } @@ -266,21 +268,38 @@ string NCPkgPackageDetails::createHtmlParagraphs( string value ) { + yuiDebug() << "Description: " << value << endl; + + // check RichText tag + if ( value.find( string(DOCTYPETAG) ) != string::npos ) + { + return value; // input is rich text + } + // escape html + boost::replace_all( value, "&", "&" ); + boost::replace_all( value, "<", "<" ); + boost::replace_all( value, ">", ">" ); + NCstring input( value ); NCtext descr( input ); NCtext html_descr( NCstring( "<p>" ) ); string description = ""; - list<NCstring>::const_iterator line; for ( line = descr.Text().begin(); line != descr.Text().end(); ++line ) { NCstring curr_line( *line ); + if ( curr_line.Str().empty() ) + { html_descr.append( NCstring("</p><p>") ); + } else + { html_descr.append( NCstring(" " + curr_line.Str()) ); + } } + html_descr.append( NCstring("</p>") ); for ( line = html_descr.Text().begin(); line != html_descr.Text().end(); ++line ) -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
gs@svn2.opensuse.org