Skip to content

Commit 73c9b55

Browse files
authored
Merge pull request #809 from bigbio/dev
Minor changes
2 parents 918933e + c652716 commit 73c9b55

File tree

9 files changed

+458
-254
lines changed

9 files changed

+458
-254
lines changed

examples/PXD042173/PXD042173.sdrf.tsv

Lines changed: 178 additions & 0 deletions
Large diffs are not rendered by default.
0 Bytes
Binary file not shown.

scripts/inject-headers.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ def inject_header(filepath: str, header_html: str, is_dev: bool = False) -> None
3838
with open(filepath, 'r', encoding='utf-8') as f:
3939
content = f.read()
4040

41-
# Resolve version link based on dev/stable mode
41+
# Resolve version link: only show in dev builds (link back to stable)
4242
if is_dev:
4343
version_link = '<a href="/" class="version-link">Stable Version</a>'
4444
else:
45-
version_link = '<a href="/dev/" class="version-link">Dev Version</a>'
45+
version_link = ''
4646
resolved_header = header_html.replace(VERSION_LINK_PLACEHOLDER, version_link)
4747

4848
# Add has-doc-header class to body
@@ -56,17 +56,24 @@ def inject_header(filepath: str, header_html: str, is_dev: bool = False) -> None
5656
f.write(content)
5757

5858

59-
def rewrite_version_links(filepath: str, is_dev: bool) -> None:
60-
"""Rewrite version links in static HTML pages (index.html, quickstart.html, etc.)."""
59+
def inject_version_link_into_static(filepath: str, is_dev: bool) -> None:
60+
"""Inject a 'Stable Version' link into static HTML pages for dev builds."""
61+
if not is_dev:
62+
return # Stable builds don't show a version link
63+
6164
with open(filepath, 'r', encoding='utf-8') as f:
6265
content = f.read()
6366

64-
if is_dev:
65-
content = content.replace(
66-
'<a href="/dev/" class="version-link">Dev Version</a>',
67-
'<a href="/" class="version-link">Stable Version</a>'
68-
)
69-
# No change needed for stable — the source files already have /dev/ links
67+
# Already has a version link — skip
68+
if 'class="version-link"' in content:
69+
return
70+
71+
# Insert "Stable Version" link before the GitHub link
72+
stable_link = '<a href="/" class="version-link">Stable Version</a>'
73+
content = content.replace(
74+
'<a href="https://github.com/bigbio/proteomics-metadata-standard"',
75+
stable_link + '<a href="https://github.com/bigbio/proteomics-metadata-standard"'
76+
)
7077

7178
with open(filepath, 'w', encoding='utf-8') as f:
7279
f.write(content)
@@ -120,13 +127,13 @@ def main():
120127
print(f"Injecting header into: {html_file}")
121128
inject_header(str(html_file), HEADERS['templates'], is_dev)
122129

123-
# Rewrite version links in static HTML pages (index.html, quickstart.html, etc.)
130+
# Inject version link into static HTML pages for dev builds
124131
for static_page in ["index.html", "quickstart.html", "sdrf-terms.html",
125132
"sdrf-explorer.html", "sdrf-editor.html", "sdrf-builder.html"]:
126133
static_file = output_dir / static_page
127134
if static_file.exists():
128-
print(f"Rewriting version links in: {static_file}")
129-
rewrite_version_links(str(static_file), is_dev)
135+
print(f"Processing version link in: {static_file}")
136+
inject_version_link_into_static(str(static_file), is_dev)
130137

131138
print("Header injection complete!")
132139

site/js/sdrf-builder.js

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
affinitySubtype: null,
4646
extraColumns: [], // columns from sdrf-terms.tsv added by user
4747
addedOptionals: [], // optional template columns the user opted into
48+
removedColumns: [], // recommended columns the user explicitly removed
4849
factorValues: [] // characteristics chosen as factor values
4950
};
5051

@@ -180,6 +181,9 @@
180181
if (req === 'optional') {
181182
// Only include if user explicitly added it
182183
if (state.addedOptionals.indexOf(colName) === -1) continue;
184+
} else if (req === 'recommended') {
185+
// Exclude if user explicitly removed it
186+
if (state.removedColumns.indexOf(colName) !== -1) continue;
183187
}
184188
result.push(col2);
185189
}
@@ -380,6 +384,7 @@
380384
state.experiments = [];
381385
state.affinitySubtype = null;
382386
state.addedOptionals = [];
387+
state.removedColumns = [];
383388
state.extraColumns = [];
384389
state.factorValues = [];
385390

@@ -608,8 +613,9 @@
608613
continue;
609614
}
610615

611-
if (req === 'optional' && !includedNames[colName]) {
612-
// Optional and not enabled -> goes in "optional" section
616+
if ((req === 'optional' && !includedNames[colName]) ||
617+
(req === 'recommended' && state.removedColumns.indexOf(colName) !== -1)) {
618+
// Optional not enabled, or recommended that user removed -> "optional" section
613619
optionalCols.push(col);
614620
} else if (includedNames[colName] && state.extraColumns.indexOf(colName) === -1) {
615621
// Included from template (not user-added extra)
@@ -734,7 +740,14 @@
734740
item.appendChild(toggleBtn);
735741

736742
item.addEventListener('click', function () {
737-
state.addedOptionals.push(col.name);
743+
var req = col.requirement || 'optional';
744+
if (req === 'recommended') {
745+
// Re-add: remove from removedColumns
746+
var idx = state.removedColumns.indexOf(col.name);
747+
if (idx !== -1) state.removedColumns.splice(idx, 1);
748+
} else {
749+
state.addedOptionals.push(col.name);
750+
}
738751
updatePreview();
739752
});
740753
optDiv.appendChild(item);
@@ -844,6 +857,11 @@
844857
// Remove from extra
845858
var idx = state.extraColumns.indexOf(colName);
846859
if (idx !== -1) state.extraColumns.splice(idx, 1);
860+
} else if (col.requirement === 'recommended') {
861+
// Move recommended column to removed list
862+
if (state.removedColumns.indexOf(colName) === -1) {
863+
state.removedColumns.push(colName);
864+
}
847865
} else {
848866
// Toggle optional template column off (remove from addedOptionals)
849867
var idx2 = state.addedOptionals.indexOf(colName);
@@ -896,11 +914,16 @@
896914
var columns = resolveColumns();
897915
if (!columns.length) return;
898916

899-
var names = [];
917+
var headers = [];
918+
var values = [];
900919
for (var i = 0; i < columns.length; i++) {
901-
names.push(columns[i].name);
920+
headers.push(columns[i].name);
921+
values.push(columns[i].example_value || '');
902922
}
903-
window.open('sdrf-editor.html?columns=' + encodeURIComponent(names.join(',')));
923+
924+
var tsv = headers.join('\t') + '\n' + values.join('\t') + '\n';
925+
var encoded = btoa(unescape(encodeURIComponent(tsv)));
926+
window.open('sdrf-editor.html?content=' + encodeURIComponent(encoded));
904927
}
905928

906929
/* ---------------------------------------------------------------

site/quickstart.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@
109109
<a href="./sdrf-explorer.html">Explorer</a>
110110
<a href="./sdrf-editor.html">Editor</a>
111111
<a href="./quickstart.html" class="nav-current">Quick Start</a>
112-
<a href="/dev/" class="version-link">Dev Version</a>
113112
<a href="https://github.com/bigbio/proteomics-metadata-standard" target="_blank">GitHub</a>
114113
</nav>
115114
</div>

site/sdrf-builder.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
<a href="./index.html#tools">Tools</a>
1818
<a href="./sdrf-explorer.html">Explorer</a>
1919
<a href="./sdrf-editor.html">Editor</a>
20-
<a href="/dev/" class="version-link">Dev Version</a>
2120
<a href="https://github.com/bigbio/proteomics-metadata-standard" target="_blank">GitHub</a>
2221
</nav>
2322
</div>

0 commit comments

Comments
 (0)