File size: 10,235 Bytes
93bff19
 
d8ff977
43d868e
a857b87
ece76b0
 
5b3dda4
ece76b0
8166716
 
 
ece76b0
8166716
ece76b0
8166716
ece76b0
8166716
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ece76b0
5b3dda4
ece76b0
 
 
 
 
 
 
 
 
1594cee
c7715ea
ece76b0
1594cee
5b3dda4
 
 
 
1594cee
ece76b0
d8ff977
ece76b0
 
5b3dda4
 
 
ece76b0
 
5b3dda4
 
d8ff977
ece76b0
 
d8ff977
9b796f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13af9c2
9b796f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f504bcb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9b796f0
 
be206a4
9b796f0
62a9eaa
 
9b796f0
 
 
 
 
 
7bb06de
9b796f0
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
import streamlit as st
import os
import json
from PIL import Image

# Set page configuration with a title and favicon
st.set_page_config(page_title="🌌🚀 Transhuman Space Encyclopedia", page_icon="🌠", layout="wide")

# Ensure the directory for storing scores exists
score_dir = "scores"
os.makedirs(score_dir, exist_ok=True)

# Function to generate a unique key for each button, including an emoji
def generate_key(label, header, idx):
    return f"{header}_{label}_{idx}_key"

# Function to increment and save score
def update_score(key, increment=1):
    score_file = os.path.join(score_dir, f"{key}.json")
    if os.path.exists(score_file):
        with open(score_file, "r") as file:
            score_data = json.load(file)
    else:
        score_data = {"clicks": 0, "score": 0}
    
    score_data["clicks"] += 1
    score_data["score"] += increment
    
    with open(score_file, "w") as file:
        json.dump(score_data, file)
    
    return score_data["score"]

# Function to load score
def load_score(key):
    score_file = os.path.join(score_dir, f"{key}.json")
    if os.path.exists(score_file):
        with open(score_file, "r") as file:
            score_data = json.load(file)
        return score_data["score"]
    return 0

# Transhuman Space glossary with full content
transhuman_glossary = {
    "🚀 Core Technologies": ["Nanotechnology🔬", "Artificial Intelligence🤖", "Quantum Computing💻", "Spacecraft Engineering🛸", "Biotechnology🧬", "Cybernetics🦾", "Virtual Reality🕶️", "Energy Systems⚡", "Material Science🧪", "Communication Technologies📡"],
    "🌐 Nations": ["Terran Federation🌍", "Martian Syndicate🔴", "Jovian Republics🪐", "Asteroid Belt Communities🌌", "Venusian Colonies🌋", "Lunar States🌖", "Outer System Alliances✨", "Digital Consciousness Collectives🧠", "Transhumanist Enclaves🦿", "Non-Human Intelligence Tribes👽"],
    "💡 Memes": ["Post-Humanism🚶‍♂️➡️🚀", "Neo-Evolutionism🧬📈", "Digital Ascendancy💾👑", "Solar System Nationalism🌞🏛", "Space Explorationism🚀🛰", "Cyber Democracy🖥️🗳️", "Interstellar Environmentalism🌍💚", "Quantum Mysticism🔮💫", "Techno-Anarchism🔌🏴", "Cosmic Preservationism🌌🛡️"],
    "🏛 Institutions": ["Interstellar Council🪖", "Transhuman Ethical Standards Organization📜", "Galactic Trade Union🤝", "Space Habitat Authority🏠", "Artificial Intelligence Safety Commission🤖🔒", "Extraterrestrial Relations Board👽🤝", "Quantum Research Institute🔬", "Biogenetics Oversight Committee🧫", "Cyberspace Regulatory Agency💻", "Planetary Defense Coalition🌍🛡"],
    "🔗 Organizations": ["Neural Network Pioneers🧠🌐", "Spacecraft Innovators Guild🚀🛠", "Quantum Computing Consortium💻🔗", "Interplanetary Miners Union⛏️🪐", "Cybernetic Augmentation Advocates🦾❤️", "Biotechnological Harmony Group🧬🕊", "Stellar Navigation Circle🧭✨", "Virtual Reality Creators Syndicate🕶️🎨", "Renewable Energy Pioneers⚡🌱", "Transhuman Rights Activists🦿📢"],
    "⚔️ War": ["Space Warfare Tactics🚀⚔️", "Cyber Warfare🖥️🔒", "Biological Warfare🧬💣", "Nanotech Warfare🔬⚔️", "Psychological Operations🧠🗣️", "Quantum Encryption & Decryption🔐💻", "Kinetic Bombardment🚀💥", "Energy Shield Defense🛡️⚡", "Stealth Spacecraft🚀🔇", "Artificial Intelligence Combat🤖⚔️"],
    "🎖 Military": ["Interstellar Navy🚀🎖", "Planetary Guard🌍🛡", "Cybernetic Marines🦾🔫", "Nanotech Soldiers🔬💂", "Space Drone Fleet🛸🤖", "Quantum Signal Corps💻📡", "Special Operations Forces👥⚔️", "Artificial Intelligence Strategists🤖🗺️", "Orbital Defense Systems🌌🛡️", "Exoskeleton Brigades🦾🚶‍♂️"],
    "🦹 Outlaws": ["Pirate Fleets🏴‍☠️🚀", "Hacktivist Collectives💻🚫", "Smuggler Caravans🛸💼", "Rebel AI Entities🤖🚩", "Black Market Biotech Dealers🧬💰", "Quantum Thieves💻🕵️‍♂️", "Space Nomad Raiders🚀🏴‍☠️", "Cyberspace Intruders💻👾", "Anti-Transhumanist Factions🚫🦾", "Rogue Nanotech Swarms🔬🦠"],
    "👽 Terrorists": ["Bioengineered Virus Spreaders🧬💉", "Nanotechnology Saboteurs🔬🧨", "Cyber Terrorist Networks💻🔥", "Rogue AI Sects🤖🛑", "Space Anarchist Cells🚀Ⓐ", "Quantum Data Hijackers💻🔓", "Environmental Extremists🌍💣", "Technological Singularity Cults🤖🙏", "Interspecies Supremacists👽👑", "Orbital Bombardment Threats🛰️💥"],
}

# Display the glossary with Streamlit components, ensuring emojis are used
def display_glossary(area):
    st.subheader(f"📘 Glossary for {area}")
    terms = transhuman_glossary[area]
    for idx, term in enumerate(terms, start=1):
        st.write(f"{idx}. {term}")

# Streamlined UI for displaying buttons with scores, integrating emojis
def display_buttons_with_scores():
    for header, terms in transhuman_glossary.items():
        st.markdown(f"## {header}")
        for term in terms:
            key = generate_key(term, header, terms.index(term))
            score = load_score(key)
            if st.button(f"{term} {score}🚀", key=key):
                update_score(key)
                st.experimental_rerun()

if __name__ == "__main__":
    st.title("🌌🚀 Transhuman Space Encyclopedia")
    st.markdown("## Explore the universe of Transhuman Space through interactive storytelling and encyclopedic knowledge.🌠")
    display_buttons_with_scores()






def fetch_wikipedia_summary(keyword):
    # Placeholder function for fetching Wikipedia summaries
    # In a real app, you might use requests to fetch from the Wikipedia API
    return f"Summary for {keyword}. For more information, visit Wikipedia."

def create_search_url_youtube(keyword):
    base_url = "https://www.youtube.com/results?search_query="
    return base_url + keyword.replace(' ', '+')

def create_search_url_bing(keyword):
    base_url = "https://www.bing.com/search?q="
    return base_url + keyword.replace(' ', '+')

def create_search_url_wikipedia(keyword):
    base_url = "https://www.wikipedia.org/search-redirect.php?family=wikipedia&language=en&search="
    return base_url + keyword.replace(' ', '+')

def create_search_url_google(keyword):
    base_url = "https://www.google.com/search?q="
    return base_url + keyword.replace(' ', '+')


def display_images_and_wikipedia_summaries():
    st.title('Gallery with Related Stories')
    image_files = [f for f in os.listdir('.') if f.endswith('.png')]
    if not image_files:
        st.write("No PNG images found in the current directory.")
        return
    
    for image_file in image_files:
        image = Image.open(image_file)
        st.image(image, caption=image_file, use_column_width=True)
        
        keyword = image_file.split('.')[0]  # Assumes keyword is the file name without extension
        
        # Display Wikipedia and Google search links
        wikipedia_url = create_search_url_wikipedia(keyword)
        google_url = create_search_url_google(keyword)
        youtube_url = create_search_url_youtube(keyword)
        bing_url = create_search_url_bing(keyword)
        
        links_md = f"""
        [Wikipedia]({wikipedia_url}) | 
        [Google]({google_url}) | 
        [YouTube]({youtube_url}) | 
        [Bing]({bing_url})
        """
        st.markdown(links_md)

display_images_and_wikipedia_summaries()

def get_all_query_params(key):
    return st.query_params().get(key, [])

def clear_query_params():
    st.query_params()  

# Assuming the transhuman_glossary and other setup code remains the same

# Function to display content or image based on a query
def display_content_or_image(query):
    # Check if the query matches any glossary term
    for category, terms in transhuman_glossary.items():
        for term in terms:
            if query.lower() in term.lower():
                st.subheader(f"Found in {category}:")
                st.write(term)
                return True  # Return after finding and displaying the first match
    
    # Check for an image match in a predefined directory (adjust path as needed)
    image_dir = "images"  # Example directory where images are stored
    image_path = f"{image_dir}/{query}.png"  # Construct image path with query
    if os.path.exists(image_path):
        st.image(image_path, caption=f"Image for {query}")
        return True
    
    # If no content or image is found
    st.warning("No matching content or image found.")
    return False



# Old Query Params:
    
st.markdown("### Query Parameters - These Deep Link Map to Remixable Methods")
st.write("Current Query Parameters:", st.query_params)

# Example: Using query parameters to navigate or trigger functionalities
if 'action' in st.query_params:
    action = st.query_params()['action'][0]  # Get the first (or only) 'action' parameter
    if action == 'show_message':
        st.success("Showing a message because 'action=show_message' was found in the URL.")
    elif action == 'clear':
        clear_query_params()
        st.experimental_rerun()

# Handling repeated keys
if 'multi' in st.query_params:
    multi_values = get_all_query_params('multi')
    st.write("Values for 'multi':", multi_values)

# Manual entry for demonstration
st.write("Enter query parameters in the URL like this: ?action=show_message&multi=1&multi=2")

# Clear query parameters button
if st.button("Clear Query Parameters"):
    clear_query_params()
    st.experimental_rerun()

    

    

# New Query Params:


    
# Streamlit UI for displaying query parameters and handling actions
st.markdown("### Query Parameters - Navigate or Trigger Functionalities")
st.write("Current Query Parameters:", st.query_params)

if 'query' in st.query_params:
    query = st.query_params['query'][0]  # Get the query parameter
    # Display content or image based on the query
    display_content_or_image(query)

# Add a clear query parameters button for convenience
if st.button("Clear Query Parameters"):
    # This will clear the browser URL's query parameters
    st.experimental_set_query_params
    st.experimental_rerun()