mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
Merge branch 'Original' into Qt4x5
This commit is contained in:
commit
3275bc462c
|
@ -20,7 +20,7 @@ This code has been run and tested on Windows XP/Vista/7, Ubuntu Linux, Mac OS X.
|
|||
sudo apt-get install git pkg-config build-essential qt4-qmake \
|
||||
libvorbis-dev zlib1g-dev libhunspell-dev x11proto-record-dev \
|
||||
libqt4-dev libqtwebkit-dev libxtst-dev liblzo2-dev libbz2-dev \
|
||||
libao-dev libavutil-dev libavformat-dev libtiff5-dev libeb-dev
|
||||
libao-dev libavutil-dev libavformat-dev libtiff5-dev libeb16-dev
|
||||
|
||||
## How to build
|
||||
|
||||
|
|
|
@ -748,7 +748,7 @@ between classic and school orthography in cyrillic)</source>
|
|||
<message>
|
||||
<location filename="../dictserver.cc" line="254"/>
|
||||
<source>Server databases</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Bases de données serveur</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
|
13
mediawiki.cc
13
mediawiki.cc
|
@ -370,10 +370,11 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r )
|
|||
|
||||
// audio url
|
||||
articleString.replace( QRegExp( "<a\\s+href=\"(//upload\\.wikimedia\\.org/wikipedia/commons/[^\"'&]*\\.ogg)" ),
|
||||
QString::fromStdString( addAudioLink( "\"http:\\1\"",this->dictPtr->getId() )+ "<a href=\"http:\\1" ) );
|
||||
QString::fromStdString( addAudioLink( string( "\"" ) + wikiUrl.scheme().toStdString() + ":\\1\"",
|
||||
this->dictPtr->getId() ) + "<a href=\"" + wikiUrl.scheme().toStdString() + ":\\1" ) );
|
||||
|
||||
// Add "http:" to image source urls
|
||||
articleString.replace( " src=\"//", " src=\"http://" );
|
||||
// Add url scheme to image source urls
|
||||
articleString.replace( " src=\"//", " src=\"" + wikiUrl.scheme() + "://" );
|
||||
//fix src="/foo/bar/Baz.png"
|
||||
articleString.replace( "src=\"/", "src=\"" + wikiUrl.toString() +"/" );
|
||||
|
||||
|
@ -381,9 +382,9 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r )
|
|||
articleString.replace( QRegExp( "<a\\shref=\"/([\\w\\.]*/)*" ), "<a href=\"" );
|
||||
|
||||
//fix audio
|
||||
articleString.replace( QRegExp("<button\\s+[^>]*(upload\\.wikimedia\\.org/wikipedia/commons/[^\"'&]*\\.ogg)[^>]*>\\s*<[^<]*</button>"),
|
||||
QString::fromStdString(addAudioLink("\"http://\\1\"",this->dictPtr->getId())+
|
||||
"<a href=\"http://\\1\"><img src=\"qrcx://localhost/icons/playsound.png\" border=\"0\" alt=\"Play\"></a>"));
|
||||
articleString.replace( QRegExp( "<button\\s+[^>]*(upload\\.wikimedia\\.org/wikipedia/commons/[^\"'&]*\\.ogg)[^>]*>\\s*<[^<]*</button>"),
|
||||
QString::fromStdString(addAudioLink( string( "\"" ) + wikiUrl.scheme().toStdString() + "://\\1\"", this->dictPtr->getId() ) +
|
||||
"<a href=\"" + wikiUrl.scheme().toStdString() + "://\\1\"><img src=\"qrcx://localhost/icons/playsound.png\" border=\"0\" alt=\"Play\"></a>" ) );
|
||||
// In those strings, change any underscores to spaces
|
||||
for( ; ; )
|
||||
{
|
||||
|
|
|
@ -49,7 +49,7 @@ bool WebMultimediaDownload::isAudioUrl( QUrl const & url )
|
|||
{
|
||||
// Note: we check for forvo sound links explicitly, as they don't have extensions
|
||||
|
||||
return url.scheme() == "http" && (
|
||||
return ( url.scheme() == "http" || url.scheme() == "https" ) && (
|
||||
Filetype::isNameOfSound( url.path().toUtf8().data() ) || url.host() == "apifree.forvo.com" );
|
||||
}
|
||||
|
||||
|
|
43
zim.cc
43
zim.cc
|
@ -423,6 +423,8 @@ quint32 readArticle( ZimFile & file, ZIM_header & header, quint32 articleNumber,
|
|||
|
||||
class ZimDictionary: public BtreeIndexing::BtreeDictionary
|
||||
{
|
||||
enum LINKS_TYPE { UNKNOWN, SLASH, NO_SLASH };
|
||||
|
||||
Mutex idxMutex;
|
||||
Mutex zimMutex, idxResourceMutex;
|
||||
File::Class idx;
|
||||
|
@ -432,6 +434,7 @@ class ZimDictionary: public BtreeIndexing::BtreeDictionary
|
|||
ZimFile df;
|
||||
ZIM_header zimHeader;
|
||||
set< quint32 > articlesIndexedForFTS;
|
||||
LINKS_TYPE linksType;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -512,7 +515,8 @@ ZimDictionary::ZimDictionary( string const & id,
|
|||
BtreeDictionary( id, dictionaryFiles ),
|
||||
idx( indexFile, "rb" ),
|
||||
idxHeader( idx.read< IdxHeader >() ),
|
||||
df( FsEncoding::decode( dictionaryFiles[ 0 ].c_str() ) )
|
||||
df( FsEncoding::decode( dictionaryFiles[ 0 ].c_str() ) ),
|
||||
linksType( UNKNOWN )
|
||||
{
|
||||
// Open data file
|
||||
|
||||
|
@ -632,11 +636,48 @@ string ZimDictionary::convert( const string & in )
|
|||
if ( !list[4].isEmpty() ) // a title, ex: title="Precambrian/Chaotian"
|
||||
tag = list[4].split("\"")[1];
|
||||
|
||||
|
||||
// Check type of links inside articles
|
||||
if( linksType == UNKNOWN && tag.indexOf( '/' ) >= 0 )
|
||||
{
|
||||
QString word = QUrl::fromPercentEncoding( tag.toLatin1() );
|
||||
word.remove( QRegExp( "\\.(s|)htm(l|)$", Qt::CaseInsensitive ) ).
|
||||
replace( "_", " " );
|
||||
|
||||
vector< WordArticleLink > links;
|
||||
links = findArticles( gd::toWString( word ) );
|
||||
|
||||
if( !links.empty() )
|
||||
{
|
||||
linksType = SLASH;
|
||||
}
|
||||
else
|
||||
{
|
||||
word.remove( QRegExp(".*/") );
|
||||
links = findArticles( gd::toWString( word ) );
|
||||
if( !links.empty() )
|
||||
{
|
||||
linksType = NO_SLASH;
|
||||
links.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( linksType == SLASH || linksType == UNKNOWN )
|
||||
{
|
||||
tag.remove( QRegExp( "\\.(s|)htm(l|)$", Qt::CaseInsensitive ) ).
|
||||
replace( "_", "%20" ).
|
||||
prepend( "<a href=\"gdlookup://localhost/" ).
|
||||
append( "\" " + list[4] + ">" );
|
||||
}
|
||||
else
|
||||
{
|
||||
tag.remove( QRegExp(".*/") ).
|
||||
remove( QRegExp( "\\.(s|)htm(l|)$", Qt::CaseInsensitive ) ).
|
||||
replace( "_", "%20" ).
|
||||
prepend( "<a href=\"gdlookup://localhost/" ).
|
||||
append( "\" " + list[4] + ">" );
|
||||
}
|
||||
|
||||
text.replace( pos, list[0].length(), tag );
|
||||
pos += tag.length() + 1;
|
||||
|
|
Loading…
Reference in a new issue