feat: add else clause and value modifiers to file naming patterns (#2724)
This commit is contained in:
+167
-57
@@ -197,6 +197,47 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="placeholder-group">
|
||||
<h4 class="group-title">
|
||||
<i class="pi pi-replay"></i>
|
||||
{{ t('placeholders.elseClause') }}
|
||||
</h4>
|
||||
<p class="group-description" [innerHTML]="t('placeholders.elseDesc')">
|
||||
</p>
|
||||
<div class="example-block">
|
||||
<div class="example-pattern">
|
||||
<span class="pattern-prefix">{{ t('placeholders.pattern') }}</span>
|
||||
<code>{{ '{<{series}|Standalone>/{title}' }}</code>
|
||||
</div>
|
||||
<div class="example-results">
|
||||
<div class="result-item">
|
||||
<span class="result-prefix">{{ t('placeholders.withSeries') }}</span>
|
||||
<code>The Kingkiller Chronicle/The Name of the Wind</code>
|
||||
</div>
|
||||
<div class="result-item">
|
||||
<span class="result-prefix">{{ t('placeholders.withoutSeries') }}</span>
|
||||
<code>Standalone/The Name of the Wind</code>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="placeholder-group">
|
||||
<h4 class="group-title">
|
||||
<i class="pi pi-wrench"></i>
|
||||
{{ t('placeholders.modifiers') }}
|
||||
</h4>
|
||||
<p class="group-description" [innerHTML]="t('placeholders.modifiersDesc')">
|
||||
</p>
|
||||
<div class="placeholder-list">
|
||||
<div class="placeholder-item"><code>{{ '{authors:first}' }}</code><span>{{ t('placeholders.modFirst') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{authors:sort}' }}</code><span>{{ t('placeholders.modSort') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{title:initial}' }}</code><span>{{ t('placeholders.modInitial') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{title:upper}' }}</code><span>{{ t('placeholders.modUpper') }}</span></div>
|
||||
<div class="placeholder-item"><code>{{ '{title:lower}' }}</code><span>{{ t('placeholders.modLower') }}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -214,44 +255,57 @@
|
||||
|
||||
<div class="section-body">
|
||||
<div class="examples-container">
|
||||
<div class="example-category">
|
||||
<div class="category-header">
|
||||
<h4 class="category-title">
|
||||
<i class="pi pi-check-circle"></i>
|
||||
{{ t('examples.withFull') }}
|
||||
</h4>
|
||||
<div class="sample-metadata">
|
||||
<div class="metadata-items">
|
||||
<span><strong>title:</strong> <code>The Name of the Wind</code></span>
|
||||
<span><strong>subtitle:</strong> <code>Special Edition</code></span>
|
||||
<span><strong>authors:</strong> <code>Patrick Rothfuss</code></span>
|
||||
<span><strong>series:</strong> <code>The Kingkiller Chronicle</code></span>
|
||||
<span><strong>seriesIndex:</strong> <code>01</code></span>
|
||||
<span><strong>year:</strong> <code>2007</code></span>
|
||||
</div>
|
||||
<div class="metadata-reference">
|
||||
<div class="metadata-panel metadata-panel-full">
|
||||
<div class="metadata-panel-header">
|
||||
<i class="pi pi-check-circle metadata-icon-full"></i>
|
||||
<span>{{ t('examples.fullMetadata') }}</span>
|
||||
</div>
|
||||
<div class="metadata-grid">
|
||||
<span class="metadata-key">title</span><code class="metadata-val">The Name of the Wind</code>
|
||||
<span class="metadata-key">subtitle</span><code class="metadata-val">Special Edition</code>
|
||||
<span class="metadata-key">authors</span><code class="metadata-val">Patrick Rothfuss</code>
|
||||
<span class="metadata-key">series</span><code class="metadata-val">The Kingkiller Chronicle</code>
|
||||
<span class="metadata-key">seriesIndex</span><code class="metadata-val">01</code>
|
||||
<span class="metadata-key">year</span><code class="metadata-val">2007</code>
|
||||
</div>
|
||||
</div>
|
||||
<div class="metadata-panel metadata-panel-partial">
|
||||
<div class="metadata-panel-header">
|
||||
<i class="pi pi-question-circle metadata-icon-partial"></i>
|
||||
<span>{{ t('examples.partialMetadata') }}</span>
|
||||
</div>
|
||||
<div class="metadata-grid">
|
||||
<span class="metadata-key">title</span><code class="metadata-val">Project Hail Mary</code>
|
||||
<span class="metadata-key">subtitle</span><em class="metadata-val not-set">{{ t('examples.notSet') }}</em>
|
||||
<span class="metadata-key">authors</span><code class="metadata-val">Andy Weir</code>
|
||||
<span class="metadata-key">year</span><code class="metadata-val">2021</code>
|
||||
<span class="metadata-key">series</span><em class="metadata-val not-set">{{ t('examples.notSet') }}</em>
|
||||
<span class="metadata-key">seriesIndex</span><em class="metadata-val not-set">{{ t('examples.notSet') }}</em>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="example-category">
|
||||
<h4 class="category-title">
|
||||
<i class="pi pi-hashtag"></i>
|
||||
{{ t('examples.basicGroup') }}
|
||||
</h4>
|
||||
<div class="example-grid">
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.basicPattern') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{authors} - {title}' }}</code></span>
|
||||
<span class="result-col"><code>Patrick Rothfuss - The Name of the Wind.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.withPunctuation') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{title}: {series}' }}</code></span>
|
||||
<span class="result-col"><code>The Name of the Wind: The Kingkiller Chronicle.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.seriesInFolder') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{authors}/{series}/{seriesIndex} - {title}' }}</code></span>
|
||||
<span class="result-col"><code>Patrick Rothfuss/The Kingkiller Chronicle/01 - The Name of the Wind.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.folderOnly') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{title}/' }}</code></span>
|
||||
<span class="result-col"><code>The Name of the Wind/name_of_the_wind_original.epub</code></span>
|
||||
<span class="pattern-label">{{ t('examples.titleSubtitle') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{title}: {subtitle}' }}</code></span>
|
||||
<span class="result-col"><code>The Name of the Wind: Special Edition.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.absolutePath') }}</span>
|
||||
@@ -259,9 +313,14 @@
|
||||
<span class="result-col"><code>/Patrick Rothfuss/The Name of the Wind.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.titleSubtitle') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{title}: {subtitle}' }}</code></span>
|
||||
<span class="result-col"><code>The Name of the Wind: Special Edition.epub</code></span>
|
||||
<span class="pattern-label">{{ t('examples.folderOnly') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{title}/' }}</code></span>
|
||||
<span class="result-col"><code>The Name of the Wind/name_of_the_wind_original.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.yearPrefix') }}</span>
|
||||
<span class="pattern-col"><code>{{ '({year}) {title}' }}</code></span>
|
||||
<span class="result-col"><code>(2007) The Name of the Wind.epub</code></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -269,53 +328,104 @@
|
||||
<div class="section-divider"><hr></div>
|
||||
|
||||
<div class="example-category">
|
||||
<div class="category-header">
|
||||
<h4 class="category-title">
|
||||
<i class="pi pi-question-circle"></i>
|
||||
{{ t('examples.withMissing') }}
|
||||
</h4>
|
||||
<div class="sample-metadata">
|
||||
<div class="metadata-items">
|
||||
<span><strong>title:</strong> <code>Project Hail Mary</code></span>
|
||||
<span><strong>subtitle:</strong> <em class="not-set">{{ t('examples.notSet') }}</em></span>
|
||||
<span><strong>authors:</strong> <code>Andy Weir</code></span>
|
||||
<span><strong>year:</strong> <code>2021</code></span>
|
||||
<span><strong>series:</strong> <em class="not-set">{{ t('examples.notSet') }}</em></span>
|
||||
<span><strong>seriesIndex:</strong> <em class="not-set">{{ t('examples.notSet') }}</em></span>
|
||||
<h4 class="category-title">
|
||||
<i class="pi pi-code"></i>
|
||||
{{ t('examples.conditionalGroup') }}
|
||||
</h4>
|
||||
<div class="example-grid">
|
||||
<div class="example-row-conditional">
|
||||
<span class="pattern-label">{{ t('examples.optionalBlock') }}</span>
|
||||
<span class="pattern-col"><code>{{ '<{seriesIndex}. >{title}' }}</code></span>
|
||||
<div class="result-col-dual">
|
||||
<span class="result-with"><i class="pi pi-check-circle"></i> <code>01. The Name of the Wind.epub</code></span>
|
||||
<span class="result-without"><i class="pi pi-question-circle"></i> <code>Project Hail Mary.epub</code></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="example-row-conditional">
|
||||
<span class="pattern-label">{{ t('examples.subtitleConditional') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{title}<: {subtitle}>' }}</code></span>
|
||||
<div class="result-col-dual">
|
||||
<span class="result-with"><i class="pi pi-check-circle"></i> <code>The Name of the Wind: Special Edition.epub</code></span>
|
||||
<span class="result-without"><i class="pi pi-question-circle"></i> <code>Project Hail Mary.epub</code></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="example-row-conditional">
|
||||
<span class="pattern-label">{{ t('examples.multipleOptional') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{authors}/<{series}/><{seriesIndex}. >{title}< ({year})>' }}</code></span>
|
||||
<div class="result-col-dual">
|
||||
<span class="result-with"><i class="pi pi-check-circle"></i> <code>Patrick Rothfuss/The Kingkiller Chronicle/01. The Name of the Wind (2007).epub</code></span>
|
||||
<span class="result-without"><i class="pi pi-question-circle"></i> <code>Andy Weir/Project Hail Mary (2021).epub</code></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="example-row-conditional">
|
||||
<span class="pattern-label">{{ t('examples.elseClause') }}</span>
|
||||
<span class="pattern-col"><code>{{ '<{series}|Standalone>/{title}' }}</code></span>
|
||||
<div class="result-col-dual">
|
||||
<span class="result-with"><i class="pi pi-check-circle"></i> <code>The Kingkiller Chronicle/The Name of the Wind.epub</code></span>
|
||||
<span class="result-without"><i class="pi pi-question-circle"></i> <code>Standalone/Project Hail Mary.epub</code></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="example-row-conditional">
|
||||
<span class="pattern-label">{{ t('examples.elseClauseFallback') }}</span>
|
||||
<span class="pattern-col"><code>{{ '<{series}/{seriesIndex} - {title}|{title}>' }}</code></span>
|
||||
<div class="result-col-dual">
|
||||
<span class="result-with"><i class="pi pi-check-circle"></i> <code>The Kingkiller Chronicle/01 - The Name of the Wind.epub</code></span>
|
||||
<span class="result-without"><i class="pi pi-question-circle"></i> <code>Project Hail Mary.epub</code></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="example-row-conditional">
|
||||
<span class="pattern-label">{{ t('examples.elseWithModifier') }}</span>
|
||||
<span class="pattern-col"><code>{{ '<{series}|{authors:sort}>/{title}' }}</code></span>
|
||||
<div class="result-col-dual">
|
||||
<span class="result-with"><i class="pi pi-check-circle"></i> <code>The Kingkiller Chronicle/The Name of the Wind.epub</code></span>
|
||||
<span class="result-without"><i class="pi pi-question-circle"></i> <code>Weir, Andy/Project Hail Mary.epub</code></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section-divider"><hr></div>
|
||||
|
||||
<div class="example-category">
|
||||
<h4 class="category-title">
|
||||
<i class="pi pi-wrench"></i>
|
||||
{{ t('examples.modifiersGroup') }}
|
||||
</h4>
|
||||
<div class="example-grid">
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.optionalBlocks') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{authors}/<{series}/><{seriesIndex}. >{title}< ({year})>' }}</code></span>
|
||||
<span class="result-col"><code>Andy Weir/Project Hail Mary (2021).epub</code></span>
|
||||
<span class="pattern-label">{{ t('examples.modifierSort') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{authors:sort}/{title}' }}</code></span>
|
||||
<span class="result-col"><code>Rothfuss, Patrick/The Name of the Wind.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.seriesIndexFallback') }}</span>
|
||||
<span class="pattern-col"><code>{{ '<{seriesIndex}. >{title}< - {authors}>' }}</code></span>
|
||||
<span class="result-col"><code>Project Hail Mary - Andy Weir.epub</code></span>
|
||||
<span class="pattern-label">{{ t('examples.modifierInitial') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{authors:initial}/{authors:sort}/{title}' }}</code></span>
|
||||
<span class="result-col"><code>R/Rothfuss, Patrick/The Name of the Wind.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.bracketsFallback') }}</span>
|
||||
<span class="pattern-col"><code>{{ '<[{series}] >{title} - {authors}' }}</code></span>
|
||||
<span class="result-col"><code>Project Hail Mary - Andy Weir.epub</code></span>
|
||||
<span class="pattern-label">{{ t('examples.modFirst') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{authors:first}/{title}' }}</code></span>
|
||||
<span class="result-col"><code>Patrick Rothfuss/The Name of the Wind.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.seriesPunctuation') }}</span>
|
||||
<span class="pattern-col"><code>{{ '<{series}: >{title} by {authors}' }}</code></span>
|
||||
<span class="result-col"><code>Project Hail Mary by Andy Weir.epub</code></span>
|
||||
<span class="pattern-label">{{ t('examples.modUpper') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{title:upper}' }}</code></span>
|
||||
<span class="result-col"><code>THE NAME OF THE WIND.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.yearPrefix') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{authors}/{year}__{currentFilename}' }}</code></span>
|
||||
<span class="result-col"><code>Andy Weir/2021__project_hail_mary_final.epub</code></span>
|
||||
<span class="pattern-label">{{ t('examples.modLower') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{title:lower}' }}</code></span>
|
||||
<span class="result-col"><code>the name of the wind.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.subtitleFallback') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{title}<: {subtitle}>' }}</code></span>
|
||||
<span class="result-col"><code>Project Hail Mary.epub</code></span>
|
||||
<span class="pattern-label">{{ t('examples.letterFolder') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{title:initial}/{authors}/{title}' }}</code></span>
|
||||
<span class="result-col"><code>T/Patrick Rothfuss/The Name of the Wind.epub</code></span>
|
||||
</div>
|
||||
<div class="example-row">
|
||||
<span class="pattern-label">{{ t('examples.combinedMods') }}</span>
|
||||
<span class="pattern-col"><code>{{ '{authors:sort} - {title:lower}' }}</code></span>
|
||||
<span class="result-col"><code>Rothfuss, Patrick - the name of the wind.epub</code></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+137
-44
@@ -371,16 +371,91 @@
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.metadata-reference {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 1rem;
|
||||
margin-bottom: 0.5rem;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.metadata-panel {
|
||||
background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
|
||||
padding: 1rem 1.25rem;
|
||||
border-radius: 6px;
|
||||
border-left: 3px solid var(--p-content-border-color);
|
||||
|
||||
&.metadata-panel-full {
|
||||
border-left-color: var(--p-green-400);
|
||||
}
|
||||
|
||||
&.metadata-panel-partial {
|
||||
border-left-color: var(--p-orange-400);
|
||||
}
|
||||
}
|
||||
|
||||
.metadata-panel-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-size: settings.$settings-label-size;
|
||||
font-weight: 600;
|
||||
color: var(--p-text-color);
|
||||
margin-bottom: 0.875rem;
|
||||
padding-bottom: 0.625rem;
|
||||
border-bottom: 1px solid color-mix(in srgb, var(--p-content-border-color) 50%, transparent);
|
||||
|
||||
.pi {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
}
|
||||
|
||||
.metadata-icon-full {
|
||||
color: var(--p-green-400);
|
||||
}
|
||||
|
||||
.metadata-icon-partial {
|
||||
color: var(--p-orange-400);
|
||||
}
|
||||
|
||||
.metadata-grid {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
||||
gap: 0.5rem 0.75rem;
|
||||
font-size: settings.$settings-section-description-size;
|
||||
align-items: baseline;
|
||||
}
|
||||
|
||||
.metadata-key {
|
||||
color: var(--p-text-muted-color);
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
|
||||
&::after {
|
||||
content: ':';
|
||||
}
|
||||
}
|
||||
|
||||
.metadata-val {
|
||||
color: var(--p-text-color);
|
||||
font-size: settings.$settings-description-size;
|
||||
|
||||
&.not-set {
|
||||
opacity: 0.5;
|
||||
font-style: italic;
|
||||
color: var(--p-text-muted-color);
|
||||
}
|
||||
}
|
||||
|
||||
.example-category {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.category-header {
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.category-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -388,48 +463,11 @@
|
||||
font-size: settings.$settings-label-size;
|
||||
font-weight: 600;
|
||||
color: var(--p-text-color);
|
||||
margin: 0 0 0.5rem 0;
|
||||
margin: 0;
|
||||
|
||||
.pi {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.pi-check-circle {
|
||||
color: var(--p-green-400);
|
||||
}
|
||||
|
||||
.pi-question-circle {
|
||||
color: var(--p-orange-400);
|
||||
}
|
||||
}
|
||||
|
||||
.sample-metadata {
|
||||
background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
|
||||
padding: 0.75rem 1rem;
|
||||
border-radius: 4px;
|
||||
border-left: 3px solid var(--p-content-border-color);
|
||||
}
|
||||
|
||||
.metadata-items {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem 1rem;
|
||||
font-size: settings.$settings-section-description-size;
|
||||
color: var(--p-text-muted-color);
|
||||
|
||||
strong {
|
||||
color: var(--p-text-color);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
code {
|
||||
color: var(--p-text-color);
|
||||
font-size: settings.$settings-description-size;
|
||||
}
|
||||
|
||||
.not-set {
|
||||
opacity: 0.6;
|
||||
font-style: italic;
|
||||
color: var(--p-primary-color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -452,7 +490,22 @@
|
||||
@media (max-width: 1024px) {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.375rem;
|
||||
padding: 0.625rem 0.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
.example-row-conditional {
|
||||
display: grid;
|
||||
grid-template-columns: 130px 1fr 1fr;
|
||||
gap: 0.75rem;
|
||||
padding: 0.625rem 0.75rem;
|
||||
background: color-mix(in srgb, var(--ground-background) 50%, var(--p-surface-800) 50%);
|
||||
border-radius: 4px;
|
||||
font-size: settings.$settings-section-description-size;
|
||||
align-items: start;
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.375rem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -491,3 +544,43 @@
|
||||
border-left: 2px solid var(--p-green-400);
|
||||
}
|
||||
}
|
||||
|
||||
.result-col-dual {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.375rem;
|
||||
|
||||
code {
|
||||
font-size: settings.$settings-description-size;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.pi {
|
||||
font-size: 0.625rem;
|
||||
margin-right: 0.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
.result-with {
|
||||
color: var(--p-green-400);
|
||||
|
||||
.pi {
|
||||
color: var(--p-green-400);
|
||||
}
|
||||
|
||||
code {
|
||||
color: var(--p-green-400);
|
||||
}
|
||||
}
|
||||
|
||||
.result-without {
|
||||
color: var(--p-orange-400);
|
||||
|
||||
.pi {
|
||||
color: var(--p-orange-400);
|
||||
}
|
||||
|
||||
code {
|
||||
color: var(--p-orange-400);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-11
@@ -12,6 +12,7 @@ import {InputText} from 'primeng/inputtext';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {ExternalDocLinkComponent} from '../../../shared/components/external-doc-link/external-doc-link.component';
|
||||
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||
import {replacePlaceholders} from '../../../shared/util/pattern-resolver';
|
||||
|
||||
@Component({
|
||||
selector: 'app-file-naming-pattern',
|
||||
@@ -58,15 +59,8 @@ export class FileNamingPatternComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
private replacePlaceholders(pattern: string, values: Record<string, string>): string {
|
||||
pattern = pattern.replace(/<([^<>]+)>/g, (_, block) => {
|
||||
const placeholders = [...block.matchAll(/{(.*?)}/g)].map((m) => m[1]);
|
||||
const allHaveValues = placeholders.every((key) => values[key]?.trim());
|
||||
return allHaveValues
|
||||
? block.replace(/{(.*?)}/g, (_: string, key: string) => values[key] ?? '')
|
||||
: '';
|
||||
});
|
||||
return pattern.replace(/{(.*?)}/g, (_, key) => values[key] ?? '').trim();
|
||||
private resolvePattern(pattern: string, values: Record<string, string>): string {
|
||||
return replacePlaceholders(pattern, values);
|
||||
}
|
||||
|
||||
private appendExtensionIfMissing(path: string, ext = '.pdf'): string {
|
||||
@@ -76,7 +70,7 @@ export class FileNamingPatternComponent implements OnInit {
|
||||
}
|
||||
|
||||
private generatePreview(pattern: string): string {
|
||||
let path = this.replacePlaceholders(pattern || '', this.exampleMetadata);
|
||||
let path = this.resolvePattern(pattern || '', this.exampleMetadata);
|
||||
|
||||
if (!path) return '/original_filename.pdf';
|
||||
if (path.endsWith('/')) return path + 'original_filename.pdf';
|
||||
@@ -97,7 +91,7 @@ export class FileNamingPatternComponent implements OnInit {
|
||||
}
|
||||
|
||||
validatePattern(pattern: string): boolean {
|
||||
const validPatternRegex = /^[\w\s\-{}\[\]\/().<>.,:'"#]*$/;
|
||||
const validPatternRegex = /^[\w\s\-{}\[\]\/().<>.,:'"#|]*$/;
|
||||
return validPatternRegex.test(pattern);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user