Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,9 +13,9 @@ def load_css():
|
|
| 13 |
st.markdown("""
|
| 14 |
<style>
|
| 15 |
.main-header {
|
| 16 |
-
padding:
|
| 17 |
text-align: center;
|
| 18 |
-
margin
|
| 19 |
}
|
| 20 |
|
| 21 |
.citation-output {
|
|
@@ -28,33 +28,35 @@ def load_css():
|
|
| 28 |
}
|
| 29 |
|
| 30 |
.warning-box {
|
| 31 |
-
background: #
|
| 32 |
border: 1px solid #e0e0e0;
|
| 33 |
border-radius: 4px;
|
| 34 |
padding: 1rem;
|
| 35 |
margin: 1rem 0;
|
|
|
|
| 36 |
}
|
| 37 |
|
| 38 |
.success-box {
|
| 39 |
-
background: #
|
| 40 |
border: 1px solid #e0e0e0;
|
| 41 |
border-radius: 4px;
|
| 42 |
padding: 1rem;
|
| 43 |
margin: 1rem 0;
|
|
|
|
| 44 |
}
|
| 45 |
|
| 46 |
.info-card {
|
| 47 |
background: white;
|
| 48 |
border-radius: 4px;
|
| 49 |
-
padding:
|
| 50 |
-
margin:
|
| 51 |
border-left: 1px solid #e0e0e0;
|
| 52 |
}
|
| 53 |
|
| 54 |
.footer {
|
| 55 |
text-align: center;
|
| 56 |
-
padding:
|
| 57 |
-
margin-top:
|
| 58 |
border-top: 1px solid #e0e0e0;
|
| 59 |
font-size: 0.9rem;
|
| 60 |
}
|
|
@@ -71,7 +73,7 @@ def load_css():
|
|
| 71 |
}
|
| 72 |
|
| 73 |
.tab-content {
|
| 74 |
-
padding:
|
| 75 |
}
|
| 76 |
|
| 77 |
.datetime-display {
|
|
@@ -83,8 +85,8 @@ def load_css():
|
|
| 83 |
}
|
| 84 |
|
| 85 |
.rendered-citation {
|
| 86 |
-
margin:
|
| 87 |
-
font-size:
|
| 88 |
}
|
| 89 |
</style>
|
| 90 |
""", unsafe_allow_html=True)
|
|
@@ -112,7 +114,6 @@ def parse_citation_text(citation_text):
|
|
| 112 |
# Match both "Author (Year)" and "(Author, Year)"
|
| 113 |
match = re.match(r'^(?:(\w[\w\s.,&et al]+)\s*\((\d{4})\)|\((\w[\w\s.,&et al]+),\s*(\d{4})\))$', citation_text.strip())
|
| 114 |
if match:
|
| 115 |
-
# If "Author (Year)" matches, take groups 1 and 2; if "(Author, Year)" matches, take groups 3 and 4
|
| 116 |
author = match.group(1) or match.group(3)
|
| 117 |
year = match.group(2) or match.group(4)
|
| 118 |
author = author.strip()
|
|
@@ -123,17 +124,14 @@ def parse_url(url):
|
|
| 123 |
if not url:
|
| 124 |
return None, None
|
| 125 |
try:
|
| 126 |
-
# Extract fragment text from URL
|
| 127 |
match = re.search(r'#:~:text=([^&]+)', url)
|
| 128 |
fragment_text = urllib.parse.unquote(match.group(1)) if match else None
|
| 129 |
-
# Extract base URL (before #)
|
| 130 |
base_url = url.split('#')[0]
|
| 131 |
return base_url, fragment_text
|
| 132 |
except:
|
| 133 |
return None, None
|
| 134 |
|
| 135 |
def parse_hash_text(hash_text):
|
| 136 |
-
# Match "Author (Year). <hash>"
|
| 137 |
match = re.match(r'.*?\(\d{4}\)\.\s*([0-9a-f]{64})', hash_text.strip())
|
| 138 |
if match:
|
| 139 |
return match.group(1)
|
|
@@ -194,45 +192,105 @@ load_css()
|
|
| 194 |
st.markdown("""
|
| 195 |
<div class="main-header">
|
| 196 |
<h1>Smart Context Citation (SCC) Tool</h1>
|
| 197 |
-
<p>Next-generation digital referencing system for the age of Generative AI</p>
|
| 198 |
</div>
|
| 199 |
""", unsafe_allow_html=True)
|
| 200 |
|
| 201 |
-
# Expandable section for About and Example
|
| 202 |
with st.expander("About SCC and Example Citation"):
|
| 203 |
st.markdown("""
|
| 204 |
<div class="info-card">
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
<strong>Technical Legitimacy:</strong> Referencing the <a href="https://wicg.github.io/scroll-to-text-fragment/" target="_blank">Text Fragments WICG specification</a> for technical legitimacy.
|
| 218 |
</div>
|
| 219 |
|
| 220 |
<div class="info-card">
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
|
|
|
|
|
|
| 235 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
</div>
|
| 237 |
""", unsafe_allow_html=True)
|
| 238 |
|
|
@@ -240,13 +298,12 @@ tabs = st.tabs(["Citation Generator", "Verify Citation"])
|
|
| 240 |
|
| 241 |
with tabs[0]:
|
| 242 |
st.markdown('<div class="tab-content">', unsafe_allow_html=True)
|
| 243 |
-
st.header("Generate New Citation")
|
| 244 |
|
| 245 |
# User Information Section
|
| 246 |
st.subheader("User Information")
|
| 247 |
col1, col2 = st.columns(2)
|
| 248 |
with col1:
|
| 249 |
-
username = st.text_input("Username", help="Your username for tracking purposes", placeholder="e.g.,
|
| 250 |
with col2:
|
| 251 |
task_name = st.text_input("Task Name", help="The name of the task or project", placeholder="e.g., Literature Review Assignment")
|
| 252 |
|
|
@@ -293,7 +350,6 @@ with tabs[0]:
|
|
| 293 |
citation_link_end = f'<a href="{source_url}#:~:text={urllib.parse.quote(annotated_text)}" data-hash="{scc_hash}">({author_name}, {publication_year})</a>'
|
| 294 |
metadata_link = format_metadata_html(source_url, author_name, publication_year, scc_hash, username, task_name, current_date, current_time)
|
| 295 |
|
| 296 |
-
st.markdown("## Generated Citations")
|
| 297 |
col_html1, col_html2 = st.columns(2)
|
| 298 |
|
| 299 |
# HTML Citation - Start of Text
|
|
@@ -311,7 +367,7 @@ with tabs[0]:
|
|
| 311 |
st.markdown('</div>', unsafe_allow_html=True)
|
| 312 |
|
| 313 |
# SCC Ledger
|
| 314 |
-
st.markdown("### SCC
|
| 315 |
st.markdown('<div class="hash-display">', unsafe_allow_html=True)
|
| 316 |
st.markdown(metadata_link, unsafe_allow_html=True)
|
| 317 |
st.markdown('</div>', unsafe_allow_html=True)
|
|
@@ -320,27 +376,19 @@ with tabs[0]:
|
|
| 320 |
|
| 321 |
with tabs[1]:
|
| 322 |
st.markdown('<div class="tab-content">', unsafe_allow_html=True)
|
| 323 |
-
st.header("Verify Citation")
|
| 324 |
-
st.markdown("""
|
| 325 |
-
<div class="info-card">
|
| 326 |
-
Copy the citation text (e.g., "Abuseif et al. (2025)" or "(Abuseif et al., 2025)") and its hyperlink URL from the 'Citation Generator' tab. Similarly, copy the hash text (e.g., "Abuseif et al. (2025). <hash>") and its hyperlink URL. Paste them into the fields below to verify the citation's authenticity. To copy the URL, right-click the hyperlink and select "Copy Link Address".
|
| 327 |
-
</div>
|
| 328 |
-
""", unsafe_allow_html=True)
|
| 329 |
-
|
| 330 |
-
# Input fields for citation and hash
|
| 331 |
st.subheader("Citation Information")
|
| 332 |
citation_text = st.text_input("Citation Text", help="Paste the citation text, e.g., 'Abuseif et al. (2025)' or '(Abuseif et al., 2025)'", placeholder="e.g., Abuseif et al. (2025)")
|
| 333 |
citation_url = st.text_input("Citation URL", help="Paste the hyperlink URL from the citation, e.g., 'https://example.com#:~:text=fragment'", placeholder="e.g., https://example.com#:~:text=fragment")
|
| 334 |
|
| 335 |
-
st.subheader("
|
| 336 |
-
hash_text = st.text_input("
|
| 337 |
-
hash_url = st.text_input("
|
| 338 |
|
| 339 |
verify_button = st.button("Verify Citation", type="primary", use_container_width=True)
|
| 340 |
|
| 341 |
if verify_button:
|
| 342 |
if not all([citation_text, citation_url, hash_text, hash_url]):
|
| 343 |
-
st.error("Please provide all fields (citation text, citation URL,
|
| 344 |
else:
|
| 345 |
# Parse citation text
|
| 346 |
author, year = parse_citation_text(citation_text)
|
|
@@ -354,9 +402,9 @@ with tabs[1]:
|
|
| 354 |
username, task_name, date, time = parse_metadata(hash_fragment)
|
| 355 |
|
| 356 |
if not all([author, year, citation_base_url, citation_fragment, scc_hash, hash_base_url, username, task_name, date, time]):
|
| 357 |
-
st.error("Invalid input format. Ensure the citation text, URLs, and
|
| 358 |
elif citation_base_url != hash_base_url:
|
| 359 |
-
st.error("The citation URL and
|
| 360 |
else:
|
| 361 |
# Recompute hash
|
| 362 |
recomputed_hash = generate_citation_hash(
|
|
@@ -366,13 +414,13 @@ with tabs[1]:
|
|
| 366 |
if recomputed_hash == scc_hash:
|
| 367 |
st.markdown("""
|
| 368 |
<div class="success-box">
|
| 369 |
-
<strong>
|
| 370 |
</div>
|
| 371 |
""", unsafe_allow_html=True)
|
| 372 |
else:
|
| 373 |
st.markdown("""
|
| 374 |
<div class="warning-box">
|
| 375 |
-
<strong>
|
| 376 |
</div>
|
| 377 |
""", unsafe_allow_html=True)
|
| 378 |
|
|
|
|
| 13 |
st.markdown("""
|
| 14 |
<style>
|
| 15 |
.main-header {
|
| 16 |
+
padding: 0.5rem 0;
|
| 17 |
text-align: center;
|
| 18 |
+
margin: 0.5rem 0;
|
| 19 |
}
|
| 20 |
|
| 21 |
.citation-output {
|
|
|
|
| 28 |
}
|
| 29 |
|
| 30 |
.warning-box {
|
| 31 |
+
background: #fff3f3;
|
| 32 |
border: 1px solid #e0e0e0;
|
| 33 |
border-radius: 4px;
|
| 34 |
padding: 1rem;
|
| 35 |
margin: 1rem 0;
|
| 36 |
+
color: #d32f2f;
|
| 37 |
}
|
| 38 |
|
| 39 |
.success-box {
|
| 40 |
+
background: #e8f5e9;
|
| 41 |
border: 1px solid #e0e0e0;
|
| 42 |
border-radius: 4px;
|
| 43 |
padding: 1rem;
|
| 44 |
margin: 1rem 0;
|
| 45 |
+
color: #2e7d32;
|
| 46 |
}
|
| 47 |
|
| 48 |
.info-card {
|
| 49 |
background: white;
|
| 50 |
border-radius: 4px;
|
| 51 |
+
padding: 1rem;
|
| 52 |
+
margin: 0.5rem 0;
|
| 53 |
border-left: 1px solid #e0e0e0;
|
| 54 |
}
|
| 55 |
|
| 56 |
.footer {
|
| 57 |
text-align: center;
|
| 58 |
+
padding: 1rem;
|
| 59 |
+
margin-top: 1rem;
|
| 60 |
border-top: 1px solid #e0e0e0;
|
| 61 |
font-size: 0.9rem;
|
| 62 |
}
|
|
|
|
| 73 |
}
|
| 74 |
|
| 75 |
.tab-content {
|
| 76 |
+
padding: 0.5rem 0;
|
| 77 |
}
|
| 78 |
|
| 79 |
.datetime-display {
|
|
|
|
| 85 |
}
|
| 86 |
|
| 87 |
.rendered-citation {
|
| 88 |
+
margin: 0.5rem 0;
|
| 89 |
+
font-size: 1.2rem;
|
| 90 |
}
|
| 91 |
</style>
|
| 92 |
""", unsafe_allow_html=True)
|
|
|
|
| 114 |
# Match both "Author (Year)" and "(Author, Year)"
|
| 115 |
match = re.match(r'^(?:(\w[\w\s.,&et al]+)\s*\((\d{4})\)|\((\w[\w\s.,&et al]+),\s*(\d{4})\))$', citation_text.strip())
|
| 116 |
if match:
|
|
|
|
| 117 |
author = match.group(1) or match.group(3)
|
| 118 |
year = match.group(2) or match.group(4)
|
| 119 |
author = author.strip()
|
|
|
|
| 124 |
if not url:
|
| 125 |
return None, None
|
| 126 |
try:
|
|
|
|
| 127 |
match = re.search(r'#:~:text=([^&]+)', url)
|
| 128 |
fragment_text = urllib.parse.unquote(match.group(1)) if match else None
|
|
|
|
| 129 |
base_url = url.split('#')[0]
|
| 130 |
return base_url, fragment_text
|
| 131 |
except:
|
| 132 |
return None, None
|
| 133 |
|
| 134 |
def parse_hash_text(hash_text):
|
|
|
|
| 135 |
match = re.match(r'.*?\(\d{4}\)\.\s*([0-9a-f]{64})', hash_text.strip())
|
| 136 |
if match:
|
| 137 |
return match.group(1)
|
|
|
|
| 192 |
st.markdown("""
|
| 193 |
<div class="main-header">
|
| 194 |
<h1>Smart Context Citation (SCC) Tool</h1>
|
|
|
|
| 195 |
</div>
|
| 196 |
""", unsafe_allow_html=True)
|
| 197 |
|
| 198 |
+
# Expandable section for About SCC and Example Citation
|
| 199 |
with st.expander("About SCC and Example Citation"):
|
| 200 |
st.markdown("""
|
| 201 |
<div class="info-card">
|
| 202 |
+
<h3>About SCC</h3>
|
| 203 |
+
<p>The Smart Context Citation (SCC) style is a modern referencing system designed to enhance transparency and integrity in academic citations, particularly in the era of generative AI. It integrates context directly into citations, uses cryptographic hashes for verification, and eliminates the need for traditional reference lists.</p>
|
| 204 |
+
|
| 205 |
+
<h4>Key Features</h4>
|
| 206 |
+
<ul>
|
| 207 |
+
<li><strong>Inline Citations:</strong> Uses author-year format, either "Author (Year)" or "(Author, Year)", hyperlinked to the source with a text fragment.</li>
|
| 208 |
+
<li><strong>SCC Index:</strong> A unique SHA-256 hash ensures citation authenticity, linked to metadata including username, task, date, and time.</li>
|
| 209 |
+
<li><strong>Benefits:</strong> Promotes digital fluency, ensures source traceability, prevents fabrication, and simplifies referencing.</li>
|
| 210 |
+
</ul>
|
| 211 |
+
|
| 212 |
+
<h4>Technical Legitimacy</h4>
|
| 213 |
+
<p>The SCC style leverages the <a href="https://wicg.github.io/scroll-to-text-fragment/" target="_blank">W3C Text Fragments specification</a>, enabling precise linking to specific text within web pages. This ensures citations are contextually accurate and verifiable, aligning with modern web standards.</p>
|
|
|
|
| 214 |
</div>
|
| 215 |
|
| 216 |
<div class="info-card">
|
| 217 |
+
<h3>Example Citation</h3>
|
| 218 |
+
<p><strong>Inputs:</strong></p>
|
| 219 |
+
<ul>
|
| 220 |
+
<li><strong>Username:</strong> jdoe</li>
|
| 221 |
+
<li><strong>Task Name:</strong> Urban Design Thesis</li>
|
| 222 |
+
<li><strong>Author:</strong> Abuseif et al.</li>
|
| 223 |
+
<li><strong>Year:</strong> 2025</li>
|
| 224 |
+
<li><strong>URL:</strong> https://www.sciencedirect.com/science/article/pii/S2772411523000046</li>
|
| 225 |
+
<li><strong>Annotated Text:</strong> A proposed design framework for green roof settings in urban environments</li>
|
| 226 |
+
</ul>
|
| 227 |
+
<p><strong>Outputs:</strong></p>
|
| 228 |
+
<ul>
|
| 229 |
+
<li><strong>Citation (Start of Text):</strong> <span style="font-size: 1.2rem;">Abuseif et al. (2025)</span> (hyperlinked to the source URL with text fragment)</li>
|
| 230 |
+
<li><strong>Citation (End of Text):</strong> <span style="font-size: 1.2rem;">(Abuseif et al., 2025)</span> (hyperlinked to the source URL with text fragment)</li>
|
| 231 |
+
<li><strong>SCC Index:</strong> <span style="font-size: 0.85rem;">Abuseif et al. (2025). <64-character SHA-256 hash></span> (hyperlinked to the source URL with metadata)</li>
|
| 232 |
+
</ul>
|
| 233 |
</div>
|
| 234 |
+
""", unsafe_allow_html=True)
|
| 235 |
+
|
| 236 |
+
# Expandable section for SCC Guidelines
|
| 237 |
+
with st.expander("SCC Style Guidelines"):
|
| 238 |
+
st.markdown("""
|
| 239 |
+
<div class="info-card">
|
| 240 |
+
<h3>SCC Style Guidelines</h3>
|
| 241 |
+
<p>The Smart Context Citation (SCC) style ensures accurate, transparent, and verifiable citations. Follow these steps to generate and verify citations using the SCC Tool.</p>
|
| 242 |
+
|
| 243 |
+
<h4>Generating Citations</h4>
|
| 244 |
+
<ol>
|
| 245 |
+
<li><strong>Access the Tool:</strong> Open the "Citation Generator" tab.</li>
|
| 246 |
+
<li><strong>Enter User Information:</strong>
|
| 247 |
+
<ul>
|
| 248 |
+
<li><strong>Username:</strong> Your unique identifier (e.g., jdoe).</li>
|
| 249 |
+
<li><strong>Task Name:</strong> The project or assignment name (e.g., Urban Design Thesis).</li>
|
| 250 |
+
</ul>
|
| 251 |
+
</li>
|
| 252 |
+
<li><strong>Enter Citation Information:</strong>
|
| 253 |
+
<ul>
|
| 254 |
+
<li><strong>Author(s) Name:</strong> The author(s) of the source (e.g., Abuseif et al.).</li>
|
| 255 |
+
<li><strong>Publication Year:</strong> The year of publication (e.g., 2025).</li>
|
| 256 |
+
<li><strong>Source URL:</strong> The full URL of the source, without text fragments (e.g., https://www.sciencedirect.com/science/article/pii/S2772411523000046).</li>
|
| 257 |
+
<li><strong>Annotated Text:</strong> The quoted or paraphrased text from the source (e.g., A proposed design framework for green roof settings).</li>
|
| 258 |
+
</ul>
|
| 259 |
+
</li>
|
| 260 |
+
<li><strong>Generate Citation:</strong> Click the "Generate Citation" button.</li>
|
| 261 |
+
<li><strong>Copy Outputs:</strong>
|
| 262 |
+
<ul>
|
| 263 |
+
<li><strong>Citation (Start of Text):</strong> Use "Author (Year)" for the start of a sentence.</li>
|
| 264 |
+
<li><strong>Citation (End of Text):</strong> Use "(Author, Year)" for in-text citations.</li>
|
| 265 |
+
<li><strong>SCC Index:</strong> Copy the hash link (e.g., "Abuseif et al. (2025). <hash>") for verification.</li>
|
| 266 |
+
<li>Right-click each link to copy the "Link Address" for verification.</li>
|
| 267 |
+
</ul>
|
| 268 |
+
</li>
|
| 269 |
+
</ol>
|
| 270 |
+
|
| 271 |
+
<h4>Verifying Citations</h4>
|
| 272 |
+
<ol>
|
| 273 |
+
<li><strong>Access the Tool:</strong> Open the "Verify Citation" tab.</li>
|
| 274 |
+
<li><strong>Enter Citation Information:</strong>
|
| 275 |
+
<ul>
|
| 276 |
+
<li><strong>Citation Text:</strong> Paste the citation text (e.g., "Abuseif et al. (2025)" or "(Abuseif et al., 2025)").</li>
|
| 277 |
+
<li><strong>Citation URL:</strong> Paste the hyperlink URL from the citation (right-click and select "Copy Link Address").</li>
|
| 278 |
+
</ul>
|
| 279 |
+
</li>
|
| 280 |
+
<li><strong>Enter SCC Index Information:</strong>
|
| 281 |
+
<ul>
|
| 282 |
+
<li><strong>SCC Index Text:</strong> Paste the hash text (e.g., "Abuseif et al. (2025). <hash>").</li>
|
| 283 |
+
<li><strong>SCC Index URL:</strong> Paste the hyperlink URL from the hash (right-click and select "Copy Link Address").</li>
|
| 284 |
+
</ul>
|
| 285 |
+
</li>
|
| 286 |
+
<li><strong>Verify Citation:</strong> Click the "Verify Citation" button.</li>
|
| 287 |
+
<li><strong>Review Result:</strong>
|
| 288 |
+
<ul>
|
| 289 |
+
<li><strong>Authentic Citation:</strong> Displayed in green if the hash matches, confirming integrity.</li>
|
| 290 |
+
<li><strong>Unauthentic Citation:</strong> Displayed in red if the hash does not match, indicating potential tampering.</li>
|
| 291 |
+
</ul>
|
| 292 |
+
</li>
|
| 293 |
+
</ol>
|
| 294 |
</div>
|
| 295 |
""", unsafe_allow_html=True)
|
| 296 |
|
|
|
|
| 298 |
|
| 299 |
with tabs[0]:
|
| 300 |
st.markdown('<div class="tab-content">', unsafe_allow_html=True)
|
|
|
|
| 301 |
|
| 302 |
# User Information Section
|
| 303 |
st.subheader("User Information")
|
| 304 |
col1, col2 = st.columns(2)
|
| 305 |
with col1:
|
| 306 |
+
username = st.text_input("Username", help="Your username for tracking purposes", placeholder="e.g., jdoe")
|
| 307 |
with col2:
|
| 308 |
task_name = st.text_input("Task Name", help="The name of the task or project", placeholder="e.g., Literature Review Assignment")
|
| 309 |
|
|
|
|
| 350 |
citation_link_end = f'<a href="{source_url}#:~:text={urllib.parse.quote(annotated_text)}" data-hash="{scc_hash}">({author_name}, {publication_year})</a>'
|
| 351 |
metadata_link = format_metadata_html(source_url, author_name, publication_year, scc_hash, username, task_name, current_date, current_time)
|
| 352 |
|
|
|
|
| 353 |
col_html1, col_html2 = st.columns(2)
|
| 354 |
|
| 355 |
# HTML Citation - Start of Text
|
|
|
|
| 367 |
st.markdown('</div>', unsafe_allow_html=True)
|
| 368 |
|
| 369 |
# SCC Ledger
|
| 370 |
+
st.markdown("### SCC Index")
|
| 371 |
st.markdown('<div class="hash-display">', unsafe_allow_html=True)
|
| 372 |
st.markdown(metadata_link, unsafe_allow_html=True)
|
| 373 |
st.markdown('</div>', unsafe_allow_html=True)
|
|
|
|
| 376 |
|
| 377 |
with tabs[1]:
|
| 378 |
st.markdown('<div class="tab-content">', unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
st.subheader("Citation Information")
|
| 380 |
citation_text = st.text_input("Citation Text", help="Paste the citation text, e.g., 'Abuseif et al. (2025)' or '(Abuseif et al., 2025)'", placeholder="e.g., Abuseif et al. (2025)")
|
| 381 |
citation_url = st.text_input("Citation URL", help="Paste the hyperlink URL from the citation, e.g., 'https://example.com#:~:text=fragment'", placeholder="e.g., https://example.com#:~:text=fragment")
|
| 382 |
|
| 383 |
+
st.subheader("SCC Index")
|
| 384 |
+
hash_text = st.text_input("SCC Index Text", help="Paste the index text, e.g., 'Abuseif et al. (2025). <hash>'", placeholder="e.g., Abuseif et al. (2025). <hash>")
|
| 385 |
+
hash_url = st.text_input("SCC Index URL", help="Paste the hyperlink URL from the index, e.g., 'https://example.com#:~:text=metadata'", placeholder="e.g., https://example.com#:~:text=metadata")
|
| 386 |
|
| 387 |
verify_button = st.button("Verify Citation", type="primary", use_container_width=True)
|
| 388 |
|
| 389 |
if verify_button:
|
| 390 |
if not all([citation_text, citation_url, hash_text, hash_url]):
|
| 391 |
+
st.error("Please provide all fields (citation text, citation URL, SCC index text, SCC index URL) before verifying.")
|
| 392 |
else:
|
| 393 |
# Parse citation text
|
| 394 |
author, year = parse_citation_text(citation_text)
|
|
|
|
| 402 |
username, task_name, date, time = parse_metadata(hash_fragment)
|
| 403 |
|
| 404 |
if not all([author, year, citation_base_url, citation_fragment, scc_hash, hash_base_url, username, task_name, date, time]):
|
| 405 |
+
st.error("Invalid input format. Ensure the citation text, URLs, and SCC index text are correctly pasted from the generated output.")
|
| 406 |
elif citation_base_url != hash_base_url:
|
| 407 |
+
st.error("The citation URL and SCC index URL must point to the same base URL.")
|
| 408 |
else:
|
| 409 |
# Recompute hash
|
| 410 |
recomputed_hash = generate_citation_hash(
|
|
|
|
| 414 |
if recomputed_hash == scc_hash:
|
| 415 |
st.markdown("""
|
| 416 |
<div class="success-box">
|
| 417 |
+
<strong>Authentic citation!</strong>
|
| 418 |
</div>
|
| 419 |
""", unsafe_allow_html=True)
|
| 420 |
else:
|
| 421 |
st.markdown("""
|
| 422 |
<div class="warning-box">
|
| 423 |
+
<strong>Unauthentic citation</strong>
|
| 424 |
</div>
|
| 425 |
""", unsafe_allow_html=True)
|
| 426 |
|