Spring Tips: Twitter "Bites" Engine
Scheduler and pipeline to produce and tweet tweet-sized Spring Tips
Using ChromeDriver on Your Operating System
This application uses Selenium to control a Google Chrome browser. Selenium only speaks a single protocol. There are
operating-system specific binaries, chromedriver
, that respond to this protocol and in turn orchestrate Google Chrome. Google Chrome is architecture and operating systems-specific, and so too must be chromedriver
. I've included the various chromedriver binaries for various operating systems. These binaries are from 2022-06
and work with version 102 of Google Chrome. Make sure when you run this program that the Spring Boot configuration property, ingest.chrome-driver-path
, points to the appropriate binary for your operating system. The default value looks like this:
springtips.chrome-driver-path=${HOME}/Desktop/spring-tips-selenium-engine/bin/macos-m1/chromedriver
Modify accordingly.
Formatting
This program uses the Spring Boot JavaFormat Maven plugin to ensure that the source code has the same formatting regardless of both how someone edits and in which IDE they edit it. It'll break the build if code is committed without first running the formatting plugin. Thus, before comitting every change, run:
mvn spring-javaformat:apply
Motivation
The goal of this project is to automate the generation of images to be included in periodic tweets promoting tips about Spring from the @SpringTipsLive
(and eventually, from @SpringCentral
) twitter handles. I'm working on figuring out how to programatically Tweet in another vein, so that's out of scope for this. Once I've figured that out, I'll integrate it with this. The scope of this program is simply to programatically take a database or Git repository of Tweets (images and code in folders, perhaps?) and then slide them into a design that supports templating. Maybe Scalable Vector Graphics (SVG, often encoded as .svg
) could work?
There are several facets to this program:
- reading and processing the content in a Git repository
- producing a good-looking graphic and friendly, 280 char-or-less Tweet
- the good-looking graphic will need to be rendered. Maybe we could use SVG, then use Selenium to load the SVG up in a browser, then use AWT
Robot
or Selenium'sTakesScreenshot
to take a screenshot and use that? See this post for more on using Selenium to take screenshots.
- the good-looking graphic will need to be rendered. Maybe we could use SVG, then use Selenium to load the SVG up in a browser, then use AWT
- tweeting the tweets
- this will require us to keep track of what's been tweeted and what not, and to do so on a schedule without overlaps and to avoid inundating the readers
ChromeDriver
Make Sure You're Using the Latest I'm using Google Chrome 104, and therefore need the appropriate chromedriver
native binaries on the PATH
before I run this program. Download all the .zip
files, unzip them, and then move the relevant chromedriver(.exe)
binary to the correct path.