Add some more fancy syntax highlighting

This commit is contained in:
R. Tyler Croy 2011-11-15 22:49:52 -08:00
parent 49786246fd
commit 8d4966dc6c
5 changed files with 70 additions and 2 deletions

View File

@ -1,6 +1,8 @@
tag_page_layout: tag_page tag_page_layout: tag_page
tag_page_dir: tag tag_page_dir: tag
paginate: 10 paginate: 10
pygments: true
markdown: rdiscount
lsi: false lsi: false
url: http://unethicalblogger.com url: http://unethicalblogger.com
exclude: ['README.markdown', 'drupal.rb', 'sync.sh', 'Makefile'] exclude: ['README.markdown', 'drupal.rb', 'sync.sh', 'Makefile']

View File

@ -22,6 +22,7 @@
http://edward.oconnor.cx the typography just looks too good to not use :D --> http://edward.oconnor.cx the typography just looks too good to not use :D -->
<link rel="stylesheet" href="/stylesheets/typography.css" type="text/css" /> <link rel="stylesheet" href="/stylesheets/typography.css" type="text/css" />
<link rel="stylesheet" href="/stylesheets/color-dark-on-light.css" type="text/css" /> <link rel="stylesheet" href="/stylesheets/color-dark-on-light.css" type="text/css" />
<link rel="stylesheet" href="/stylesheets/monokai.css" type="text/css" />
{% for css in page.css %} {% for css in page.css %}

View File

@ -26,9 +26,11 @@ magic ActiveRecord developers seem to love, this post is more about the latter.
In general, JOINs involve two tables, JOINing together the tables typically for In general, JOINs involve two tables, JOINing together the tables typically for
a nested query of some form or fashion. For an example, let's use this make believe query: a nested query of some form or fashion. For an example, let's use this make believe query:
{% highlight sql %}
SELECT `guests`.* FROM `guests` JOIN `plates` \ SELECT `guests`.* FROM `guests` JOIN `plates` \
ON plates.guest_id = guests.id WHERE \ ON plates.guest_id = guests.id WHERE \
(guests.favorite = 'sushi' OR plates.content = 'sushi'); (guests.favorite = 'sushi' OR plates.content = 'sushi');
{% endhighlight %}
There are five basic JOINs in SQL land, and in this context they mean: There are five basic JOINs in SQL land, and in this context they mean:
@ -46,6 +48,7 @@ which in Rails 3 has been deprecated in favor of just
[scope](http://apidock.com/rails/ActiveRecord/NamedScope/ClassMethods/scope), [scope](http://apidock.com/rails/ActiveRecord/NamedScope/ClassMethods/scope),
I'd write code something like this: I'd write code something like this:
{% highlight ruby %}
class Guest < ActiveRecord::Base class Guest < ActiveRecord::Base
has_one :plate has_one :plate
# ... # ...
@ -54,6 +57,7 @@ I'd write code something like this:
:joins => :plate :joins => :plate
}} }}
end end
{% endhighlight %}
Underneath the hood, ActiveRecord generates a query *almost* exactly like the Underneath the hood, ActiveRecord generates a query *almost* exactly like the
one above with one subtle difference. "`JOIN`" is instead an "`INNER JOIN`" one above with one subtle difference. "`JOIN`" is instead an "`INNER JOIN`"
@ -65,6 +69,7 @@ The "solution" is to use a `LEFT JOIN`, which is unfortunately rather gnarly.
There may be a better way to perform alternate JOINs in ActiveRecord, but I There may be a better way to perform alternate JOINs in ActiveRecord, but I
don't yet of one: don't yet of one:
{% highlight ruby %}
class Guest < ActiveRecord::Base class Guest < ActiveRecord::Base
has_one :plate has_one :plate
# ... # ...
@ -73,6 +78,7 @@ don't yet of one:
:joins => "LEFT JOIN `plates` ON plates.guest_id = guests.id" :joins => "LEFT JOIN `plates` ON plates.guest_id = guests.id"
}} }}
end end
{% endhighlight %}
Basically if you want to use anything other than a simple `INNER JOIN`, you've Basically if you want to use anything other than a simple `INNER JOIN`, you've
got to enter it in yourself. At a certain point ActiveRecord throws up its got to enter it in yourself. At a certain point ActiveRecord throws up its

View File

@ -99,9 +99,9 @@ h3 {
} }
.highlight pre { .highlight pre {
background: #eee; /* background: #eee; conflicts with the monokai theme */
border: 1px solid #ccc; border: 1px solid #ccc;
padding: 15px; padding: 5px;
} }
.update { .update {

59
stylesheets/monokai.css Normal file
View File

@ -0,0 +1,59 @@
.hll { background-color: #49483e }
.c { color: #75715e } /* Comment */
.err { color: #960050; background-color: #1e0010 } /* Error */
.k { color: #66d9ef } /* Keyword */
.l { color: #ae81ff } /* Literal */
.n { color: #f8f8f2 } /* Name */
.o { color: #f92672 } /* Operator */
.p { color: #f8f8f2 } /* Punctuation */
.cm { color: #75715e } /* Comment.Multiline */
.cp { color: #75715e } /* Comment.Preproc */
.c1 { color: #75715e } /* Comment.Single */
.cs { color: #75715e } /* Comment.Special */
.ge { font-style: italic } /* Generic.Emph */
.gs { font-weight: bold } /* Generic.Strong */
.kc { color: #66d9ef } /* Keyword.Constant */
.kd { color: #66d9ef } /* Keyword.Declaration */
.kn { color: #f92672 } /* Keyword.Namespace */
.kp { color: #66d9ef } /* Keyword.Pseudo */
.kr { color: #66d9ef } /* Keyword.Reserved */
.kt { color: #66d9ef } /* Keyword.Type */
.ld { color: #e6db74 } /* Literal.Date */
.m { color: #ae81ff } /* Literal.Number */
.s { color: #e6db74 } /* Literal.String */
.na { color: #a6e22e } /* Name.Attribute */
.nb { color: #f8f8f2 } /* Name.Builtin */
.nc { color: #a6e22e } /* Name.Class */
.no { color: #66d9ef } /* Name.Constant */
.nd { color: #a6e22e } /* Name.Decorator */
.ni { color: #f8f8f2 } /* Name.Entity */
.ne { color: #a6e22e } /* Name.Exception */
.nf { color: #a6e22e } /* Name.Function */
.nl { color: #f8f8f2 } /* Name.Label */
.nn { color: #f8f8f2 } /* Name.Namespace */
.nx { color: #a6e22e } /* Name.Other */
.py { color: #f8f8f2 } /* Name.Property */
.nt { color: #f92672 } /* Name.Tag */
.nv { color: #f8f8f2 } /* Name.Variable */
.ow { color: #f92672 } /* Operator.Word */
.w { color: #f8f8f2 } /* Text.Whitespace */
.mf { color: #ae81ff } /* Literal.Number.Float */
.mh { color: #ae81ff } /* Literal.Number.Hex */
.mi { color: #ae81ff } /* Literal.Number.Integer */
.mo { color: #ae81ff } /* Literal.Number.Oct */
.sb { color: #e6db74 } /* Literal.String.Backtick */
.sc { color: #e6db74 } /* Literal.String.Char */
.sd { color: #e6db74 } /* Literal.String.Doc */
.s2 { color: #e6db74 } /* Literal.String.Double */
.se { color: #ae81ff } /* Literal.String.Escape */
.sh { color: #e6db74 } /* Literal.String.Heredoc */
.si { color: #e6db74 } /* Literal.String.Interpol */
.sx { color: #e6db74 } /* Literal.String.Other */
.sr { color: #e6db74 } /* Literal.String.Regex */
.s1 { color: #e6db74 } /* Literal.String.Single */
.ss { color: #e6db74 } /* Literal.String.Symbol */
.bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
.vc { color: #f8f8f2 } /* Name.Variable.Class */
.vg { color: #f8f8f2 } /* Name.Variable.Global */
.vi { color: #f8f8f2 } /* Name.Variable.Instance */
.il { color: #ae81ff } /* Literal.Number.Integer.Long */