#markdown #tweet #twitter #front-matter #archive #convert #archived

app tweet-archive-to-markdown

Convert archived Tweets to MarkDown with FrontMatter

2 releases

0.0.2 Apr 30, 2024
0.0.1 Apr 29, 2024

#1048 in Parser implementations

AGPL-3.0

31KB
404 lines

Tweet Archive To Markdown

Convert archived Tweets to MarkDown with FrontMatter

Byte size of Tweet Archive To Markdown Open Issues Open Pull Requests Latest commits GitHub Actions Build Status License



Requirements

This repository requires Rust language/compiler to build from source. As of last update to this ReadMe file, the recommended method of installing Rust is via their installer script;

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Quick Start

This repository is a Rust binary

  • Install via cargo

    cargo install tweet-archive-to-markdown
    
  • Write tab completions for preferred shell (if supported), Bash with XDG support example;

    _shell_name="bash"
    
    _completions_directory="${XDG_DATA_HOME:-${HOME}/.local/share}/bash-completion/completions"
    
    tweet-archive-to-markdown --build-completions "${_shell_name}" |
      tee "${_completions_directory}/tweet-archive-to-markdown" 1>/dev/null
    

    possible values: bash, elvish, fish, powershell, zsh


Usage

  • Print all available command-line options

    tweet-archive-to-markdown -h
    #> Convert archived Tweets to MarkDown with FrontMater
    #>
    #> Usage: tweet-archive-to-markdown [OPTIONS] --input-path <INPUT_PATH>
    #>
    #> Options:
    #>       --input-path <INPUT_PATH>
    #>           Path to input file
    #>       --output-directory <OUTPUT_DIRECTORY>
    #>           Path to directory where MarkDown files will be written
    #>       --javascript-pattern <JAVASCRIPT_PATTERN>
    #>           Useful if/when `--input-path` targets an explicit `data/tweets.js` file path [default: window.YTD.tweets.part0]
    #>       --post-date-format <POST_DATE_FORMAT>
    #>           Custom format string for `DateTime` output parsed from `.tweets[].tweet.created_at` used to
    #>           generate post FrontMatter for `date` YAML [default: "%F %T %z"]
    #>       --post-author <POST_AUTHOR>
    #>           Post `author` FrontMatter value for all MarkDown files written
    #>       --post-layout <POST_LAYOUT>
    #>           Post `layout` FrontMatter value for all MarkDown files written [default: post]
    #>       --post-twitter-key <POST_TWITTER_KEY>
    #>           FrontMatter key under which extra Twitter Post metadata and links will be provided [default: twitter]
    #>       --build-completions <BUILD_COMPLETIONS>
    #>           Output shell completions to standard out then exit [possible values: bash, elvish, fish, powershell, zsh]
    #>       --dry-run
    #>           Send data to standard out without writing files
    #>       --verbose
    #>           Send parsing data and debugging information to standard error
    #>   -h, --help
    #>           Print help (see more with '--help')
    #>   -V, --version
    #>           Print version
    
  • Example usage

    GH_NAME="S0AndS0"
    
    tweet-archive-to-markdown --input-path "~/Downloads/twitter.archive.zip" \
      --output-directory "~/git/hub/${GH_NAME}.github.io/_tweets" \
      --post-date-format "%Y-%m-%d %H:%M:%S %z" \
      --post-author "${GH_NAME}" \
      --post-layout "post" \
      --post-twitter-key "twitter" \
      --verbose \
      --dry-run
    
  • Example result -- ~/git/hub/S0AndS0.github.io/_tweets/2023-08-30-1697011324369178968.md

    ---
    layout: post
    date: "2023-08-30 22:20:03 +0000"
    author: S0AndS0
    twitter:
      post: https://twitter.com/i/web/status/1697011324369178968
    ---
    
    Anyone else occasionally annoyed we're not allowed to modify visibility of `details` HTML element children via `:target` ID with CSS only?
    
    details:is(:target) &gt; *:not(summary) {
      background: hotpink;
      display: block;
      visibility: visible;
    }
    

Notes

This repository may not be feature complete and/or fully functional, Pull Requests that add features or fix bugs are certainly welcomed.


Contributing

Options for contributing to tweet-archive-to-markdown and rust-utilities


Forking

⚠️ Creating fork(s), submitting contribution(s), publishing derivative work(s), etc. based on this repository will form an agreement to be bound by the use-cased based licensing sub-sections.

I.E. if you choose to contribute to or use this project, you acknowledge and accept these usage based licensing terms will apply to any such works too.

Start making a Fork of this repository to an account that you have write permissions for.

  • Add remote for fork URL. The URL syntax is git@github.com:<NAME>/<REPO>.git...
cd ~/git/hub/rust-utilities/tweet-archive-to-markdown

git remote add fork git@github.com:<NAME>/tweet-archive-to-markdown.git
  • Commit your changes and push to your fork, eg. to fix an issue...
cd ~/git/hub/rust-utilities/tweet-archive-to-markdown


git commit -F- <<'EOF'
:bug: Fixes #42 Issue


**Edits**


- `<SCRIPT-NAME>` script, fixes some bug reported in issue
EOF


git push fork main

Note, the -u option may be used to set fork as the default remote, eg. git push -u fork main however, this will also default the fork remote for pulling from too! Meaning that pulling updates from origin must be done explicitly, eg. git pull origin main

  • Then on GitHub submit a Pull Request through the Web-UI, the URL syntax is https://github.com/<NAME>/<REPO>/pull/new/<BRANCH>

Note; to decrease the chances of your Pull Request needing modifications before being accepted, please check the dot-github repository for detailed contributing guidelines.


Sponsor

Thanks for even considering it!

Via Liberapay you may sponsor__shields_io__liberapay on a repeating basis.

Regardless of if you're able to financially support projects such as tweet-archive-to-markdown that rust-utilities maintains, please consider sharing projects that are useful with others, because one of the goals of maintaining Open Source repositories is to provide value to the community.


Attribution


License

This project is licensed based on use-case


Commercial and/or proprietary use

If a project is either commercial or (||) proprietary, then please contact the author for pricing and licensing options to make use of code and/or features from this repository.


Non-commercial and FOSS use

If a project is both non-commercial and (&&) published with a licence compatible with AGPL-3.0, then it may utilize code from this repository under the following terms.

Convert archived Tweets to MarkDown with FrontMatter
Copyright (C) 2024 S0AndS0

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, version 3 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

Dependencies

~9.5MB
~162K SLoC