Files @ 46c50ec0b192
Branch filter:

Location: website/www/conservancy/static/admin/js/urlify.js

Bradley M. Kuhn
Copyleft Compliance: Minor rewrite of strategy & firmware liberation

This rewrite should improve the stand-alone nature of these documents
and allow for better integration with other summary text and
announcements on the website.

Note that they have now drifted heavily from the original formulation
of the items as grant proposals.
function URLify(s, num_chars) {
    // changes, e.g., "Petty theft" to "petty_theft"
    // remove all these words from the string before urlifying
    removelist = ["a", "an", "as", "at", "before", "but", "by", "for", "from",
                  "is", "in", "into", "like", "of", "off", "on", "onto", "per",
                  "since", "than", "the", "this", "that", "to", "up", "via",
                  "with"];
    r = new RegExp('\\b(' + removelist.join('|') + ')\\b', 'gi');
    s = s.replace(r, '');
    s = s.replace(/[^-A-Z0-9\s]/gi, '');  // remove unneeded chars
    s = s.replace(/^\s+|\s+$/g, ''); // trim leading/trailing spaces
    s = s.replace(/[-\s]+/g, '-');   // convert spaces to hyphens
    s = s.toLowerCase();             // convert to lowercase
    return s.substring(0, num_chars);// trim to first num_chars chars
}