You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

703 lines
25KB

  1. use std::collections::{HashMap};
  2. use std::iter::FromIterator;
  3. use std::fs::{remove_dir_all, copy, create_dir_all};
  4. use std::path::{Path, PathBuf};
  5. use glob::glob;
  6. use tera::{Tera, Context};
  7. use slug::slugify;
  8. use walkdir::WalkDir;
  9. use errors::{Result, ResultExt};
  10. use config::{Config, get_config};
  11. use page::{Page, populate_previous_and_next_pages, sort_pages};
  12. use pagination::Paginator;
  13. use utils::{create_file, create_directory};
  14. use section::{Section};
  15. use front_matter::{SortBy};
  16. use filters;
  17. use global_fns;
  18. lazy_static! {
  19. pub static ref GUTENBERG_TERA: Tera = {
  20. let mut tera = Tera::default();
  21. tera.add_raw_templates(vec![
  22. ("rss.xml", include_str!("templates/rss.xml")),
  23. ("sitemap.xml", include_str!("templates/sitemap.xml")),
  24. ("robots.txt", include_str!("templates/robots.txt")),
  25. ("anchor-link.html", include_str!("templates/anchor-link.html")),
  26. ("shortcodes/youtube.html", include_str!("templates/shortcodes/youtube.html")),
  27. ("shortcodes/vimeo.html", include_str!("templates/shortcodes/vimeo.html")),
  28. ("shortcodes/gist.html", include_str!("templates/shortcodes/gist.html")),
  29. ("internal/alias.html", include_str!("templates/internal/alias.html")),
  30. ]).unwrap();
  31. tera
  32. };
  33. }
  34. /// Renders the `internal/alias.html` template that will redirect
  35. /// via refresh to the url given
  36. fn render_alias(url: &str, tera: &Tera) -> Result<String> {
  37. let mut context = Context::new();
  38. context.add("url", &url);
  39. tera.render("internal/alias.html", &context)
  40. .chain_err(|| format!("Failed to render alias for '{}'", url))
  41. }
  42. #[derive(Debug, PartialEq)]
  43. enum RenderList {
  44. Tags,
  45. Categories,
  46. }
  47. /// A tag or category
  48. #[derive(Debug, Serialize, PartialEq)]
  49. struct ListItem {
  50. name: String,
  51. slug: String,
  52. count: usize,
  53. }
  54. impl ListItem {
  55. pub fn new(name: &str, count: usize) -> ListItem {
  56. ListItem {
  57. name: name.to_string(),
  58. slug: slugify(name),
  59. count: count,
  60. }
  61. }
  62. }
  63. #[derive(Debug)]
  64. pub struct Site {
  65. pub base_path: PathBuf,
  66. pub config: Config,
  67. pub pages: HashMap<PathBuf, Page>,
  68. pub sections: HashMap<PathBuf, Section>,
  69. pub tera: Tera,
  70. live_reload: bool,
  71. output_path: PathBuf,
  72. static_path: PathBuf,
  73. pub tags: HashMap<String, Vec<PathBuf>>,
  74. pub categories: HashMap<String, Vec<PathBuf>>,
  75. pub permalinks: HashMap<String, String>,
  76. }
  77. impl Site {
  78. /// Parse a site at the given path. Defaults to the current dir
  79. /// Passing in a path is only used in tests
  80. pub fn new<P: AsRef<Path>>(path: P, config_file: &str) -> Result<Site> {
  81. let path = path.as_ref();
  82. let tpl_glob = format!("{}/{}", path.to_string_lossy().replace("\\", "/"), "templates/**/*.*ml");
  83. let mut tera = Tera::new(&tpl_glob).chain_err(|| "Error parsing templates")?;
  84. tera.extend(&GUTENBERG_TERA)?;
  85. tera.register_filter("markdown", filters::markdown);
  86. tera.register_filter("base64_encode", filters::base64_encode);
  87. tera.register_filter("base64_decode", filters::base64_decode);
  88. let site = Site {
  89. base_path: path.to_path_buf(),
  90. config: get_config(path, config_file),
  91. pages: HashMap::new(),
  92. sections: HashMap::new(),
  93. tera: tera,
  94. live_reload: false,
  95. output_path: path.join("public"),
  96. static_path: path.join("static"),
  97. tags: HashMap::new(),
  98. categories: HashMap::new(),
  99. permalinks: HashMap::new(),
  100. };
  101. Ok(site)
  102. }
  103. /// What the function name says
  104. pub fn enable_live_reload(&mut self) {
  105. self.live_reload = true;
  106. }
  107. /// Gets the path of all ignored pages in the site
  108. pub fn get_ignored_pages(&self) -> Vec<PathBuf> {
  109. self.sections
  110. .values()
  111. .flat_map(|s| s.ignored_pages.iter().map(|p| p.file_path.clone()))
  112. .collect()
  113. }
  114. /// Get all the orphan (== without section) pages in the site
  115. pub fn get_all_orphan_pages(&self) -> Vec<&Page> {
  116. let mut pages_in_sections = vec![];
  117. let mut orphans = vec![];
  118. for s in self.sections.values() {
  119. pages_in_sections.extend(s.all_pages_path());
  120. }
  121. for page in self.pages.values() {
  122. if !pages_in_sections.contains(&page.file_path) {
  123. orphans.push(page);
  124. }
  125. }
  126. orphans
  127. }
  128. /// Used by tests to change the output path to a tmp dir
  129. #[doc(hidden)]
  130. pub fn set_output_path<P: AsRef<Path>>(&mut self, path: P) {
  131. self.output_path = path.as_ref().to_path_buf();
  132. }
  133. /// Reads all .md files in the `content` directory and create pages/sections
  134. /// out of them
  135. pub fn load(&mut self) -> Result<()> {
  136. let base_path = self.base_path.to_string_lossy().replace("\\", "/");
  137. let content_glob = format!("{}/{}", base_path, "content/**/*.md");
  138. for entry in glob(&content_glob).unwrap().filter_map(|e| e.ok()) {
  139. let path = entry.as_path();
  140. if path.file_name().unwrap() == "_index.md" {
  141. self.add_section(path)?;
  142. } else {
  143. self.add_page(path)?;
  144. }
  145. }
  146. // Insert a default index section so we don't need to create a _index.md to render
  147. // the index page
  148. let index_path = self.base_path.join("content").join("_index.md");
  149. if !self.sections.contains_key(&index_path) {
  150. let mut index_section = Section::default();
  151. index_section.permalink = self.config.make_permalink("");
  152. self.sections.insert(index_path, index_section);
  153. }
  154. // A map of all .md files (section and pages) and their permalink
  155. // We need that if there are relative links in the content that need to be resolved
  156. let mut permalinks = HashMap::new();
  157. for page in self.pages.values() {
  158. permalinks.insert(page.relative_path.clone(), page.permalink.clone());
  159. }
  160. for section in self.sections.values() {
  161. permalinks.insert(section.relative_path.clone(), section.permalink.clone());
  162. }
  163. for page in self.pages.values_mut() {
  164. page.render_markdown(&permalinks, &self.tera, &self.config)?;
  165. }
  166. for section in self.sections.values_mut() {
  167. section.render_markdown(&permalinks, &self.tera, &self.config)?;
  168. }
  169. self.permalinks = permalinks;
  170. self.populate_sections();
  171. self.populate_tags_and_categories();
  172. self.tera.register_global_function("get_page", global_fns::make_get_page(&self.pages));
  173. Ok(())
  174. }
  175. /// Simple wrapper fn to avoid repeating that code in several places
  176. fn add_page(&mut self, path: &Path) -> Result<()> {
  177. let page = Page::from_file(&path, &self.config)?;
  178. self.pages.insert(page.file_path.clone(), page);
  179. Ok(())
  180. }
  181. /// Simple wrapper fn to avoid repeating that code in several places
  182. fn add_section(&mut self, path: &Path) -> Result<()> {
  183. let section = Section::from_file(path, &self.config)?;
  184. self.sections.insert(section.file_path.clone(), section);
  185. Ok(())
  186. }
  187. /// Called in serve, add the section and render it
  188. fn add_section_and_render(&mut self, path: &Path) -> Result<()> {
  189. self.add_section(path)?;
  190. let mut section = self.sections.get_mut(path).unwrap();
  191. self.permalinks.insert(section.relative_path.clone(), section.permalink.clone());
  192. section.render_markdown(&self.permalinks, &self.tera, &self.config)?;
  193. Ok(())
  194. }
  195. /// Called in serve, add a page again updating permalinks and its content
  196. /// The bool in the result is whether the front matter has been updated or not
  197. /// TODO: the above is very confusing, change that
  198. fn add_page_and_render(&mut self, path: &Path) -> Result<(bool, Page)> {
  199. let existing_page = self.pages.get(path).cloned();
  200. self.add_page(path)?;
  201. let mut page = self.pages.get_mut(path).unwrap();
  202. self.permalinks.insert(page.relative_path.clone(), page.permalink.clone());
  203. page.render_markdown(&self.permalinks, &self.tera, &self.config)?;
  204. if let Some(prev_page) = existing_page {
  205. return Ok((prev_page.meta != page.meta, page.clone()));
  206. }
  207. Ok((true, page.clone()))
  208. }
  209. /// Find out the direct subsections of each subsection if there are some
  210. /// as well as the pages for each section
  211. pub fn populate_sections(&mut self) {
  212. for page in self.pages.values() {
  213. if self.sections.contains_key(&page.parent_path.join("_index.md")) {
  214. self.sections.get_mut(&page.parent_path.join("_index.md")).unwrap().pages.push(page.clone());
  215. }
  216. }
  217. let mut grandparent_paths = HashMap::new();
  218. for section in self.sections.values() {
  219. if let Some(grand_parent) = section.parent_path.parent() {
  220. grandparent_paths.entry(grand_parent.to_path_buf()).or_insert_with(|| vec![]).push(section.clone());
  221. }
  222. }
  223. for section in self.sections.values_mut() {
  224. // TODO: avoid this clone
  225. let (mut sorted_pages, cannot_be_sorted_pages) = sort_pages(section.pages.clone(), section.meta.sort_by());
  226. sorted_pages = populate_previous_and_next_pages(&sorted_pages);
  227. section.pages = sorted_pages;
  228. section.ignored_pages = cannot_be_sorted_pages;
  229. match grandparent_paths.get(&section.parent_path) {
  230. Some(paths) => section.subsections.extend(paths.clone()),
  231. None => continue,
  232. };
  233. }
  234. }
  235. /// Separated from `parse` for easier testing
  236. pub fn populate_tags_and_categories(&mut self) {
  237. for page in self.pages.values() {
  238. if let Some(ref category) = page.meta.category {
  239. self.categories
  240. .entry(category.to_string())
  241. .or_insert_with(|| vec![])
  242. .push(page.file_path.clone());
  243. }
  244. if let Some(ref tags) = page.meta.tags {
  245. for tag in tags {
  246. self.tags
  247. .entry(tag.to_string())
  248. .or_insert_with(|| vec![])
  249. .push(page.file_path.clone());
  250. }
  251. }
  252. }
  253. }
  254. /// Inject live reload script tag if in live reload mode
  255. fn inject_livereload(&self, html: String) -> String {
  256. if self.live_reload {
  257. return html.replace(
  258. "</body>",
  259. r#"<script src="/livereload.js?port=1112&mindelay=10"></script></body>"#
  260. );
  261. }
  262. html
  263. }
  264. pub fn ensure_public_directory_exists(&self) -> Result<()> {
  265. let public = self.output_path.clone();
  266. if !public.exists() {
  267. create_directory(&public)?;
  268. }
  269. Ok(())
  270. }
  271. /// Copy static file to public directory.
  272. pub fn copy_static_file<P: AsRef<Path>>(&self, path: P) -> Result<()> {
  273. let relative_path = path.as_ref().strip_prefix(&self.static_path).unwrap();
  274. let target_path = self.output_path.join(relative_path);
  275. if let Some(parent_directory) = target_path.parent() {
  276. create_dir_all(parent_directory)?;
  277. }
  278. copy(path.as_ref(), &target_path)?;
  279. Ok(())
  280. }
  281. /// Copy the content of the `static` folder into the `public` folder
  282. pub fn copy_static_directory(&self) -> Result<()> {
  283. for entry in WalkDir::new(&self.static_path).into_iter().filter_map(|e| e.ok()) {
  284. let relative_path = entry.path().strip_prefix(&self.static_path).unwrap();
  285. let target_path = self.output_path.join(relative_path);
  286. if entry.path().is_dir() {
  287. if !target_path.exists() {
  288. create_directory(&target_path)?;
  289. }
  290. } else {
  291. let entry_fullpath = self.base_path.join(entry.path());
  292. self.copy_static_file(entry_fullpath)?;
  293. }
  294. }
  295. Ok(())
  296. }
  297. /// Deletes the `public` directory if it exists
  298. pub fn clean(&self) -> Result<()> {
  299. if self.output_path.exists() {
  300. // Delete current `public` directory so we can start fresh
  301. remove_dir_all(&self.output_path).chain_err(|| "Couldn't delete `public` directory")?;
  302. }
  303. Ok(())
  304. }
  305. pub fn rebuild_after_content_change(&mut self, path: &Path) -> Result<()> {
  306. let is_section = path.ends_with("_index.md");
  307. if path.exists() {
  308. // file exists, either a new one or updating content
  309. if is_section {
  310. self.add_section_and_render(path)?;
  311. self.render_sections()?;
  312. } else {
  313. // probably just an update so just re-parse that page
  314. let (frontmatter_changed, page) = self.add_page_and_render(path)?;
  315. // TODO: can probably be smarter and check what changed
  316. if frontmatter_changed {
  317. self.populate_sections();
  318. self.populate_tags_and_categories();
  319. self.build()?;
  320. } else {
  321. self.render_page(&page)?;
  322. }
  323. }
  324. } else {
  325. // File doesn't exist -> a deletion so we remove it from everything
  326. let relative_path = if is_section {
  327. self.sections[path].relative_path.clone()
  328. } else {
  329. self.pages[path].relative_path.clone()
  330. };
  331. self.permalinks.remove(&relative_path);
  332. if is_section {
  333. self.sections.remove(path);
  334. } else {
  335. self.pages.remove(path);
  336. }
  337. // TODO: probably no need to do that, we should be able to only re-render a page or a section.
  338. self.populate_sections();
  339. self.populate_tags_and_categories();
  340. self.build()?;
  341. }
  342. Ok(())
  343. }
  344. pub fn rebuild_after_template_change(&mut self, path: &Path) -> Result<()> {
  345. self.tera.full_reload()?;
  346. match path.file_name().unwrap().to_str().unwrap() {
  347. "sitemap.xml" => self.render_sitemap(),
  348. "rss.xml" => self.render_rss_feed(),
  349. _ => self.build() // TODO: change that
  350. }
  351. }
  352. /// Renders a single content page
  353. pub fn render_page(&self, page: &Page) -> Result<()> {
  354. self.ensure_public_directory_exists()?;
  355. // Copy the nesting of the content directory if we have sections for that page
  356. let mut current_path = self.output_path.to_path_buf();
  357. for component in page.path.split('/') {
  358. current_path.push(component);
  359. if !current_path.exists() {
  360. create_directory(&current_path)?;
  361. }
  362. }
  363. // Make sure the folder exists
  364. create_directory(&current_path)?;
  365. // Finally, create a index.html file there with the page rendered
  366. let output = page.render_html(&self.tera, &self.config)?;
  367. create_file(current_path.join("index.html"), &self.inject_livereload(output))?;
  368. // Copy any asset we found previously into the same directory as the index.html
  369. for asset in &page.assets {
  370. let asset_path = asset.as_path();
  371. copy(&asset_path, &current_path.join(asset_path.file_name().unwrap()))?;
  372. }
  373. Ok(())
  374. }
  375. /// Builds the site to the `public` directory after deleting it
  376. pub fn build(&self) -> Result<()> {
  377. self.clean()?;
  378. self.render_sections()?;
  379. self.render_orphan_pages()?;
  380. self.render_sitemap()?;
  381. if self.config.generate_rss.unwrap() {
  382. self.render_rss_feed()?;
  383. }
  384. self.render_robots()?;
  385. if self.config.generate_categories_pages.unwrap() {
  386. self.render_categories_and_tags(RenderList::Categories)?;
  387. }
  388. if self.config.generate_tags_pages.unwrap() {
  389. self.render_categories_and_tags(RenderList::Tags)?;
  390. }
  391. self.copy_static_directory()
  392. }
  393. /// Renders robots.txt
  394. fn render_robots(&self) -> Result<()> {
  395. self.ensure_public_directory_exists()?;
  396. create_file(
  397. self.output_path.join("robots.txt"),
  398. &self.tera.render("robots.txt", &Context::new())?
  399. )
  400. }
  401. /// Render the /{categories, list} pages and each individual category/tag page
  402. /// They are the same thing fundamentally, a list of pages with something in common
  403. fn render_categories_and_tags(&self, kind: RenderList) -> Result<()> {
  404. let items = match kind {
  405. RenderList::Categories => &self.categories,
  406. RenderList::Tags => &self.tags,
  407. };
  408. if items.is_empty() {
  409. return Ok(());
  410. }
  411. let (list_tpl_name, single_tpl_name, name, var_name) = if kind == RenderList::Categories {
  412. ("categories.html", "category.html", "categories", "category")
  413. } else {
  414. ("tags.html", "tag.html", "tags", "tag")
  415. };
  416. self.ensure_public_directory_exists()?;
  417. // Create the categories/tags directory first
  418. let public = self.output_path.clone();
  419. let mut output_path = public.to_path_buf();
  420. output_path.push(name);
  421. create_directory(&output_path)?;
  422. // Then render the index page for that kind.
  423. // We sort by number of page in that category/tag
  424. let mut sorted_items = vec![];
  425. for (item, count) in Vec::from_iter(items).into_iter().map(|(a, b)| (a, b.len())) {
  426. sorted_items.push(ListItem::new(item, count));
  427. }
  428. sorted_items.sort_by(|a, b| b.count.cmp(&a.count));
  429. let mut context = Context::new();
  430. context.add(name, &sorted_items);
  431. context.add("config", &self.config);
  432. context.add("current_url", &self.config.make_permalink(name));
  433. context.add("current_path", &format!("/{}", name));
  434. // And render it immediately
  435. let list_output = self.tera.render(list_tpl_name, &context)?;
  436. create_file(output_path.join("index.html"), &self.inject_livereload(list_output))?;
  437. // Now, each individual item
  438. for (item_name, pages_paths) in items.iter() {
  439. let pages: Vec<&Page> = self.pages
  440. .iter()
  441. .filter(|&(path, _)| pages_paths.contains(path))
  442. .map(|(_, page)| page)
  443. .collect();
  444. // TODO: how to sort categories and tag content?
  445. // Have a setting in config.toml or a _category.md and _tag.md
  446. // The latter is more in line with the rest of Gutenberg but order ordering
  447. // doesn't really work across sections.
  448. let mut context = Context::new();
  449. let slug = slugify(&item_name);
  450. context.add(var_name, &item_name);
  451. context.add(&format!("{}_slug", var_name), &slug);
  452. context.add("pages", &pages);
  453. context.add("config", &self.config);
  454. context.add("current_url", &self.config.make_permalink(&format!("{}/{}", name, slug)));
  455. context.add("current_path", &format!("/{}/{}", name, slug));
  456. let single_output = self.tera.render(single_tpl_name, &context)?;
  457. create_directory(&output_path.join(&slug))?;
  458. create_file(
  459. output_path.join(&slug).join("index.html"),
  460. &self.inject_livereload(single_output)
  461. )?;
  462. }
  463. Ok(())
  464. }
  465. fn render_sitemap(&self) -> Result<()> {
  466. self.ensure_public_directory_exists()?;
  467. let mut context = Context::new();
  468. context.add("pages", &self.pages.values().collect::<Vec<&Page>>());
  469. context.add("sections", &self.sections.values().collect::<Vec<&Section>>());
  470. let mut categories = vec![];
  471. if self.config.generate_categories_pages.unwrap() && !self.categories.is_empty() {
  472. categories.push(self.config.make_permalink("categories"));
  473. for category in self.categories.keys() {
  474. categories.push(
  475. self.config.make_permalink(&format!("categories/{}", slugify(category)))
  476. );
  477. }
  478. }
  479. context.add("categories", &categories);
  480. let mut tags = vec![];
  481. if self.config.generate_tags_pages.unwrap() && !self.tags.is_empty() {
  482. tags.push(self.config.make_permalink("tags"));
  483. for tag in self.tags.keys() {
  484. tags.push(
  485. self.config.make_permalink(&format!("tags/{}", slugify(tag)))
  486. );
  487. }
  488. }
  489. context.add("tags", &tags);
  490. let sitemap = self.tera.render("sitemap.xml", &context)?;
  491. create_file(self.output_path.join("sitemap.xml"), &sitemap)?;
  492. Ok(())
  493. }
  494. fn render_rss_feed(&self) -> Result<()> {
  495. self.ensure_public_directory_exists()?;
  496. let mut context = Context::new();
  497. let pages = self.pages.values()
  498. .filter(|p| p.meta.date.is_some())
  499. .take(15) // limit to the last 15 elements
  500. .cloned()
  501. .collect::<Vec<Page>>();
  502. // Don't generate a RSS feed if none of the pages has a date
  503. if pages.is_empty() {
  504. return Ok(());
  505. }
  506. context.add("last_build_date", &pages[0].meta.date);
  507. let (sorted_pages, _) = sort_pages(pages, SortBy::Date);
  508. context.add("pages", &sorted_pages);
  509. context.add("config", &self.config);
  510. let rss_feed_url = if self.config.base_url.ends_with('/') {
  511. format!("{}{}", self.config.base_url, "rss.xml")
  512. } else {
  513. format!("{}/{}", self.config.base_url, "rss.xml")
  514. };
  515. context.add("feed_url", &rss_feed_url);
  516. let sitemap = self.tera.render("rss.xml", &context)?;
  517. create_file(self.output_path.join("rss.xml"), &sitemap)?;
  518. Ok(())
  519. }
  520. /// Create a hashmap of paths to section
  521. /// For example `content/posts/_index.md` key will be `posts`
  522. fn get_sections_map(&self) -> HashMap<String, Section> {
  523. self.sections
  524. .values()
  525. .map(|s| (s.components.join("/"), s.clone()))
  526. .collect()
  527. }
  528. /// Renders a single section
  529. fn render_section(&self, section: &Section) -> Result<()> {
  530. self.ensure_public_directory_exists()?;
  531. let public = self.output_path.clone();
  532. let mut output_path = public.to_path_buf();
  533. for component in &section.components {
  534. output_path.push(component);
  535. if !output_path.exists() {
  536. create_directory(&output_path)?;
  537. }
  538. }
  539. for page in &section.pages {
  540. self.render_page(page)?;
  541. }
  542. if !section.meta.should_render() {
  543. return Ok(());
  544. }
  545. if section.meta.is_paginated() {
  546. self.render_paginated(&output_path, section)?;
  547. } else {
  548. let output = section.render_html(
  549. if section.is_index() { self.get_sections_map() } else { HashMap::new() },
  550. &self.tera,
  551. &self.config,
  552. )?;
  553. create_file(output_path.join("index.html"), &self.inject_livereload(output))?;
  554. }
  555. Ok(())
  556. }
  557. /// Renders all sections
  558. fn render_sections(&self) -> Result<()> {
  559. for section in self.sections.values() {
  560. self.render_section(section)?;
  561. }
  562. Ok(())
  563. }
  564. /// Renders all pages that do not belong to any sections
  565. fn render_orphan_pages(&self) -> Result<()> {
  566. self.ensure_public_directory_exists()?;
  567. for page in self.get_all_orphan_pages() {
  568. self.render_page(page)?;
  569. }
  570. Ok(())
  571. }
  572. /// Renders a list of pages when the section/index is wanting pagination.
  573. fn render_paginated(&self, output_path: &Path, section: &Section) -> Result<()> {
  574. self.ensure_public_directory_exists()?;
  575. let paginate_path = match section.meta.paginate_path {
  576. Some(ref s) => s.clone(),
  577. None => unreachable!()
  578. };
  579. let paginator = Paginator::new(&section.pages, section);
  580. for (i, pager) in paginator.pagers.iter().enumerate() {
  581. let folder_path = output_path.join(&paginate_path);
  582. let page_path = folder_path.join(&format!("{}", i + 1));
  583. create_directory(&folder_path)?;
  584. create_directory(&page_path)?;
  585. let output = paginator.render_pager(pager, self)?;
  586. if i > 0 {
  587. create_file(page_path.join("index.html"), &self.inject_livereload(output))?;
  588. } else {
  589. create_file(output_path.join("index.html"), &self.inject_livereload(output))?;
  590. create_file(page_path.join("index.html"), &render_alias(&section.permalink, &self.tera)?)?;
  591. }
  592. }
  593. Ok(())
  594. }
  595. }