Make pretty formatted timestamps using BB codes for Xenforo2 forum posts.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Yotsubaaa 1951bb6f5f Update 'bb_timestamps.rb' 7 kuukautta sitten
.gitignore Initial commit 9 kuukautta sitten
LICENSE Initial commit 9 kuukautta sitten
README.md Calling it bb_timestamps.rb now (more general) 7 kuukautta sitten
bb_timestamps.rb Update 'bb_timestamps.rb' 7 kuukautta sitten
kiwi_timestamps_eg1.png Uploaded pics for readme example 9 kuukautta sitten
kiwi_timestamps_eg2.png Uploaded pics for readme example 9 kuukautta sitten
kiwi_timestamps_eg3.png Uploaded pics for readme example 9 kuukautta sitten
kiwi_timestamps_eg4.png Uploaded pics for readme example 9 kuukautta sitten

README.md

bb_timestamps

Make pretty formatted timestamps using BB codes for Xenforo 2 forum posts.

The Ruby script bb_timestamps.rb automates the process I use to make timestamps for YouTube streams and videos in my Kiwi Farms posts. See the Demonstration below for a usage example.

Released under the Unlicense License. Feel free to do anything you want with this script; just don’t hold me liable if anything bad happens!

## Demonstration Here's a step-by-step example of using the `bb_timestamps.rb` script to make a pretty list of timestamps.

1. Write the timestamps using any text editor.

Using your favorite text editor, write your timestamp lines in the following format, e.g.

  00:12:34 Something funny happens here at 1hr, 23mins, 45secs
  00:13:45 Something else happens
  23:45 This timestamp doesn't have the hours column (this is fine!)
  
  01:23:45 This timestamp comes after a blank line (this is also fine!)
  
  1:34:56 This timestamp doesn't have padded zeros (again, perfectly fine!) 

with a single space separating the time and the comment, and with each new timestamp on a new line.

  • The times do not have to be exactly hr:mn:sc. You can drop the hour column and use mn:sc for shorter videos/streams (or even just sc for really short videos), and everything still works fine with the script. The formatted times in the output will appear exactly as you enter them.
  • The times do not have to be padded with zeros, either. I pad with zeros simply so that the times align with each other in the monospaced output (the formatted times will appear exactly as you enter them), but you don’t have to do this for the script to work.
  • You can have blank lines between timestamps. The kiwi_timestamps.rb script ignores any blank lines and extraneous whitespace when reading the timestamps. Only the single space between the time and the comment is important.

Optionally (but most usefully!), if the first line of your text file of timestamps is a link to the YouTube video/stream, e.g.

https://www.youtube.com/watch?v=XXXXXXXXXXX

then the timestamps will be formatted to include a hyperlink to that exact moment in the video/stream, using YouTube’s &time_continue= parameter. Otherwise, if no link is provided, the timestamps will simply be colored light blue so that they stand out a bit.

Example

Here’s me making some timestamps for a YouTube stream. Note the timestamps file in the EMACS editor on the right-hand side. The file includes the link to the YouTube stream as the first line, then a blank line (which gets ignored by the script), and then the timestamps I want. The timestamps file is saved as MADI_timestamps.

2. Run bb_timestamps.rb and grab the output.

Once you’ve written all of your timestamps to a file (called timestamps_file for example), simply run the script bb_timestamps.rb as a Ruby script and pass in your file of timestamps with

ruby bb_timestamps.rb timestamps_file

or, if you’ve given the script permission to run as an executable,

./bb_timestamps.rb timestamps_file

The version of Ruby I had on hand when I wrote the script was Ruby 2.3, so the script should (presumably?) run on any version >=2.3.

When executed, the script prints each of the formatted timestamps to the standard output stream. Optionally redirect the output to a file for easier copy-pasting.

Example

Here I run the bb_timestamps.rb script at the command line, passing in MADI_timestamps as an argument and redirecting the script output to a new file MADI_formatted. The script only takes a moment to run, and we can see (using cat MADI_formatted to look at the file contents) that all of the timestamps have been formatted to include the font and hyperlink information.

3. Toggle BB codes for your Kiwi Farms post.

The formatted output text contains the explicit BB codes that are used to format posts on Kiwi Farms (and other Xenforo2 forum boards). But if we paste it into a new post like usual, then those code strings will just appear as text in the post. So we first click the ‘Toggle BB code’ button in the top-right corner so that the BB codes for the font/url/color/etc are interpreted properly.

Example

When I go to make my Kiwi Farms post, I click the ‘Toggle BB code’ button in the top-right corner.

4. Copy-paste in the formatted timestamp text.

At this point, all that’s left is to paste in the formatted timestamp text, and perhaps click ‘Preview’ to make sure that everything appears nicely as expected.

Example

Here I have copy-pasted the formatted timestamps from MADI_formatted into my post, and clicked ‘Preview’. The timestamps come up all pretty and monospaced, and clicking on any of them opens a link to that moment in the YouTube stream (see the hyperlink hovertext in the bottom-left corner).

5. All done!

And that’s all there is to it! After you’ve copy-pasted in the formatted timestamp text, you can click ‘Toggle BB code’ again to return to the normal post interface and do more things (change text around, maybe put the timestamps inside spoiler tags if they’re a long list, etc). Voila!