acorn_lib/
constants.rs

1//! # Constants, regular expressions, and configuration values
2//!
3//! This module contains a collection of regular expressions, configuration values, and guidelines for research activity data. This includes section character counts and line counts.
4//!
5use fancy_regex::Regex;
6use lazy_static::lazy_static;
7
8/// ORNL disclaimer
9pub const DISCLAIMER: &str = "Oak Ridge National Laboratory is managed by UT-Batelle LLC for the US Department of Energy";
10/// Base URL for deploying ORNL data
11pub const BASE_URL: &str = "https://research.ornl.gov";
12/// RGB color for transparency
13pub const COLOR_TRANSPARENT: [u8; 4] = [255, 255, 255, 0];
14/// RGB ORNL brand primary color
15///
16// See <https://www.olcf.ornl.gov/about-olcf/media-assets/>
17pub const COLOR_PRIMARY: [u8; 4] = [0, 121, 52, 255];
18/// URL for Vale releases
19pub const VALE_RELEASES_URL: &str = "https://github.com/errata-ai/vale/releases";
20/// Version of Vale to use with ACORN
21pub const VALE_VERSION: &str = "3.9.4";
22/// URL for custom ORNL Science Vale package
23pub const DEFAULT_VALE_PACKAGE_URL: &str = "https://code.ornl.gov/research-enablement/vale-package/-/archive/v0.0.1/vale-package-v0.0.1.zip";
24/// Custom Vale package name
25pub const CUSTOM_VALE_PACKAGE_NAME: &str = "Science";
26/// Enabled Vale packages
27pub const ENABLED_VALE_PACKAGES: [&str; 4] = ["Google", "proselint", "write-good", "Joblint"];
28/// Disabled Vale rules
29pub const DISABLED_VALE_RULES: [&str; 14] = [
30    "Vale.Terms",
31    "Google.EmDash",
32    "Google.Contractions",
33    "Google.GenderBias",
34    "Google.Headings",
35    "Google.Parens",
36    "Google.Quotes",
37    "Google.We",
38    "Joblint.Competitive",
39    "proselint.GenderBias",
40    "write-good.E-Prime",
41    "write-good.Passive",
42    "write-good.TooWordy",
43    "write-good.Weasel",
44];
45// Project folder values
46/// Application name
47pub const APPLICATION: &str = "acorn";
48/// Organization name
49pub const ORGANIZATION: &str = "ornl";
50/// Organization qualifier
51pub const QUALIFIER: &str = "org";
52// Schema defaults
53/// Default affiliation
54pub const DEFAULT_AFFILIATION: &str = "Oak Ridge National Laboratory";
55/// Default graphic content URL (href)
56pub const DEFAULT_GRAPHIC_HREF: &str = "00.png";
57/// Default graphic caption
58pub const DEFAULT_GRAPHIC_CAPTION: &str = "";
59/// Maxumum number of [`ResearchActivity`] [`approaches`]
60///
61/// [`ResearchActivity`]: ../schema/struct.ResearchActivity.html
62/// [`approaches`]: ../schema/struct.Sections.html#structfield.approach
63pub const MAX_COUNT_APPROACH: u64 = 6;
64/// Maxumum number of [`ResearchActivity`] [`capabilities`]
65///
66/// [`ResearchActivity`]: ../schema/struct.ResearchActivity.html
67/// [`capabilities`]: ../schema/struct.Sections.html#structfield.capabilities
68pub const MAX_COUNT_CAPABILITIES: u64 = 6;
69/// Maxumum number of [impact statements](../schema/struct.Sections.html#structfield.impact)
70pub const MAX_COUNT_IMPACT: u64 = 6;
71/// Maximum number of [research areas](../schema/struct.Research.html#structfield.areas)
72pub const MAX_COUNT_RESEARCH_AREAS: u64 = 4;
73/// Maximum number of characters for an [`approach`] statement
74///
75/// [`approach`]: ../schema/struct.Sections.html#structfield.approach
76pub const MAX_LENGTH_APPROACH: usize = 150;
77/// Maximum number of characters for a single [`capability`] description
78///
79/// [`capability`]: ../schema/struct.Sections.html#structfield.capabilities
80pub const MAX_LENGTH_CAPABILIY: usize = 300;
81/// Maximum number of characters for a single image caption
82pub const MAX_LENGTH_IMAGE_CAPTION: u64 = 100;
83/// Maximum number of characters for a single impact description
84pub const MAX_LENGTH_IMPACT: usize = 150;
85/// Maximum number of characters for a single [research area](../schema/struct.Research.html#structfield.areas) description
86pub const MAX_LENGTH_RESEARCH_AREA: usize = 40;
87/// Maximum number of characters for an single [research focus](../schema/struct.Research.html#structfield.focus) description
88pub const MAX_LENGTH_RESEARCH_FOCUS: u64 = 150;
89/// Maximum number of characters for a  [challenge](../schema/struct.Sections.html#structfield.challenge) section
90pub const MAX_LENGTH_SECTION_CHALLENGE: u64 = 500;
91/// Maximum number of characters for a [mission](../schema/struct.Sections.html#structfield.mission) section
92pub const MAX_LENGTH_SECTION_MISSION: u64 = 250;
93/// Maximum number of characters for a [`subtitle`]
94///
95/// [`subtitle`]: ../schema/struct.ResearchActivity.html#structfield.subtitle
96pub const MAX_LENGTH_SUBTITLE: u64 = 75;
97/// Maximum number of characters for a [`title`]
98///
99/// [`title`]: ../schema/struct.ResearchActivity.html#structfield.title
100pub const MAX_LENGTH_TITLE: u64 = 45;
101// Readability defaults
102/// Automated Readability Index (ARI) maximum allowed value
103pub const MAX_ALLOWED_ARI: f64 = 20.0;
104/// Coleman-Liau Index (CLI) maximum allowed value
105pub const MAX_ALLOWED_CLI: f64 = 20.0;
106/// Flesch-Kincaid Grade Level (FKGL) maximum allowed value
107pub const MAX_ALLOWED_FKGL: f64 = 20.0;
108/// Flesch Reading Ease Score (FRES) maximum allowed value
109pub const MAX_ALLOWED_FRES: f64 = 20.0;
110/// Gunning Fog Index (GFI) maximum allowed value
111pub const MAX_ALLOWED_GFI: f64 = 20.0;
112/// Lix Index (Lix) maximum allowed value
113pub const MAX_ALLOWED_LIX: f64 = 20.0;
114/// Simple Measure of Gobbledygook (SMOG) maximum allowed value
115pub const MAX_ALLOWED_SMOG: f64 = 20.0;
116
117lazy_static! {
118    /// Regex that should match a Digital Object Identifier (DOI)
119    ///
120    /// See <https://www.doi.org/> for more information
121    pub static ref RE_DOI: Regex = Regex::new(r#"^(doi\:)?10\.\d+/.*$"#).unwrap();
122    /// Regex that should match a Research Activity Identifier (RAiD)
123    ///
124    /// See <https://raid.org/> for more information
125    pub static ref RE_RAID: Regex = Regex::new(r#"^(doi\:)?10\.\d+/.*$"#).unwrap();
126    /// Regex that should match a Research Organization Registry (ROR)
127    ///
128    /// See <https://www.ror.org/> for more information
129    pub static ref RE_ROR: Regex = Regex::new(r#"^0[a-hj-km-np-tv-z|0-9]{6}[0-9]{2}$"#).unwrap();
130    /// Regex that should match an image extension (e.g. .png, .jpg, .jpeg, .svg)
131    pub static ref RE_IMAGE_EXTENSION: Regex = Regex::new(r#".*[.](png|PNG|jpg|JPG|jpeg|JPEG|svg|SVG|gif|GIF|webp|WEBP|tiff|TIFF)$"#).unwrap();
132    /// Regex that should match an IP6 address
133    pub static ref RE_IP6: Regex = Regex::new(r#"(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))"#).unwrap();
134    /// Regex that should match an ISO 8601 date (e.g., `YYYY-MM-DD`)
135    /// ### Example
136    /// > `2025-06-04`
137    pub static ref RE_ISO_8601_DATE: Regex = Regex::new(r#"^(?<year>(19[5-9][0-9]|20[0-2][0-9]))-(?<month>(((0[13578]|(10|12)))-(?<day>(0[1-9]|[1-2][0-9]|3[0-1]))|(02-(0[1-9]|[1-2][0-9]))|((0[469]|11)-(0[1-9]|[1-2][0-9]|30))))$"#).unwrap();
138    /// Regex that should match an ISO 8601 year from modern times, 1950 through 2029
139    /// ### Example
140    /// > `2025`
141    pub static ref RE_ISO_8601_YEAR: Regex = Regex::new(r#"^(?<year>(19[5-9][0-9]|20[0-2][0-9]))$"#).unwrap();
142    /// Regex that should match a phone number (with optional country and area codes)
143    pub static ref RE_PHONE: Regex = Regex::new(r#"^(?<country>\+\d{1,2}\s?)?(?<area>\(?\d{3}\)?)[\s.-]?(?<prefix>\d{3})[\s.-]?(?<line>\d{4})$"#).unwrap();
144    /// Regex that should match a fake phone number (e.g. 555.555.5555)
145    pub static ref RE_FAKE_PHONE: Regex = Regex::new(r#"^(\+\d{1,2}\s?)?\(?5{3}\)?[\s.-]?5{3}[\s.-]?5{4}$"#).unwrap();
146}