| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
mod git; |
| 7 |
mod health; |
| 8 |
|
| 9 |
pub use git::*; |
| 10 |
pub use health::*; |
| 11 |
|
| 12 |
use std::sync::Arc; |
| 13 |
|
| 14 |
use askama::Template; |
| 15 |
|
| 16 |
use crate::auth::SessionUser; |
| 17 |
use crate::types::{ |
| 18 |
BlogPostSummary, Chapter, Collection, CollectionItem, CustomLink, DiscoverItem, |
| 19 |
DiscoverProject, Item, ItemContent, ItemSection, Project, SidebarView, SubscriptionTier, |
| 20 |
TagBreadcrumb, TagTreeNode, User, Version, |
| 21 |
}; |
| 22 |
|
| 23 |
use super::CsrfTokenOption; |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
#[derive(Template)] |
| 29 |
#[template(path = "pages/sandbox.html")] |
| 30 |
pub struct SandboxTemplate { |
| 31 |
pub csrf_token: CsrfTokenOption, |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
#[derive(Template)] |
| 36 |
#[template(path = "pages/policy.html")] |
| 37 |
pub struct PolicyTemplate { |
| 38 |
|
| 39 |
pub csrf_token: CsrfTokenOption, |
| 40 |
|
| 41 |
pub session_user: Option<SessionUser>, |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
#[derive(Template)] |
| 46 |
#[template(path = "pages/index.html")] |
| 47 |
pub struct IndexTemplate { |
| 48 |
pub csrf_token: CsrfTokenOption, |
| 49 |
pub host_url: Arc<str>, |
| 50 |
pub total_creators: u32, |
| 51 |
pub total_items: u32, |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
pub founder_window_open: bool, |
| 56 |
|
| 57 |
|
| 58 |
pub founder_slots_remaining: Option<u32>, |
| 59 |
pub tier_prices: crate::tier_prices::TierPrices, |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
pub landing_carousel: Vec<super::CarouselFrame>, |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
pub last_shipped: Option<LandingVelocity>, |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
pub notify_ok: Option<bool>, |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
pub struct LandingVelocity { |
| 77 |
|
| 78 |
pub title: String, |
| 79 |
|
| 80 |
pub date: String, |
| 81 |
|
| 82 |
pub href: String, |
| 83 |
} |
| 84 |
|
| 85 |
|
| 86 |
#[derive(Template)] |
| 87 |
#[template(path = "pages/library.html")] |
| 88 |
pub struct LibraryTemplate { |
| 89 |
pub csrf_token: CsrfTokenOption, |
| 90 |
pub session_user: Option<SessionUser>, |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
pub tabs: String, |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
#[derive(Template)] |
| 103 |
#[template(path = "pages/cart.html")] |
| 104 |
pub struct CartTemplate { |
| 105 |
pub csrf_token: CsrfTokenOption, |
| 106 |
pub session_user: Option<SessionUser>, |
| 107 |
pub seller_groups: Vec<CartSellerGroup>, |
| 108 |
pub wishlist_suggestions: Vec<crate::db::wishlists::WishlistItem>, |
| 109 |
pub total_items: usize, |
| 110 |
|
| 111 |
pub checkout_status: String, |
| 112 |
|
| 113 |
pub offer_conversion_choice: bool, |
| 114 |
|
| 115 |
pub conversion: crate::currency::ConversionChoice, |
| 116 |
} |
| 117 |
|
| 118 |
impl CartTemplate { |
| 119 |
|
| 120 |
pub fn conversion_at_checkout(&self) -> bool { |
| 121 |
matches!( |
| 122 |
self.conversion, |
| 123 |
crate::currency::ConversionChoice::AtCheckout |
| 124 |
) |
| 125 |
} |
| 126 |
} |
| 127 |
|
| 128 |
|
| 129 |
pub struct CartSellerGroup { |
| 130 |
pub seller_username: String, |
| 131 |
pub seller_id: String, |
| 132 |
pub stripe_ready: bool, |
| 133 |
pub items: Vec<crate::db::cart::CartItem>, |
| 134 |
|
| 135 |
|
| 136 |
pub subtotal_cents: i64, |
| 137 |
pub item_count: usize, |
| 138 |
|
| 139 |
pub savings_cents: i32, |
| 140 |
|
| 141 |
|
| 142 |
pub currency: crate::currency::SettlementCurrency, |
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
pub offer_conversion_choice: bool, |
| 150 |
|
| 151 |
|
| 152 |
pub conversion: crate::currency::ConversionChoice, |
| 153 |
} |
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
pub fn cart_conversion_applies( |
| 167 |
buyer_currency: Option<crate::currency::SettlementCurrency>, |
| 168 |
seller_currency: crate::currency::SettlementCurrency, |
| 169 |
) -> bool { |
| 170 |
buyer_currency != Some(seller_currency) |
| 171 |
} |
| 172 |
|
| 173 |
impl CartSellerGroup { |
| 174 |
|
| 175 |
pub fn conversion_at_checkout(&self) -> bool { |
| 176 |
matches!( |
| 177 |
self.conversion, |
| 178 |
crate::currency::ConversionChoice::AtCheckout |
| 179 |
) |
| 180 |
} |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
pub fn currency_symbol(&self) -> &'static str { |
| 185 |
self.currency.symbol() |
| 186 |
} |
| 187 |
|
| 188 |
pub fn subtotal_display(&self) -> String { |
| 189 |
crate::formatting::format_revenue(self.subtotal_cents, self.currency) |
| 190 |
} |
| 191 |
|
| 192 |
pub fn savings_display(&self) -> String { |
| 193 |
crate::formatting::format_revenue(self.savings_cents as i64, self.currency) |
| 194 |
} |
| 195 |
} |
| 196 |
|
| 197 |
|
| 198 |
#[derive(Template)] |
| 199 |
#[template(path = "pages/login.html")] |
| 200 |
pub struct LoginTemplate { |
| 201 |
pub csrf_token: CsrfTokenOption, |
| 202 |
|
| 203 |
|
| 204 |
pub prefill_login: String, |
| 205 |
|
| 206 |
pub error: Option<String>, |
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
pub notice: Option<String>, |
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
pub sso_enabled: bool, |
| 215 |
} |
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
#[derive(Template)] |
| 221 |
#[template(path = "wizards/wizard_join.html")] |
| 222 |
pub struct WizardJoinTemplate { |
| 223 |
pub csrf_token: CsrfTokenOption, |
| 224 |
pub nav: Vec<super::StepNavItem>, |
| 225 |
pub invite_code: Option<String>, |
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
pub username: String, |
| 230 |
pub email: String, |
| 231 |
pub error: Option<String>, |
| 232 |
pub error_field: Option<String>, |
| 233 |
} |
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
#[derive(Template)] |
| 240 |
#[template(path = "wizards/steps/join/account.html")] |
| 241 |
pub struct WizardJoinAccountTemplate { |
| 242 |
pub nav: Vec<super::StepNavItem>, |
| 243 |
pub csrf_token: CsrfTokenOption, |
| 244 |
pub invite_code: Option<String>, |
| 245 |
pub username: String, |
| 246 |
pub email: String, |
| 247 |
pub error: Option<String>, |
| 248 |
pub error_field: Option<String>, |
| 249 |
} |
| 250 |
|
| 251 |
|
| 252 |
#[derive(Template)] |
| 253 |
#[template(path = "wizards/steps/join/profile.html")] |
| 254 |
pub struct WizardJoinProfileTemplate { |
| 255 |
pub nav: Vec<super::StepNavItem>, |
| 256 |
} |
| 257 |
|
| 258 |
|
| 259 |
#[derive(Template)] |
| 260 |
#[template(path = "wizards/steps/join/complete.html")] |
| 261 |
pub struct WizardJoinCompleteTemplate { |
| 262 |
pub nav: Vec<super::StepNavItem>, |
| 263 |
pub display_name: String, |
| 264 |
|
| 265 |
pub is_creator: bool, |
| 266 |
|
| 267 |
pub has_invite: bool, |
| 268 |
} |
| 269 |
|
| 270 |
|
| 271 |
#[derive(Template)] |
| 272 |
#[template(path = "pages/two_factor.html")] |
| 273 |
pub struct TwoFactorTemplate { |
| 274 |
pub csrf_token: CsrfTokenOption, |
| 275 |
pub session_user: Option<SessionUser>, |
| 276 |
pub error: Option<String>, |
| 277 |
} |
| 278 |
|
| 279 |
|
| 280 |
#[derive(Template)] |
| 281 |
#[template(path = "pages/oauth_authorize.html")] |
| 282 |
pub struct OAuthAuthorizeTemplate { |
| 283 |
pub csrf_token: CsrfTokenOption, |
| 284 |
pub session_user: Option<SessionUser>, |
| 285 |
pub app_name: String, |
| 286 |
pub client_id: String, |
| 287 |
pub redirect_uri: String, |
| 288 |
pub state: String, |
| 289 |
pub code_challenge: String, |
| 290 |
pub code_challenge_method: String, |
| 291 |
|
| 292 |
|
| 293 |
pub scope: String, |
| 294 |
pub error_message: Option<String>, |
| 295 |
} |
| 296 |
|
| 297 |
|
| 298 |
#[derive(Template)] |
| 299 |
#[template(path = "pages/forgot_password.html")] |
| 300 |
pub struct ForgotPasswordTemplate { |
| 301 |
pub csrf_token: CsrfTokenOption, |
| 302 |
} |
| 303 |
|
| 304 |
|
| 305 |
#[derive(Template)] |
| 306 |
#[template(path = "pages/reset_password.html")] |
| 307 |
pub struct ResetPasswordTemplate { |
| 308 |
pub csrf_token: CsrfTokenOption, |
| 309 |
pub valid: bool, |
| 310 |
|
| 311 |
|
| 312 |
pub token: String, |
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
pub error: Option<String>, |
| 317 |
} |
| 318 |
|
| 319 |
|
| 320 |
#[derive(Template)] |
| 321 |
#[template(path = "pages/user.html")] |
| 322 |
#[allow(dead_code)] |
| 323 |
pub struct UserTemplate { |
| 324 |
pub csrf_token: CsrfTokenOption, |
| 325 |
pub session_user: Option<SessionUser>, |
| 326 |
pub user: User, |
| 327 |
pub custom_links: Vec<CustomLink>, |
| 328 |
pub projects: Vec<Project>, |
| 329 |
pub public_collections: Vec<Collection>, |
| 330 |
|
| 331 |
pub user_id: String, |
| 332 |
|
| 333 |
pub is_own_profile: bool, |
| 334 |
|
| 335 |
pub is_following: bool, |
| 336 |
|
| 337 |
pub follower_count: i64, |
| 338 |
|
| 339 |
pub host_url: Arc<str>, |
| 340 |
|
| 341 |
pub creator_paused: bool, |
| 342 |
|
| 343 |
pub tips_enabled: bool, |
| 344 |
|
| 345 |
pub creator_id: String, |
| 346 |
|
| 347 |
pub tip_project_id: Option<String>, |
| 348 |
|
| 349 |
|
| 350 |
pub theme_css: &'static str, |
| 351 |
} |
| 352 |
|
| 353 |
|
| 354 |
#[derive(Template)] |
| 355 |
#[template(path = "pages/collection.html")] |
| 356 |
#[allow(dead_code)] |
| 357 |
pub struct CollectionTemplate { |
| 358 |
pub csrf_token: CsrfTokenOption, |
| 359 |
pub session_user: Option<SessionUser>, |
| 360 |
pub collection: Collection, |
| 361 |
pub items: Vec<CollectionItem>, |
| 362 |
pub owner_username: String, |
| 363 |
pub owner_display_name: Option<String>, |
| 364 |
pub is_owner: bool, |
| 365 |
} |
| 366 |
|
| 367 |
|
| 368 |
#[derive(Template)] |
| 369 |
#[template(path = "pages/project.html")] |
| 370 |
#[allow(dead_code)] |
| 371 |
pub struct ProjectTemplate { |
| 372 |
pub csrf_token: CsrfTokenOption, |
| 373 |
pub session_user: Option<SessionUser>, |
| 374 |
pub project: Project, |
| 375 |
pub creator_username: String, |
| 376 |
pub items: Vec<Item>, |
| 377 |
|
| 378 |
pub project_id: String, |
| 379 |
|
| 380 |
pub is_following: bool, |
| 381 |
|
| 382 |
pub follower_count: i64, |
| 383 |
|
| 384 |
pub subscription_tiers: Vec<SubscriptionTier>, |
| 385 |
|
| 386 |
pub has_subscription: bool, |
| 387 |
|
| 388 |
pub host_url: Arc<str>, |
| 389 |
|
| 390 |
pub git_repos: Vec<(String, String)>, |
| 391 |
|
| 392 |
pub has_blog_posts: bool, |
| 393 |
|
| 394 |
pub community_url: Option<String>, |
| 395 |
|
| 396 |
pub tips_enabled: bool, |
| 397 |
|
| 398 |
pub creator_id: String, |
| 399 |
|
| 400 |
pub tip_project_id: Option<String>, |
| 401 |
|
| 402 |
pub is_owner: bool, |
| 403 |
|
| 404 |
pub sections: Vec<crate::types::ProjectSection>, |
| 405 |
|
| 406 |
|
| 407 |
pub gallery: Vec<super::CarouselFrame>, |
| 408 |
|
| 409 |
|
| 410 |
pub theme_css: &'static str, |
| 411 |
} |
| 412 |
|
| 413 |
|
| 414 |
#[derive(Template)] |
| 415 |
#[template(path = "pages/project_paywall.html")] |
| 416 |
pub struct ProjectPaywallTemplate { |
| 417 |
pub csrf_token: CsrfTokenOption, |
| 418 |
pub session_user: Option<SessionUser>, |
| 419 |
pub project: Project, |
| 420 |
pub creator_username: String, |
| 421 |
|
| 422 |
pub price_display: String, |
| 423 |
|
| 424 |
pub checkout_type: crate::pricing::CheckoutType, |
| 425 |
|
| 426 |
pub subscription_tiers: Vec<SubscriptionTier>, |
| 427 |
|
| 428 |
pub host_url: Arc<str>, |
| 429 |
} |
| 430 |
|
| 431 |
|
| 432 |
#[derive(Template)] |
| 433 |
#[template(path = "pages/item.html")] |
| 434 |
#[allow(dead_code)] |
| 435 |
pub struct ItemTemplate { |
| 436 |
pub csrf_token: CsrfTokenOption, |
| 437 |
pub session_user: Option<SessionUser>, |
| 438 |
pub item: Item, |
| 439 |
pub creator_username: String, |
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
pub price_currency: &'static str, |
| 444 |
pub project_title: String, |
| 445 |
pub project_slug: String, |
| 446 |
|
| 447 |
pub host_url: Arc<str>, |
| 448 |
|
| 449 |
pub discussion_url: Option<String>, |
| 450 |
|
| 451 |
pub discussion_count: Option<i64>, |
| 452 |
|
| 453 |
pub project_cover_image_url: Option<String>, |
| 454 |
|
| 455 |
pub bundle_items: Vec<Item>, |
| 456 |
|
| 457 |
pub containing_bundles: Vec<Item>, |
| 458 |
|
| 459 |
pub sections: Vec<ItemSection>, |
| 460 |
|
| 461 |
pub is_owner: bool, |
| 462 |
|
| 463 |
pub is_wishlisted: bool, |
| 464 |
|
| 465 |
pub in_cart: bool, |
| 466 |
|
| 467 |
pub collection_count: u32, |
| 468 |
|
| 469 |
|
| 470 |
pub has_access: bool, |
| 471 |
|
| 472 |
|
| 473 |
pub gallery: Vec<super::CarouselFrame>, |
| 474 |
|
| 475 |
|
| 476 |
pub theme_css: &'static str, |
| 477 |
} |
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
#[derive(Template)] |
| 483 |
#[template(path = "pages/library_downloads.html")] |
| 484 |
#[allow(dead_code)] |
| 485 |
pub struct LibraryDownloadsTemplate { |
| 486 |
pub csrf_token: CsrfTokenOption, |
| 487 |
pub session_user: Option<SessionUser>, |
| 488 |
pub item: Item, |
| 489 |
pub creator_username: String, |
| 490 |
pub project_title: String, |
| 491 |
pub project_slug: String, |
| 492 |
pub host_url: Arc<str>, |
| 493 |
pub versions: Vec<Version>, |
| 494 |
|
| 495 |
|
| 496 |
pub bundle_items: Vec<Item>, |
| 497 |
pub sections: Vec<ItemSection>, |
| 498 |
pub discussion_url: Option<String>, |
| 499 |
pub discussion_count: Option<i64>, |
| 500 |
pub is_owner: bool, |
| 501 |
} |
| 502 |
|
| 503 |
|
| 504 |
#[derive(Template)] |
| 505 |
#[template(path = "pages/library_locked.html")] |
| 506 |
#[allow(dead_code)] |
| 507 |
pub struct LibraryLockedTemplate { |
| 508 |
pub csrf_token: CsrfTokenOption, |
| 509 |
pub session_user: Option<SessionUser>, |
| 510 |
pub item: Item, |
| 511 |
pub creator_username: String, |
| 512 |
pub host_url: Arc<str>, |
| 513 |
|
| 514 |
pub containing_bundles: Vec<Item>, |
| 515 |
pub is_logged_in: bool, |
| 516 |
} |
| 517 |
|
| 518 |
|
| 519 |
#[derive(Template)] |
| 520 |
#[template(path = "pages/library_text.html")] |
| 521 |
#[allow(dead_code)] |
| 522 |
pub struct LibraryTextTemplate { |
| 523 |
pub csrf_token: CsrfTokenOption, |
| 524 |
pub session_user: Option<SessionUser>, |
| 525 |
pub item: Item, |
| 526 |
pub creator_username: String, |
| 527 |
pub creator_display_name: Option<String>, |
| 528 |
pub creator_avatar_initials: String, |
| 529 |
pub project_title: String, |
| 530 |
pub project_slug: String, |
| 531 |
|
| 532 |
pub body_html: Option<String>, |
| 533 |
pub reading_time: Option<String>, |
| 534 |
pub host_url: Arc<str>, |
| 535 |
pub discussion_url: Option<String>, |
| 536 |
pub discussion_count: Option<i64>, |
| 537 |
pub is_owner: bool, |
| 538 |
} |
| 539 |
|
| 540 |
|
| 541 |
#[derive(Template)] |
| 542 |
#[template(path = "pages/text_reader.html")] |
| 543 |
#[allow(dead_code)] |
| 544 |
pub struct TextReaderTemplate { |
| 545 |
pub csrf_token: CsrfTokenOption, |
| 546 |
pub session_user: Option<SessionUser>, |
| 547 |
pub item: Item, |
| 548 |
pub creator_username: String, |
| 549 |
pub creator_display_name: Option<String>, |
| 550 |
|
| 551 |
pub creator_avatar_initials: String, |
| 552 |
pub project_title: String, |
| 553 |
pub project_slug: String, |
| 554 |
|
| 555 |
pub is_free: bool, |
| 556 |
|
| 557 |
pub in_library: bool, |
| 558 |
|
| 559 |
pub has_access: bool, |
| 560 |
pub reading_time: Option<String>, |
| 561 |
|
| 562 |
pub excerpt: Option<String>, |
| 563 |
|
| 564 |
pub host_url: Arc<str>, |
| 565 |
|
| 566 |
pub discussion_url: Option<String>, |
| 567 |
|
| 568 |
pub discussion_count: Option<i64>, |
| 569 |
} |
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
#[derive(Template)] |
| 574 |
#[template(path = "pages/library_audio.html")] |
| 575 |
#[allow(dead_code)] |
| 576 |
pub struct LibraryAudioTemplate { |
| 577 |
pub csrf_token: CsrfTokenOption, |
| 578 |
pub session_user: Option<SessionUser>, |
| 579 |
pub item: Item, |
| 580 |
pub creator_username: String, |
| 581 |
pub creator_display_name: Option<String>, |
| 582 |
pub creator_avatar_initials: String, |
| 583 |
pub project_title: Option<String>, |
| 584 |
pub project_slug: String, |
| 585 |
pub audio_url: Option<String>, |
| 586 |
pub chapters: Vec<Chapter>, |
| 587 |
pub segments_json: String, |
| 588 |
|
| 589 |
pub versions: Vec<Version>, |
| 590 |
pub host_url: Arc<str>, |
| 591 |
pub discussion_url: Option<String>, |
| 592 |
pub discussion_count: Option<i64>, |
| 593 |
pub is_owner: bool, |
| 594 |
} |
| 595 |
|
| 596 |
|
| 597 |
#[derive(Template)] |
| 598 |
#[template(path = "pages/audio_player.html")] |
| 599 |
pub struct AudioPlayerTemplate { |
| 600 |
pub csrf_token: CsrfTokenOption, |
| 601 |
pub session_user: Option<SessionUser>, |
| 602 |
pub item: Item, |
| 603 |
pub creator_username: String, |
| 604 |
pub creator_display_name: Option<String>, |
| 605 |
|
| 606 |
pub creator_avatar_initials: String, |
| 607 |
pub project_title: Option<String>, |
| 608 |
pub project_slug: String, |
| 609 |
|
| 610 |
pub is_free: bool, |
| 611 |
|
| 612 |
pub in_library: bool, |
| 613 |
|
| 614 |
pub has_access: bool, |
| 615 |
|
| 616 |
pub host_url: Arc<str>, |
| 617 |
|
| 618 |
pub discussion_url: Option<String>, |
| 619 |
|
| 620 |
pub discussion_count: Option<i64>, |
| 621 |
} |
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
#[derive(Template)] |
| 626 |
#[template(path = "pages/library_video.html")] |
| 627 |
#[allow(dead_code)] |
| 628 |
pub struct LibraryVideoTemplate { |
| 629 |
pub csrf_token: CsrfTokenOption, |
| 630 |
pub session_user: Option<SessionUser>, |
| 631 |
pub item: Item, |
| 632 |
pub creator_username: String, |
| 633 |
pub creator_display_name: Option<String>, |
| 634 |
pub creator_avatar_initials: String, |
| 635 |
pub project_title: Option<String>, |
| 636 |
pub project_slug: String, |
| 637 |
pub video_url: Option<String>, |
| 638 |
pub chapters: Vec<Chapter>, |
| 639 |
pub segments_json: String, |
| 640 |
pub versions: Vec<Version>, |
| 641 |
pub host_url: Arc<str>, |
| 642 |
pub discussion_url: Option<String>, |
| 643 |
pub discussion_count: Option<i64>, |
| 644 |
pub is_owner: bool, |
| 645 |
} |
| 646 |
|
| 647 |
|
| 648 |
#[derive(Template)] |
| 649 |
#[template(path = "pages/video_player.html")] |
| 650 |
pub struct VideoPlayerTemplate { |
| 651 |
pub csrf_token: CsrfTokenOption, |
| 652 |
pub session_user: Option<SessionUser>, |
| 653 |
pub item: Item, |
| 654 |
pub creator_username: String, |
| 655 |
pub creator_display_name: Option<String>, |
| 656 |
pub creator_avatar_initials: String, |
| 657 |
pub project_title: Option<String>, |
| 658 |
pub project_slug: String, |
| 659 |
pub is_free: bool, |
| 660 |
pub in_library: bool, |
| 661 |
pub has_access: bool, |
| 662 |
pub host_url: Arc<str>, |
| 663 |
pub discussion_url: Option<String>, |
| 664 |
pub discussion_count: Option<i64>, |
| 665 |
} |
| 666 |
|
| 667 |
|
| 668 |
#[derive(Template)] |
| 669 |
#[template(path = "pages/discover.html")] |
| 670 |
pub struct DiscoverTemplate { |
| 671 |
pub csrf_token: CsrfTokenOption, |
| 672 |
pub session_user: Option<SessionUser>, |
| 673 |
pub items: Vec<DiscoverItem>, |
| 674 |
pub projects: Vec<DiscoverProject>, |
| 675 |
|
| 676 |
pub mode: String, |
| 677 |
pub total_items: u32, |
| 678 |
pub current_page: u32, |
| 679 |
pub total_pages: u32, |
| 680 |
pub search_query: String, |
| 681 |
|
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
pub is_search: bool, |
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
|
| 690 |
pub count_label: String, |
| 691 |
|
| 692 |
pub sort_by: String, |
| 693 |
|
| 694 |
pub pagination_range: Vec<u32>, |
| 695 |
pub showing_start: u32, |
| 696 |
pub showing_end: u32, |
| 697 |
|
| 698 |
|
| 699 |
pub sidebar: SidebarView, |
| 700 |
|
| 701 |
pub is_authenticated: bool, |
| 702 |
|
| 703 |
|
| 704 |
pub oob_sidebar: bool, |
| 705 |
} |
| 706 |
|
| 707 |
|
| 708 |
#[derive(Template)] |
| 709 |
#[template(path = "pages/tag_tree.html")] |
| 710 |
pub struct TagTreeTemplate { |
| 711 |
pub csrf_token: CsrfTokenOption, |
| 712 |
pub session_user: Option<SessionUser>, |
| 713 |
pub categories: Vec<TagTreeNode>, |
| 714 |
pub breadcrumbs: Vec<TagBreadcrumb>, |
| 715 |
pub current_tag: Option<TagBreadcrumb>, |
| 716 |
} |
| 717 |
|
| 718 |
|
| 719 |
#[derive(Template)] |
| 720 |
#[template(path = "pages/purchase.html")] |
| 721 |
pub struct PurchaseTemplate { |
| 722 |
pub csrf_token: CsrfTokenOption, |
| 723 |
pub item: Item, |
| 724 |
pub creator_username: String, |
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
pub currency_symbol: &'static str, |
| 729 |
|
| 730 |
|
| 731 |
pub show_fee_estimate: bool, |
| 732 |
pub stripe_fee: String, |
| 733 |
pub creator_receives: String, |
| 734 |
|
| 735 |
pub promo_code: String, |
| 736 |
|
| 737 |
pub pwyw_enabled: bool, |
| 738 |
|
| 739 |
pub pwyw_min_cents: i32, |
| 740 |
|
| 741 |
pub suggested_price: String, |
| 742 |
|
| 743 |
pub pwyw_min_dollars: String, |
| 744 |
|
| 745 |
pub stripe_tax_enabled: bool, |
| 746 |
|
| 747 |
pub is_logged_in: bool, |
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
pub pending_started: String, |
| 752 |
} |
| 753 |
|
| 754 |
|
| 755 |
#[derive(Template)] |
| 756 |
#[template(path = "pages/buy.html")] |
| 757 |
pub struct BuyPageTemplate { |
| 758 |
pub item: Item, |
| 759 |
pub creator_username: String, |
| 760 |
|
| 761 |
pub currency_symbol: &'static str, |
| 762 |
pub creator_display_name: Option<String>, |
| 763 |
pub pwyw_enabled: bool, |
| 764 |
pub pwyw_min_dollars: String, |
| 765 |
pub suggested_price: String, |
| 766 |
pub host_url: Arc<str>, |
| 767 |
} |
| 768 |
|
| 769 |
|
| 770 |
#[derive(Template)] |
| 771 |
#[template(path = "pages/feed.html")] |
| 772 |
pub struct FeedTemplate { |
| 773 |
pub csrf_token: CsrfTokenOption, |
| 774 |
pub session_user: Option<SessionUser>, |
| 775 |
pub items: Vec<DiscoverItem>, |
| 776 |
pub total_items: u32, |
| 777 |
pub current_page: u32, |
| 778 |
pub total_pages: u32, |
| 779 |
pub pagination_range: Vec<u32>, |
| 780 |
pub showing_start: u32, |
| 781 |
pub showing_end: u32, |
| 782 |
} |
| 783 |
|
| 784 |
|
| 785 |
#[derive(Template)] |
| 786 |
#[template(path = "pages/stripe_disclaimer.html")] |
| 787 |
pub struct StripeConnectDisclaimerTemplate { |
| 788 |
pub csrf_token: CsrfTokenOption, |
| 789 |
} |
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
#[derive(Template)] |
| 795 |
#[template(path = "pages/fan_plus.html")] |
| 796 |
pub struct FanPlusTemplate { |
| 797 |
pub csrf_token: CsrfTokenOption, |
| 798 |
pub session_user: Option<SessionUser>, |
| 799 |
|
| 800 |
pub is_subscribed: bool, |
| 801 |
|
| 802 |
pub period_end: Option<String>, |
| 803 |
|
| 804 |
pub just_subscribed: bool, |
| 805 |
} |
| 806 |
|
| 807 |
|
| 808 |
|
| 809 |
|
| 810 |
#[derive(Template)] |
| 811 |
#[template(path = "pages/project_blog.html")] |
| 812 |
pub struct ProjectBlogTemplate { |
| 813 |
pub csrf_token: CsrfTokenOption, |
| 814 |
pub session_user: Option<SessionUser>, |
| 815 |
pub project: Project, |
| 816 |
pub creator_username: String, |
| 817 |
pub project_slug: String, |
| 818 |
pub posts: Vec<BlogPostSummary>, |
| 819 |
} |
| 820 |
|
| 821 |
|
| 822 |
#[derive(Template)] |
| 823 |
#[template(path = "pages/blog_post.html")] |
| 824 |
pub struct BlogPostTemplate { |
| 825 |
pub csrf_token: CsrfTokenOption, |
| 826 |
pub session_user: Option<SessionUser>, |
| 827 |
pub title: String, |
| 828 |
|
| 829 |
pub title_json: String, |
| 830 |
pub body_html: String, |
| 831 |
pub published_at: String, |
| 832 |
pub creator_username: String, |
| 833 |
pub creator_display_name: Option<String>, |
| 834 |
pub creator_avatar_initials: String, |
| 835 |
pub project_title: String, |
| 836 |
|
| 837 |
pub project_title_json: String, |
| 838 |
pub project_slug: String, |
| 839 |
|
| 840 |
pub post_slug: String, |
| 841 |
|
| 842 |
pub host_url: Arc<str>, |
| 843 |
|
| 844 |
pub project_cover_image_url: Option<String>, |
| 845 |
|
| 846 |
pub discussion_url: Option<String>, |
| 847 |
|
| 848 |
pub discussion_count: Option<i64>, |
| 849 |
} |
| 850 |
|
| 851 |
|
| 852 |
|
| 853 |
|
| 854 |
#[derive(Template)] |
| 855 |
#[template(path = "pages/doc.html")] |
| 856 |
pub struct DocTemplate { |
| 857 |
pub csrf_token: CsrfTokenOption, |
| 858 |
pub session_user: Option<SessionUser>, |
| 859 |
pub title: String, |
| 860 |
pub section: String, |
| 861 |
pub content: String, |
| 862 |
|
| 863 |
|
| 864 |
|
| 865 |
pub backlinks: Vec<DocSectionEntry>, |
| 866 |
} |
| 867 |
|
| 868 |
|
| 869 |
pub struct DocSectionEntry { |
| 870 |
pub title: String, |
| 871 |
pub slug: String, |
| 872 |
} |
| 873 |
|
| 874 |
|
| 875 |
pub struct DocSubsection { |
| 876 |
pub label: String, |
| 877 |
pub entries: Vec<DocSectionEntry>, |
| 878 |
} |
| 879 |
|
| 880 |
|
| 881 |
pub struct DocSection { |
| 882 |
pub name: String, |
| 883 |
pub entries: Vec<DocSectionEntry>, |
| 884 |
pub subsections: Vec<DocSubsection>, |
| 885 |
} |
| 886 |
|
| 887 |
|
| 888 |
#[derive(Template)] |
| 889 |
#[template(path = "pages/doc_index.html")] |
| 890 |
pub struct DocIndexTemplate { |
| 891 |
pub csrf_token: CsrfTokenOption, |
| 892 |
pub session_user: Option<SessionUser>, |
| 893 |
pub sections: Vec<DocSection>, |
| 894 |
} |
| 895 |
|
| 896 |
|
| 897 |
|
| 898 |
|
| 899 |
|
| 900 |
#[derive(Template)] |
| 901 |
#[template(path = "pages/pricing.html")] |
| 902 |
pub struct PricingTemplate { |
| 903 |
pub csrf_token: CsrfTokenOption, |
| 904 |
pub tier_prices: crate::tier_prices::TierPrices, |
| 905 |
|
| 906 |
|
| 907 |
|
| 908 |
|
| 909 |
|
| 910 |
pub founder_window_open: bool, |
| 911 |
|
| 912 |
|
| 913 |
pub inputs: crate::fee_calculator::Inputs, |
| 914 |
|
| 915 |
|
| 916 |
pub other_pct_display: String, |
| 917 |
pub other_per_sale_display: String, |
| 918 |
|
| 919 |
|
| 920 |
pub outcome: crate::fee_calculator::Outcome, |
| 921 |
} |
| 922 |
|
| 923 |
|
| 924 |
|
| 925 |
#[derive(Template)] |
| 926 |
#[template(path = "partials/fee_calculator.html")] |
| 927 |
pub struct FeeCalculatorPartial { |
| 928 |
pub outcome: crate::fee_calculator::Outcome, |
| 929 |
} |
| 930 |
|
| 931 |
|
| 932 |
|
| 933 |
|
| 934 |
|
| 935 |
#[derive(Template)] |
| 936 |
#[template(path = "pages/economics.html")] |
| 937 |
#[allow(dead_code)] |
| 938 |
pub struct EconomicsTemplate { |
| 939 |
pub csrf_token: CsrfTokenOption, |
| 940 |
pub session_user: Option<SessionUser>, |
| 941 |
|
| 942 |
|
| 943 |
pub runway_config: crate::tier_prices::RunwayConfig, |
| 944 |
|
| 945 |
|
| 946 |
|
| 947 |
pub paying_creators: i64, |
| 948 |
|
| 949 |
|
| 950 |
|
| 951 |
pub trialing_or_grace: i64, |
| 952 |
} |
| 953 |
|
| 954 |
|
| 955 |
#[derive(Template)] |
| 956 |
#[template(path = "pages/use_cases.html")] |
| 957 |
pub struct UseCasesTemplate { |
| 958 |
pub csrf_token: CsrfTokenOption, |
| 959 |
pub session_user: Option<SessionUser>, |
| 960 |
pub tier_prices: crate::tier_prices::TierPrices, |
| 961 |
} |
| 962 |
|
| 963 |
|
| 964 |
#[derive(Template)] |
| 965 |
#[template(path = "pages/team.html")] |
| 966 |
pub struct TeamTemplate { |
| 967 |
pub csrf_token: CsrfTokenOption, |
| 968 |
pub session_user: Option<SessionUser>, |
| 969 |
} |
| 970 |
|
| 971 |
|
| 972 |
|
| 973 |
|
| 974 |
#[derive(Template)] |
| 975 |
#[template(path = "pages/creators.html")] |
| 976 |
pub struct CreatorsTemplate { |
| 977 |
pub csrf_token: CsrfTokenOption, |
| 978 |
pub session_user: Option<SessionUser>, |
| 979 |
pub total_creators: u32, |
| 980 |
pub is_creator: bool, |
| 981 |
pub tier_prices: crate::tier_prices::TierPrices, |
| 982 |
} |
| 983 |
|
| 984 |
|
| 985 |
|
| 986 |
|
| 987 |
#[derive(Template)] |
| 988 |
#[template(path = "pages/email_result.html")] |
| 989 |
pub struct EmailResultTemplate { |
| 990 |
pub csrf_token: CsrfTokenOption, |
| 991 |
pub title: String, |
| 992 |
pub message: String, |
| 993 |
pub link_url: String, |
| 994 |
pub link_text: String, |
| 995 |
} |
| 996 |
|
| 997 |
|
| 998 |
|
| 999 |
|
| 1000 |
|
| 1001 |
#[derive(Template)] |
| 1002 |
#[template(path = "pages/email_preferences.html")] |
| 1003 |
pub struct EmailPreferencesTemplate { |
| 1004 |
pub csrf_token: CsrfTokenOption, |
| 1005 |
|
| 1006 |
|
| 1007 |
pub token: String, |
| 1008 |
pub signature: String, |
| 1009 |
|
| 1010 |
|
| 1011 |
pub origin_subscription: crate::db::ListSubscriptionId, |
| 1012 |
pub subscriptions: Vec<crate::db::lists::SubscriptionRow>, |
| 1013 |
} |
| 1014 |
|
| 1015 |
|
| 1016 |
#[derive(Template)] |
| 1017 |
#[template(path = "pages/receipt.html")] |
| 1018 |
pub struct ReceiptTemplate { |
| 1019 |
pub csrf_token: CsrfTokenOption, |
| 1020 |
|
| 1021 |
|
| 1022 |
pub currency_symbol: &'static str, |
| 1023 |
|
| 1024 |
|
| 1025 |
|
| 1026 |
|
| 1027 |
|
| 1028 |
|
| 1029 |
|
| 1030 |
pub presented_amount: String, |
| 1031 |
pub session_user: Option<crate::auth::SessionUser>, |
| 1032 |
pub transaction_id: String, |
| 1033 |
pub item_id: String, |
| 1034 |
pub item_title: String, |
| 1035 |
pub seller_username: String, |
| 1036 |
pub amount: String, |
| 1037 |
pub is_free: bool, |
| 1038 |
pub status: String, |
| 1039 |
pub date: String, |
| 1040 |
} |
| 1041 |
|
| 1042 |
|
| 1043 |
#[derive(Template)] |
| 1044 |
#[template(path = "pages/confirm_delete.html")] |
| 1045 |
pub struct ConfirmDeleteTemplate { |
| 1046 |
pub csrf_token: CsrfTokenOption, |
| 1047 |
pub user: String, |
| 1048 |
pub expires: String, |
| 1049 |
pub sig: String, |
| 1050 |
} |
| 1051 |
|
| 1052 |
|
| 1053 |
|
| 1054 |
|
| 1055 |
|
| 1056 |
|
| 1057 |
#[derive(Template)] |
| 1058 |
#[template(path = "pages/acknowledge.html")] |
| 1059 |
pub struct AcknowledgeTemplate { |
| 1060 |
|
| 1061 |
|
| 1062 |
|
| 1063 |
pub csrf_token: CsrfTokenOption, |
| 1064 |
pub title: String, |
| 1065 |
|
| 1066 |
|
| 1067 |
pub detail: Vec<String>, |
| 1068 |
pub token: String, |
| 1069 |
pub acknowledged: bool, |
| 1070 |
} |
| 1071 |
|
| 1072 |
|
| 1073 |
#[derive(Template)] |
| 1074 |
#[template(path = "pages/account-deleted.html")] |
| 1075 |
pub struct AccountDeletedTemplate { |
| 1076 |
pub csrf_token: CsrfTokenOption, |
| 1077 |
} |
| 1078 |
|
| 1079 |
#[cfg(test)] |
| 1080 |
mod conversion_visibility_tests { |
| 1081 |
use super::cart_conversion_applies; |
| 1082 |
use crate::currency::SettlementCurrency; |
| 1083 |
|
| 1084 |
#[test] |
| 1085 |
fn an_unknown_buyer_currency_always_gets_the_choice() { |
| 1086 |
|
| 1087 |
|
| 1088 |
for seller in SettlementCurrency::ALL { |
| 1089 |
assert!(cart_conversion_applies(None, seller), "{seller}"); |
| 1090 |
} |
| 1091 |
} |
| 1092 |
|
| 1093 |
#[test] |
| 1094 |
fn a_known_match_hides_the_choice() { |
| 1095 |
assert!(!cart_conversion_applies( |
| 1096 |
Some(SettlementCurrency::Gbp), |
| 1097 |
SettlementCurrency::Gbp |
| 1098 |
)); |
| 1099 |
} |
| 1100 |
|
| 1101 |
#[test] |
| 1102 |
fn a_known_mismatch_shows_the_choice() { |
| 1103 |
assert!(cart_conversion_applies( |
| 1104 |
Some(SettlementCurrency::Gbp), |
| 1105 |
SettlementCurrency::Usd |
| 1106 |
)); |
| 1107 |
} |
| 1108 |
} |
| 1109 |
|