Next-generation digital referencing system for the age of Generative AI
""", unsafe_allow_html=True)
# Expandable section for About and Example
with st.expander("About SCC and Example Citation"):
st.markdown("""
About SCC
The Smart Context Citation (SCC) style is a next-generation digital referencing system designed for the age of Generative AI. It embeds citation context directly in the document, uses cryptographic hash signatures for integrity, and eliminates traditional reference lists.
Purpose: Transparency, integrity, and digital fluency in citations.
Structure:
- Inline general author name and date style citation
- Hyperlinked URL with text fragment (#:~:text=)
- SHA-256 hash for verification
Benefits: Enhances fairness, integrates with source contexts, promotes digital fluency, prevents fabrication, and eliminates traditional reference lists.
Technical Legitimacy: Referencing the Text Fragments WICG specification for technical legitimacy.
Example Citation
Input:
- Author: Abuseif et al.
- Year: 2025
- URL: https://www.sciencedirect.com/science/article/pii/S2772411523000046
- Text: A proposed design framework for green roof settings in general and trees on buildings Output (HTML):
<a href="https://www.sciencedirect.com/science/article/pii/S2772411523000046#:~:text=A%20proposed%20design%20framework%20for%20green%20roof%20settings%20in%20general%20and%20trees%20on%20buildings" data-hash="[GENERATED_HASH]">Abuseif et al., 2025</a>
', unsafe_allow_html=True)
st.header("Generate New Citation")
# User Information Section
st.subheader("User Information")
col1, col2 = st.columns(2)
with col1:
username = st.text_input("Username", help="Your username for tracking purposes", placeholder="e.g., john_doe")
with col2:
task_name = st.text_input("Task Name", help="The name of the task or project", placeholder="e.g., Literature Review Assignment")
# Citation Info Section
st.subheader("Citation Info")
col3, col4 = st.columns(2)
with col3:
author_name = st.text_input("Author(s) Name", help="The author(s) of the source", placeholder="e.g., Smith or Smith et al.")
with col4:
publication_year = st.text_input("Publication Year", help="The year of publication", placeholder="e.g., 2023")
col5, col6 = st.columns(2)
with col5:
source_url = st.text_input("Source URL", help="The full URL of the source", placeholder="https://example.com/article")
with col6:
annotated_text = st.text_input("Annotated Text", help="The text quoted or paraphrased from the source", placeholder="e.g., Thermal comfort thresholds...")
# Live date and time display
st.markdown("### Current Date and Time")
components.html(live_clock(), height=50)
# Get current date and time in Melbourne timezone for hash generation
melbourne_tz = pytz.timezone(MELBOURNE_TIMEZONE)
current_datetime_melbourne = datetime.now(melbourne_tz)
current_date = current_datetime_melbourne.strftime("%Y-%m-%d")
current_time = current_datetime_melbourne.strftime("%H:%M:%S")
generate_button = st.button("Generate Citation", type="primary", use_container_width=True)
if generate_button:
if not all([username, task_name, author_name, publication_year, source_url, annotated_text]):
st.error("Please fill in all fields before generating a citation.")
elif check_for_fragment(source_url):
st.markdown("""
Warning: It seems like your URL already contains a text fragment (#:~:text=).
This suggests you may have used AI assistance in generating this link. Please go back to the original source,
read the context carefully, and copy the source link again without any existing fragment.
""", unsafe_allow_html=True)
else:
scc_hash = generate_citation_hash(author_name, publication_year, source_url, annotated_text, annotated_text, username, task_name, current_date, current_time)
st.markdown("## Generated Citations")
col_html1, col_html2 = st.columns(2)
# HTML Citation - Start of Text
with col_html1:
st.markdown("### HTML Citation (Start of Text)")
html_citation_start = f'"{annotated_text}" ({author_name}, {publication_year})'
st.markdown('
', unsafe_allow_html=True)
# HTML Citation - End of Text
with col_html2:
st.markdown("### HTML Citation (End of Text)")
html_citation_end = f'({author_name}, {publication_year}) "{annotated_text}"'
st.markdown('
', unsafe_allow_html=True)
# Instructions section
st.markdown("## Instructions for Copying to Word")
st.markdown("""
To use the generated HTML citation in Microsoft Word:
1. Copy the desired HTML citation (Start or End of Text) using the 'Copy to Clipboard' button
2. In Word, go to the 'Insert' tab
3. Click on 'Object' → 'Text from File...'
4. Select 'HTML Document' from the file type dropdown
5. Paste the copied HTML into a new text file (e.g., using Notepad) and save it with a .html extension
6. Select this .html file in the 'Text from File...' dialog
Alternative method: You might be able to paste directly into Word and then right-click and choose 'Keep Source Formatting' or 'Merge Formatting' if available, but the 'Text from File' method is more reliable for preserving hyperlinks and data attributes.
""", unsafe_allow_html=True)
st.markdown("## Guidance on Verifying Citations")
st.markdown("""
To verify a citation, you can recompute the hash using the original input data and compare it to the embedded hash.
The 'Verify Citation' tab allows you to do this easily.
""", unsafe_allow_html=True)
st.markdown('
', unsafe_allow_html=True)
with tabs[1]:
st.markdown('
Enter the citation details below to recompute and verify the hash. This ensures the citation hasn't been tampered with or fabricated.
""", unsafe_allow_html=True)
# Initialize session state for storing verified hashes
if 'verified_hashes' not in st.session_state:
st.session_state.verified_hashes = []
# User Information Section
st.subheader("User Information")
col1, col2 = st.columns(2)
with col1:
verify_username = st.text_input("Username (for verification)", placeholder="e.g., john_doe")
with col2:
verify_task_name = st.text_input("Task Name (for verification)", placeholder="e.g., Literature Review Assignment")
# Citation Info Section
st.subheader("Citation Info")
col3, col4 = st.columns(2)
with col3:
verify_author_name = st.text_input("Author(s) Name (for verification)", placeholder="e.g., Smith or Smith et al.")
with col4:
verify_publication_year = st.text_input("Publication Year (for verification)", placeholder="e.g., 2023")
col5, col6 = st.columns(2)
with col5:
verify_source_url = st.text_input("Source URL (for verification)", placeholder="https://example.com/article")
with col6:
verify_annotated_text = st.text_input("Annotated Text (for verification)", placeholder="e.g., Thermal comfort thresholds...")
col7, col8 = st.columns(2)
with col7:
verify_date = st.text_input("Date (YYYY-MM-DD) (for verification)", placeholder="e.g., 2025-01-08")
with col8:
verify_time = st.text_input("Time (HH:MM:SS) (for verification)", placeholder="e.g., 14:30:25")
expected_hash = st.text_input("Expected Hash (from the citation)", placeholder="Enter the full hash from the citation")
verify_button = st.button("Verify Hash", type="primary", use_container_width=True)
if verify_button:
if not all([verify_username, verify_task_name, verify_author_name, verify_publication_year,
verify_source_url, verify_annotated_text, verify_date, verify_time, expected_hash]):
st.error("Please fill in all fields before verifying the hash.")
else:
recomputed_hash = generate_citation_hash(
verify_author_name, verify_publication_year, verify_source_url,
verify_annotated_text, verify_annotated_text, verify_username, verify_task_name,
verify_date, verify_time
)
if recomputed_hash == expected_hash:
st.markdown("""
Hash verified successfully! The citation is authentic and hasn't been tampered with.