From 5a399a106cbc274792ea4e0ac20c181446e23bb2 Mon Sep 17 00:00:00 2001 From: Guillaume Dott Date: Fri, 5 Dec 2014 17:27:23 +0100 Subject: [PATCH] Add Slim layout for views --- Gemfile | 2 ++ Gemfile.lock | 12 ++++++++++++ nikoli.rb | 2 ++ views/index.slim | 6 +----- views/layout.slim | 10 ++++++++++ views/nurikabe.slim | 28 +++++++++++----------------- 6 files changed, 38 insertions(+), 22 deletions(-) create mode 100644 views/layout.slim diff --git a/Gemfile b/Gemfile index db6a62d..b9ebccf 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,8 @@ source 'https://rubygems.org' gem 'sinatra', '~> 1.4' +gem 'sinatra-contrib' + gem 'slim' gem 'coffee-script' gem 'therubyracer' diff --git a/Gemfile.lock b/Gemfile.lock index ce22866..a73d76e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,21 +1,32 @@ GEM remote: https://rubygems.org/ specs: + backports (3.6.4) coffee-script (2.3.0) coffee-script-source execjs coffee-script-source (1.8.0) execjs (2.2.2) libv8 (3.16.14.7) + multi_json (1.10.1) rack (1.5.2) rack-protection (1.5.3) rack + rack-test (0.6.2) + rack (>= 1.0) ref (1.0.5) sass (3.2.19) sinatra (1.4.5) rack (~> 1.4) rack-protection (~> 1.4) tilt (~> 1.3, >= 1.3.4) + sinatra-contrib (1.4.2) + backports (>= 2.0) + multi_json + rack-protection + rack-test + sinatra (~> 1.4.0) + tilt (~> 1.3) slim (2.1.0) temple (~> 0.6.9) tilt (>= 1.3.3, < 2.1) @@ -32,5 +43,6 @@ DEPENDENCIES coffee-script sass sinatra (~> 1.4) + sinatra-contrib slim therubyracer diff --git a/nikoli.rb b/nikoli.rb index 56eea4b..21ba16a 100755 --- a/nikoli.rb +++ b/nikoli.rb @@ -1,6 +1,8 @@ #!/usr/bin/env ruby require 'sinatra' +require 'sinatra/content_for' + require 'coffee-script' require 'slim' require 'sass' diff --git a/views/index.slim b/views/index.slim index 081f8f0..67dee2a 100644 --- a/views/index.slim +++ b/views/index.slim @@ -1,5 +1 @@ -doctype html -html - head - body - h1 Hello world! +h1 Hello world! diff --git a/views/layout.slim b/views/layout.slim new file mode 100644 index 0000000..44a7989 --- /dev/null +++ b/views/layout.slim @@ -0,0 +1,10 @@ +doctype html +html + head + title = yield_content :title + meta charset="utf-8" + meta name="viewport" content="initial-scale=1.0, user-scalable=yes" + link rel="stylesheet" media="all" href="/application.css" + body + == yield + diff --git a/views/nurikabe.slim b/views/nurikabe.slim index 91951ba..f2d8c8f 100644 --- a/views/nurikabe.slim +++ b/views/nurikabe.slim @@ -1,19 +1,13 @@ -doctype html -html - head - title Nurikabe - meta charset="utf-8" - meta name="viewport" content="initial-scale=1.0, user-scalable=yes" - link rel="stylesheet" media="all" href="/application.css" - script type="text/javascript" src="/nurikabe.js" - body - h1 Nurikabe - #board +- content_for(:title) { 'Nurikabe' } - javascript: - document.addEventListener("DOMContentLoaded", function() { - var game = JSON.parse("[[4,-1,-1,0,2],[0,-1,2,-1,-1],[0,-1,0,-1,3],[0,-1,-1,-1,0],[-1,-1,1,-1,0]]"); +h1 Nurikabe +#board - nurikabe = new Nurikabe(document.getElementById('board')); - nurikabe.generate(game); - }); +script type="text/javascript" src="/nurikabe.js" +javascript: + document.addEventListener("DOMContentLoaded", function() { + var game = JSON.parse("[[4,-1,-1,0,2],[0,-1,2,-1,-1],[0,-1,0,-1,3],[0,-1,-1,-1,0],[-1,-1,1,-1,0]]"); + + nurikabe = new Nurikabe(document.getElementById('board')); + nurikabe.generate(game); + });