A simple but effective way to responsibly share links about or containing potentially
sensitive subjects.
Process
My wife told me about an article that was posted on social media about a dog that was
murdered. The article featured a photo of the dog, and overall it was a disturbing and
alarming experience. I wanted to make a web app that would allow someone to share a link
but warn people about sensitive content that might be on the link’s page, so I looked
into how I could alias a web address to show an alternate image that warns the audience
about what content was on the page.
I used PHP to access an manipulate a SQLite database, which stores encrypted links that
users enter. When the PHP fetches the data from the database, I use Hashids
to create a shortlink out of the link’s id in the database combined with the selected warnings.
I also set up the website’s .htaccess
file to intelligently interpret the url to send users
to the correct place without needing to use ?
query strings in the url.
Once the base was finished, I used jQuery to make the interaction for the website smooth
and easy for myself to maintain. I used a jQuery plugin called Select2
to make the searching and selection of warnings nicer.
Lessons
This was my first time using classes in PHP’s object oriented structure, and I found
it very useful. I tried to utilize classes as much as I could to keep my code as structured
and separated as possible.
Using a pseudo-MVC structure, I was able to separate my code in a healthy way, keeping the text
itself separate from the container that displayed the text made it possible to keep terminology
completely consistent across the site, and separating the code that controlled the website’s
behavior from the code that displayed the content made it easier to find and fix bugs and add
new features.