Skip to content
This repository has been archived by the owner on Mar 20, 2019. It is now read-only.

Adding spamspan module #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sites/all/modules/contrib/spamspan/INSTALL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Please see README.txt
339 changes: 339 additions & 0 deletions sites/all/modules/contrib/spamspan/LICENSE.txt

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions sites/all/modules/contrib/spamspan/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Readme
------

The SpamSpan module obfuscates email addresses to help prevent spambots from
collecting them. It implements the technique at http://www.spamspan.com

The problem with most email address obfuscators is that they rely upon
JavaScript being enabled on the client side. This makes the technique
inaccessible to people with screen readers. SpamSpan however will produce
clickable links if JavaScript is enabled, and will show the email address as
<code>example [at] example [dot] com</code> if the browser does not support
JavaScript or if JavaScript is disabled.

Installation
------------

1. Create a directory in your Drupal modules directory (probably
sites/all/modules/) called spamspan and copy all of the module's
files into it.

2. Go to the Modules administration page (admin/modules), and enable the
spamspan module (under Input Filters)

3. Go to the Text Formats Configuration page (admin/config/content/formats)
and configure the desired input formats to enable the filter.

4. Rearrange the Filter processing order to resolve conflicts with other
filters. NB: To avoid problems, you should at least make sure that the
SpamSpan filter has a higher weighting (greater number) than the line break
filter which comes with Drupal ("Convert line breaks into HTML" should come
above SpamSpan in the list of Enabled filters). If you use HTML filter
("Limit allowed HTML tags"), you may need to make sure that <span> is
one of the allowed tags. Also, URL filter ("Convert URLs into links") must
come after SpamSpan.

5. (optional) Set available options under "Filter Settings".

Bugs
----

Please report any bugs using the bug tracker at
http://drupal.org/project/issues/spamspan


Module Author
------------
Original: Lawrence Akka : http://drupal.org/user/63367
November 2014 rewrite: Peter Moulding : http://petermoulding.com/spamspan

Binary file added sites/all/modules/contrib/spamspan/image.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions sites/all/modules/contrib/spamspan/spamspan.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name = SpamSpan
description = "The SpamSpan module obfuscates email addresses to help prevent spambots from collecting them. It implements the technique at http://www.spamspan.com."
package = "Input filters"
dependencies[] = filter
core = 7.x
configure = admin/config/content/formats
files[] = spamspan_admin.php
files[] = spamspan_admin_page.php
files[] = spamspan.test
; load javascript on every page
scripts[] = spamspan.js
; Information added by Drupal.org packaging script on 2014-11-27
version = "7.x-1.2"
core = "7.x"
project = "spamspan"
datestamp = "1417110482"

51 changes: 51 additions & 0 deletions sites/all/modules/contrib/spamspan/spamspan.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
--------------------------------------------------------------------------
(c) 2007 Lawrence Akka
- jquery version of the spamspan code (c) 2006 SpamSpan (www.spamspan.com)

This program is distributed under the terms of the GNU General Public
Licence version 2, available at http://www.gnu.org/licenses/gpl.txt
--------------------------------------------------------------------------
*/

(function ($) { //Standard drupal jQuery wrapper. See http://drupal.org/update/modules/6/7#javascript_compatibility
// load SpamSpan
Drupal.behaviors.spamspan = {
attach: function(context, settings) {
// get each span with class spamspan
$("span.spamspan", context).each(function (index) {
// Replace each <spam class="t"></spam> with .
if ($('span.t', this).length) {
$('span.t', this).replaceWith('.');
}

// For each selected span, set mail to the relevant value, removing spaces
var _mail = ($("span.u", this).text() +
"@" +
$("span.d", this).text())
.replace(/\s+/g, '');
// Find the header text, and remove the round brackets from the start and end
var _headerText = $("span.h", this).text().replace(/^ ?\((.*)\) ?$/, "$1");
// split into individual headers, and return as an array of header=value pairs
var _headers = $.map(_headerText.split(/, /), function(n, i){
return (n.replace(/: /,"="));
});
// Find the anchor text, and remove the round brackets from the start and end
var _anchorText = $("span.t", this).text().replace(/^ \((.*)\)$/, "$1");
// Build the mailto URI
var _mailto = "mailto:" + encodeURIComponent(_mail);
var _headerstring = _headers.join('&');
_mailto += _headerstring ? ("?" + _headerstring) : '';
// create the <a> element, and replace the original span contents
// Issue https://www.drupal.org/node/1540732
// .attr("href", _mailto) replaced by .attr("href", decodeURIComponent(_mailto))
$(this).after(
$("<a></a>")
.attr("href", decodeURIComponent(_mailto))
.html(_anchorText ? _anchorText : _mail)
.addClass("spamspan")
).remove();
});
}
};
}) (jQuery);
Loading