feat(bundler): expose {{long_description}} to custom templates (#9494)

* feat(bundler): expose `{{long_description}}` to custom templates

closes #9437

* fix linux
This commit is contained in:
Amr Bashir 2024-04-18 17:09:05 +02:00 committed by GitHub
parent e64b8f1dce
commit 05088b0679
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 2 deletions

View File

@ -0,0 +1,6 @@
---
"tauri-bundler": "patch:feat"
---
Expose `{{long_description}}` variable for custom templates.

View File

@ -93,7 +93,7 @@ pub fn copy_icon_files(settings: &Settings, data_dir: &Path) -> crate::Result<Ve
/// path in the package. /// path in the package.
pub fn generate_desktop_file( pub fn generate_desktop_file(
settings: &Settings, settings: &Settings,
template_settings: &Option<PathBuf>, custom_template_path: &Option<PathBuf>,
data_dir: &Path, data_dir: &Path,
) -> crate::Result<(PathBuf, PathBuf)> { ) -> crate::Result<(PathBuf, PathBuf)> {
let bin_name = settings.main_binary_name(); let bin_name = settings.main_binary_name();
@ -105,7 +105,7 @@ pub fn generate_desktop_file(
let mut handlebars = Handlebars::new(); let mut handlebars = Handlebars::new();
handlebars.register_escape_fn(handlebars::no_escape); handlebars.register_escape_fn(handlebars::no_escape);
if let Some(template) = template_settings { if let Some(template) = custom_template_path {
handlebars handlebars
.register_template_string("main.desktop", read_to_string(template)?) .register_template_string("main.desktop", read_to_string(template)?)
.with_context(|| "Failed to setup custom handlebar template")?; .with_context(|| "Failed to setup custom handlebar template")?;
@ -123,6 +123,7 @@ pub fn generate_desktop_file(
icon: &'a str, icon: &'a str,
name: &'a str, name: &'a str,
mime_type: Option<String>, mime_type: Option<String>,
long_description: String,
} }
let mut mime_type: Vec<String> = Vec::new(); let mut mime_type: Vec<String> = Vec::new();
@ -162,6 +163,7 @@ pub fn generate_desktop_file(
icon: bin_name, icon: bin_name,
name: settings.product_name(), name: settings.product_name(),
mime_type, mime_type,
long_description: settings.long_description().unwrap_or_default().to_string(),
}, },
file, file,
)?; )?;

View File

@ -518,6 +518,10 @@ pub fn build_wix_app_installer(
data.insert("product_name", to_json(settings.product_name())); data.insert("product_name", to_json(settings.product_name()));
data.insert("version", to_json(app_version)); data.insert("version", to_json(app_version));
data.insert(
"long_description",
to_json(settings.long_description().unwrap_or_default()),
);
let bundle_id = settings.bundle_identifier(); let bundle_id = settings.bundle_identifier();
let manufacturer = settings let manufacturer = settings
.publisher() .publisher()

View File

@ -210,6 +210,10 @@ fn build_nsis_app_installer(
data.insert("manufacturer", to_json(manufacturer)); data.insert("manufacturer", to_json(manufacturer));
data.insert("product_name", to_json(settings.product_name())); data.insert("product_name", to_json(settings.product_name()));
data.insert("short_description", to_json(settings.short_description())); data.insert("short_description", to_json(settings.short_description()));
data.insert(
"long_description",
to_json(settings.long_description().unwrap_or_default()),
);
data.insert("copyright", to_json(settings.copyright_string())); data.insert("copyright", to_json(settings.copyright_string()));
// Code signing is currently only supported on Windows hosts // Code signing is currently only supported on Windows hosts