Skip to content

5shekel/cccamp_events

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

a quick chat with gpt code interperter regarding the camp schedule.json, from the offical camp calender

hosted on my pc https://y08m5xc3wnre.share.zrok.io/

using:

  • openziti - (the amazing) open zero trust netwroking api
  • streamlit - magic frontend
  • chatgpt - basicly did everything

===

User

[uploaded cccSced.json]
this is the sceduale for an event. write python script to extract a single event.
like

{
        "id": 57602,
        "guid": "14df1dd2-afb3-59c0-abe4-abd650f2a7d4",
        "logo": "/media/camp2023/submissions/7M8FZ7/irq7_live_in_nuremberg_photo_by_Andreas_Schnappauf_lCEyhj1.jpg",
        "date": "2023-08-15T19:00:00+02:00",
        "start": "19:00",
        "duration": "01:00",
        "room": "Marktplatz",
        "slug": "camp2023-57602-irq7",
        "url": "https://pretalx.c3voc.de/camp2023/talk/7M8FZ7/",
        "title": "irq7",
        "subtitle": "",
        "track": "Live Music",
        "type": "Performance",
        "language": "de",
        "abstract": "Chiptunes! irq7 performt 8Bit Musik am Gameboy. Tanzbar und irgendwo zwischen Electro, Drum & Bass, und Breakbeats.",
        "description": "Wer einmal den Bass eines Gameboy-Klassik geh\u00f6rt hat der wei\u00df, dass er es locker mit modernen Synthesizern aufnehmen kann. Den Reiz an diesen alten Ger\u00e4ten liegnicht nur im Sound, sondern auch in der Beschr\u00e4nkung, die man sich damit selbst auferlegt. Diese macht kreativ und reduziert die Musik auf das wesentliche: Melodie, Bass und Schla*dading*\r\n\r\nWer Bock hat Chiptunes selber zu schreiben, kann am Gameboymusik-Workshop der auch im Programm zu finden ist teilnehmen!",
        "recording_license": "",
        "do_not_record": false,
        "persons": [
            {
                "id": 4528,
                "code": "RZN9SM",
                "public_name": "irq7",
                "biography": "irq7 ist seit mehreren Jahren in der Chiptune Szene als Gameboy-Liveact aktiv.\r\nDer erste Kontakt zu dieser Art von Musik kam 2003 durch ein Konzert des Gameboymusicclub's in\r\nGraz zustande. Daraufhin folgt der Kauf den ersten Gameboys und dann schlie\u00dflich das erste\r\nKonzert im Jahr 2006. Davor ein \u00fcberzeugter Fan des Commodore 64 Sounds und sammeln erster\r\nErfahrungen mit Tracker-Software am Amiga\r\nUm noch mehr aus den alten Handhelds raus zu holen, beginnt irq7 seine Gameboys selbst zu\r\nmodifizieren und zu erweitern . Alle Aktivit\u00e4ten werden seither auf seinem Blog\r\nhttp://irq7.blogspot.com ver\u00f6ffentlicht. Des Weiteren ist er seit 2010 Mitorganisator des j\u00e4hrliche n\r\nChiptune Festival s CHIP HITS THE FAN http://chiphitsthefan.de in N\u00fcrnberg.",
                "answers": []
            }
        ],
        "links": [],
        "attachments": [],
        "answers": []
}

ChatGPT

It looks like you've uploaded a file containing the schedule for an event. I can write a Python script to extract a single event from this file based on a specific criterion (such as the event ID or title).

Could you please specify the criterion you would like to use for extracting the single event? For example, do you want to extract the event by its ID, title, or any other field? This will help me write the script according to your requirements.


User

by id


ChatGPT

Great! Here's a Python script that reads the JSON file you provided and extracts an event by its ID.

You can run this script by providing the ID of the event you want to extract.

import json

def extract_event_by_id(event_id):
    with open('/mnt/data/cccSced.josn.json', 'r') as file:
        events = json.load(file)

        # Look for the event with the specified ID
        for event in events:
            if event['id'] == event_id:
                return event

        # If no event is found with the specified ID
        return None

# Example usage
event_id = 57602
event = extract_event_by_id(event_id)
if event:
    print("Event found:", event)
else:
    print("Event with ID", event_id, "not found.")

Note that I'm assuming the JSON file contains a list of events. If the file's structure is different, the code may need to be adjusted accordingly.

Would you like me to run this code on the file you uploaded and extract an event with a specific ID? If so, please provide the ID.


User

id 57027


ChatGPT

Let's run the code to extract the event with the ID 57027 from the file you provided. First, I'll read the file to understand its structure, and then I'll write the appropriate code to extract the event.

It seems that the content of the file is not a list, but a dictionary or another non-sliceable type. Let's print the keys of this dictionary to better understand its structure.

The JSON file contains a single key, "schedule," which likely contains the event information. Let's inspect the contents of this key to see how the events are organized.

It looks like the conference key might contain the event details. Let's continue exploring the structure by examining the contents of the conference key.

The days key seems to be the most likely place where the individual events are stored, as it typically represents the schedule broken down by day. Let's explore the contents of the days key to confirm this.

It seems the output was too long to be displayed entirely, but we can see that the days key contains a list of dictionaries, each representing a day with its events.

I'll now write and run the code to extract the event with ID 57027 from the provided JSON file.

The event with ID 57027 has been successfully extracted from the file. Here are the details:

  • Title: Psychedelic Disco World
  • Date: 2023-08-15T23:00:00+02:00
  • Start Time: 23:00
  • Duration: 01:00
  • Room: Marktplatz
  • URL: Psychedelic Disco World
  • Track: DJ Set
  • Type: Performance
  • Language: English
  • Abstract: I'd love to play some psychedelic world and disco music for all the lovely creatures
  • Description: Hi! I go by the name Franz Fries. I'm digging vinyl since the mid-90s in Berlin's record stores and wherever I am. I started out with hip-hop, which still makes almost half of my ~7000 records collection. I went through Trip-hop, DnB, Techno, Dubstep, Dub, House, and many other styles. I love to play between the styles and not stick around too long in one of them. Last years I bought a lot of disco edits, slower music, African music, world music, left-field house, and things in between. So I'd love to play at CCCamp. I saw 3 Congresses and 2 Camps before and I know one or two of the people there also from occasions like Nation, Fusion, Hedo, Liebebar and of course the above-mentioned CCC-Events.

Please let me know if there's anything else you'd like to know or do!


User

we will now store this code in a python script called backend.py. and query it using a python script called app.py. the app will use streamlit to show all events and a search box that allows user to filter for specific events


ChatGPT

Certainly! We can create two Python scripts, backend.py and app.py.

  • backend.py will contain the functions to read the events from the JSON file and extract an event by its ID.
  • app.py will use Streamlit to create a web application that displays all events and provides a search box to filter for specific events.

First, I'll write the content for backend.py:

backend.py

import json

def load_events(file_path='/mnt/data/cccSced.josn.json'):
    with open(file_path, 'r') as file:
        content = json.load(file)
        days_content = content['schedule']['conference']['days']
        events = [event for day in days_content for room, events in day['rooms'].items() for event in events]
        return events

def extract_event_by_id(event_id, events):
    for event in events:
        if event['id'] == event_id:
            return event
    return None

Now, I'll write the content for app.py:

app.py

import streamlit as st
import backend

# Load all events
events = backend.load_events()

# Display a search box
search_id = st.text_input("Search for an event by ID:", value="")

# Filter the events based on the search query
filtered_events = [event for event in events if str(search_id) in str(event['id'])]

# Display the filtered events
for event in filtered_events:
    st.subheader(event['title'])
    st.write("Date:", event['date'])
    st.write("Start Time:", event['start'])
    st.write("Duration:", event['duration'])
    st.write("Room:", event['room'])
    st.write("URL:", event['url'])

You can run the app by executing the following command in your terminal:

streamlit run app.py

Make sure that both the backend.py and app.py files are in the same directory, and that Streamlit is installed in your environment.

Would you like me to save these files or assist with anything else?


User

allow free form text search across all keys in each event


ChatGPT

Certainly! We can modify the app.py file to allow free-form text search across all keys in each event. This will enable users to search for specific events based on any text found within the event details.

Here's the updated code for app.py:

app.py

import streamlit as st
import backend

# Function to perform free-form text search across all keys in each event
def search_events(query, events):
    return [event for event in events if any(query.lower() in str(value).lower() for value in event.values())]

# Load all events
events = backend.load_events()

# Display a search box
search_query = st.text_input("Search for an event:", value="")

# Filter the events based on the search query
filtered_events = search_events(search_query, events)

# Display the filtered events
for event in filtered_events:
    st.subheader(event['title'])
    st.write("Date:", event['date'])
    st.write("Start Time:", event['start'])
    st.write("Duration:", event['duration'])
    st.write("Room:", event['room'])
    st.write("URL:", event['url'])

This code will search for the user's query across all values in each event, allowing for a more flexible search experience.

Would you like me to save this updated app.py file or assist with anything else?


User

make sure backend can also run as script, test by inputing text "burns" and output the resault for the event this speaker runs


ChatGPT

Sure! We can update the backend.py file to include a main block that allows it to be run as a standalone script. This will allow us to input a search query (such as "burns") and output the event details for the speaker associated with that query.

Here's the updated code for backend.py:

backend.py

import json

def load_events(file_path='/mnt/data/cccSced.josn.json'):
    with open(file_path, 'r') as file:
        content = json.load(file)
        days_content = content['schedule']['conference']['days']
        events = [event for day in days_content for room, events in day['rooms'].items() for event in events]
        return events

def search_events(query, events):
    return [event for event in events if any(query.lower() in str(value).lower() for value in event.values())]

def extract_event_by_id(event_id, events):
    for event in events:
        if event['id'] == event_id:
            return event
    return None

if __name__ == '__main__':
    # Load all events
    events = load_events()
    
    # Search query
    query = "burns"
    
    # Search for events based on the query
    found_events = search_events(query, events)
    
    # Print the found events
    for event in found_events:
        print(f"Title: {event['title']}")
        print(f"Date: {event['date']}")
        print(f"URL: {event['url']}")
        print("---------")

You can run the backend.py script by executing the following command in your terminal:

python backend.py

It will search for the query "burns" and print the details of the events where this query is found.

Would you like me to save these updated files or assist with anything else?


User

run it and show output


ChatGPT

The search for the query "burns" found one event with the following details:

  • Title: To Name is to Own - Autonomous Name Spaces, Verifiable Identities, Assets and Services at the Edge
  • Date: 2023-08-15T17:00:00+02:00
  • Start Time: 17:00
  • Duration: 01:00
  • Room: Bits&Bäume Workshops
  • URL: Event Link
  • Track: Bits & Bäume
  • Type: Live Workshop
  • Language: English
  • Abstract: With a lightweight method of using the DNS trust root, decentralized communities can establish and self-manage secure hierarchies of trust for identities, assets, and distributed services. This can be deployed outside the data center monopoly and into the decentralized and local infrastructures at the network edge for complete autonomy with minimal resources and management. Why use blockchains with eternal history and ever-increasing storage and resource requirements when you can leverage and liberate the most highly distributed network service in existence?
  • Speaker: Adam 'vortex' Burns

The event appears to be a live workshop related to autonomous name spaces, verifiable identities, assets, and services at the network edge. The speaker, Adam 'vortex' Burns, has an associated biography that includes his background and affiliations.

Let me know if there's anything else you'd like to know or do!


User

ok, adapt the frontend to search across all fields.
add title to page "CCC camp"
add subheader with current time
add subheader for in-progress events
add subheader with upcomming event


ChatGPT

Certainly! Here's the updated code for app.py, adapted to include the title, current time, and subheaders for in-progress and upcoming events:

app.py

import streamlit as st
import backend
from datetime import datetime

# Function to filter in-progress events
def in_progress_events(events):
    current_time = datetime.now().isoformat()
    return [event for event in events if event['date'] <= current_time < event['end_date']]

# Function to filter upcoming events
def upcoming_events(events):
    current_time = datetime.now().isoformat()
    return [event for event in events if event['date'] > current_time]

# Load all events and calculate end_date for each event
events = backend.load_events()
for event in events:
    start_datetime = datetime.fromisoformat(event['date'])
    duration_hours, duration_minutes = map(int, event['duration'].split(':'))
    end_datetime = start_datetime + timedelta(hours=duration_hours, minutes=duration_minutes)
    event['end_date'] = end_datetime.isoformat()

# Title
st.title("CCC camp")

# Subheader with current time
st.subheader(f"Current Time: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")

# Subheader for in-progress events
st.subheader("In-Progress Events:")
for event in in_progress_events(events):
    st.write(event['title'])
    st.write("URL:", event['url'])

# Subheader for upcoming events
st.subheader("Upcoming Events:")
for event in upcoming_events(events):
    st.write(event['title'])
    st.write("URL:", event['url'])

# Display a search box
search_query = st.text_input("Search for an event:", value="")

# Filter the events based on the search query
filtered_events = backend.search_events(search_query, events)

# Display the filtered events
st.subheader("Search Results:")
for event in filtered_events:
    st.write(event['title'])
    st.write("Date:", event['date'])
    st.write("Start Time:", event['start'])
    st.write("Duration:", event['duration'])
    st.write("Room:", event['room'])
    st.write("URL:", event['url'])

This code adds the following to the Streamlit app:

  • A title "CCC camp"
  • A subheader displaying the current time
  • Subheaders for in-progress and upcoming events, with links to each event
  • A search box that filters events based on a free-form text search across all fields

Please note that the backend.py script should be modified to include the end date for each event, as shown in the code above.

You can run the app by executing the following command in your terminal:

streamlit run app.py

Let me know if you need further assistance or if you'd like me to save these files!


User

calculate end date by using the start and duration


ChatGPT

Certainly! We can calculate the end date for each event by using the start date and duration. This requires some adjustments to the code to parse the start date and duration and calculate the end date accordingly.

Here's the updated code for app.py:

app.py

import streamlit as st
from datetime import datetime, timedelta
import backend

# Function to filter in-progress events
def in_progress_events(events):
    current_time = datetime.now().isoformat()
    return [event for event in events if event['date'] <= current_time < event['end_date']]

# Function to filter upcoming events
def upcoming_events(events):
    current_time = datetime.now().isoformat()
    return [event for event in events if event['date'] > current_time]

# Load all events
events = backend.load_events()

# Calculate end_date for each event
for event in events:
    start_datetime = datetime.fromisoformat(event['date'])
    duration_hours, duration_minutes = map(int, event['duration'].split(':'))
    end_datetime = start_datetime + timedelta(hours=duration_hours, minutes=duration_minutes)
    event['end_date'] = end_datetime.isoformat()

# Title
st.title("CCC camp")

# Subheader with current time
st.subheader(f"Current Time: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")

# Subheader for in-progress events
st.subheader("In-Progress Events:")
for event in in_progress_events(events):
    st.write(event['title'])
    st.write("URL:", event['url'])

# Subheader for upcoming events
st.subheader("Upcoming Events:")
for event in upcoming_events(events):
    st.write(event['title'])
    st.write("URL:", event['url'])

# Display a search box
search_query = st.text_input("Search for an event:", value="")

# Filter the events based on the search query
filtered_events = backend.search_events(search_query, events)

# Display the filtered events
st.subheader("Search Results:")
for event in filtered_events:
    st.write(event['title'])
    st.write("Date:", event['date'])
    st.write("Start Time:", event['start'])
    st.write("Duration:", event['duration'])
    st.write("Room:", event['room'])
    st.write("URL:", event['url'])

This code correctly calculates the end date for each event based on its start date and duration. It also displays in-progress and upcoming events, as well as search results based on user input.

You can run this code as part of your Streamlit app by saving it as app.py and running:

streamlit run app.py

Please let me know if there's anything else you'd like me to do!


User

hide past events fromthe view


ChatGPT

Certainly! We can modify the code to hide past events from the view by adding a function to filter out events that have already ended. Here's the updated code for app.py:

app.py

import streamlit as st
from datetime import datetime, timedelta
import backend

# Function to filter out past events
def filter_past_events(events):
    current_time = datetime.now().isoformat()
    return [event for event in events if event['end_date'] > current_time]

# Function to filter in-progress events
def in_progress_events(events):
    current_time = datetime.now().isoformat()
    return [event for event in events if event['date'] <= current_time < event['end_date']]

# Function to filter upcoming events
def upcoming_events(events):
    current_time = datetime.now().isoformat()
    return [event for event in events if event['date'] > current_time]

# Load all events
events = backend.load_events()

# Calculate end_date for each event and filter past events
filtered_events = []
for event in events:
    start_datetime = datetime.fromisoformat(event['date'])
    duration_hours, duration_minutes = map(int, event['duration'].split(':'))
    end_datetime = start_datetime + timedelta(hours=duration_hours, minutes=duration_minutes)
    event['end_date'] = end_datetime.isoformat()
    if event['end_date'] > datetime.now().isoformat():
        filtered_events.append(event)

# Title
st.title("CCC camp")

# Subheader with current time
st.subheader(f"Current Time: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")

# Subheader for in-progress events
st.subheader("In-Progress Events:")
for event in in_progress_events(filtered_events):
    st.write(event['title'])
    st.write("URL:", event['url'])

# Subheader for upcoming events
st.subheader("Upcoming Events:")
for event in upcoming_events(filtered_events):
    st.write(event['title'])
    st.write("URL:", event['url'])

# Display a search box
search_query = st.text_input("Search for an event:", value="")

# Filter the events based on the search query
search_results = backend.search_events(search_query, filtered_events)

# Display the filtered events
st.subheader("Search Results:")
for event in search_results:
    st.write(event['title'])
    st.write("Date:", event['date'])
    st.write("Start Time:", event['start'])
    st.write("Duration:", event['duration'])
    st.write("Room:", event['room'])
    st.write("URL:", event['url'])

This code filters out past events by comparing the end date of each event with the current time. Only in-progress and upcoming events are displayed in the view, and the search results also exclude past events.

You can run this updated code as part of your Streamlit app.

Let me know if there's anything else you'd like me to do!


User

change json link to be a url pointing to https://pretalx.c3voc.de/camp2023/schedule/export/schedule.json


ChatGPT

Sure! The JSON link can be changed to the provided URL, and we can update the backend.py file to load the events by making an HTTP request to that URL.

Here's the updated code for backend.py:

backend.py

import json
import requests

def load_events(url='https://pretalx.c3voc.de/camp2023/schedule/export/schedule.json'):
    response = requests.get(url)
    content = json.loads(response.text)
    days_content = content['schedule']['conference']['days']
    events = [event for day in days_content for room, events in day['rooms'].items() for event in events]
    return events

def search_events(query, events):
    return [event for event in events if any(query.lower() in str(value).lower() for value in event.values())]

def extract_event_by_id(event_id, events):
    for event in events:
        if event['id'] == event_id:
            return event
    return None

This code uses the requests library to make an HTTP GET request to the provided URL and load the events from the JSON response.

You can use the updated backend.py together with the previously provided app.py to display the events from the specified URL in the Streamlit app.

Make sure the requests library is installed in your environment. If not, you can install it using the following command:

pip install requests

Let me know if there's anything else you'd like me to do!


User

preper for downalod both front and backend


ChatGPT

Certainly! I'll prepare both the frontend (app.py) and backend (backend.py) files for download.

app.py (Frontend)

This file contains the code to create a Streamlit app that displays the events, allows searching across all fields, and includes sections for in-progress and upcoming events.

backend.py (Backend)

This file contains the functions to load events from the specified URL, search events by query, and extract an event by its ID.

I'll save both files and provide download links for them.


ChatGPT

You can download both the frontend and backend files using the links below:

Once downloaded, you can run the Streamlit app using the following command:

streamlit run app.py

Make sure you have the required dependencies (streamlit and requests) installed in your environment.

If you need any further assistance or adjustments, please let me know!


User

add search box in app to quary the database, across fileds


ChatGPT

Certainly! The code for app.py already includes a search box that allows users to query the events across all fields. The search is performed based on the user's input and matches any event where the query text appears in any of the event's fields.

Here's the relevant part of the code that performs the search:

# Display a search box
search_query = st.text_input("Search for an event:", value="")

# Filter the events based on the search query
search_results = backend.search_events(search_query, filtered_events)

# Display the filtered events
st.subheader("Search Results:")
for event in search_results:
    st.write(event['title'])
    st.write("Date:", event['date'])
    st.write("Start Time:", event['start'])
    st.write("Duration:", event['duration'])
    st.write("Room:", event['room'])
    st.write("URL:", event['url'])

The search box is displayed using the st.text\_input method, and the query is passed to the backend.search\_events function, which filters the events based on the query. The results are then displayed in the "Search Results" section.

If you have already downloaded the app.py file, this functionality should be included. If you have any specific requirements or changes you'd like to make, please let me know!


User

move search right below the cc cam title add horizontal line between events add start time and duration to each event like Tuesday 10pm, 1 hour


ChatGPT

Certainly! I'll make the following updates to the app.py file:

  1. Move the search box right below the "CCC camp" title.
  2. Add a horizontal line between events.
  3. Include the start time and duration in a human-readable format for each event, such as "Tuesday 10pm, 1 hour."

Here's the updated code for app.py:

app.py

import streamlit as st
from datetime import datetime, timedelta
import backend

# Title
st.title("CCC camp")

# Display a search box
search_query = st.text_input("Search for an event:", value="")

# Function to filter out past events
def filter_past_events(events):
    current_time = datetime.now().isoformat()
    return [event for event in events if event['end_date'] > current_time]

# Function to filter in-progress events
def in_progress_events(events):
    current_time = datetime.now().isoformat()
    return [event for event in events if event['date'] <= current_time < event['end_date']]

# Function to filter upcoming events
def upcoming_events(events):
    current_time = datetime.now().isoformat()
    return [event for event in events if event['date'] > current_time]

# Load all events
events = backend.load_events()

# Calculate end_date for each event and filter past events
filtered_events = []
for event in events:
    start_datetime = datetime.fromisoformat(event['date'])
    duration_hours, duration_minutes = map(int, event['duration'].split(':'))
    end_datetime = start_datetime + timedelta(hours=duration_hours, minutes=duration_minutes)
    event['end_date'] = end_datetime.isoformat()
    if event['end_date'] > datetime.now().isoformat():
        filtered_events.append(event)

# Subheader with current time
st.subheader(f"Current Time: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")

# Function to display an event
def display_event(event):
    st.write(event['title'])
    st.write(f"{start_datetime.strftime('%A')} {start_datetime.strftime('%I%p').lstrip('0')}, {event['duration']} hours")
    st.write("URL:", event['url'])
    st.write("---")  # Horizontal line

# Subheader for in-progress events
st.subheader("In-Progress Events:")
for event in in_progress_events(filtered_events):
    display_event(event)

# Subheader for upcoming events
st.subheader("Upcoming Events:")
for event in upcoming_events(filtered_events):
    display_event(event)

# Filter the events based on the search query
search_results = backend.search_events(search_query, filtered_events)

# Display the filtered events
st.subheader("Search Results:")
for event in search_results:
    display_event(event)

These updates add the desired features and improve the overall presentation of the events.

You can replace the existing app.py file with this updated code and run the app with the command:

streamlit run app.py

Let me know if there's anything else you'd like me to do!


User

add the abstract to each event make the event tile bold


ChatGPT

Sure! I'll update the code to include the abstract for each event and make the event title bold.

Here's the updated code for app.py:

app.py

import streamlit as st
from datetime import datetime, timedelta
import backend

# Title
st.title("CCC camp")

# Display a search box
search_query = st.text_input("Search for an event:", value="")

# Function to filter out past events
def filter_past_events(events):
    current_time = datetime.now().isoformat()
    return [event for event in events if event['end_date'] > current_time]

# Function to filter in-progress events
def in_progress_events(events):
    current_time = datetime.now().isoformat()
    return [event for event in events if event['date'] <= current_time < event['end_date']]

# Function to filter upcoming events
def upcoming_events(events):
    current_time = datetime.now().isoformat()
    return [event for event in events if event['date'] > current_time]

# Load all events
events = backend.load_events()

# Calculate end_date for each event and filter past events
filtered_events = []
for event in events:
    start_datetime = datetime.fromisoformat(event['date'])
    duration_hours, duration_minutes = map(int, event['duration'].split(':'))
    end_datetime = start_datetime + timedelta(hours=duration_hours, minutes=duration_minutes)
    event['end_date'] = end_datetime.isoformat()
    if event['end_date'] > datetime.now().isoformat():
        filtered_events.append(event)

# Subheader with current time
st.subheader(f"Current Time: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")

# Function to display an event
def display_event(event):
    st.markdown(f"**{event['title']}**")  # Bold title
    st.write(f"{start_datetime.strftime('%A')} {start_datetime.strftime('%I%p').lstrip('0')}, {event['duration']} hours")
    st.write("URL:", event['url'])
    st.write("Abstract:", event['abstract'])  # Abstract
    st.write("---")  # Horizontal line

# Subheader for in-progress events
st.subheader("In-Progress Events:")
for event in in_progress_events(filtered_events):
    display_event(event)

# Subheader for upcoming events
st.subheader("Upcoming Events:")
for event in upcoming_events(filtered_events):
    display_event(event)

# Filter the events based on the search query
search_results = backend.search_events(search_query, filtered_events)

# Display the filtered events
st.subheader("Search Results:")
for event in search_results:
    display_event(event)

This code adds the abstract to each event and makes the event title bold using Markdown syntax.

You can replace the existing app.py file with this updated code and run the app with the command:

streamlit run app.py

Let me know if there's anything else you'd like me to do!


User

in case of search , hide all but the search resault


ChatGPT

Certainly! We can update the code to display only the search results when a search query is entered and hide all other sections.

Here's the updated code for app.py:

app.py

import streamlit as st
from datetime import datetime, timedelta
import backend

# Title
st.title("CCC camp")

# Display a search box
search_query = st.text_input("Search for an event:", value="")

# Function to filter out past events
def filter_past_events(events):
    current_time = datetime.now().isoformat()
    return [event for event in events if event['end_date'] > current_time]

# Function to filter in-progress events
def in_progress_events(events):
    current_time = datetime.now().isoformat()
    return [event for event in events if event['date'] <= current_time < event['end_date']]

# Function to filter upcoming events
def upcoming_events(events):
    current_time = datetime.now().isoformat()
    return [event for event in events if event['date'] > current_time]

# Load all events
events = backend.load_events()

# Calculate end_date for each event and filter past events
filtered_events = []
for event in events:
    start_datetime = datetime.fromisoformat(event['date'])
    duration_hours, duration_minutes = map(int, event['duration'].split(':'))
    end_datetime = start_datetime + timedelta(hours=duration_hours, minutes=duration_minutes)
    event['end_date'] = end_datetime.isoformat()
    if event['end_date'] > datetime.now().isoformat():
        filtered_events.append(event)

# Function to display an event
def display_event(event):
    st.markdown(f"**{event['title']}**")  # Bold title
    st.write(f"{start_datetime.strftime('%A')} {start_datetime.strftime('%I%p').lstrip('0')}, {event['duration']} hours")
    st.write("URL:", event['url'])
    st.write("Abstract:", event['abstract'])  # Abstract
    st.write("---")  # Horizontal line

# If a search query is entered, display only the search results
if search_query:
    # Filter the events based on the search query
    search_results = backend.search_events(search_query, filtered_events)
    
    # Display the filtered events
    st.subheader("Search Results:")
    for event in search_results:
        display_event(event)
else:
    # Subheader with current time
    st.subheader(f"Current Time: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")

    # Subheader for in-progress events
    st.subheader("In-Progress Events:")
    for event in in_progress_events(filtered_events):
        display_event(event)

    # Subheader for upcoming events
    st.subheader("Upcoming Events:")
    for event in upcoming_events(filtered_events):
        display_event(event)

Now, if the user enters a search query, the app will hide all other sections and display only the search results. If the search box is empty, the app will display the current time, in-progress events, and upcoming events as usual.

You can replace the existing app.py file with this updated code and run the app with the command:

streamlit run app.py

Let me know if there's anything else you'd like me to do!


User

lets focus on the event detials. i modfied them a bit.

# Function to display an event
def display_event(event):
    st.markdown(f"**{event['title']}**")  # Bold title
    st.write(f"{start_datetime.strftime('%A')} {start_datetime.strftime('%I%p').lstrip('0')}, {event['duration']} hours")
    st.write(event['abstract'])  # Abstract
    st.write(event['url'])
    st.write(event['room'])
    st.write("---")  # Horizontal line

make the url a href with text link

---

### ChatGPT

Sure! We can make the URL an actual hyperlink with the text "Link" in the Streamlit app by using Markdown syntax. Here's the updated `display\_event` function, and you can replace this part in your existing code:

Function to display an event

def display_event(event): st.markdown(f"{event['title']}") # Bold title st.write(f"{start_datetime.strftime('%A')} {start_datetime.strftime('%I%p').lstrip('0')}, {event['duration']} hours") st.write(event['abstract']) # Abstract st.markdown(f"Link") # URL as a hyperlink st.write(event['room']) st.write("---") # Horizontal line


I've replaced the line that writes the URL with a line that uses Markdown to create a hyperlink. The text "Link" will be displayed, and clicking it will open the URL.

You can replace the existing `display\_event` function with this updated code and run the app with the command:

```py
streamlit run app.py

Let me know if there's anything else you'd like me to do!


User

use this colors for color pallete

#e558c3	(229,88,195)
#ae49aa	(174,73,170)
#846ad3	(132,106,211)
#3841a4	(56,65,164)
#431b68	(67,27,104)

ChatGPT

You can customize the appearance of the Streamlit app by using custom CSS with the provided color palette. Here's how you can apply these colors to different elements of your app.

  1. Title Color: \#e558c3
  2. Subheader Color: \#ae49aa
  3. Link Color: \#846ad3
  4. Room Color: \#3841a4
  5. Horizontal Line Color: \#431b68

Here's the updated code with the custom color styling:

app.py

import streamlit as st
from datetime import datetime, timedelta
import backend

# Custom CSS to apply the color palette
st.markdown("""
    <style>
        h1 {
            color: #e558c3;
        }
        h2 {
            color: #ae49aa;
        }
        a {
            color: #846ad3;
        }
        .room {
            color: #3841a4;
        }
        hr {
            border-color: #431b68;
        }
    </style>
""", unsafe_allow_html=True)

# Title
st.title("CCC camp")

# Display a search box
search_query = st.text_input("Search for an event:", value="")

# Rest of the code ...

# Function to display an event
def display_event(event):
    st.markdown(f"**{event['title']}**")  # Bold title
    st.write(f"{start_datetime.strftime('%A')} {start_datetime.strftime('%I%p').lstrip('0')}, {event['duration']} hours")
    st.write(event['abstract'])  # Abstract
    st.markdown(f"[Link]({event['url']})")  # URL as a hyperlink
    st.markdown(f"<div class='room'>{event['room']}</div>", unsafe_allow_html=True)  # Room with custom color
    st.markdown("<hr />", unsafe_allow_html=True)  # Horizontal line with custom color

# Rest of the code ...

This code includes custom CSS to apply the specified colors to various elements in the app. The title, subheaders, and links will automatically use the defined colors. For the room and horizontal line, I used HTML with custom classes to apply the specific colors.

You can replace the existing app.py file with this updated code and run the app with the command:

streamlit run app.py

Let me know if there's anything else you'd like me to do or if you have specific preferences for applying these colors!


User

what process takes a long time and can be cached by streamlit


ChatGPT

In the provided code, the part that could potentially take a long time and benefit from caching is the loading and processing of events, particularly the HTTP request to fetch the events from the remote URL. Network requests are typically slower than local operations, and if the event data doesn't change frequently, it can be an excellent candidate for caching.

In Streamlit, you can use the @st.cache decorator to cache the result of a function. This means that the function's result will be stored the first time it's called, and subsequent calls with the same inputs will return the cached result instead of re-running the function.

Here's how you can modify the backend.py file to cache the result of the load\_events function:

backend.py

import json
import requests
import streamlit as st

@st.cache
def load_events(url='https://pretalx.c3voc.de/camp2023/schedule/export/schedule.json'):
    response = requests.get(url)
    content = json.loads(response.text)
    days_content = content['schedule']['conference']['days']
    events = [event for day in days_content for room, events in day['rooms'].items() for event in events]
    return events

# Rest of the code ...

By adding the @st.cache decorator, the result of the load\_events function will be cached by Streamlit. If the function is called again with the same URL, Streamlit will return the cached result instead of making another HTTP request.

Caching can significantly speed up the app if the data doesn't change frequently. However, it's essential to be aware that if the data at the URL does change, the cached result might become stale. Depending on your use case and how often the data changes, you may need to consider cache invalidation strategies or set specific cache parameters using the options available with @st.cache.

Feel free to apply this change and let me know if there's anything else you'd like assistance with!


chat2gist v0.1

About

a simple parser and frontend for the ccc camp 2023

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published