In my last long scroll post I went over the steps for forking and editing a silly GitHub page to mess with the lyrics of “Home on the Range.” That is like, so, not really useful.

This one might not be either. But it could be fun.

When you use a bookmarklet tool created with my Flickr CC Attribution Helper, there are a series of random messages that cycle through while the browser waits for the flickr API to return the data it needs.

Here is a crude approximation as a 4 frame animated GIF:

cc--attribution-helper

I wanted something to animate while this communication happened so you know that the thing is in process, so it was learning how to use the Javascript setInterval() and SetTimeout() functions. It can also generate a pop up if a longer than expected period passes (sometimes the flickr API chokes).

ANYHOW, I got the idea from… was it Slack’s loading messages that inspired me?

Last week Brian Bennett noticed!

That’s true- I think once after Ken Bauer said something nice about the Flickr CC Attribution Helper I slipped a “Waving at Ken” into the array of messages.

I was ready to offer to add any message Brian wanted into the mix.. and then saw the light bulb go off

Why should I change the code when anyone else can via a GitHub pull request?

So I went in to motion to write this up… and paused. I saw some un-necessary redundancy in my code.

You see, each “flavor” of the tool (that means the kind of attribution it generates, a WordPress One with caption tags, even one in Markdown) exists as an HTML file that is passed the flickr ID of the photo of interest, and has in it the Javascript code to spawn the attribution window.

I had the same code repeated in each, so I did some consolidation to put common used JavaScript, including the array for the funnymessages array, into a single Javascript file.

That’s a long way to say here is the file you need to fork and edit if you want to add a new message. You just need to put a quoted string into the funnymessages array, putting it and a comma after the last element.

Here is how the function that does the work looks now:

// Holders for message to let 'em know wheels are spinning
// Here is where you can have fun by adding new messages FORK IT BABY!

function ChangeStatusMessage() {
	var funnymessages = ['Greasing the tubes for transmission', 'Feeding the squirrels who spin the turbines', 'Checking the weather for stormy clouds', 'Waving at Ken', 'Spreading smooth peanut butter', 'Barking like a big dog', 'Has anyone seen my data? Jason?', 'Wondering about the meaning of life', 'Knocking on the doors of yahoo saying please give us some api data', 'Crosswiring the figwitz circuit', 'Gazing up at the sky', 'Getting the lovely stuff', 'Sautéing onions and garlic in butter' ];

	// Attach the message to the screen. Aren't we clever?	
	$('#attribution').text( funnymessages[Math.floor(Math.random()*funnymessages.length)] + '...');
}

I could fork/edit this to add a message for maybe Brian, see the last element in the funnymessages array:

// Holders for message to let 'em know wheels are spinning
// Here is where you can have fun by adding new messages FORK IT BABY!


function ChangeStatusMessage() {
	var funnymessages = ['Greasing the tubes for transmission', 'Feeding the squirrels who spin the turbines', 'Checking the weather for stormy clouds', 'Waving at Ken', 'Spreading smooth peanut butter', 'Barking like a big dog', 'Has anyone seen my data? Jason?', 'Wondering about the meaning of life', 'Knocking on the doors of yahoo saying please give us some api data', 'Crosswiring the figwitz circuit', 'Gazing up at the sky', 'Getting the lovely stuff', 'Sautéing onions and garlic in butter', 'Being cool in school like @bennettscience' ];

	// Attach the message to the screen. Aren't we clever?	
	$('#attribution').text( funnymessages[Math.floor(Math.random()*funnymessages.length)] + '...');
}

And once I merge the request, that message may surprise Brian the next time he fetches a flickr attribution with his bookmarklet. I can change how it works without changing his tool at all.

And you can do this too.

All ya gotta do is fork.

I triple dog dare ya. Here’s the keys.

triple-dog


Top / Featured Image credit: I ran out of inspiration for a metaphor, so I am just using a screenshot of one of the random messages that flash when you use the Flickr CC Attribution Helper.

The post "Forking Your Way into the Flickr CC Attribution Helper" was originally assembled from spare parts of a 1957 Chevy at CogDogBlog (http://cogdogblog.com/2016/04/forking-your-way-into-the-flickr-cc-attribution-helper/) on April 5, 2016.

3 Comments

  • John

    Hi Alan,
    So I gave this a go too.
    What was interesting is that I had already forked this repo a while back.
    Hitting the edit link on your file created a new branch on my repo. Where I made an edit and a pull request.
    This raise the question, for me, was my forked repo keeping unto date with yours? More digging to do…

    • Alan Levine aka CogDog cogdogblog.com

      This is the part I remain fuzzy, another reason for the experiment here. A forked repo should not change, but when I look at it’s status it notifies you that yours is a commit “behind” mine.

      But your forked repo does not have the new file I added, that you forked and edited (/assets/javascript/cc-attributor.js) the question is where is that in your repo?

      There is some irony that the only people you have taken up my Fork Challenge are you and David Wright, and both of you are among the few that have already done this in my stuff. It’s a steep uphill to get other people to do this….

      • john

        It does seem a steep hill but the stuff you are doing has really helped me. I’ve dipped into git now and again but it didn’t stick. The Fork Challenges have given me some traction at, hopefully the right time. I even did the daily create on Github today:-)

Leave a Comment

All fields are required. Your email address will not be published.