Merge branch 'staged' into dev

This commit is contained in:
Xiao YiFang 2022-11-24 20:34:56 +08:00
commit ff5d82d7af
14 changed files with 70 additions and 34 deletions

View file

@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
env:
version: 22.9.24
version: 22.11.24
version-suffix: alpha
prerelease: true

View file

@ -29,7 +29,7 @@ jobs:
qt_arch: [clang_64]
env:
targetName: GoldenDict
version: 22.9.24
version: 22.11.24
version-suffix: alpha
prerelease: true

View file

@ -26,7 +26,7 @@ jobs:
qt_arch: [clang_64]
env:
targetName: GoldenDict
version: 22.9.24
version: 22.11.24
version-suffix: alpha
prerelease: true
steps:

View file

@ -30,7 +30,7 @@ jobs:
qt_arch: [clang_64]
env:
targetName: GoldenDict
version: 22.9.24
version: 22.11.24
version-suffix: alpha
prerelease: true

View file

@ -30,7 +30,7 @@ jobs:
qt_ver: [6.3.2,6.4.1]
qt_arch: [gcc_64]
env:
version: 22.9.24
version: 22.11.24
version-suffix: alpha
prerelease: true
steps:

View file

@ -30,7 +30,7 @@ jobs:
qt_ver: [5.15.2]
qt_arch: [gcc_64]
env:
version: 22.9.24
version: 22.11.24
version-suffix: alpha
prerelease: true
steps:

View file

@ -27,11 +27,11 @@ jobs:
strategy:
matrix:
os: [windows-2019]
qt_ver: [6.3.2,6.4.1]
qt_ver: [6.3.2]
qt_arch: [win64_msvc2019_64]
env:
targetName: GoldenDict.exe
version: 22.9.24
version: 22.11.24
version-suffix: alpha
prerelease: true
steps:

View file

@ -27,11 +27,11 @@ jobs:
strategy:
matrix:
os: [windows-2019]
qt_ver: [6.3.2,6.4.1]
qt_ver: [6.3.2]
qt_arch: [win64_msvc2019_64]
env:
targetName: GoldenDict.exe
version: 22.9.24
version: 22.11.24
version-suffix: alpha
prerelease: true
steps:

View file

@ -32,7 +32,7 @@ jobs:
qt_arch: [win64_msvc2019_64]
env:
targetName: GoldenDict.exe
version: 22.9.24
version: 22.11.24
version-suffix: alpha
prerelease: true
# 步骤

View file

@ -170,14 +170,9 @@ QNetworkReply * ArticleNetworkAccessManager::getArticleReply( QNetworkRequest co
if( !path.isEmpty() )
{
url.setPath( "" );
QByteArray referer = req.rawHeader( "Referer" );
QUrl refererUrl = QUrl::fromEncoded( referer );
Utils::Url::addQueryItem( url, "word", path.mid( 1 ) );
if( Utils::Url::hasQueryItem( refererUrl, "group" ) )
{
Utils::Url::addQueryItem( url, "group", Utils::Url::queryItemValue( refererUrl, "group" ) );
}
Utils::Url::addQueryItem( url, "group", QString::number(GlobalBroadcaster::instance()->currentGroupId ) );
}
}
@ -318,7 +313,7 @@ sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource(
bool ignoreDiacritics = Utils::Url::queryItemValue( url, "ignore_diacritics" ) == "1";
if ( phrase.isValid() ) // Require group and phrase to be passed
if ( groupIsValid && phrase.isValid() ) // Require group and phrase to be passed
return articleMaker.makeDefinitionFor( phrase, group, contexts, mutedDicts, QStringList(), ignoreDiacritics );
}

View file

@ -25,6 +25,7 @@ public:
void addWhitelist(QString host);
bool existedInWhitelist(QString host);
static GlobalBroadcaster * instance();
unsigned currentGroupId;
signals:
void dictionaryChanges( ActiveDictIds ad );

View file

@ -1,6 +1,6 @@
TEMPLATE = app
TARGET = goldendict
VERSION = 22.9.24-alpha
VERSION = 22.11.24-alpha
# Generate version file. We do this here and in a build rule described later.
# The build rule is required since qmake isn't run each time the project is
@ -89,7 +89,7 @@ win32 {
win32-msvc* {
# VS does not recognize 22.number.alpha,cause errors during compilation under MSVC++
VERSION = 22.9.24
VERSION = 22.11.24
DEFINES += __WIN32 _CRT_SECURE_NO_WARNINGS
contains(QMAKE_TARGET.arch, x86_64) {
DEFINES += NOMINMAX __WIN64

View file

@ -572,6 +572,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
igrp->checkMutedDictionaries( &grp->mutedDictionaries );
dictionaryBar.setMutedDictionaries( grp ? &grp->mutedDictionaries : 0 );
}
GlobalBroadcaster::instance()->currentGroupId = cfg.lastMainGroupId;
showDictBarNamesTriggered(); // Make update its state according to initial
// setting
@ -2323,6 +2324,10 @@ void MainWindow::currentGroupChanged( int )
dictionaryBar.setMutedDictionaries( 0 );
}
if(igrp){
GlobalBroadcaster::instance()->currentGroupId = cfg.lastMainGroupId;
}
updateDictionaryBar();
// Update word search results

63
zim.cc
View file

@ -128,7 +128,7 @@ __attribute__((packed))
enum
{
Signature = 0x584D495A, // ZIMX on little-endian, XMIZ on big-endian
CurrentFormatVersion = 3 + BtreeIndexing::FormatVersion + Folding::Version
CurrentFormatVersion = 4 + BtreeIndexing::FormatVersion + Folding::Version
};
struct IdxHeader
@ -839,8 +839,44 @@ string ZimDictionary::convert( const string & in )
QString( "<body \\1" ) );
// pattern of img and script
text.replace( QRegularExpression( "<\\s*(img|script)\\s+([^>]*)src=(\"|)(\\.\\./)*" ),
QString( "<\\1 \\2src=\\3bres://%1/").arg( getId().c_str() ) );
// text.replace( QRegularExpression( "<\\s*(img|script)\\s+([^>]*)src=(\")([^\"]*)\\3" ),
// QString( "<\\1 \\2src=\\3bres://%1/").arg( getId().c_str() ) );
QRegularExpression rxImgScript( "<\\s*(img|script)\\s+([^>]*)src=(\")([^\"]*)\\3" );
QRegularExpressionMatchIterator it = rxImgScript.globalMatch( text );
int pos = 0;
QString newText;
while( it.hasNext() )
{
QRegularExpressionMatch match = it.next();
newText += text.mid( pos, match.capturedStart() - pos );
pos = match.capturedEnd();
QStringList list = match.capturedTexts();
QString url = list[ 4 ]; // a url
QString urlLink = match.captured();
QString replacedLink = urlLink;
if( !url.isEmpty() && !url.startsWith( "//" ) && !url.startsWith( "http://" ) && !url.startsWith( "https://" ) )
{
//<\\1 \\2src=\\3bres://%1/
url.remove(QRegularExpression("^\\.*\\/[A-Z]\\/", QRegularExpression::CaseInsensitiveOption));
replacedLink =
QString( "<%1 %2 src=\"bres://%3/%4\"" ).arg( list[ 1 ], list[ 2 ], QString::fromStdString( getId() ), url );
}
newText += replacedLink;
}
if( pos )
{
newText += text.mid( pos );
text = newText;
}
newText.clear();
// Fix links without '"'
text.replace( QRegularExpression( "href=(\\.\\.|)/([^\\s>]+)" ),
@ -860,9 +896,8 @@ string ZimDictionary::convert( const string & in )
// these links will be translated into local definitions
// <meta http-equiv="Refresh" content="0;url=../dsalsrv02.uchicago.edu/cgi-bin/0994.html">
QRegularExpression rxLink( "<\\s*(?:a|meta)\\s+([^>]*)(?:href|url)=\"?(?!(?:\\w+://|#|mailto:|tel:))()([^\"]*)\"\\s*(title=\"[^\"]*\")?[^>]*>" );
QRegularExpressionMatchIterator it = rxLink.globalMatch( text );
int pos = 0;
QString newText;
it = rxLink.globalMatch( text );
pos = 0;
while( it.hasNext() )
{
QRegularExpressionMatch match = it.next();
@ -1485,7 +1520,7 @@ void ZimResourceRequest::run()
sptr< Dictionary::DataRequest > ZimDictionary::getResource( string const & name )
{
auto formatedName = QString::fromStdString(name).replace(RX::Zim::linkSpecialChar,"");
auto formatedName = QString::fromStdString(name).remove(QRegularExpression("^\\.*\\/[A-Z]\\/", QRegularExpression::CaseInsensitiveOption));
return new ZimResourceRequest( *this, formatedName.toStdString() );
}
@ -1658,8 +1693,10 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
}
else
{
auto formatedUrl = QString::fromStdString(url).replace(RX::Zim::linkSpecialChar,"");
indexedResources.addSingleWord( Utf8::decode( formatedUrl.toStdString() ), n );
// url.insert( url.begin(), '/' );
// url.insert( url.begin(), nameSpace );
// auto formatedUrl = QString::fromStdString(url).replace(RX::Zim::linkSpecialChar," ");
indexedResources.addSingleWord( Utf8::decode( url ), n );
}
}
else
@ -1689,16 +1726,14 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
}
}
else
if( nameSpace == 'X' )
if( nameSpace == 'X' || nameSpace=='V' || nameSpace=='U'|| nameSpace=='W' )
{
continue;
}
else
{
// url.insert( url.begin(), '/' );
// url.insert( url.begin(), nameSpace );
auto formatedUrl = QString::fromStdString(url).replace(RX::Zim::linkSpecialChar,"");
indexedResources.addSingleWord( Utf8::decode( formatedUrl.toStdString() ), n );
// auto formatedUrl = QString::fromStdString(url).replace(RX::Zim::linkSpecialChar," ");
indexedResources.addSingleWord( Utf8::decode( url ), n );
}
}