Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
MirkoCindric committed Feb 26, 2010
1 parent 2489ade commit 16e2dcd
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "sentia-generators"
gem.summary = %Q{TODO: one-line summary of your gem}
gem.summary = "A collection of useful Rails generator scripts that we use on our projects"
gem.description = %Q{TODO: longer description of your gem}
gem.email = "michael.cindric@sentia.com.au"
gem.homepage = "http://github.com/Sentia/sentia-generators"
gem.authors = ["Michael Cindric"]
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
gem.add_development_dependency "haml", ">= 0"
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
end
Jeweler::GemcutterTasks.new
Expand Down
18 changes: 18 additions & 0 deletions rails_generators/sentia_layout/USEAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Description:
The sentia_layout generator creates a basic layout and stylesheet.

The generator takes one argument which will be the name of the
layout and stylesheet files. If no argument is passed then it defaults
to "application".

Examples:
script/generate sentia_layout

Layout: app/views/layouts/application.html.haml
Stylesheet: public/stylesheets/sass/application.css


script/generate nifty_layout admin

Layout: app/views/layouts/admin.html.haml
Stylesheet: public/stylesheets/sass/admin.sass
36 changes: 36 additions & 0 deletions rails_generators/sentia_layout/sentia_layout_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
class SentiaLayoutGenerator < Rails::Generator::Base
def initialize(runtime_args, runtime_options = {})
super
@name = @args.first || 'application'
end

def manifest
record do |m|
m.directory 'app/views/layouts'
m.directory 'public/stylesheets/sass'

m.template "layout.html.haml", "app/views/layouts/#{file_name}.html.haml"
m.file "stylesheet.sass", "public/stylesheets/sass/#{file_name}.sass"
end
end

def file_name
@name.underscore
end

protected

def add_options!(opt)
opt.separator ''
opt.separator 'Options:'
opt.on("--haml", "Generate HAML for view, and SASS for stylesheet.") { |v| options[:haml] = v }
end

def banner
<<-EOS
Creates generic layout and stylesheet files.
USAGE: #{$0} #{spec.name} [layout_name]
EOS
end
end
14 changes: 14 additions & 0 deletions rails_generators/sentia_layout/templates/layout.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
!!! Strict
%html{html_attrs}

%head
%title Untitled
%meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/
= stylesheet_link_tag '<%= file_name %>'
%body
#container
- flash.each do |name, msg|
= content_tag :div, msg, :id => "flash_#{name}"

= yield
67 changes: 67 additions & 0 deletions rails_generators/sentia_layout/templates/stylesheet.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
!primary_color = #4B7399

body
:background-color = !primary_color
:font
:family Verdana, Helvetica, Arial
:size 14px

a
:color #0000FF
img
:border none

.clear
:clear both
:height 0
:overflow hidden

#container
:width 75%
:margin 0 auto
:background #fff
:padding 20px 40px
:border solid 1px black
:margin-top 20px

#flash_notice,
#flash_error
:padding 5px 8px
:margin 10px 0

#flash_notice
:background-color #CFC
:border solid 1px #6C6

#flash_error
:background-color #FCC
:border solid 1px #C66

.fieldWithErrors
:display inline

#errorExplanation
:width 400px
:border 2px solid #CF0000
:padding 0
:padding-bottom 12px
:margin-bottom 20px
:background-color #f0f0f0
h2
:text-align left
:padding 5px 5px 5px 15px
:margin 0
:font
:weight bold
:size 12px
:background-color #c00
:color #fff
p
:color #333
:margin-bottom 0
:padding 8px
ul
:margin 2px 24px
li
:font-size 12px
:list-style disc
9 changes: 9 additions & 0 deletions script/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env ruby
# File: script/console
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'

libs = " -r irb/completion"
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
puts "Loading nifty-generators gem"
exec "#{irb} #{libs} --simple-prompt"
14 changes: 14 additions & 0 deletions script/destroy
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env ruby
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))

begin
require 'rubigen'
rescue LoadError
require 'rubygems'
require 'rubigen'
end
require 'rubigen/scripts/destroy'

ARGV.shift if ['--help', '-h'].include?(ARGV[0])
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
RubiGen::Scripts::Destroy.new.run(ARGV)
14 changes: 14 additions & 0 deletions script/generate
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env ruby
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))

begin
require 'rubigen'
rescue LoadError
require 'rubygems'
require 'rubigen'
end
require 'rubigen/scripts/generate'

ARGV.shift if ['--help', '-h'].include?(ARGV[0])
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
RubiGen::Scripts::Generate.new.run(ARGV)

0 comments on commit 16e2dcd

Please sign in to comment.