We have been in public beta for a while. One of the many ways our site gets attention is via the Hot Network Questions(HNQ) feed and site bar on StackExchange.
There is a formula that will elect questions from our site into the HNQ feed. This gives certain questions more exposure in the StackExchange network and generates more traffic for the site for a period of time.
These questions serve as representation of what our site is. That should be true always for all of our question but perhaps more so during this HNQ period. Therefore I wanted to come up with a way for us to be aware of when these questions become elected to the HNQ in case it was not already obvious. If the question or current answers could use some touch up it would be in our best interest to address it.
Currently the only HNQ feed we can subscribe to only handles the first 30 questions of the entire SE network. I have a hosted script that reduces the feed to only our questions. It has the name Ember in chat. If you ever see a post from that feed check it to see if it could use some TLC.
How it works
I got the gist of the code given to me by Napoleon over on Movies.SE Chat. I updated the logic a bit both to suit our needs and make it a little more potable and fault tolerant. I also littered it with comments as I didn't understand how it worked at first.
function doGet()
{
// This function will take the hot network question feed and filter out all of the questions that are not part of
// a particular site as designated by the var filterOn
var filterOn = "crafts"
// RSS Url
var rssFeedUrl = 'http://stackexchange.com/feeds'
// Fetch URL content
var feed = UrlFetchApp.fetch(rssFeedUrl).getContentText();
// Creates a Document from the given XML, without validating the XML.
var document = XmlService.parse(feed);
// Gets the document's root Element node.
var root = document.getRootElement();
// Creates a Namespace with the given prefix and URI.
var atom = XmlService.getNamespace('http://www.w3.org/2005/Atom');
// Get the children
var entries = root.getChildren('entry', atom);
// Cycle each entry and remove it if certain criteria are matched.
for (var entryIndex = 0; entryIndex < entries.length; entryIndex++)
{
// Capture the text if the ID.
var id = entries[entryIndex].getChildText('id', atom);
// Match the stack exchange sub site.
var regex = /http:\/\/(.*?).stackexchange\.com/.exec(id);
// Check to see if it is not null and does not match crafts.
if(regex == null || regex[1] != filterOn){
// Remove the entry if it is null or doesnt match crafts
entries[entryIndex].detach();
}
}
// Create a new feed with the parsed information from the StackExchange one.
feed = XmlService.getCompactFormat().setLineSeparator('\n').setEncoding('UTF-8').setIndent(' ').format(document);
// Return the new feed object
return ContentService.createTextOutput(feed).setMimeType(ContentService.MimeType.RSS);
}
This script is hosted as a webapp on my Google account and given anonymous read access. I then added it as a feed in the chat.
In practice this has been working.