Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix content scraping/exploring #60

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions explorer.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import streamlit as st

def show_document(document):
st.write("**Document Content**")
st.write(document)

def view_document(supabase):
# Get the document from the database
response = supabase.table("documents").select("content").execute()
st.write("**This feature is in active development**")
st.write("**Document List**")

# Display a list of elements from the documents
# If the user clicks on an element, display the content of the document
for document in response.data:
if st.button(document['content'][:50].replace("\n", " ")):
continue
selected_document = None
for index, document in enumerate(response.data):
if st.button(document['content'][:50].replace("\n", " "), key=f"document_button_{index}"):
selected_document = document['content']

if selected_document:
show_document(selected_document)
4 changes: 2 additions & 2 deletions loaders/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get_html(url):
def create_html_file(url, content):
file_name = slugify(url) + ".html"
temp_file_path = os.path.join(tempfile.gettempdir(), file_name)
with open(temp_file_path, 'w') as temp_file:
with open(temp_file_path, "w", encoding="utf-8") as temp_file:
temp_file.write(content)

record = UploadedFileRec(id=None, name=file_name, type='text/html', data=open(temp_file_path, 'rb').read())
Expand All @@ -44,4 +44,4 @@ def slugify(text):
text = unicodedata.normalize('NFKD', text).encode('ascii', 'ignore').decode('utf-8')
text = re.sub(r'[^\w\s-]', '', text).strip().lower()
text = re.sub(r'[-\s]+', '-', text)
return text
return text