aboutsummaryrefslogtreecommitdiff
path: root/guidelines
diff options
context:
space:
mode:
authorGravatar Rogan Creswick <creswick@gmail.com>2013-12-19 13:31:29 -0800
committerGravatar Rogan Creswick <creswick@gmail.com>2013-12-19 13:31:29 -0800
commitaa2a7b34b64be8daf1a9d50f589563275284d50e (patch)
treeda898aabcbca0191a57140e635e167b88aaa84e0 /guidelines
parent3b53cef842cf0288ad55fe55ae2f578f75b40ae7 (diff)
parent15a644f91a8b6e80bbd24a824b91c24547b80035 (diff)
merge
Diffstat (limited to 'guidelines')
-rw-r--r--guidelines/wikipedia/bullets.js8
-rw-r--r--guidelines/wikipedia/color.js27
-rw-r--r--guidelines/wikipedia/horizontalRule.js8
-rw-r--r--guidelines/wikipedia/imageSize.js22
-rw-r--r--guidelines/wikipedia/paragraphLength.js15
-rw-r--r--guidelines/wikipedia/pseudoHeadings.js14
-rw-r--r--guidelines/wikipedia/spaceBetweenParagraphs.js28
-rw-r--r--guidelines/wikipedia/wikipedia.json8
8 files changed, 126 insertions, 4 deletions
diff --git a/guidelines/wikipedia/bullets.js b/guidelines/wikipedia/bullets.js
new file mode 100644
index 0000000..80c5c4b
--- /dev/null
+++ b/guidelines/wikipedia/bullets.js
@@ -0,0 +1,8 @@
+exports.name = "Minimize use of bullet points";
+exports.description = "Bullet points should be minimized in the body and lead of the article, if they are used at all.";
+
+exports.rule = function(report) {
+ $5('#mw-content-text > ul, #mw-content-text > ol').each(function() {
+ report.warning('Minimize use of bullet points.', this);
+ });
+};
diff --git a/guidelines/wikipedia/color.js b/guidelines/wikipedia/color.js
index 13c5422..045a8ac 100644
--- a/guidelines/wikipedia/color.js
+++ b/guidelines/wikipedia/color.js
@@ -52,9 +52,10 @@ exports.rule = function (report) {
var $this = $(this);
return $this.children().length == 0 && $.trim($this.text()).length > 0;
})
- .each(function (i,elt) {
- var fg = fc.colorToRGB($(elt).css('color'));
- var bg = fc.findBGColor($(elt));
+ .filter(exceptions)
+ .each(function (i) {
+ var fg = fc.colorToRGB($(this).css('color'));
+ var bg = fc.findBGColor($(this));
if (fg && bg) {
var ratio = fc.contrast(fc.luminance(fg), fc.luminance(bg));
console.log("comparing witch ratio" + ratio);
@@ -68,3 +69,23 @@ exports.rule = function (report) {
}
});
};
+
+function exceptions() {
+ var $elem = $(this);
+ return !isStandardLink($elem) &&
+ !isNavboxLink($elem);
+}
+
+function isStandardLink($elem) {
+ var standard = ['new', 'external', 'extiw'];
+ var $a = $elem.closest('a');
+ return $a.is('a') && standard.some(function(klass) {
+ return $a.hasClass(klass);
+ });
+}
+
+function isNavboxLink($elem) {
+ var $a = $elem.closest('a');
+ var $nav = $a.closest('th.navbox-group');
+ return $a.length > 0 && $nav.length > 0;
+}
diff --git a/guidelines/wikipedia/horizontalRule.js b/guidelines/wikipedia/horizontalRule.js
new file mode 100644
index 0000000..b16375d
--- /dev/null
+++ b/guidelines/wikipedia/horizontalRule.js
@@ -0,0 +1,8 @@
+exports.name = "Horizontal rules are deprecated";
+exports.description = "Horizontal rules (----) are deprecated.";
+
+exports.rule = function(report) {
+ $5('#mw-content-text hr').each(function(i, hr) {
+ report.warning('Remove horizontal rule.', hr);
+ });
+};
diff --git a/guidelines/wikipedia/imageSize.js b/guidelines/wikipedia/imageSize.js
new file mode 100644
index 0000000..7000b0b
--- /dev/null
+++ b/guidelines/wikipedia/imageSize.js
@@ -0,0 +1,22 @@
+exports.name = "Large image";
+exports.description = "Images should be sized for comfortable display on the smallest displays in common use.";
+
+exports.rule = function(report) {
+ $5('#mw-content-text img').each(function() {
+ var $img = $(this);
+ if ($img.width() > 400 && !centered($img) && !locationNone($img)) {
+ report.warning('Image is more than 400px wide. Consider using the "center" or "none" location options for wide images', this);
+ }
+ if ($img.height() > 500 && !centered($img) && !locationNone($img)) {
+ report.warning('Image is more than 500px tall.', this);
+ }
+ });
+};
+
+function centered($img) {
+ return $img.closest('.center').length > 0;
+}
+
+function locationNone($img) {
+ return !centered($img) && $img.closest('.tnone').length > 0;
+}
diff --git a/guidelines/wikipedia/paragraphLength.js b/guidelines/wikipedia/paragraphLength.js
new file mode 100644
index 0000000..ba20306
--- /dev/null
+++ b/guidelines/wikipedia/paragraphLength.js
@@ -0,0 +1,15 @@
+exports.name = "Avoid single-sentence paragraphs";
+exports.description = "The number of single-sentence paragraphs should be minimized.";
+
+exports.rule = function(report) {
+ var sentenceBoundary = /[.?!](?:(?:\[\d+\])|['"])*(?:\s|$)/gm;
+
+ $5('#mw-content-text p').each(function(i, p) {
+ var $p = $(p);
+ var text = $.trim($p.text());
+ var boundaries = text && text.match(sentenceBoundary);
+ if (boundaries && boundaries.length === 1) {
+ report.warning('Paragraph with only one sentence: "' + text +'"', p);
+ }
+ });
+};
diff --git a/guidelines/wikipedia/pseudoHeadings.js b/guidelines/wikipedia/pseudoHeadings.js
new file mode 100644
index 0000000..bbf7d8d
--- /dev/null
+++ b/guidelines/wikipedia/pseudoHeadings.js
@@ -0,0 +1,14 @@
+exports.name = "Do not make pseudo-headings";
+exports.description = "Do not make pseudo-headings using bold or semicolon markup.";
+
+exports.rule = function(report) {
+ $5('#mw-content-text p > b:only-child').each(function(i, b) {
+ var text = $.trim($(b).text());
+ report.error('Bold text used as pseudo-heading: '+ text, b);
+ });
+
+ $5('#mw-content-text dl:not(:has(dd)) dt').each(function(i, dt) {
+ var text = $.trim($(dt).text());
+ report.error('Semicolon markup used to create pseudo-heading: '+ text, dt);
+ });
+};
diff --git a/guidelines/wikipedia/spaceBetweenParagraphs.js b/guidelines/wikipedia/spaceBetweenParagraphs.js
new file mode 100644
index 0000000..ccab3a4
--- /dev/null
+++ b/guidelines/wikipedia/spaceBetweenParagraphs.js
@@ -0,0 +1,28 @@
+exports.name = "There should only be one blank line between paragraphs";
+exports.description = "Between sections - as between sections - there should be only a single blank line.";
+
+exports.rule = function(report) {
+ var problemPs = [];
+
+ $5('p:has(> br)').each(function(i, p) {
+ var $p = $(p), prevP;
+ if ($.trim($p.text()).length === 0) {
+ prevP = $p.prevAll('p').filter(function(i, pp) {
+ return $.trim($(pp).text()).length > 0;
+ }).first();
+
+ if (prevP.length) {
+ problemPs.push(prevP.get(0));
+ }
+ else {
+ report.error('Paragraph contains line breaks but does not contain text.', p);
+ }
+ }
+ });
+
+ _.uniq(problemPs, false).forEach(function(p) {
+ var text = $.trim($(p).text());
+ report.error('Paragraph is followed by more than one blank line: '+ text, p);
+ });
+};
+
diff --git a/guidelines/wikipedia/wikipedia.json b/guidelines/wikipedia/wikipedia.json
index 87b20b1..67adf30 100644
--- a/guidelines/wikipedia/wikipedia.json
+++ b/guidelines/wikipedia/wikipedia.json
@@ -3,7 +3,13 @@
, "license": "BSD3"
, "rules":
[ "headingOrder.js"
+ , "bullets.js"
, "strikeout.js"
, "color.js"
+ , "spaceBetweenParagraphs.js"
+ , "paragraphLength.js"
+ , "imageSize.js"
+ , "horizontalRule.js"
+ , "pseudoHeadings.js"
]
-} \ No newline at end of file
+}