Skip to content

Commit

Permalink
Better search result display
Browse files Browse the repository at this point in the history
  • Loading branch information
EndermanPC committed Feb 12, 2024
1 parent ad70fac commit 864b2dd
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 32 deletions.
1 change: 1 addition & 0 deletions log.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

68 changes: 41 additions & 27 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,32 +94,46 @@
st.session_state.add_state = True

if search_type == 'Text':
for row in Search_Result:
row2 = return_special_characters(row[2])
row6 = return_special_characters(row[6])
st.markdown('```' + str(row[0]) + '``` ```' + row[1] + '```')
row_title = row2.replace('\n', ' ')
row_title = row_title.replace(':', ' ')
st.markdown("### [" + row_title + ']' + '(' + row[1] + ')')
row_shorttext = row6.replace('\n', ' ')
row_shorttext = row_shorttext.replace('```', ' ')
st.markdown("```" + row_shorttext + "```")
st.markdown("   ")
if Search_Result is None:
st.write("No results found")
else:
for row in Search_Result:
row2 = return_special_characters(row[2])
row6 = return_special_characters(row[6])
row_title = row2.replace('\n', ' ')
row_title = row_title.replace(':', ' ')
row_shorttext = row6.replace('\n', ' ')
row_shorttext = row_shorttext.replace('```', ' ')
st.markdown("### [" + row_title + ']' + '(' + row[1] + ') ' + '```' + str(row[0]) + '```')
st.markdown(row_shorttext)
st.markdown("   ")
elif search_type == 'Image':
for row in Search_Result:
st.image(image=row[1])
row2 = return_special_characters(row[2])
st.markdown('```' + str(row[0]) + '``` ```' + row[1] + '```')
row_title = row2.replace('\n', ' ')
row_title = row_title.replace(':', ' ')
st.markdown("### [" + row_title + ']' + '(' + row[1] + ')')
st.markdown("   ")
if Search_Result is None:
st.write("No results found")
else:
for i in range(0, len(Search_Result), 2):
cols = st.columns(2)
for j in range(2):
if i + j < len(Search_Result):
row = Search_Result[i + j]
cols[j].image(image=row[1])
row2 = return_special_characters(row[2])
row_title = row2.replace('\n', ' ')
row_title = row_title.replace(':', ' ')
cols[j].markdown("### [" + row_title + ']' + '(' + row[1] + ')' + '```' + str(row[0]) + '```')
cols[j].markdown(row[4])
cols[j].markdown("   ")
elif search_type == 'Video':
for row in Search_Result:
st.video(row[1])
row2 = return_special_characters(row[2])
st.markdown('```' + str(row[0]) + '``` ```' + row[1] + '```')
row_title = row2.replace('\n', ' ')
row_title = row_title.replace(':', ' ')
st.markdown("### [" + row_title + ']' + '(' + row[1] + ')')
st.markdown("&nbsp;&nbsp;&nbsp;")
if Search_Result is None:
st.write("No results found")
else:
for row in Search_Result:
col1, col2 = st.columns([1, 3])
col1.video(row[1])
row2 = return_special_characters(row[2])
row_title = row2.replace('\n', ' ')
row_title = row_title.replace(':', ' ')
col2.markdown('```' + str(row[0]) + '``` ```' + row[1] + '```')
col2.markdown("### [" + row_title + ']' + '(' + row[1] + ')')
col2.markdown(row[7])
st.markdown("   ")
6 changes: 1 addition & 5 deletions search/index.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import streamlit as st

from atmt import ATMT_STRT
from search.safe import escape_special_characters

def Search_Data(conn, keyword):
Expand All @@ -14,7 +11,6 @@ def Search_Data(conn, keyword):
rows = cursor.fetchall()

if len(rows) == 0:
st.write("No results found")
#ATMT_STRT(keyword)
return None
else:
return rows

0 comments on commit 864b2dd

Please sign in to comment.