[paidaccount] Automatic Meme Filtering

Jul 30, 2004 18:56


Paid Accounts Only The following tutorial requires creating and editing a custom style, which in turn requires a paid, permanent, or early adopter account. Please read What are the paid account benefits? and How do I buy a paid account? to learn about the paid account benefits and how to buy a paid account.
This tutorial describes a simple method for automatically detecting and cut-tagging many common quiz memes. This override will be placed in the theme layer of your style. The code in this example is based on the Punquin Elegant style, but it should adapt easily to any other style. If you already have a theme layer, go ahead and edit it. Otherwise, create one by following the instructions in the Theme Layer tutorial.

At this point, you will need to copy a function that controls the entries into your theme layer. This tutorial is based on Punquin Elegant. The Punquin Elegant layout uses a method called "print_entry" to print journal entries, which is called from the "FriendsPage::print_entry" override. At the Public Layers page, select an existing layout from the list of public layouts. Click "Raw Source Code" when viewing a layout to download the S2 source for that layout. For Punquin Elegant copy the function print_entry (Page p, Entry e, Color bgcolor, Color fgcolor, bool hide_text) from this file into the layer edit window for your theme layer. If you are not using the Punquin Elegant layout, you will need to locate and copy the "FriendsPage::print_entry" override (or "Page::print_entry", if this method isn't overridden in your layout).

Most layouts will contain a fair bit of code in this override to handle user icons, moods, and other formatting. You will need to locate the following line of code:

$e->print_text(); "
";
This line prints the content of the journal entry. Replace it with the following code:

var string[] memedomains = [ "quizdiva.com", "quizilla.com", "similarminds.com", "4degreez.com", "theferrett.com", "bzoink.com", "stvlive.com", "deskslave.org", "steve.org.uk" ]; var bool contains_meme = false; foreach var string memedomain ($memedomains) { if ($e.text->contains($memedomain)) { $contains_meme = true; } } if (($p.view == "friends") and ($e.poster.username != $p.journal.username) and ($contains_meme)) { """
( Meme detected. Automatically cut-tagged.)
"""; } else { $e->print_text(); "
"; }
In the code above, you will notice a string array called "memedomains" containing the domain names of several popular quiz meme hosting sites. This meme detection algorithm depends on the fact that most meme websites embed a self-referential link in the HTML they generate. Most memes are hosted on very small number of sites. If a meme slips through the filter, simply copy the domain name from the post and add it to the "memedomains" array in "contains_meme".

You will need to apply your layout layer via the Customize interface in order for your changes to take effect.

Tutorial by gamble. Elements of this tutorial were borrowed from a previous tutorial by dianna_wills and aajwind. Rewritten by camomiletea.

meme filtering, automatic meme filtering, - all styles, paid accounts only

Previous post Next post
Up