From: Claromes Date: Tue, 20 Jun 2023 20:24:35 +0000 (-0300) Subject: about, cache and theme X-Git-Url: https://git.claromes.com/?a=commitdiff_plain;h=3a4c1e02eebbc4005d374f97b6e9ac16ae76f51e;p=waybacktweets.git about, cache and theme --- diff --git a/.streamlit/config.toml b/.streamlit/config.toml index 606fe4c..d50b434 100644 --- a/.streamlit/config.toml +++ b/.streamlit/config.toml @@ -1,3 +1,8 @@ [theme] base="light" -primaryColor="#ab2e33" \ No newline at end of file +primaryColor="#ab2e33" +backgroundColor="#e7e7e7" + +[client] +displayEnabled=true +toolbarMode="minimal" diff --git a/README.md b/README.md index 28a0b42..41f3004 100644 --- 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 2018280..e59dbf6 100644 --- 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 = ''' - -''' + '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)