about, cache and theme
authorClaromes <claromes@hey.com>
Tue, 20 Jun 2023 20:24:35 +0000 (17:24 -0300)
committerClaromes <claromes@hey.com>
Tue, 20 Jun 2023 20:24:35 +0000 (17:24 -0300)
.streamlit/config.toml
README.md
app.py

index 606fe4ce821bead80709002d2daa2a55b970e686..d50b43438a8ade74c04777408612a3cb925f4f6f 100644 (file)
@@ -1,3 +1,8 @@
 [theme]
 base="light"
-primaryColor="#ab2e33"
\ No newline at end of file
+primaryColor="#ab2e33"
+backgroundColor="#e7e7e7"
+
+[client]
+displayEnabled=true
+toolbarMode="minimal"
index 28a0b42c9a06632ab108eec369f765c34369fd87..41f3004261f516364e98d4d6102ade59af2b57f5 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
 # 🏛️ Wayback Tweets
 
-[![GitHub release (latest by date)](https://img.shields.io/github/v/release/claromes/waybacktweets)](https://github.com/claromes/waybacktweets/releases)
+[![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/claromes/waybacktweets?include_prereleases)](https://github.com/claromes/waybacktweets/releases)
 
-Archived tweets on Wayback Machine in an easy way
+Tool that displays multiple archived tweets on Wayback Machine to avoid opening each link manually.
 
 [waybacktweets.streamlit.app](https://waybacktweets.streamlit.app/)
 
@@ -10,7 +10,7 @@ Archived tweets on Wayback Machine in an easy way
 
 ## Development
 
-### Requirements
+### Requirement
 
 - Python 3.8+
 
@@ -38,12 +38,11 @@ Streamlit will be served at http://localhost:8501
 - [x] Pagination
     - [x] Footer
     - [x] Disabled/ Empty
-- [ ] Feedbacks
+- [x] Feedbacks
 - [ ] Download dataset
 - [ ] Review data cache
 - [ ] Range size defined by user
 - [ ] Prevent duplicate URLs
 - [ ] Hide Twitter header banner (iframe)
-- [ ] Contributing/ Docs
 - [ ] Changelog
 - [ ] `parse_links` exception
diff --git a/app.py b/app.py
index 2018280c58b64cced95657d6bce8f7d63a57bcf9..e59dbf677ec95ed249c499ee92dc0ce9d446e4f0 100644 (file)
--- a/app.py
+++ b/app.py
@@ -3,48 +3,32 @@ import datetime
 import streamlit as st
 import streamlit.components.v1 as components
 
-__version__ = '0.1.3.2'
+__version__ = '0.1.4-beta'
+
+year = datetime.datetime.now().year
 
 st.set_page_config(
     page_title='Wayback Tweets',
     page_icon='🏛️',
-    layout='centered'
-)
+    layout='centered',
+    menu_items={
 
-# https://discuss.streamlit.io/t/remove-hide-running-man-animation-on-top-of-page/21773/3
-hide_streamlit_style = '''
-<style>
-    div[data-testid="stToolbar"] {
-    visibility: hidden;
-    height: 0%;
-    position: fixed;
-    }
-    div[data-testid="stDecoration"] {
-    visibility: hidden;
-    height: 0%;
-    position: fixed;
-    }
-    div[data-testid="stStatusWidget"] {
-    visibility: hidden;
-    height: 0%;
-    position: fixed;
-    }
-    #MainMenu {
-    visibility: hidden;
-    height: 0%;
-    }
-    header {
-    visibility: hidden;
-    height: 0%;
-    }
-    footer {
-    visibility: hidden;
-    height: 0%;
-    }
-</style>
-'''
+        'About': '''
+        ## 🏛️ Wayback Tweets
 
-st.markdown(hide_streamlit_style, unsafe_allow_html=True)
+        [![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/claromes/waybacktweets?include_prereleases)](https://github.com/claromes/waybacktweets/releases) [![License](https://img.shields.io/github/license/claromes/waybacktweets)](https://github.com/claromes/waybacktweets/blob/main/LICENSE.md)
+
+        Tool that displays multiple archived tweets on Wayback Machine to avoid opening each link manually.
+
+        This tool is experimental, please feel free to send your [feedbacks](https://github.com/claromes/waybacktweets/issues).
+
+        Copyright © {}, [claromes.gitlab.io](https://claromes.gitlab.io).
+
+        -------
+        '''.format(year),
+        'Report a bug': 'https://github.com/claromes/waybacktweets/issues'
+    }
+)
 
 if 'current_index' not in st.session_state:
     st.session_state.current_index = 0
@@ -80,7 +64,7 @@ def scroll_into_view():
 
     components.html(js, width=0, height=0)
 
-@st.cache_data(ttl=1800, show_spinner=False)
+@st.cache_data(ttl=3600, show_spinner=False)
 def embed(tweet):
     api = 'https://publish.twitter.com/oembed?url={}'.format(tweet)
     response = requests.get(api)
@@ -90,7 +74,7 @@ def embed(tweet):
     else:
         return None
 
-@st.cache_data(ttl=1800, show_spinner=False)
+@st.cache_data(ttl=3600, show_spinner=False)
 def query_api(handle):
     if not handle:
         st.warning('username, please!')
@@ -103,7 +87,7 @@ def query_api(handle):
     else:
         return None
 
-@st.cache_data(ttl=1800, show_spinner=False)
+@st.cache_data(ttl=3600, show_spinner=False)
 def parse_links(links):
     parsed_links = []
     timestamp = []
@@ -120,16 +104,20 @@ def parse_links(links):
 
     return parsed_links, tweet_links, parsed_mimetype, timestamp
 
+@st.cache_data(ttl=3600, show_spinner=False)
 def attr(i):
     st.markdown('''
     {}. **Wayback Machine:** [link]({}) | **MIME Type:** {} | **From:** {} | **Tweet:** [link]({})
     '''.format(i+1, link, mimetype[i], datetime.datetime.strptime(timestamp[i], "%Y%m%d%H%M%S"), tweet_links[i]))
 
 st.title('''
-Wayback Tweets
-[![GitHub release (latest by date)](https://img.shields.io/github/v/release/claromes/waybacktweets)](https://github.com/claromes/waybacktweets/releases)
+Wayback Tweets [![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/claromes/waybacktweets?include_prereleases)](https://github.com/claromes/waybacktweets/releases)
 ''', anchor=False)
-st.write('Search archived tweets on Wayback Machine in an easy way')
+st.write('''
+Display multiple archived tweets on Wayback Machine and avoid opening each link manually
+
+*via Wayback CDX Server API*
+''')
 
 handle = st.text_input('username', placeholder='username', label_visibility='collapsed')
 query = st.button('Query', type='primary', use_container_width=True)