16

Note:

This page is due for an update but until then you can add StackAd to your site by adding:

<script type='text/javascript'
        src='http://files.quickmediasolutions.com/stackad/stackad.min.js'>
</script>

to the <head> section of your page and sticking the following <div> on the page where you want the ads to appear:

<div class='stackad' data-site='stackoverflow.com'></div>

...where data-site is the parent site of the Stack Exchange site whose ads you want to display.

Screenshot / Code Snippet


StackAd demo available here.


About

StackAd pulls the answers from this question that have 6 or more upvotes and displays a random ad in the box. The code is provided as a .js file you can embed in your pages. The instructions are here.

License

As is common with all of my open-source apps, I am going with the MIT license.

Download

http://stackoverflow.quickmediasolutions.com/stackad/stackad.js <- This file can be hotlinked and has been minified to save bandwidth
http://stackoverflow.quickmediasolutions.com/stackad/stackad-source.js <- This is the source
http://stackoverflow.quickmediasolutions.com/stackad/test.html <- to see a demo
http://stackoverflow.quickmediasolutions.com/stackad/fancy.html <- to see an even better demo

Platform

The code should work with any JavaScript enabled browser.


Contact

I can be reached at admin@quickmediasolutions.com


Code

The code is written in JavaScript and uses the Soapi.js wrapper for interfacing with the API.

Nathan Osman
  • 23,286
  • 11
  • 60
  • 107
  • Hey, that's a pretty unique use for the API! But... what are you going to do when a new thread is created and the question number changes? - nevermind, if you do a copy/paste style app then you can change your hotlinked JS file. – Mark Henderson Jun 16 '10 at 02:25
  • @Farseeker: Ya, that's basically the idea :) – Nathan Osman Jun 16 '10 at 02:27
  • 2
    I like it. Short, Sweet, Scooby Snack of an app. – Sky Sanders Jun 16 '10 at 02:52
  • Please also vote for this app here so I can win the mini-contest. – Nathan Osman Jun 16 '10 at 03:14
  • 1
    You can now link to stackad.js! – Nathan Osman Jun 16 '10 at 03:35
  • 1
    Please let me know when you use it on your blog/site. I really appreciate feedback! – Nathan Osman Jun 16 '10 at 03:40
  • As a complete side-note, consider supporting another open-source project by voting for this. – Nathan Osman Jun 16 '10 at 03:44
  • @George, just looking at stackad.js, a few suggestions: 1) Check for JQuery and include it's not there (hotlink to the Google Hosted version), 2) Check for SOAPI.js and include it automatically if it's not there. 3) The ID of "banner" is incredibly common. Maybe call it "so-oss-banner" or something? This way it's an all-in-one solution and is really just a copy/paste solution. Also, 4) for your own bandwidths sake, you might want to run it through a minifier. That copyright notice will cost you a lot of money if you're not careful Other than that, looking good! – Mark Henderson Jun 16 '10 at 05:27
  • @Farseeker: Ya, those pretty much mirror my todo list - I will fix those pretty quickly. #2 might be slightly more difficult though. Update: Fixed #3 already. – Nathan Osman Jun 16 '10 at 05:35
  • @code: Do you mind if we hotlink Soapi.js and Soapi.Generated.js? – Nathan Osman Jun 16 '10 at 05:39
  • I have created a minified version suitable for hotlinking. – Nathan Osman Jun 16 '10 at 05:45
  • well, the files will be in the same place but until the api goes gold and stops moving I can guarantee the functionality. This would be the issue with hotlinking. And I have yet to wire up minification to my build process yet. when I find myself with some time I will build in minification and output files with version numbers that can be linked. – Sky Sanders Jun 16 '10 at 05:57
  • @Farseeker: I implemented your idea - the script now searches for and detects if jQuery has been included and otherwise loads it from Google. – Nathan Osman Jun 16 '10 at 06:03
  • @code: In the meantime? Ah, never mind. I'll just host them on mine until you get something set up. – Nathan Osman Jun 16 '10 at 06:04
  • I have minified the Soapi files and they are automatically included with the stackad.js source when necessary. – Nathan Osman Jun 16 '10 at 06:31
  • Looking good :) – Mark Henderson Jun 16 '10 at 10:43
  • geo - when the api froze, i suspended code generation and began refactoring and polishing soapi.js. i am about to push the much refactored and streamlined soapi.js, so if you are linking you will want to get a local copy as a lot of the redundancy and other artifacts that are common in code generation have been removed and a few typenames have changed. Nothing outwardly drastic, but a much better library has emerged. upgrading your apps should be a piece of cake. I will be pushing @ midnight. heads up. – Sky Sanders Jun 30 '10 at 01:50
  • This demo no longer appears to function. Closing... – Kevin Montrose Aug 04 '10 at 01:22
  • @Kevin: Whoooah... I need a chance to fix it! There. Fixed. – Nathan Osman Aug 04 '10 at 04:23
  • Reopened, as it works now. – Kevin Montrose Aug 04 '10 at 04:35
  • geo - help a brother out, wouldja? http://meta.stackoverflow.com/questions/53346/open-source-advertising-sidebar-2h-2010/60263#60263 – Sky Sanders Aug 10 '10 at 23:36
  • @code: Smart looking ad! +1 – Nathan Osman Aug 10 '10 at 23:51
  • @code: Can you consider voting for this one, please? – Nathan Osman Aug 11 '10 at 01:24
  • geo - the copyright is missing your name. – Sky Sanders Nov 04 '10 at 02:52
  • @Sky: Sorry, which copyright? – Nathan Osman Nov 04 '10 at 06:52
  • I am relatively new to this site and open-source-Advertising. I love open source and admire the concept. Can you please tell me if it is legal / acceptable to put these open source ads in my blog I am building? I have put up the ad related code in my blog – raghu.kiran Jul 14 '12 at 17:23
  • @MonkeyInstincts: I'm not a lawyer, but I certainly don't see anything wrong with it. – Nathan Osman Jul 15 '12 at 03:40
  • Hi George thanks for a quick turn around. I can't see the ads loading now for me. It was wroking fine few hours back. I see below error message in Console logs of Google Chrome & Firefox browsers. GET http://api.meta.undefined/1.1/questions?tagged=community-ads&sort=creation&jsonp=jsonp_callback_0&key=bLgPLydVUkSNtkp6LNPwNw stackad.min.js:1 – raghu.kiran Jul 16 '12 at 05:36
  • @MonkeyInstincts: Ah, sorry for the confusion. You're using an older version of StackAd. The latest version (and instructions for using it) are listed at the very top of this question (in the light-grey box). – Nathan Osman Jul 16 '12 at 16:15
  • Thank you for clarification George. I have the ads up and running now. I love the concept. I don't have enough reputation to +1 the post. – raghu.kiran Jul 17 '12 at 04:50
  • Links and subdomain are (long) dead. – Brock Adams Oct 03 '18 at 02:36

1 Answers1

2

Is there a way for this work for other, non-stackoverflow (think: Ask Ubuntu) community ads?

jrg
  • 121
  • 7