Twitter Archivist: Fix display of tweet author

Also:

* Cleaner user interface
* Added data model spec
* Added todo list
* Icons for archives
This commit is contained in:
jeremy@jermolene.com 2022-11-13 11:18:47 +00:00
parent fedc23d73c
commit 34353f4065
10 changed files with 149 additions and 57 deletions

View File

@ -1,3 +1,4 @@
title: $:/DefaultTiddlers
HelloThere
[[Twitter Archives]]
HelloThere

View File

@ -1,3 +1,9 @@
title: HelloThere
{{$:/plugins/tiddlywiki/twitter-archivist/readme}}
!!! Welcome to the Twitter Archivist for TiddlyWiki
<$tiddler tiddler="$:/plugins/tiddlywiki/twitter-archivist">
<$set name="tabsList" filter="[list<currentTiddler>]">
<$macrocall $name="tabs" state=<<qualify "$:/state/tabs/twitter-archivist">> tabsList=<<tabsList>> default={{{ [enlist<tabsList>] }}} template="$:/core/ui/PluginInfo"/>
</$set>
</$tiddler>

View File

@ -0,0 +1,5 @@
title: Twitter Archives
color: #1D9CF0
icon: $:/core/images/twitter
<<list-archives>>

View File

@ -29,6 +29,8 @@ TwitterArchivist.prototype.loadArchive = async function(options) {
user_id = manifestData.userInfo.accountId;
wiki.addTiddler({
title: "Twitter Archive for @" + username,
icon: "$:/core/images/twitter",
color: "#1D9CF0",
tags: "$:/tags/TwitterArchive",
user_id: user_id,
username: username,

View File

@ -45,13 +45,22 @@ tags: $:/tags/Macro
\define list-archives()
\whitespace trim
<ul>
<$list filter="[tag[$:/tags/TwitterArchive]sort[displayname]]">
<li>
<$link><$text text=<<currentTiddler>>/></$link>
</li>
<$list filter="[tag[$:/tags/TwitterArchive]limit[1]]" emptyMessage=<<list-archives-empty>> variable="ignore">
<ul>
<$list filter="[tag[$:/tags/TwitterArchive]sort[displayname]]">
<li>
<$link><$text text=<<currentTiddler>>/></$link>
</li>
</$list>
</ul>
</$list>
</ul>
\end
\define list-archives-empty()
<p style="background:#ff3;color:#333;padding:8px;font-weight:bold;">
No Twitter Archives are currently loaded
</p>
<$transclude tiddler="$:/plugins/tiddlywiki/twitter-archivist/usage" mode="block"/>
\end
\define show-archive()
@ -122,24 +131,24 @@ tags: $:/tags/Macro
\define show-tweet()
<div class="tc-twitter-tweet">
<div class="tc-twitter-tweet-header">
<$let user_id={{{ [<__archive__>get[user_id]] }}}>
<$list filter="[{!user_id}match<user_id>]" variable="ignore">
<$list filter="[<currentTiddler>has[user_id]]" variable="ignore">
<$let archive={{{ [tag[$:/tags/TwitterArchive]field:user_id{!!user_id}] }}}>
<span class="tc-twitter-tweet-header-displayname">
<$text text={{{ [<__archive__>get[displayname]] }}}/>
<$text text={{{ [<archive>get[displayname]] }}}/>
</span>
<span class="tc-twitter-tweet-header-username">
@<$text text={{{ [<__archive__>get[username]] }}}/>
@<$text text={{{ [<archive>get[username]] }}}/>
</span>
</$list>
</$let>
</$let>
</$list>
<$link to=<<currentTiddler>>>
<span class="tc-twitter-tweet-header-date">
<$view field="created" format="date" template="DDth mmm YYYY 0hh:0mm:0ss"/>
</span>
</$link>
</div>
<$list filter="[<__title__>get[in_reply_to_status_id]addprefix[Tweet - ]is[tiddler]]" variable="replyTo">
<$list filter="[<currentTiddler>get[in_reply_to_status_id]addprefix[Tweet - ]is[tiddler]]" variable="replyTo">
<div class="tc-twitter-tweet-reply-to">
Reply to <$link to=<<replyTo>>><$text text=<<replyTo>>/></$link>
</div>
@ -148,11 +157,9 @@ tags: $:/tags/Macro
<$transclude field="text"/>
</div>
<div class="tc-twitter-tweet-media">
<$let status_id={{!!status_id}}>
<$list filter="[tag[$:/tags/TweetMedia]field:status_id<status_id>]" variable="mediaItem">
<$transclude tiddler=<<mediaItem>>/>
</$list>
</$let>
<$list filter="[tag[$:/tags/TweetMedia]field:status_id{!!status_id}]" variable="mediaItem">
<$transclude tiddler=<<mediaItem>>/>
</$list>
</div>
<div class="tc-twitter-tweet-footer">
<$list filter="[<currentTiddler>has[retweet_count]]" variable="ignore">

View File

@ -2,5 +2,5 @@
"title": "$:/plugins/tiddlywiki/twitter-archivist",
"name": "Twitter Archivist",
"description": "Twitter archiving tools",
"list": "readme"
"list": "readme usage spec todo"
}

View File

@ -4,14 +4,23 @@ title: $:/plugins/tiddlywiki/twitter-archivist/readme
The Twitter Archivist imports the tweets and associated media from a [[Twitter Archive|https://help.twitter.com/en/managing-your-account/how-to-download-your-twitter-archive]] as individual tiddlers.
The Twitter Archivist plugin is available from the official plugin library for installation in your own wikis.
The first step is to request your Tweet archive from Twitter. Once it is available, download file compressed file and unzip it.
! Limitations
! Installation
This initial version of the Twitter Archivist has several shortcomings that may be addressed in the future:
For browser-based wikis, drag and drop this link to install the Twitter Archivist plugin in your own wikis (note that a reload will be required after installing the plugin and saving the wiki):
* Does not handle editable tweets
* Does not handle direct messages
{{$:/plugins/tiddlywiki/twitter-archivist||$:/core/ui/Components/plugin-info}}
For Node.js-based wikis, add `tiddlywiki/twitter-archivist` to the `plugin` section of `tiddlywiki.info`:
```
...
"plugins": [
"tiddlywiki/twitter-archivist"
],
...
```
! Limitations of Twitter Archives
@ -19,37 +28,6 @@ The Twitter Archive format itself has many shortcomings which affect this tool:
* Retweets come through as old-school RTs, which means that they are often truncated
* Likes only have minimal information, lacking date, author and mentions
* External links go to the t.co shortener
* Twitter archives can be delivered in multiple parts, but this tool has only been tested with single archives. It is hoped that cumulatively importing each of the archives in turn should work
A future version of this tool may use the Twitter API to get around these restrictions.
! Getting Started
First, request your Tweet archive from Twitter. Once it is available, download and unzip it.
The Twitter Archivist can operate in the browser or under Node.js.
!! In the Browser
To import a Twitter archive in the browser, click the button below and navigate to the root of the archive:
<$button>
<$action-sendmessage $message="tm-load-twitter-archive"/>
Open Twitter archive
</$button>
!! Under Node.js
To import a Twitter archive under Node.js, use the `--loadtwitterarchive` command:
```
tiddlywiki editions/twitter-archivist/ --loadtwitterarchive '/path/to/archive' --build index
```
! Imported Archives
Any imported archives will show here:
<<list-archives>>

View File

@ -0,0 +1,61 @@
title: $:/plugins/tiddlywiki/twitter-archivist/spec
! Twitter Archivist Data Model
The Twitter Archivist imports the following tiddlers:
* A single tiddler tagged <<tag "$:/tags/TwitterArchive">> containing details about the archive
* Tweets/favourites represented by tiddlers tagged <<tag "$:/tags/Tweet">>
* Twitter users represented by tiddlers tagged <<tag "$:/tags/Tweeter">>
* Tweet images/videos represented by tiddlers tagged <<tag "$:/tags/TweetMedia">>
!! Twitter Archive Tiddler Fields
|!Field |!Description |
|''account_created_date'' |Date of account creation (in TiddlyWiki format) |
|''bio'' |Account biography |
|''displayname'' |Account displayname |
|''generation_date'' |Date of archive generation (in TiddlyWiki format) |
|''location'' |Account location |
|''tags'' |`$:/tags/TwitterArchive` |
|''title'' |Formed from `Twitter Archive for @` concatenated with the account username |
|''user_id'' |Unique numeric identifier for account |
|''username'' |Account username |
|''website'' |Account website |
!! Tweet Tiddler Fields
|!Field |!Description |
|''created'' |Tweet creation date (in TiddlyWiki format) |
|''favorite_count'' |Number of favourites received by this tweet |
|''modified'' |Tweet creation date (in TiddlyWiki format) |
|''retweet_count'' |Number of retweets received by this tweet |
|''status_id'' |Unique numeric identifier for tweet |
|''tags'' |`$:/tags/Tweet` along with the titles of any tweeters mentioned in the tweet |
|''text'' |The text of the tweet (see below) |
|''title'' |Formed from `Tweet - ` concatenated with the tweet ID |
|''user_id'' |Unique numeric identifier for tweeter of this tweet |
The text of the tweet includes the following changes:
* The pragma `\rules only html entity extlink` is prepended to restrict the parse rules recognised within the text
* Mentions are linked to the associated tweeter tiddler
* Line breaks are replaced by `<br/>`
!! Tweeter Tiddler Fields
|!Field |!Description |
|''name'' |Account displayname |
|''screenname'' |Account screenname (including the @) |
|''tags'' |`$:/tags/Tweeter` |
|''title'' |Formed from `Tweeter - ` concatenated with the account ID |
|''user_id'' |Unique numeric identifier for account |
!! Tweet Media Fields
|!Field |!Description |
|''status_id'' |Identifier of tweet associated with this media item |
|''tags'' |`$:/tags/TweetMedia` |
|''text'' |The body of the media item |
|''title'' |Formed from `Tweet Media - ` concatenated with the ID of the associated tweet and a further unique identifier |
|''type'' |`image/jpg`, `image/png` or `video/mp4` |

View File

@ -0,0 +1,14 @@
title: $:/plugins/tiddlywiki/twitter-archivist/todo
!! Done
* Fixed display of tweet account information
* Data model documentation
!! To Do
* Expand t.co URLs
* Import direct messages
* Control over which media types are imported
* `_canonical_uri` support for media
* Handle editable tweets

View File

@ -0,0 +1,18 @@
title: $:/plugins/tiddlywiki/twitter-archivist/usage
! In the Browser
To import a Twitter archive in the browser, click the button below and navigate to the root of the archive:
<$button>
<$action-sendmessage $message="tm-load-twitter-archive"/>
Open Twitter archive
</$button>
! Under Node.js
To import a Twitter archive under Node.js, use the `--loadtwitterarchive` command:
```
tiddlywiki editions/twitter-archivist/ --loadtwitterarchive '/path/to/archive' --build index
```