mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 16:54:08 +00:00
Merge branch 'staged' into dev
This commit is contained in:
commit
ff5d82d7af
2
.github/workflows/AutoTag.yml
vendored
2
.github/workflows/AutoTag.yml
vendored
|
@ -22,7 +22,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
version: 22.9.24
|
||||
version: 22.11.24
|
||||
version-suffix: alpha
|
||||
prerelease: true
|
||||
|
||||
|
|
2
.github/workflows/macos-6.x.yml
vendored
2
.github/workflows/macos-6.x.yml
vendored
|
@ -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
|
||||
|
||||
|
|
2
.github/workflows/macos-homebrew.yml
vendored
2
.github/workflows/macos-homebrew.yml
vendored
|
@ -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:
|
||||
|
|
2
.github/workflows/macos.yml
vendored
2
.github/workflows/macos.yml
vendored
|
@ -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
|
||||
|
||||
|
|
2
.github/workflows/ubuntu-6.2.yml
vendored
2
.github/workflows/ubuntu-6.2.yml
vendored
|
@ -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:
|
||||
|
|
2
.github/workflows/ubuntu.yml
vendored
2
.github/workflows/ubuntu.yml
vendored
|
@ -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:
|
||||
|
|
4
.github/workflows/windows-6.x-xapian.yml
vendored
4
.github/workflows/windows-6.x-xapian.yml
vendored
|
@ -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:
|
||||
|
|
4
.github/workflows/windows-6.x.yml
vendored
4
.github/workflows/windows-6.x.yml
vendored
|
@ -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:
|
||||
|
|
2
.github/workflows/windows.yml
vendored
2
.github/workflows/windows.yml
vendored
|
@ -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
|
||||
# 步骤
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ public:
|
|||
void addWhitelist(QString host);
|
||||
bool existedInWhitelist(QString host);
|
||||
static GlobalBroadcaster * instance();
|
||||
unsigned currentGroupId;
|
||||
|
||||
signals:
|
||||
void dictionaryChanges( ActiveDictIds ad );
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
63
zim.cc
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue