Skip to content

Commit

Permalink
Various improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakhellesoy committed May 10, 2010
1 parent 99b12dd commit ffe8dd8
Show file tree
Hide file tree
Showing 16 changed files with 1,221 additions and 960 deletions.
2 changes: 2 additions & 0 deletions README.textile
Expand Up @@ -23,6 +23,8 @@ h2. TODO
* Only show programming language icons for certain pages. Use Textile header to turn on/off?

* Layout inspiration
** http://diveintohtml5.org/extensibility.html (big letters)
** http://opentochoice.org/en/
** http://ninject.org
** http://matthewjamestaylor.com/blog/perfect-2-column-right-menu.htm
* The tags page should have a section (sidebar?) for known special tags like @allow-rescue, @javascript etc. with links to where to learn more.
13 changes: 4 additions & 9 deletions Rakefile
Expand Up @@ -2,10 +2,9 @@ class I18nExamplesGenerator
attr_reader :languages

def initialize
require 'gherkin'
require 'cucumber'
@i18ndir = File.expand_path(File.join(Cucumber::LIBDIR, '../examples/i18n'))

@languages = Cucumber::LANGUAGES.keys.sort
end

def generate
Expand All @@ -15,19 +14,15 @@ class I18nExamplesGenerator
io.write(template.result(binding))
end
end
def keyword(lang, key)
Cucumber::LANGUAGES[lang][key]

def keyword_spans(i18n, key)
%Q{<span class="keyword">} + i18n.keywords(key).join(%Q{</span>&nbsp;<span class="keyword">}) + %Q{</span>}
end

def example(lang)
Dir["#{@i18ndir}/#{lang}/features/*feature"][0]
end

def lang_name(lang)
keyword(lang, 'native') == keyword(lang, 'name') ? keyword(lang, 'native') : "#{keyword(lang, 'native')} (#{keyword(lang, 'name')})"
end

def pygmentize(lang)
pygmentize = "pygmentize -f html -O encoding=utf-8 #{example(lang)}"
puts pygmentize
Expand Down
32 changes: 16 additions & 16 deletions _includes/i18n_examples.erb
@@ -1,37 +1,37 @@
<div id="i18n" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
<% languages.each do |lang| %>
<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#<%= lang %>"><%= lang %></a></li>
<% Gherkin::I18n.all.each do |i18n| %>
<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#<%= i18n.iso_code %>"><%= i18n.iso_code %></a></li>
<% end %>
</ul>

<% languages.each do |lang| %>
<div id="<%= lang %>">
<h2><%= lang_name(lang) %></h2>
<% Gherkin::I18n.all.each do |i18n| %>
<div id="<%= i18n.iso_code %>">
<h2><%= i18n.keywords(:native)[0] %></h2>
<dl class="keywords">
<dt>Feature</dt>
<dd><%= keyword(lang, 'feature') %></dd>
<dd><%= keyword_spans(i18n, :feature) %></dd>
<dt>Scenario</dt>
<dd><%= keyword(lang, 'scenario') %></dd>
<dd><%= keyword_spans(i18n, :scenario) %></dd>
<dt>Given</dt>
<dd><%= keyword(lang, 'given') %></dd>
<dd><%= keyword_spans(i18n, :given) %></dd>
<dt>When</dt>
<dd><%= keyword(lang, 'when') %></dd>
<dd><%= keyword_spans(i18n, :when) %></dd>
<dt>Then</dt>
<dd><%= keyword(lang, 'then') %></dd>
<dd><%= keyword_spans(i18n, :then) %></dd>
<dt>And</dt>
<dd><%= keyword(lang, 'and') %></dd>
<dd><%= keyword_spans(i18n, :and) %></dd>
<dt>But</dt>
<dd><%= keyword(lang, 'but') %></dd>
<dd><%= keyword_spans(i18n, :but) %></dd>
<dt>Scenario Outline</dt>
<dd><%= keyword(lang, 'scenario_outline') %></dd>
<dd><%= keyword_spans(i18n, :scenario_outline) %></dd>
<dt>Background</dt>
<dd><%= keyword(lang, 'background') %></dd>
<dd><%= keyword_spans(i18n, :background) %></dd>
<dt>Examples</dt>
<dd><%= keyword(lang, 'examples') %></dd>
<dd><%= keyword_spans(i18n, :examples) %></dd>
</dl>

<% if example(lang) %><%= pygmentize(lang) %><% else %>No example. Maybe you want to contribute one?<% end %>
<% if example(i18n.iso_code) %><%= pygmentize(i18n.iso_code) %><% else %>No example. Maybe you want to contribute one?<% end %>
</div>
<% end %>
</div>
1,988 changes: 1,054 additions & 934 deletions _includes/i18n_examples.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _layouts/default.html
Expand Up @@ -11,7 +11,7 @@
<link type="text/css" href="http://jquery-ui.googlecode.com/svn/tags/1.7.2/themes/base/ui.all.css" rel="stylesheet" />

<!-- syntax highlighting CSS -->
<link rel="stylesheet" href="/css/syntax.css" type="text/css" />
<link rel="stylesheet" href="/css/gherkin-black-pygments.css" type="text/css" />

<!-- Homepage CSS -->
<link rel="stylesheet" href="/css/screen.css" type="text/css" media="screen, projection" />
Expand Down
14 changes: 14 additions & 0 deletions css/gherkin-black-pygments.css
@@ -0,0 +1,14 @@
/*
Gherkin on Black stylesheet for Pygments
Based on colours from http://colorschemedesigner.com/#2P32mw0w0w0w0
(C) Aslak Hellesøy
*/

.highlight { background: #000000; }
.highlight .c { color: #9F3ED5; } /* Comment (# Comments) (dark violet) */
.highlight .nt { color: #AD66D5; } /* Name.Tag (Tags) (bright violet) */
.highlight .k { color: #269926; } /* Keyword (Feature, Scenario, Given, | etc) (light green) */
.highlight .nf { color: #67E667; } /* Name.Function (Names) (dark green) */
.highlight .s { color: #FFD073; } /* Literal.String (String, PyString and numeric values) (light orange) */
.highlight .nv { color: #FFAA00; } /* Name.Variable (Scenario Outline variables) (orange) */
14 changes: 14 additions & 0 deletions css/gherkin-white-pygments.css
@@ -0,0 +1,14 @@
/*
Gherkin on White stylesheet for Pygments
Based on colours from http://colorschemedesigner.com/#2P32mw0w0w0w0
(C) Aslak Hellesøy
*/

.highlight { background: #FFFFFF; }
.highlight .c { color: #9F3ED5; } /* Comment (# Comments) (dark violet) */
.highlight .nt { color: #7109AA; font-weight: bold; } /* Name.Tag (Tags) (bright violet) */
.highlight .k { color: #005D00; font-weight: bold; } /* Keyword (Feature, Scenario, Given, | etc) (light green) */
.highlight .nf { color: #317D31; } /* Name.Function (Names) (dark green) */
.highlight .s { color: #FFAA00; font-weight: bold; } /* Literal.String (String, PyString and numeric values) (light orange) */
.highlight .nv { color: #744D00; font-weight: bold; } /* Name.Variable (Scenario Outline variables) (orange) */
4 changes: 4 additions & 0 deletions css/screen.css
Expand Up @@ -26,4 +26,8 @@ dl.keywords dt {

#language img {
cursor: pointer;
}

span.keyword {
background-color: green;
}
16 changes: 16 additions & 0 deletions editors.textile
@@ -0,0 +1,16 @@
---
layout: default
title: Editors and IDEs
---
h1. Editors and IDEs

All of the most popular text editors and IDEs have Cucumber support. Click on the screenshot
to go to the project page for a specific one.

|Editor/IDE|Screenshot|Run features|Code completion/Intellisense|Highlight variables|
||!images/editors/textmate.png!|Yes|Yes|No|
||!images/editors/rubymine.png!|Yes|Yes|No|
||!images/editors/netbeans.png!|Yes|Yes|No|
||!images/editors/vim.png!|Yes|Yes|No|
||!images/editors/emacs.png!|Yes|Yes|No|
||!images/editors/visual_studio.png!|Yes|Yes|No|
Binary file added favicon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/architecture/cucumber_gherkin.graffle
Binary file not shown.
Binary file added images/architecture/gherkin.graffle
Binary file not shown.
Binary file added images/editors/netbeans.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/editors/rubymine.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/editors/textmate.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
96 changes: 96 additions & 0 deletions js/jquery.cookie.js
@@ -0,0 +1,96 @@
/**
* Cookie plugin
*
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/

/**
* Create a cookie with the given name and value and other optional parameters.
*
* @example $.cookie('the_cookie', 'the_value');
* @desc Set the value of a cookie.
* @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
* @desc Create a cookie with all available options.
* @example $.cookie('the_cookie', 'the_value');
* @desc Create a session cookie.
* @example $.cookie('the_cookie', null);
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
* used when the cookie was set.
*
* @param String name The name of the cookie.
* @param String value The value of the cookie.
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
* If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
* If set to null or omitted, the cookie will be a session cookie and will not be retained
* when the the browser exits.
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
* require a secure protocol (like HTTPS).
* @type undefined
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/

/**
* Get the value of a cookie with the given name.
*
* @example $.cookie('the_cookie');
* @desc Get the value of a cookie.
*
* @param String name The name of the cookie.
* @return The value of the cookie.
* @type String
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
jQuery.cookie = function(name, value, options) {
if (typeof value != 'undefined') { // name and value given, set cookie
options = options || {};
if (value === null) {
value = '';
options.expires = -1;
}
var expires = '';
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
var date;
if (typeof options.expires == 'number') {
date = new Date();
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
}
// CAUTION: Needed to parenthesize options.path and options.domain
// in the following expressions, otherwise they evaluate to undefined
// in the packed version for some reason...
var path = options.path ? '; path=' + (options.path) : '';
var domain = options.domain ? '; domain=' + (options.domain) : '';
var secure = options.secure ? '; secure' : '';
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
} else { // only name given, get cookie
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
};

0 comments on commit ffe8dd8

Please sign in to comment.