Skip to content

Commit

Permalink
feat: add git commit hash to the pkg url. closes #35
Browse files Browse the repository at this point in the history
  • Loading branch information
akarras committed Oct 7, 2023
1 parent aa5a893 commit adf9eb6
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 6 deletions.
8 changes: 8 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ yoke = "0.7.1"
xiv-gen = {path = "./xiv-gen", features = ["item", "item_ui_category", "item_search_category", "class_job", "recipe", "class_job_category", "base_param"]}
leptos_icons = {version = "0.0.16-beta", features = ["IoSettingsSharp", "AiOrderedListOutlined", "BsDiscord", "BsClipboard2Fill", "BsClipboard2CheckFill", "AiEditFilled", "FaMoneyBillTrendUpSolid", "BsCheck", "BsPencilFill", "BiSortDownRegular", "BiSortUpRegular", "BiPlusRegular", "BiTrashSolid", "AiExclamationOutlined", "BiSaveSolid", "BiGroupSolid", "BiHomeSolid", "FaScrewdriverWrenchSolid", "AiSearchOutlined", "ImPriceTag", "BiCalendarAltRegular"]}
cfg-if = "1.0.0"
git-const = "1.1.0"

[patch.crates-io]
leptos = { git = "https://github.com/leptos-rs/leptos.git"}
Expand Down
1 change: 1 addition & 0 deletions ultros-frontend/ultros-app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ serde_qs = "0.12.0"
gloo-timers = {version = "0.3.0", features = ["futures"]}
cfg-if.workspace = true
paginate = "1.1.11"
git-const.workspace = true

[features]
default = ["ssr"] # this is mostly so if I run cargo check, it has a flavor to work on
Expand Down
9 changes: 5 additions & 4 deletions ultros-frontend/ultros-app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use crate::{
lists::*, retainers::*, settings::*,
},
};
use git_const::git_short_hash;
use leptos::*;
use leptos_icons::*;
use leptos_meta::*;
Expand All @@ -40,11 +41,11 @@ pub fn App(worlds: AppResult<Arc<WorldHelper>>, region: String) -> impl IntoView
provide_context(GlobalLastCopiedText(create_rw_signal(None)));
provide_context(RecentItems::new());
let login = create_resource(move || {}, move |_| async move { get_login().await.ok() });
// provide_context(LoggedInUser(login));
// HIDE_ADS is user set, entirely optional whether users want to opt in or not.
let (homeworld, _set_homeworld) = get_homeworld();
let git_hash = git_short_hash!();
let sheet_url = ["/pkg/", git_hash, "/ultros.css"].concat();
view! {
<Stylesheet id="leptos" href="/pkg/ultros.css"/>
<Stylesheet id="leptos" href=sheet_url/>
<Stylesheet id="xiv-icons" href="/static/classjob-icons/src/xivicon.css"/>
<Title text="Ultros" />
// <Meta name="twitter:card" content="summary_large_image"/>
Expand Down Expand Up @@ -143,7 +144,7 @@ pub fn App(worlds: AppResult<Arc<WorldHelper>>, region: String) -> impl IntoView
<a href="https://leekspin.com">"Patreon"</a>
</div>
<span>"Made using "<a href="https://universalis.app/">"universalis"</a>"' API.Please contribute to Universalis to help this site stay up to date."</span>
<span></span>
<span>"Version: "{git_hash}</span>
<span>"FINAL FANTASY XIV © 2010 - 2020 SQUARE ENIX CO., LTD. All Rights Reserved."</span>
</footer>
}
Expand Down
1 change: 1 addition & 0 deletions ultros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ plotters-svg = {version = "0.3.2", features = ["bitmap_encoder"]}
resvg = "0.33.0"
image.workspace = true
isocountry = "0.3.2"
git-const.workspace = true
10 changes: 8 additions & 2 deletions ultros/src/leptos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use axum::{
routing::get,
Extension, Router,
};
use git_const::git_short_hash;
use leptos::*;
use leptos_axum::generate_route_list;
use leptos_router::RouteListing;
Expand Down Expand Up @@ -44,7 +45,7 @@ pub(crate) async fn create_leptos_app(
use tower_http::services::ServeDir;

let conf = get_configuration(None).await?;
let leptos_options = conf.leptos_options;
let mut leptos_options = conf.leptos_options;
let site_root = &leptos_options.site_root;
let pkg_dir = &leptos_options.site_pkg_dir;

Expand All @@ -62,6 +63,8 @@ pub(crate) async fn create_leptos_app(
// because all Errors are converted into Responses
// let static_service = HandleError::new(ServeDir::new("./static"), handle_file_error);
//let pkg_service = HandleError::new(ServeDir::new("./pkg"), handle_file_error);
let git_hash = git_short_hash!();
leptos_options.site_pkg_dir = ["pkg/", git_hash].concat();
let cargo_leptos_service = HandleError::new(ServeDir::new(&bundle_filepath), handle_file_error);
tracing::info!("Serving pkg dir: {bundle_filepath}");
/// Convert the Errors from ServeDir to a type that implements IntoResponse
Expand All @@ -79,7 +82,10 @@ pub(crate) async fn create_leptos_app(
// build our application with a route
Ok(Router::new()
// `GET /` goes to `root`
.nest_service("/pkg", cargo_leptos_service.clone()) // Only need if using wasm-pack. Can be deleted if using cargo-leptos
.nest_service(
&["/", &leptos_options.site_pkg_dir].concat(),
cargo_leptos_service.clone(),
) // Only need if using wasm-pack. Can be deleted if using cargo-leptos
.nest_service(&bundle_path, cargo_leptos_service) // Only needed if using cargo-leptos. Can be deleted if using wasm-pack and cargo-run
//.nest_service("/static", static_service)
.leptos_routes_with_handler_stateful(routes, custom_handler)
Expand Down

0 comments on commit adf9eb6

Please sign in to comment.