Update pages/reader.py
Browse files- pages/reader.py +64 -57
pages/reader.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
# Import libraries
|
| 2 |
import streamlit as st
|
| 3 |
import pandas as pd
|
|
|
|
| 4 |
|
| 5 |
|
| 6 |
#===config===
|
|
@@ -24,6 +25,9 @@ def connect_gsheet():
|
|
| 24 |
|
| 25 |
df = connect_gsheet()
|
| 26 |
|
|
|
|
|
|
|
|
|
|
| 27 |
st.title('TXTperpus: Reader')
|
| 28 |
|
| 29 |
paramx = st.query_params["art"]
|
|
@@ -33,60 +37,63 @@ filtered_df = df[df['ID'] == paramx]
|
|
| 33 |
|
| 34 |
import html
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
</div>
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# Import libraries
|
| 2 |
import streamlit as st
|
| 3 |
import pandas as pd
|
| 4 |
+
import html
|
| 5 |
|
| 6 |
|
| 7 |
#===config===
|
|
|
|
| 25 |
|
| 26 |
df = connect_gsheet()
|
| 27 |
|
| 28 |
+
def format_html(text):
|
| 29 |
+
return html.escape(text).replace("\n", "<br>")
|
| 30 |
+
|
| 31 |
st.title('TXTperpus: Reader')
|
| 32 |
|
| 33 |
paramx = st.query_params["art"]
|
|
|
|
| 37 |
|
| 38 |
import html
|
| 39 |
|
| 40 |
+
row = {
|
| 41 |
+
"Title": "Sample Title <with tags>",
|
| 42 |
+
"Author": "John Doe",
|
| 43 |
+
"Introduction": "This is an introduction\nwith multiple lines.",
|
| 44 |
+
"Method": "This is the method section.\nIt includes steps."
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
title = format_html(row["Title"])
|
| 48 |
+
author = format_html(row["Author"])
|
| 49 |
+
intro = format_html(row["Introduction"])
|
| 50 |
+
method = format_html(row["Method"])
|
| 51 |
+
|
| 52 |
+
html_content = f"""
|
| 53 |
+
<style>
|
| 54 |
+
.article-container {{
|
| 55 |
+
font-family: 'Georgia', serif;
|
| 56 |
+
font-size: 16px;
|
| 57 |
+
line-height: 1.8;
|
| 58 |
+
color: #333;
|
| 59 |
+
padding: 20px;
|
| 60 |
+
background-color: #fefefe;
|
| 61 |
+
border-radius: 10px;
|
| 62 |
+
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
|
| 63 |
+
}}
|
| 64 |
+
.article-title {{
|
| 65 |
+
font-size: 28px;
|
| 66 |
+
font-weight: bold;
|
| 67 |
+
margin-bottom: 5px;
|
| 68 |
+
}}
|
| 69 |
+
.article-author {{
|
| 70 |
+
font-size: 16px;
|
| 71 |
+
color: #666;
|
| 72 |
+
margin-bottom: 20px;
|
| 73 |
+
}}
|
| 74 |
+
.section-title {{
|
| 75 |
+
font-size: 20px;
|
| 76 |
+
font-weight: bold;
|
| 77 |
+
margin-top: 25px;
|
| 78 |
+
margin-bottom: 10px;
|
| 79 |
+
color: #004488;
|
| 80 |
+
}}
|
| 81 |
+
.section-content {{
|
| 82 |
+
text-align: justify;
|
| 83 |
+
}}
|
| 84 |
+
</style>
|
| 85 |
+
|
| 86 |
+
<div class="article-container">
|
| 87 |
+
<div class="article-title">{title}</div>
|
| 88 |
+
<div class="article-author">By {author}</div>
|
| 89 |
+
|
| 90 |
+
<div class="section-title">Introduction</div>
|
| 91 |
+
<div class="section-content">{intro}</div>
|
| 92 |
+
|
| 93 |
+
<div class="section-title">Method</div>
|
| 94 |
+
<div class="section-content">{method}</div>
|
| 95 |
+
</div>
|
| 96 |
+
"""
|
| 97 |
+
|
| 98 |
+
# Streamlit usage
|
| 99 |
+
st.markdown(html_content, unsafe_allow_html=True)
|