Skip to content

Instantly share code, notes, and snippets.

@tinomen
Created October 23, 2010 04:59
Show Gist options
  • Save tinomen/641811 to your computer and use it in GitHub Desktop.
Save tinomen/641811 to your computer and use it in GitHub Desktop.
choose javascript framework
#----------------------------------------------------------------------------
# Choose Javascript Framework
#----------------------------------------------------------------------------
run 'mkdir public/uploads && chmod 777 public/uploads'
run 'mkdir public/ui'
ask_js = ask("\r\n\r\nWhat javascript framework do you want to use?\r\n\r\n(1) Prototype\r\n(2) jQuery\r\n(3) MooTools\r\n(4) RightJS")
if ["1", "2", "3", "4"].include?(ask_db_type)
@prototype = (ask_db_type=="1")
@jquery = (ask_db_type=="2")
@mootools = (ask_db_type=="3")
@rightjs = (ask_db_type=="4")
else
puts "Woops! You must enter a number between 1 and 4"
ask_js
end
js_framework = [:all,"jquery","mootools","rightjs"][ask_db_type.to_i - 1]
if !@prototype
run 'rm public/javascripts/controls.js'
run 'rm public/javascripts/dragdrop.js'
run 'rm public/javascripts/effects.js'
run 'rm public/javascripts/prototype.js'
end
if @jquery
run "curl -L http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js > public/javascripts/jquery.js"
end
if @mootools
run "curl -L http://mootools.net/download/get/mootools-1.2.4-core-yc.js > public/javascripts/mootools.js"
end
if @rightjs
run "curl -L http://rightjs.org/builds/current/right-min.js > public/javascripts/right.js"
run "curl -L http://rightjs.org/builds/current/right-olds-min.js > public/javascripts/right-olds.js"
end
#----------------------------------------------------------------------------
# Generate Application Layout
# (Assumes you have Haml and Lovely Layouts installed)
#----------------------------------------------------------------------------
file 'app/views/layouts/application.html.haml', <<-CODE
!!!
%html
%head
= title_tag "optional default title here", :prefix => "optional prefix text", :suffix => "optional suffix text"
= description_tag "optional default meta description here"
= keywords_tag "optional default meta keywords here"
= copyright_tag "optional default meta copyright notice here"
= stylesheet_link_tag 'screen.css', :media => 'screen, projection'
= stylesheet_link_tag 'print.css', :media => 'print'
= stylesheet_link_tag 'ie.css', :media => 'screen, projection'
= javascript_include_tag #{js_framework}
- body do
#wrap
#header
#logo Logo
%ul#nav
%li= link_to "Home", root_url
#page
= yield
CODE
#----------------------------------------------------------------------------
# Create Default Static Pages
#----------------------------------------------------------------------------
route "map.root :controller => 'pages', :action => 'index'"
generate :controller, "pages index"
file 'app/views/pages/index.html.haml', <<-END
%h1 Home Page
%p
:textile
Edit me in *app/views/pages/index.html.haml*
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment