From 465de586078eb40e6d0ae820d9da8a254c181021 Mon Sep 17 00:00:00 2001
From: Saku Ytti <saku@ytti.fi>
Date: Sat, 1 Mar 2014 19:27:44 +0200
Subject: Switch from CSS to SASS

I probably should figure out how to start rack in the code, so I'd get
caching of the SASS (and in future Coffee) files, instead of Sinatra
generating them always on the fly
---
 Gemfile.lock                                 |  4 ++-
 TODO.md                                      |  3 --
 lib/oxidized/api/web/public/css/oxidized.css | 43 -----------------------
 lib/oxidized/api/web/views/head.haml         |  2 +-
 lib/oxidized/api/web/views/oxidized.sass     | 51 ++++++++++++++++++++++++++++
 lib/oxidized/api/web/webapp.rb               | 11 +++---
 oxidized.gemspec                             |  9 ++---
 7 files changed, 66 insertions(+), 57 deletions(-)
 delete mode 100644 lib/oxidized/api/web/public/css/oxidized.css
 create mode 100644 lib/oxidized/api/web/views/oxidized.sass

diff --git a/Gemfile.lock b/Gemfile.lock
index e40712b..3003aa8 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,11 +1,12 @@
 PATH
   remote: .
   specs:
-    oxidized (0.0.30)
+    oxidized (0.0.33)
       grit
       haml
       net-ssh
       puma
+      sass
       sequel
       sinatra
       sinatra-contrib
@@ -33,6 +34,7 @@ GEM
       rack
     rack-test (0.6.2)
       rack (>= 1.0)
+    sass (3.2.14)
     sequel (4.7.0)
     sinatra (1.4.4)
       rack (~> 1.4)
diff --git a/TODO.md b/TODO.md
index 5913e84..74ac8c0 100644
--- a/TODO.md
+++ b/TODO.md
@@ -8,9 +8,6 @@
 # config
   * save keys as strings, load as symbols?
 
-# REST API
-  * figure out if is somehow possible to run rack/puma/sinatra stack with oxidized select()
-
 # other 
 should it offer cli mass config-pusher? (I think not, I have ideas for such
 program and I'm not sure if synergies are high enough for shared code without
diff --git a/lib/oxidized/api/web/public/css/oxidized.css b/lib/oxidized/api/web/public/css/oxidized.css
deleted file mode 100644
index 9df98c6..0000000
--- a/lib/oxidized/api/web/public/css/oxidized.css
+++ /dev/null
@@ -1,43 +0,0 @@
-body {
-  background: #fdf6e3;
-  color: #002b36;
-}
-
-a:link {
-  color: #dc322f;
-  text-decoration: none;
-}
-
-a:visited {
-}
-
-a:hover {
-  color: #d33682;
-  text-decoration: underline;
-}
-
-a:active {
-}
-
-.center {
-  margin-left: auto;
-  margin-right: auto;
-  text-align: center;
-}
-
-th {
-  color: #2aa198;
-}
-
-tr.odd {
-  background: #eee8d5;
-}
-
-tr.even {
-  background: #fdf6e3;
-}
-
-tr:hover {
-  background: #586e75;
-  color: #fdf6e3;
-}
diff --git a/lib/oxidized/api/web/views/head.haml b/lib/oxidized/api/web/views/head.haml
index 1619512..55fdb7c 100644
--- a/lib/oxidized/api/web/views/head.haml
+++ b/lib/oxidized/api/web/views/head.haml
@@ -1,3 +1,3 @@
 %head
   %title oxidized
-  %link{:rel=>'stylesheet', :href=>'/css/oxidized.css'}
+  %link{:rel=>'stylesheet', :href=>'/stylesheets/oxidized.css'}
diff --git a/lib/oxidized/api/web/views/oxidized.sass b/lib/oxidized/api/web/views/oxidized.sass
new file mode 100644
index 0000000..39d090f
--- /dev/null
+++ b/lib/oxidized/api/web/views/oxidized.sass
@@ -0,0 +1,51 @@
+$font-stack: Helvetica, sans-serif
+$base03:     #002b36
+$base02:     #073642
+$base01:     #586e75
+$base00:     #657b83
+$base0:      #839496
+$base1:      #93a1a1
+$base2:      #eee8d5
+$base3:      #fdf6e3
+$yellow:     #b58900
+$orange:     #cb4b16
+$red:        #dc322f
+$magenta:    #d33682
+$violet:     #6c71c4
+$blue:       #268bd2
+$cyan:       #2aa198
+$green:      #859900
+
+body
+  font: 100% $font-stack
+  color: $base03
+  background: $base3
+
+a:link
+  color: $red
+  text-decoration: none
+
+// a:visited
+// a:active
+
+a:hover
+  color: $magenta
+  text-decoration: underline
+
+.center
+  margin-left: auto
+  margin-right: auto
+  text-align: center
+
+th
+  color: $cyan
+
+tr.odd
+  background: $base2
+
+tr.even
+  background: $base3
+
+tr:hover
+  background: $base01
+  color: $base3
diff --git a/lib/oxidized/api/web/webapp.rb b/lib/oxidized/api/web/webapp.rb
index 4cec200..3d66ba8 100644
--- a/lib/oxidized/api/web/webapp.rb
+++ b/lib/oxidized/api/web/webapp.rb
@@ -1,7 +1,7 @@
 require 'sinatra/base'
 require 'sinatra/json'
 require 'haml'
-require 'pp'
+require 'sass'
 module Oxidized
   module API
     class WebApp < Sinatra::Base
@@ -68,10 +68,11 @@ module Oxidized
         out :node
       end
 
-      #get '/node/:node' do
-      #  @data = nodes.show params[:node]
-      #  out
-      #end
+      get '/stylesheets/*.css' do
+        sass params[:splat].first.to_sym
+      end
+
+      private
 
       def out template=:default
         if @json or params[:format] == 'json'
diff --git a/oxidized.gemspec b/oxidized.gemspec
index db9c761..9e2e8cf 100644
--- a/oxidized.gemspec
+++ b/oxidized.gemspec
@@ -1,6 +1,6 @@
 Gem::Specification.new do |s|
   s.name              = 'oxidized'
-  s.version           = '0.0.31'
+  s.version           = '0.0.33'
   s.platform          = Gem::Platform::RUBY
   s.authors           = [ 'Saku Ytti' ]
   s.email             = %w( saku@ytti.fi )
@@ -12,13 +12,14 @@ Gem::Specification.new do |s|
   s.executables       = %w( oxidized )
   s.require_path      = 'lib'
 
-  s.add_dependency 'sequel'
-  s.add_dependency 'sqlite3'
   s.add_dependency 'net-ssh'
+  s.add_dependency 'sqlite3'
   s.add_dependency 'grit'
+  s.add_dependency 'sequel'
   s.add_dependency 'sinatra'
   s.add_dependency 'sinatra-contrib'
-  s.add_dependency 'haml'
   s.add_dependency 'puma'
+  s.add_dependency 'haml'
+  s.add_dependency 'sass'
 
 end
-- 
cgit v1.2.3