Skip to content

Commit

Permalink
Merge pull request #27 from claromes/1.0rc
Browse files Browse the repository at this point in the history
v1.0rc
  • Loading branch information
claromes authored Jul 18, 2024
2 parents 76ebec4 + f3b58a0 commit 30a5cc6
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 27 deletions.
11 changes: 9 additions & 2 deletions app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,22 @@ def scroll_page():
collapse = "urlkey"
matchtype = "prefix"

start_timestamp = None
end_timestamp = None

if st.session_state.archived_timestamp_filter:
start_timestamp = st.session_state.archived_timestamp_filter[0]
end_timestamp = st.session_state.archived_timestamp_filter[1]

try:
with st.spinner(
f"Waybacking @{st.session_state.current_username}'s archived tweets"
):
wayback_tweets = wayback_tweets(
st.session_state.current_username,
collapse,
st.session_state.archived_timestamp_filter[0],
st.session_state.archived_timestamp_filter[1],
start_timestamp,
end_timestamp,
limit,
offset,
matchtype,
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "waybacktweets"
version = "1.0a7"
version = "1.0rc"
description = "Retrieves archived tweets CDX data from the Wayback Machine, performs necessary parsing, and saves the data."
authors = ["Claromes <[email protected]>"]
license = "GPLv3"
Expand All @@ -16,7 +16,7 @@ keywords = [
"command-line",
]
classifiers = [
"Development Status :: 3 - Alpha",
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
Expand All @@ -38,6 +38,7 @@ python = "^3.10"
requests = "^2.30.0"
rich = "^13.6.0"
click = "^8.1.7"
pandas = "^2.2.2"

[tool.poetry.group.docs.dependencies]
sphinx = "^7.3.7"
Expand Down
42 changes: 20 additions & 22 deletions waybacktweets/api/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ def generate(self) -> str:
tweet = self.json_path[index]
html += '<div class="tweet">\n'

if not tweet["available_tweet_text"]:
if not tweet.get("available_tweet_text"):
iframe_src = {
"Archived Tweet": tweet["archived_tweet_url"],
"Parsed Archived Tweet": tweet["parsed_archived_tweet_url"],
"Original Tweet": tweet["original_tweet_url"],
"Parsed Tweet": tweet["parsed_tweet_url"],
"Archived Tweet": tweet.get("archived_tweet_url"),
"Parsed Archived Tweet": tweet.get("parsed_archived_tweet_url"),
"Original Tweet": tweet.get("original_tweet_url"),
"Parsed Tweet": tweet.get("parsed_tweet_url"),
}

for key, value in iframe_src.items():
Expand All @@ -131,7 +131,7 @@ def generate(self) -> str:
html += '<div class="accordion-content">\n'

html += f'<div id="loading_{index}_{key_cleaned}" class="loading">Loading...</div>\n'
html += f'<iframe id="iframe_{index}_{key_cleaned}" frameborder="0" scrolling="auto" loading="lazy" style="display: none;" onload="document.getElementById(\'loading_{index}_{key_cleaned}\').style.display=\'none\'; this.style.display=\'block\';"></iframe>\n'
html += f'<iframe id="iframe_{index}_{key_cleaned}" height="600" width="600" frameborder="0" scrolling="auto" style="display: none;" onload="document.getElementById(\'loading_{index}_{key_cleaned}\').style.display=\'none\'; this.style.display=\'block\';"></iframe>\n'
html += "</div>\n"
html += "</div>\n"

Expand All @@ -149,25 +149,23 @@ def generate(self) -> str:
index=index, url=value, key_cleaned=key_cleaned
)

if tweet["available_tweet_text"]:
if tweet.get("available_tweet_text"):
html += "<br>\n"
html += f'<p><strong class="content">Available Tweet Content:</strong> {tweet["available_tweet_text"]}</p>\n'
html += f'<p><strong class="content">Available Tweet Is Retweet:</strong> {tweet["available_tweet_is_RT"]}</p>\n'
html += f'<p><strong class="content">Available Tweet Username:</strong> {tweet["available_tweet_info"]}</p>\n'
html += f'<p><strong class="content">Available Tweet Content:</strong> {tweet.get("available_tweet_text")}</p>\n'
html += f'<p><strong class="content">Available Tweet Is Retweet:</strong> {tweet.get("available_tweet_is_RT")}</p>\n'
html += f'<p><strong class="content">Available Tweet Username:</strong> {tweet.get("available_tweet_info")}</p>\n'

html += "<br>\n"
html += f'<p><strong>Archived Tweet:</strong> <a href="{tweet["archived_tweet_url"]}" target="_blank">{tweet["archived_tweet_url"]}</a></p>\n'
html += f'<p><strong>Parsed Archived Tweet:</strong> <a href="{tweet["parsed_archived_tweet_url"]}" target="_blank">{tweet["parsed_archived_tweet_url"]}</a></p>\n'
html += f'<p><strong>Original Tweet:</strong> <a href="{tweet["original_tweet_url"]}" target="_blank">{tweet["original_tweet_url"]}</a></p>\n'
html += f'<p><strong>Parsed Tweet:</strong> <a href="{tweet["parsed_tweet_url"]}" target="_blank">{tweet["parsed_tweet_url"]}</a></p>\n'
html += f'<p><strong>Archived URL Key:</strong> {tweet["archived_urlkey"]}</p>\n'
html += f'<p><strong>Archived Timestamp:</strong> {timestamp_parser(tweet["archived_timestamp"])} ({tweet["archived_timestamp"]})</p>\n'
html += f'<p><strong>Archived mimetype:</strong> {tweet["archived_mimetype"]}</p>\n'
html += f'<p><strong>Archived Statuscode:</strong> {tweet["archived_statuscode"]}</p>\n'
html += (
f'<p><strong>Archived Digest:</strong> {tweet["archived_digest"]}\n'
)
html += f'<p><strong>Archived Length:</strong> {tweet["archived_length"]}</p>\n'
html += f'<p><strong>Archived Tweet:</strong> <a href="{tweet.get("archived_tweet_url")}" target="_blank">{tweet.get("archived_tweet_url")}</a></p>\n'
html += f'<p><strong>Parsed Archived Tweet:</strong> <a href="{tweet.get("parsed_archived_tweet_url")}" target="_blank">{tweet.get("parsed_archived_tweet_url")}</a></p>\n'
html += f'<p><strong>Original Tweet:</strong> <a href="{tweet.get("original_tweet_url")}" target="_blank">{tweet.get("original_tweet_url")}</a></p>\n'
html += f'<p><strong>Parsed Tweet:</strong> <a href="{tweet.get("parsed_tweet_url")}" target="_blank">{tweet.get("parsed_tweet_url")}</a></p>\n'
html += f'<p><strong>Archived URL Key:</strong> {tweet.get("archived_urlkey")}</p>\n'
html += f'<p><strong>Archived Timestamp:</strong> {timestamp_parser(tweet.get("archived_timestamp"))} ({tweet.get("archived_timestamp")})</p>\n'
html += f'<p><strong>Archived mimetype:</strong> {tweet.get("archived_mimetype")}</p>\n'
html += f'<p><strong>Archived Statuscode:</strong> {tweet.get("archived_statuscode")}</p>\n'
html += f'<p><strong>Archived Digest:</strong> {tweet.get("archived_digest")}\n'
html += f'<p><strong>Archived Length:</strong> {tweet.get("archived_length")}</p>\n'
html += "</div>\n"

html += "</div>\n</div>\n" # Closes the page div and the container
Expand Down

0 comments on commit 30a5cc6

Please sign in to comment.