Skip to content

Commit

Permalink
feat(bundler): expose {{long_description}} to custom templates (#9494)
Browse files Browse the repository at this point in the history
* feat(bundler): expose `{{long_description}}` to custom templates

closes #9437

* fix linux
  • Loading branch information
amrbashir committed Apr 18, 2024
1 parent e64b8f1 commit 05088b0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changes/bundler-long_description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri-bundler": "patch:feat"
---

Expose `{{long_description}}` variable for custom templates.

6 changes: 4 additions & 2 deletions tooling/bundler/src/bundle/linux/freedesktop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub fn copy_icon_files(settings: &Settings, data_dir: &Path) -> crate::Result<Ve
/// path in the package.
pub fn generate_desktop_file(
settings: &Settings,
template_settings: &Option<PathBuf>,
custom_template_path: &Option<PathBuf>,
data_dir: &Path,
) -> crate::Result<(PathBuf, PathBuf)> {
let bin_name = settings.main_binary_name();
Expand All @@ -105,7 +105,7 @@ pub fn generate_desktop_file(

let mut handlebars = Handlebars::new();
handlebars.register_escape_fn(handlebars::no_escape);
if let Some(template) = template_settings {
if let Some(template) = custom_template_path {
handlebars
.register_template_string("main.desktop", read_to_string(template)?)
.with_context(|| "Failed to setup custom handlebar template")?;
Expand All @@ -123,6 +123,7 @@ pub fn generate_desktop_file(
icon: &'a str,
name: &'a str,
mime_type: Option<String>,
long_description: String,
}

let mut mime_type: Vec<String> = Vec::new();
Expand Down Expand Up @@ -162,6 +163,7 @@ pub fn generate_desktop_file(
icon: bin_name,
name: settings.product_name(),
mime_type,
long_description: settings.long_description().unwrap_or_default().to_string(),
},
file,
)?;
Expand Down
4 changes: 4 additions & 0 deletions tooling/bundler/src/bundle/windows/msi/wix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,10 @@ pub fn build_wix_app_installer(

data.insert("product_name", to_json(settings.product_name()));
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 manufacturer = settings
.publisher()
Expand Down
4 changes: 4 additions & 0 deletions tooling/bundler/src/bundle/windows/nsis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ fn build_nsis_app_installer(
data.insert("manufacturer", to_json(manufacturer));
data.insert("product_name", to_json(settings.product_name()));
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()));

// Code signing is currently only supported on Windows hosts
Expand Down

0 comments on commit 05088b0

Please sign in to comment.