Skip to content

Commit

Permalink
Merge branch 'staged' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyifang committed Oct 9, 2023
2 parents e7cbf9f + 3f1b43a commit 0067d19
Show file tree
Hide file tree
Showing 22 changed files with 68 additions and 333 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/macos-homebrew-PR-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,12 @@ jobs:
- name: install deps on macos
run: |
brew install pcre2 harfbuzz freetype
brew install cmake ninja python
brew install cmake ninja
brew install automake
brew install autoconf
brew install libtool
brew install opencc
# brew install speex
# brew tap homebrew-ffmpeg/ffmpeg
# brew install homebrew-ffmpeg/ffmpeg/ffmpeg --with-speex
brew install libao
brew install libiconv
brew install lzo bzip2
Expand All @@ -69,7 +65,6 @@ jobs:
wget ftp://ftp.sra.co.jp/pub/misc/eb/eb-4.4.3.tar.bz2
tar xvjf eb-4.4.3.tar.bz2
cd eb-4.4.3 && ./configure && make -j 8 && sudo make install && cd ..
#brew install qt # or use official offline installer
brew install xz lzo
brew install pkg-config
brew install libiconv
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/macos-homebrew-breakpad.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,15 @@ jobs:
- name: install deps on macos
run: |
brew install pcre2 harfbuzz freetype
brew install cmake ninja python
brew install cmake ninja
brew install automake
brew install autoconf
brew install libtool
brew install opencc
brew install speex
brew install wavpack
brew install automake fdk-aac git lame libass libtool libvorbis libvpx opus sdl shtool texi2html theora wget x264 x265 xvid nasm
brew install speex
brew tap homebrew-ffmpeg/ffmpeg
brew install homebrew-ffmpeg/ffmpeg/ffmpeg --with-speex
brew install libiconv
brew install lzo bzip2
brew install libogg
Expand Down Expand Up @@ -105,7 +100,7 @@ jobs:

- name: compile
run: |
qmake CONFIG+=release CONFIG+=no_macos_universal CONFIG+=zim_support CONFIG+=use_xapian CONFIG+=use_breakpad
qmake CONFIG+=release CONFIG+=no_macos_universal CONFIG+=zim_support CONFIG+=use_xapian CONFIG+=use_breakpad CONFIG+=no_ffmpeg_player CONFIG+=no_tts_support
make -j8
- name: package
Expand Down
14 changes: 3 additions & 11 deletions .github/workflows/macos-homebrew.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,12 @@ jobs:
- name: install deps on macos
run: |
brew install pcre2 harfbuzz freetype
brew install cmake ninja python
brew install cmake ninja
brew install automake
brew install autoconf
brew install libtool
brew install opencc
# brew install speex
brew install wavpack
brew install automake git lame libass libtool shtool texi2html theora wget xvid nasm
# brew install automake fdk-aac git lame libass libtool libvorbis libvpx opus sdl shtool texi2html theora wget x264 x265 xvid nasm
# brew tap homebrew-ffmpeg/ffmpeg
# brew options homebrew-ffmpeg/ffmpeg/ffmpeg
# brew install homebrew-ffmpeg/ffmpeg/ffmpeg --with-speex
brew install libiconv
brew install lzo bzip2
Expand All @@ -76,8 +68,8 @@ jobs:
cmake -B build -DCMAKE_BUILD_TYPE=release
cmake --build build --config release
sudo make install
find /usr/local -name libzstd.1.dylib
find /usr/local -name liblzma.5.dylib
# find /usr/local -name libzstd.1.dylib
# find /usr/local -name liblzma.5.dylib
- name: version-file
shell: bash
env:
Expand Down
23 changes: 9 additions & 14 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,16 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
# workflow_run:
# workflows: [AutoTag]
# types: [completed]
workflow_dispatch:
push:
branches:
- dev
- master
# - staged
paths-ignore:
- 'docs/**'
# - ".github/**"
- "howto/**"
- "*.md"
- ".clang-format"
# push:
# branches:
# - dev
# - master
# paths-ignore:
# - 'docs/**'
# - "howto/**"
# - "*.md"
# - ".clang-format"

jobs:
build:
Expand Down
Binary file added icons/audio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/document.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions resources.qrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<RCC>
<qresource prefix="/">
<file>icons/add-anki-icon.svg</file>
<file>icons/document.png</file>
<file>icons/audio.png</file>
<file>version.txt</file>
<file>icons/arrow.png</file>
<file>icons/prefix.png</file>
Expand Down
7 changes: 3 additions & 4 deletions src/article_maker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ body { background: #242525; }
.gdarticle { background: initial;}
.gdarticlebody img{
background: white;
background: white !important;
}
</style>
<script>
Expand Down Expand Up @@ -444,9 +444,8 @@ string ArticleMaker::makeEmptyPageHtml() const

sptr< Dictionary::DataRequest > ArticleMaker::makePicturePage( string const & url ) const
{
string const result = makeHtmlHeader( tr( "(picture)" ), QString(), true )
+ R"lit(<a href="javascript: if(history.length>2) history.go(-1)">)lit" + R"(<img src=")" + url + R"(" /></a>)"
+ "</body></html>";
string const result =
makeHtmlHeader( tr( "(picture)" ), QString(), true ) + R"(<img src=")" + url + R"(" />)" + "</body></html>";

sptr< Dictionary::DataRequestInstant > r = std::make_shared< Dictionary::DataRequestInstant >( true );

Expand Down
79 changes: 10 additions & 69 deletions src/article_netmgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,45 +62,7 @@ AllowFrameReply::AllowFrameReply( QNetworkReply * _reply ):

void AllowFrameReply::applyMetaData()
{
// Set raw headers except X-Frame-Options
QList< QByteArray > rawHeaders = baseReply->rawHeaderList();
for ( QList< QByteArray >::iterator it = rawHeaders.begin(); it != rawHeaders.end(); ++it ) {
auto headerName = it->toLower();
if ( headerName != "x-frame-options" && headerName != "content-security-policy" )
setRawHeader( *it, baseReply->rawHeader( *it ) );
}

// Set known headers
setHeader( QNetworkRequest::ContentDispositionHeader,
baseReply->header( QNetworkRequest::ContentDispositionHeader ) );
setHeader( QNetworkRequest::ContentTypeHeader, baseReply->header( QNetworkRequest::ContentTypeHeader ) );
setHeader( QNetworkRequest::ContentLengthHeader, baseReply->header( QNetworkRequest::ContentLengthHeader ) );
setHeader( QNetworkRequest::LocationHeader, baseReply->header( QNetworkRequest::LocationHeader ) );
setHeader( QNetworkRequest::LastModifiedHeader, baseReply->header( QNetworkRequest::LastModifiedHeader ) );
setHeader( QNetworkRequest::CookieHeader, baseReply->header( QNetworkRequest::CookieHeader ) );
setHeader( QNetworkRequest::SetCookieHeader, baseReply->header( QNetworkRequest::SetCookieHeader ) );
setHeader( QNetworkRequest::UserAgentHeader, baseReply->header( QNetworkRequest::UserAgentHeader ) );
setHeader( QNetworkRequest::ServerHeader, baseReply->header( QNetworkRequest::ServerHeader ) );

// Set attributes
setAttribute( QNetworkRequest::HttpStatusCodeAttribute,
baseReply->attribute( QNetworkRequest::HttpStatusCodeAttribute ) );
setAttribute( QNetworkRequest::HttpReasonPhraseAttribute,
baseReply->attribute( QNetworkRequest::HttpReasonPhraseAttribute ) );
setAttribute( QNetworkRequest::RedirectionTargetAttribute,
baseReply->attribute( QNetworkRequest::RedirectionTargetAttribute ) );
setAttribute( QNetworkRequest::ConnectionEncryptedAttribute,
baseReply->attribute( QNetworkRequest::ConnectionEncryptedAttribute ) );
setAttribute( QNetworkRequest::SourceIsFromCacheAttribute,
baseReply->attribute( QNetworkRequest::SourceIsFromCacheAttribute ) );
setAttribute( QNetworkRequest::HttpPipeliningWasUsedAttribute,
baseReply->attribute( QNetworkRequest::HttpPipeliningWasUsedAttribute ) );
setAttribute( QNetworkRequest::BackgroundRequestAttribute,
baseReply->attribute( QNetworkRequest::BackgroundRequestAttribute ) );
setAttribute( QNetworkRequest::Http2WasUsedAttribute,
baseReply->attribute( QNetworkRequest::Http2WasUsedAttribute ) );

emit metaDataChanged();
// The webengine does not support to customize the headers right now ,maybe until Qt6.7 there should be some api supports
}

void AllowFrameReply::setReadBufferSize( qint64 size )
Expand Down Expand Up @@ -135,29 +97,14 @@ void AllowFrameReply::finishedSlot()

QNetworkReply * ArticleNetworkAccessManager::getArticleReply( QNetworkRequest const & req )
{
QUrl url;
auto op = GetOperation;

if ( req.url().scheme() == "qrcx" ) {
// We had to override the local load policy for the qrc URL scheme until QWebSecurityOrigin::addLocalScheme() was
// introduced in Qt 4.6. Hence we used a custom qrcx URL scheme and redirected it here back to qrc. Qt versions
// older than 4.6 are no longer supported, so GoldenDict itself no longer uses the qrcx scheme. However, qrcx has
// been used for many years in our built-in article styles, and so may appear in user-defined article styles.
// TODO: deprecate (print a warning or show a warning message box) and eventually remove support for the obsolete
// qrcx URL scheme. A recent commit "Add support for qrc:// URL scheme" is the first one where the qrc scheme
// works correctly. So the deprecation has to wait until older GoldenDict versions become rarely used.
QUrl newUrl( req.url() );

newUrl.setScheme( "qrc" );
newUrl.setHost( "" );

QNetworkRequest newReq( req );
newReq.setUrl( newUrl );

return QNetworkAccessManager::createRequest( op, newReq, nullptr );
// Do not support qrcx which is the custom define protocol.
return new BlockedNetworkReply( this );
}

url = req.url();
auto op = GetOperation;

QUrl url = req.url();
QMimeType mineType = db.mimeTypeForUrl( url );
QString contentType = mineType.name();

Expand Down Expand Up @@ -345,13 +292,6 @@ sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource( QUrl c
}
}

if ( url.scheme() == "gdpicture" ) {
contentType = "text/html";
QUrl imgUrl( url );
imgUrl.setScheme( "bres" );
return articleMaker.makePicturePage( imgUrl.toEncoded().data() );
}

return sptr< Dictionary::DataRequest >();
}

Expand Down Expand Up @@ -418,11 +358,12 @@ qint64 ArticleResourceReply::bytesAvailable() const
if ( avail < 0 )
return 0;

if ( !req->isFinished() ) {
return 65536;
qint64 availBytes = avail - alreadyRead + QNetworkReply::bytesAvailable();
if ( availBytes == 0 && !req->isFinished() ) {
return 10240;
}

return avail - alreadyRead + QNetworkReply::bytesAvailable();
return availBytes;
}


Expand Down
3 changes: 2 additions & 1 deletion src/common/globalregex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ QRegularExpression Ftx::token( R"((".*?")|([\w\W\+\-]+))",
| QRegularExpression::CaseInsensitiveOption );
//mdx
QRegularExpression Mdx::allLinksRe( R"((?:<\s*(a(?:rea)?|img|link|script|source)(?:\s+[^>]+|\s*)>))",
//<audio src="xxx"> is also a valid url.
QRegularExpression Mdx::allLinksRe( R"((?:<\s*(a(?:rea)?|img|link|script|source|audio|video)(?:\s+[^>]+|\s*)>))",
QRegularExpression::CaseInsensitiveOption );
QRegularExpression Mdx::wordCrossLink( R"(([\s"']href\s*=)\s*(["'])entry://([^>#]*?)((?:#[^>]*?)?)\2)",
QRegularExpression::CaseInsensitiveOption );
Expand Down
7 changes: 0 additions & 7 deletions src/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1160,9 +1160,6 @@ Class load()
if ( !root.namedItem( "editDictionaryCommandLine" ).isNull() )
c.editDictionaryCommandLine = root.namedItem( "editDictionaryCommandLine" ).toElement().text();

if ( !root.namedItem( "maxPictureWidth" ).isNull() )
c.maxPictureWidth = root.namedItem( "maxPictureWidth" ).toElement().text().toInt();

if ( !root.namedItem( "maxHeadwordSize" ).isNull() ) {
unsigned int value = root.namedItem( "maxHeadwordSize" ).toElement().text().toUInt();
if ( value != 0 ) // 0 is invalid value for our purposes
Expand Down Expand Up @@ -2172,10 +2169,6 @@ void save( Class const & c )
opt.appendChild( dd.createTextNode( c.editDictionaryCommandLine ) );
root.appendChild( opt );

opt = dd.createElement( "maxPictureWidth" );
opt.appendChild( dd.createTextNode( QString::number( c.maxPictureWidth ) ) );
root.appendChild( opt );

opt = dd.createElement( "maxHeadwordSize" );
opt.appendChild( dd.createTextNode( QString::number( c.maxHeadwordSize ) ) );
root.appendChild( opt );
Expand Down
3 changes: 0 additions & 3 deletions src/config.hh
Original file line number Diff line number Diff line change
Expand Up @@ -881,8 +881,6 @@ struct Class

bool usingSmallIconsInToolbars;

int maxPictureWidth; // Maximum picture width

/// Maximum size for the headwords.
/// Bigger headwords won't be indexed. For now, only in DSL.
unsigned int maxHeadwordSize;
Expand All @@ -899,7 +897,6 @@ struct Class
pinPopupWindow( false ),
showingDictBarNames( false ),
usingSmallIconsInToolbars( false ),
maxPictureWidth( 0 ),
maxHeadwordSize( 256U ),
maxHeadwordsToExpand( 0 )
{
Expand Down
Loading

0 comments on commit 0067d19

Please sign in to comment.