mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-06-08 16:00:18 +00:00
fix download path
This commit is contained in:
5
.github/workflows/appimage-build.yml
vendored
5
.github/workflows/appimage-build.yml
vendored
@@ -62,6 +62,11 @@ jobs:
|
||||
rm -rf AppDir
|
||||
DESTDIR="${PWD}/AppDir" ninja -C build install
|
||||
|
||||
- name: Verify offline docs install
|
||||
run: |
|
||||
set -eux
|
||||
test -f AppDir/usr/share/doc/zoitechat/html/index.html
|
||||
|
||||
- name: Bundle scripting runtimes in AppDir
|
||||
run: |
|
||||
set -eux
|
||||
|
||||
6
.github/workflows/flatpak-build.yml
vendored
6
.github/workflows/flatpak-build.yml
vendored
@@ -37,6 +37,12 @@ jobs:
|
||||
cache: false
|
||||
restore-cache: false
|
||||
|
||||
- name: Verify offline docs install
|
||||
run: |
|
||||
flatpak --user install -y zoitechat.flatpak
|
||||
app_dir="$(flatpak info --user --show-location net.zoite.Zoitechat)"
|
||||
test -f "$app_dir/files/share/doc/net.zoite.Zoitechat/html/index.html"
|
||||
|
||||
- name: Upload Flatpak Bundle
|
||||
id: upload_flatpak
|
||||
uses: actions/upload-artifact@v6
|
||||
|
||||
10
.github/workflows/windows-build.yml
vendored
10
.github/workflows/windows-build.yml
vendored
@@ -132,6 +132,16 @@ jobs:
|
||||
msbuild win32\zoitechat.sln /m /verbosity:minimal /p:Configuration=Release /p:Platform=${{ matrix.platform }}
|
||||
shell: cmd
|
||||
|
||||
- name: Verify offline docs install
|
||||
run: |
|
||||
if not exist "..\zoitechat-build\${{ matrix.platform }}\rel\offline-docs\index.html" exit /b 1
|
||||
findstr /C:"Name:" "..\zoitechat-build\${{ matrix.platform }}\bin\zoitechat.iss" | findstr /C:"docs"
|
||||
findstr /C:"OFFLINEDOCSURL" "..\zoitechat-build\${{ matrix.platform }}\bin\zoitechat.iss"
|
||||
findstr /C:"Source:" "..\zoitechat-build\${{ matrix.platform }}\bin\zoitechat.iss" | findstr /C:"offline-docs"
|
||||
findstr /C:"offline-docs.tar.gz" "..\zoitechat-build\${{ matrix.platform }}\bin\zoitechat.iss"
|
||||
findstr /C:"InstallOfflineDocs" "..\zoitechat-build\${{ matrix.platform }}\bin\zoitechat.iss"
|
||||
shell: cmd
|
||||
|
||||
- name: Preparing Artifacts
|
||||
run: |
|
||||
move ..\zoitechat-build\${{ matrix.platform }}\ZoiteChat-*.exe .\
|
||||
|
||||
@@ -7,3 +7,15 @@ if get_option('gtk-frontend')
|
||||
subdir('misc')
|
||||
subdir('man')
|
||||
endif
|
||||
|
||||
offline_docs_url = get_option('offline-docs-url')
|
||||
offline_docs = custom_target('offline-docs',
|
||||
output: 'offline-docs.stamp',
|
||||
command: [find_program('python3'), files('misc/fetch_offline_docs.py'), offline_docs_url, '@OUTDIR@', meson.source_root()],
|
||||
build_by_default: true,
|
||||
)
|
||||
meson.add_install_script(
|
||||
files('misc/install_offline_docs.py'),
|
||||
join_paths(meson.current_build_dir(), 'offline-docs'),
|
||||
offline_docs_dir,
|
||||
)
|
||||
|
||||
42
data/misc/fetch_offline_docs.py
Normal file
42
data/misc/fetch_offline_docs.py
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env python3
|
||||
import html
|
||||
import io
|
||||
import pathlib
|
||||
import shutil
|
||||
import sys
|
||||
import tarfile
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
url = sys.argv[1]
|
||||
out_dir = pathlib.Path(sys.argv[2])
|
||||
source_dir = pathlib.Path(sys.argv[3]) if len(sys.argv) > 3 else pathlib.Path.cwd()
|
||||
docs_dir = out_dir / 'offline-docs'
|
||||
if docs_dir.exists():
|
||||
shutil.rmtree(docs_dir)
|
||||
docs_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
def write_source_docs():
|
||||
parts = ['<!doctype html><html><head><meta charset="utf-8"><title>ZoiteChat Documentation</title></head><body><h1>ZoiteChat Documentation</h1>']
|
||||
for name in ('readme.md', 'troubleshooting.md', 'changelog.rst'):
|
||||
path = source_dir / name
|
||||
if path.exists():
|
||||
parts.append(f'<h2>{html.escape(name)}</h2><pre>{html.escape(path.read_text(encoding="utf-8", errors="replace"))}</pre>')
|
||||
parts.append('</body></html>')
|
||||
(docs_dir / 'index.html').write_text('\n'.join(parts), encoding='utf-8')
|
||||
|
||||
if url:
|
||||
try:
|
||||
with urllib.request.urlopen(url, timeout=30) as r:
|
||||
data = r.read()
|
||||
with tarfile.open(fileobj=io.BytesIO(data), mode='r:gz') as tar:
|
||||
try:
|
||||
tar.extractall(docs_dir, filter='data')
|
||||
except TypeError:
|
||||
tar.extractall(docs_dir)
|
||||
except (OSError, tarfile.TarError, urllib.error.URLError) as error:
|
||||
print(f'offline docs download failed: {error}', file=sys.stderr)
|
||||
write_source_docs()
|
||||
else:
|
||||
write_source_docs()
|
||||
(out_dir / 'offline-docs.stamp').write_text('ok')
|
||||
13
data/misc/install_offline_docs.py
Normal file
13
data/misc/install_offline_docs.py
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import pathlib
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
src = pathlib.Path(sys.argv[1])
|
||||
dest = pathlib.Path(os.environ['MESON_INSTALL_DESTDIR_PREFIX']) / sys.argv[2]
|
||||
if not (src / 'index.html').exists():
|
||||
sys.exit(0)
|
||||
if dest.exists():
|
||||
shutil.rmtree(dest)
|
||||
shutil.copytree(src, dest)
|
||||
@@ -56,7 +56,8 @@
|
||||
"-Ddbus-service-use-appid=true",
|
||||
"-Dwith-perl=perl",
|
||||
"-Dwith-python=python3",
|
||||
"-Dwith-lua=lua"
|
||||
"-Dwith-lua=lua",
|
||||
"-Doffline-docs-package=net.zoite.Zoitechat"
|
||||
],
|
||||
"build-options": {
|
||||
"cflags": "-Wno-error=missing-include-dirs"
|
||||
|
||||
10
meson.build
10
meson.build
@@ -32,8 +32,18 @@ config_h = configuration_data()
|
||||
config_h.set_quoted('PACKAGE_VERSION', meson.project_version())
|
||||
config_h.set_quoted('PACKAGE_NAME', meson.project_name())
|
||||
config_h.set_quoted('GETTEXT_PACKAGE', 'zoitechat')
|
||||
offline_docs_package = get_option('offline-docs-package')
|
||||
if offline_docs_package == ''
|
||||
offline_docs_package = meson.project_name()
|
||||
endif
|
||||
offline_docs_dir = get_option('offline-docs-dir')
|
||||
if offline_docs_dir == ''
|
||||
offline_docs_dir = join_paths(get_option('datadir'), 'doc', offline_docs_package, 'html')
|
||||
endif
|
||||
config_h.set_quoted('LOCALEDIR', join_paths(get_option('prefix'),
|
||||
get_option('datadir'), 'locale'))
|
||||
config_h.set_quoted('ZOITECHATDOCDIR', join_paths(get_option('prefix'),
|
||||
offline_docs_dir))
|
||||
config_h.set10('ENABLE_NLS', true)
|
||||
|
||||
# Optional features
|
||||
|
||||
@@ -62,3 +62,13 @@ option('with-upd', type: 'boolean',
|
||||
option('with-perl-legacy-api', type: 'boolean', value: false,
|
||||
description: 'Enables the legacy IRC perl module for compatibility with old scripts'
|
||||
)
|
||||
|
||||
option('offline-docs-url', type: 'string', value: '',
|
||||
description: 'URL for offline documentation archive (tar.gz)'
|
||||
)
|
||||
option('offline-docs-package', type: 'string', value: '',
|
||||
description: 'Package or app id to use under the installed documentation directory'
|
||||
)
|
||||
option('offline-docs-dir', type: 'string', value: 'https://dl.zoitechat.org/offlinedocs/zoitechat-docs-html-2.18.1.tar.gz',
|
||||
description: 'Installed offline documentation directory relative to prefix'
|
||||
)
|
||||
|
||||
@@ -66,4 +66,5 @@ build() {
|
||||
|
||||
package() {
|
||||
meson install -C build --destdir "$pkgdir"
|
||||
test -f "$pkgdir/usr/share/doc/zoitechat/html/index.html"
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ REM zoitechat.rc needs to be in UCS-2 or Resource Compiler will complain
|
||||
powershell "Get-Content -Encoding UTF8 '$(ZoiteChatLib)zoitechat.rc.utf8' | Out-File '$(ZoiteChatLib)zoitechat.rc'; Remove-Item '$(ZoiteChatLib)zoitechat.rc.utf8'"
|
||||
"$(DepsRoot)\bin\glib-compile-resources.exe" --generate-header --manual-register --sourcedir "$(DataDir)" --target "$(ZoiteChatLib)resources.h" "$(DataDir)zoitechat.gresource.xml"
|
||||
"$(DepsRoot)\bin\glib-compile-resources.exe" --generate-source --manual-register --sourcedir "$(DataDir)" --target "$(ZoiteChatLib)resources.c" "$(DataDir)zoitechat.gresource.xml"
|
||||
"$(Python3Path)\python.exe" "$(DataDir)misc\fetch_offline_docs.py" "$(OfflineDocsUrl)" "$(ZoiteChatRel)." "$(SolutionDir).."
|
||||
]]></Command>
|
||||
<Message>Build zoitechat.rc and gresource file</Message>
|
||||
</PreBuildEvent>
|
||||
|
||||
@@ -1717,7 +1717,32 @@ menu_ctcpguiopen (void)
|
||||
static void
|
||||
menu_docs (GtkWidget *wid, gpointer none)
|
||||
{
|
||||
fe_open_url ("https://docs.zoitechat.org/en/latest/");
|
||||
GNetworkMonitor *monitor;
|
||||
char *offline_docs;
|
||||
gboolean online;
|
||||
|
||||
offline_docs = g_build_filename (get_xdir (), "offline-docs", "index.html", NULL);
|
||||
if (g_access (offline_docs, R_OK) == 0)
|
||||
{
|
||||
fe_open_url (offline_docs);
|
||||
g_free (offline_docs);
|
||||
return;
|
||||
}
|
||||
g_free (offline_docs);
|
||||
offline_docs = g_build_filename (ZOITECHATDOCDIR, "index.html", NULL);
|
||||
if (g_access (offline_docs, R_OK) == 0)
|
||||
{
|
||||
fe_open_url (offline_docs);
|
||||
g_free (offline_docs);
|
||||
return;
|
||||
}
|
||||
g_free (offline_docs);
|
||||
online = TRUE;
|
||||
monitor = g_network_monitor_get_default ();
|
||||
if (monitor)
|
||||
online = g_network_monitor_get_network_available (monitor);
|
||||
if (online)
|
||||
fe_open_url ("https://docs.zoitechat.org/en/latest/");
|
||||
}
|
||||
|
||||
/*static void
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#define PACKAGE_VERSION "<#= [string]::Join('.', $versionParts) #>"
|
||||
#define ZOITECHATLIBDIR ".\\plugins"
|
||||
#define ZOITECHATSHAREDIR "."
|
||||
#define ZOITECHATDOCDIR "offline-docs"
|
||||
#define OLD_PERL
|
||||
#define GETTEXT_PACKAGE "zoitechat"
|
||||
#define PACKAGE_TARNAME "zoitechat-<#= [string]::Join('.', $versionParts) #>"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#define APPNAM "ZoiteChat"
|
||||
#define APPVER "<#= [string]::Join('.', $versionParts) #>"
|
||||
#define OFFLINEDOCSURL "https://dl.zoitechat.org/offlinedocs/zoitechat-docs-html-{#APPVER}.tar.gz"
|
||||
; These are defined by our installer project at build time
|
||||
;#define APPARCH "x64"
|
||||
;#define PROJECTDIR "C:\...\zoitechat\win32\installer\"
|
||||
@@ -49,6 +50,7 @@ Name: "icons"; Description: "Create Shortcuts"; Types: custom; Flags: disablenou
|
||||
Name: "icons\desktopicon"; Description: "Create Desktop Shortcut"; Types: custom; Flags: disablenouninstallwarning
|
||||
Name: "icons\quicklaunchicon"; Description: "Create Quick Launch Shortcut"; Types: custom; Flags: disablenouninstallwarning
|
||||
Name: "translations"; Description: "Translations"; Types: normal custom; Flags: disablenouninstallwarning
|
||||
Name: "docs"; Description: "Offline Documentation"; Types: normal minimal custom; Flags: disablenouninstallwarning
|
||||
Name: "spell"; Description: "Spelling Dictionaries"; Types: custom; Flags: disablenouninstallwarning
|
||||
Name: "plugins"; Description: "Plugins"; Types: custom; Flags: disablenouninstallwarning
|
||||
Name: "plugins\checksum"; Description: "Checksum"; Types: custom; Flags: disablenouninstallwarning
|
||||
@@ -95,6 +97,7 @@ Filename: "{sys}\WindowsPowerShell\v1.0\powershell.exe"; Parameters: "-NoProfile
|
||||
|
||||
[Dirs]
|
||||
Name: "{userappdata}\ZoiteChat\gtk3-themes"; Components: themes
|
||||
Name: "{app}\offline-docs"; Components: docs
|
||||
|
||||
[Files]
|
||||
Source: "portable-mode"; DestDir: "{app}"; Tasks: portable
|
||||
@@ -105,6 +108,7 @@ Source: "cert.pem"; DestDir: "{app}"; Flags: ignoreversion; Components: libs
|
||||
Source: "share\xml\*"; DestDir: "{app}\share\xml"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: libs
|
||||
Source: "share\doc\zoitechat\*"; DestDir: "{app}\share\doc\zoitechat"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: libs
|
||||
Source: "share\doc\WinSparkle\*"; DestDir: "{app}\share\doc\WinSparkle"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: libs
|
||||
Source: "offline-docs\*"; DestDir: "{app}\offline-docs"; Flags: ignoreversion createallsubdirs recursesubdirs; Components: docs
|
||||
Source: "share\themes\MS-Windows\*"; DestDir: "{app}\share\themes\MS-Windows"; Flags: ignoreversion createallsubdirs recursesubdirs skipifsourcedoesntexist; Components: libs
|
||||
Source: "share\glib-2.0\schemas\*"; DestDir: "{app}\share\glib-2.0\schemas"; Flags: ignoreversion createallsubdirs recursesubdirs skipifsourcedoesntexist; Components: libs
|
||||
Source: "share\icons\hicolor\*"; DestDir: "{app}\share\icons\hicolor"; Flags: ignoreversion createallsubdirs recursesubdirs skipifsourcedoesntexist; Components: libs
|
||||
@@ -314,7 +318,34 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
function InstallOfflineDocs(): Boolean;
|
||||
var
|
||||
Archive: String;
|
||||
DocsDir: String;
|
||||
ResultCode: Integer;
|
||||
Script: String;
|
||||
WorkDir: String;
|
||||
begin
|
||||
Result := True;
|
||||
Archive := ExpandConstant('{tmp}\offline-docs.tar.gz');
|
||||
DocsDir := ExpandConstant('{app}\offline-docs');
|
||||
WorkDir := ExpandConstant('{tmp}\offline-docs-extract');
|
||||
if not FileExists(Archive) then
|
||||
Exit;
|
||||
Script := 'Remove-Item -LiteralPath ''' + WorkDir + ''' -Recurse -Force -ErrorAction SilentlyContinue; ' +
|
||||
'New-Item -ItemType Directory -LiteralPath ''' + WorkDir + ''' -Force | Out-Null; ' +
|
||||
'tar -xzf ''' + Archive + ''' -C ''' + WorkDir + '''; ' +
|
||||
'$i = Get-ChildItem -LiteralPath ''' + WorkDir + ''' -Recurse -Filter index.html | Select-Object -First 1; ' +
|
||||
'if (-not $i) { exit 1 }; ' +
|
||||
'Remove-Item -LiteralPath ''' + DocsDir + ''' -Recurse -Force -ErrorAction SilentlyContinue; ' +
|
||||
'New-Item -ItemType Directory -LiteralPath ''' + DocsDir + ''' -Force | Out-Null; ' +
|
||||
'Copy-Item -Path (Join-Path $i.DirectoryName ''*'') -Destination ''' + DocsDir + ''' -Recurse -Force';
|
||||
if not Exec(GetSysDir() + 'WindowsPowerShell\v1.0\powershell.exe', '-NoProfile -ExecutionPolicy Bypass -Command "' + Script + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then
|
||||
Result := False
|
||||
else
|
||||
Result := ResultCode = 0;
|
||||
end;
|
||||
|
||||
function CheckSpellInstall(): Boolean;
|
||||
var
|
||||
Version: TWindowsVersion;
|
||||
@@ -351,6 +382,9 @@ begin
|
||||
if IsComponentSelected('themes\windows10dark') then
|
||||
idpAddFile('https://dl.zoitechat.zoite.net/themes/GTK3Themes/Windows-10-Dark-3.2.1-dark.zip', ExpandConstant('{tmp}\Windows-10-Dark-3.2.1-dark.zip'));
|
||||
|
||||
if IsComponentSelected('docs') then
|
||||
idpAddFile('{#OFFLINEDOCSURL}', ExpandConstant('{tmp}\offline-docs.tar.gz'));
|
||||
|
||||
if not IsTaskSelected('portable') then
|
||||
begin
|
||||
|
||||
@@ -419,6 +453,13 @@ begin
|
||||
Exit;
|
||||
end;
|
||||
|
||||
if IsComponentSelected('docs') and not FileExists(ExpandConstant('{tmp}\offline-docs.tar.gz')) then
|
||||
begin
|
||||
MsgBox('Offline documentation could not be downloaded. Please retry setup or rerun setup with Offline Documentation deselected.', mbError, MB_OK);
|
||||
Result := False;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
if IsComponentSelected('deps\vcredist2015') and not CheckVCInstall() and not FileExists(ExpandConstant('{tmp}\vcredist.exe')) then
|
||||
begin
|
||||
MsgBox('Visual C++ Redistributable could not be downloaded. Please retry setup or install it manually and rerun setup.', mbError, MB_OK);
|
||||
@@ -497,4 +538,10 @@ begin
|
||||
DeleteFile(ExpandConstant('{app}\portable-mode'));
|
||||
end;
|
||||
end;
|
||||
|
||||
if (CurStep=ssPostInstall) and IsComponentSelected('docs') then
|
||||
begin
|
||||
if not InstallOfflineDocs() then
|
||||
MsgBox('Offline documentation could not be installed from the downloaded archive.', mbError, MB_OK);
|
||||
end;
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user