Skip to content

Commit

Permalink
Fractal Analysis Output
Browse files Browse the repository at this point in the history
* Added analysis.xsl to transform the fractal validation xml into html which is injected into the analysis iframe. This allowed for easier styling of the returned xml data.
* Added xslt query plugin to fetch and transform the xml
* Styled the output in a similar manner to the Fractal website
  • Loading branch information
rmontgomery429 committed Dec 11, 2011
1 parent c1027de commit a9e46c1
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 17 deletions.
1 change: 1 addition & 0 deletions mailcatcher.gemspec
Expand Up @@ -21,6 +21,7 @@ Gem::Specification.new do |s|
"public/images/**/*",
"public/javascripts/**/*.js",
"public/stylesheets/**/*.css",
"public/stylesheets/**/*.xsl",
"views/**/*"
]
s.require_paths = ["lib"]
Expand Down
10 changes: 2 additions & 8 deletions public/javascripts/application.coffee
Expand Up @@ -150,7 +150,6 @@ class MailCatcher
<h1>Analyse your email with Fractal</h1>
<p><a href="http://getfractal.com/" target="_blank">Fractal</a> is a really neat service that applies common email design and development knowledge from <a href="http://www.email-standards.org/" target="_blank">Email Standards Project</a> to your HTML email and tells you what you've done wrong or what you should do instead.</p>
<p>Please note that this <strong>sends your email to the Fractal service</strong> for analysis. Read their <a href="http://getfractal.com/terms" target="_blank">terms of service</a> if you're paranoid.</p>
<p>(This output is still just raw XML. Someone keen to transform this into something prettier would be greatly appreciated!)</p>
<form>
<input type="submit" value="Analyse" /><span class="loading" style="color: #999; display: none">Analysing&hellip;</span>
</form>
Expand All @@ -163,13 +162,8 @@ class MailCatcher
$(this)
.find('input[type="submit"]').attr('disabled', 'disabled').end()
.find('.loading').show()
$.ajax
url: "/messages/#{id}/analysis.xml",
dataType: "text"
success: (data) ->
$form.replaceWith('<h2>Results</h2><pre id="result"></pre>')
$iframe.find("#result").text data

$form.xslt("/messages/#{id}/analysis.xml", "/stylesheets/analysis.xsl")

refresh: ->
$.getJSON '/messages', (messages) =>
$.each messages, (i, message) =>
Expand Down
11 changes: 2 additions & 9 deletions public/javascripts/application.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions public/javascripts/xslt-3.2.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions public/stylesheets/analysis.xsl
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/xml">

<section class="fractal-analysis">
<xsl:for-each select="result/errors/error">
<xsl:variable name="errorCount" select="position()"/>
<p class="report-intro">
<strong><xsl:value-of select="$errorCount" />.</strong> The <span class="code"><xsl:value-of select="rule/rule_name" /></span> near <span class="code"><xsl:value-of select="snippet" /></span> on line <span class="code"><xsl:value-of select="error_line" /></span> of your code.
</p>
<dl class="unsupported-clients">
<dt>This is unsupported in:</dt>
<dd>
<ul>
<xsl:for-each select="rule/email_client//item">
<li>
<xsl:value-of select="." />
</li>
</xsl:for-each>
</ul>
</dd>
</dl>
</xsl:for-each>
</section>
</xsl:template>
</xsl:stylesheet>
17 changes: 17 additions & 0 deletions public/stylesheets/application.css
Expand Up @@ -335,6 +335,23 @@ body > header {
#message > header .views .action {
*display: inline; }

.fractal-analysis .report-intro {
background: #eef4f5;
margin-top: 1.5em;
padding: 1em; }
.fractal-analysis .report-intro strong {
font-weight: bold; }
.fractal-analysis .report-intro .code {
background-color: white;
font-family: comic Sans MS;
padding: 1px 5px; }
.fractal-analysis .unsupported-clients {
margin: 1em; }
.fractal-analysis .unsupported-clients dt {
padding-left: 1em; }
.fractal-analysis .unsupported-clients dd {
padding-left: 2em; }

iframe {
display: -moz-box;
display: -webkit-box;
Expand Down
18 changes: 18 additions & 0 deletions public/stylesheets/application.sass
Expand Up @@ -200,6 +200,24 @@ body > header
float: right
margin: 0 .25em

.fractal-analysis
.report-intro
background: #EEF4F5
margin-top: 1.5em
padding: 1em
strong
font-weight: bold
.code
background-color: white
font-family: comic Sans MS
padding: 1px 5px
.unsupported-clients
margin: 1em
dt
padding-left: 1em
dd
padding-left: 2em

iframe
+display-box
+box-flex(1)
Expand Down

0 comments on commit a9e46c1

Please sign in to comment.