playmo 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +4 -0
  3. data/README.md +55 -0
  4. data/Rakefile +2 -0
  5. data/TODO.md +16 -0
  6. data/lib/app/helpers/playmo_helper.rb +54 -0
  7. data/lib/generators/playmo/USAGE +8 -0
  8. data/lib/generators/playmo/install_generator.rb +166 -0
  9. data/lib/generators/playmo/templates/application.html.erb +56 -0
  10. data/lib/generators/playmo/templates/application_controller.rb +9 -0
  11. data/lib/generators/playmo/templates/application_helper.rb +21 -0
  12. data/lib/generators/playmo/templates/assets.yml +32 -0
  13. data/lib/generators/playmo/templates/deploy.rb +50 -0
  14. data/lib/generators/playmo/templates/jquery/jquery-1.5.2.min.js +16 -0
  15. data/lib/generators/playmo/templates/jquery/rails.js +157 -0
  16. data/lib/generators/playmo/templates/mootools/mootools-core-1.3.1.js +485 -0
  17. data/lib/generators/playmo/templates/mootools/mootools-more-1.3.1.1.js +741 -0
  18. data/lib/generators/playmo/templates/mootools/rails.js +161 -0
  19. data/lib/generators/playmo/templates/tasks/assets.rake +10 -0
  20. data/lib/generators/playmo/templates/tasks/sass.rake +8 -0
  21. data/lib/playmo.rb +12 -0
  22. data/playmo.gemspec +22 -0
  23. data/stylesheets/_playmo_rails.sass +13 -0
  24. data/stylesheets/playmo-rails/_fonts.scss +46 -0
  25. data/stylesheets/playmo-rails/_handheld.scss +8 -0
  26. data/stylesheets/playmo-rails/_helpers.scss +57 -0
  27. data/stylesheets/playmo-rails/_media.scss +60 -0
  28. data/stylesheets/playmo-rails/_reset.scss +56 -0
  29. data/stylesheets/playmo-rails/_styles.scss +125 -0
  30. data/templates/project/boilerplate/css/handheld.scss +7 -0
  31. data/templates/project/boilerplate/css/style.scss +141 -0
  32. data/templates/project/boilerplate/files/apple-touch-icon.png +0 -0
  33. data/templates/project/boilerplate/files/crossdomain.xml +25 -0
  34. data/templates/project/boilerplate/files/favicon.ico +0 -0
  35. data/templates/project/boilerplate/files/robots.txt +5 -0
  36. data/templates/project/boilerplate/js/libs/dd_belatedpng.js +13 -0
  37. data/templates/project/boilerplate/js/libs/modernizr-1.7.min.js +2 -0
  38. data/templates/project/google/google.yml +22 -0
  39. data/templates/project/manifest.rb +34 -0
  40. data/templates/project/playmo/article.scss +69 -0
  41. data/templates/project/playmo/icons/outgoing.png +0 -0
  42. data/templates/project/playmo/playmo.scss +90 -0
  43. data/templates/project/rails/public/stylesheets/layout.scss +20 -0
  44. data/templates/project/rails/public/stylesheets/print.scss +11 -0
  45. data/templates/project/rails/public/stylesheets/screen.scss +14 -0
  46. data/templates/project/rails/public/stylesheets/wysiwyg.scss +19 -0
  47. metadata +112 -0
@@ -0,0 +1,4 @@
1
+ nbproject/
2
+ .rvmrc
3
+ .idea/
4
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in playmo.gemspec
4
+ gemspec
@@ -0,0 +1,55 @@
1
+ # Playmo
2
+ This is the special kit that allows you create html5-ready Rails 3 apps quick with pre-included few useful libs in your app.
3
+ It includes:
4
+
5
+ * [Compass](http://compass-style.org/)
6
+ * [Jammit](https://github.com/documentcloud/jammit) - industrial strength asset packaging for Rails
7
+ * [HTML5 Boilerplate](http://html5boilerplate.com/)
8
+ * [Mootools](http://mootools.net)
9
+ * [Jquery](http://jquery.com)
10
+ * [Devise](https://github.com/plataformatec/devise) - flexible authentication solution for Rails
11
+ * [Cancan](https://github.com/ryanb/cancan) - authorization gem for Rails
12
+ * [Capistrano](https://github.com/capistrano/capistrano) - remote multi-server automation tool
13
+ * Set of useful rails helpers
14
+
15
+ *Don't forget that playmo supports only Rails 3 apps*
16
+
17
+ ## How to install
18
+ First, create new Rails 3 application
19
+
20
+ $ rails new appname
21
+ $ cd ./appname
22
+
23
+ Then add to your Gemfile these lines
24
+
25
+ group :development do
26
+ gem 'playmo', :git => 'git://github.com/tanraya/playmo.git'
27
+ end
28
+
29
+ After that, run bundle to install necessary gems
30
+
31
+ $ bundle
32
+
33
+ After installing the files we need to generate playmo files in our application
34
+
35
+ $ rails g playmo:install
36
+
37
+ That's all. Now you can run your app:
38
+
39
+ $ rails s
40
+
41
+ ***
42
+
43
+ ## What it does (details)
44
+
45
+ * Installs JQuery or Mootools depending on your preference
46
+ * Replaces default layout with HTML5-Boilerplate
47
+ * Generates HomeController with index action and view
48
+ * Generates a set of useful helpers in ApplicationHelper
49
+ * Removes default rails javascripts
50
+ * Replaces prototype-ujs with jquery-ujs or mootools-ujs
51
+ * Installs devise, cancan and compass (and their dependencies)
52
+ * Adds _User.current_ class method as alias for devise _current_user_ helper, thus you access to current user object from other models.
53
+
54
+ ## Limitations
55
+ Install the gem *only* into new empty app. Installation into ready apps is *only on your risk* because you may accidentally damage the files in your app.
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/TODO.md ADDED
@@ -0,0 +1,16 @@
1
+ # TODO
2
+ - Integrates with jammit
3
+ * Add content for sidebar
4
+ * Add footer content
5
+ * Modify default layout styles
6
+ * Add styles for formtastic
7
+ * Transform boilerplate & other styles to scss
8
+ * Templates customizing (http://zigzag.github.com/2010/01/18/customizing-your-scaffold-template-become-easier-in-rails3.html)
9
+ - Create an html5 simple template and rails application to develop playmo gem
10
+ - Add link to homepage into "Welcome to abroad!"
11
+ * Add default users into seeds
12
+ - Generate assets.yml
13
+ - Modify compass.rb
14
+ - initialize git repository
15
+ - add capistrano and capify!
16
+ * https://gist.github.com/280196/5c075f4a3d3a4118d1d706fce07e40572a3873c7
@@ -0,0 +1,54 @@
1
+ module PlaymoHelper
2
+ # Create a named haml tag to wrap IE conditional around a block
3
+ # http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither
4
+ def ie_tag(name=:body, attrs={}, &block)
5
+ attrs.symbolize_keys!
6
+ result = "<!--[if lt IE 7 ]> #{ tag(name, add_class('ie6', attrs), true) } <![endif]-->\n".html_safe
7
+ result += "<!--[if IE 7 ]> #{ tag(name, add_class('ie7', attrs), true) } <![endif]-->\n".html_safe
8
+ result += "<!--[if IE 8 ]> #{ tag(name, add_class('ie8', attrs), true) } <![endif]-->\n".html_safe
9
+ result += "<!--[if IE 9 ]> #{ tag(name, add_class('ie9', attrs), true) } <![endif]-->\n".html_safe
10
+ result += "<!--[if (gte IE 9)|!(IE)]><!-->".html_safe
11
+
12
+
13
+ #tag name, attrs do
14
+ # haml_concat("<!--<![endif]-->".html_safe)
15
+ # block.call
16
+ #end
17
+ result += content_tag name, attrs do
18
+ "<!--<![endif]-->\n".html_safe + with_output_buffer(&block)
19
+ end
20
+
21
+ result
22
+ end
23
+
24
+ def ie_html(attrs={}, &block)
25
+ ie_tag(:html, attrs, &block)
26
+ end
27
+
28
+ def ie_body(attrs={}, &block)
29
+ ie_tag(:body, attrs, &block)
30
+ end
31
+
32
+ def google_account_id
33
+ ENV['GOOGLE_ACCOUNT_ID'] || google_config(:google_account_id)
34
+ end
35
+
36
+ def google_api_key
37
+ ENV['GOOGLE_API_KEY'] || google_config(:google_api_key)
38
+ end
39
+
40
+ private
41
+
42
+ def add_class(name, attrs)
43
+ classes = attrs[:class] || ''
44
+ classes.strip!
45
+ classes = ' ' + classes if !classes.blank?
46
+ classes = name + classes
47
+ attrs.merge(:class => classes)
48
+ end
49
+
50
+ def google_config(key)
51
+ configs = YAML.load_file(File.join(Rails.root, 'config', 'google.yml'))[Rails.env.to_sym] rescue {}
52
+ configs[key]
53
+ end
54
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ rails generate playmo Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,166 @@
1
+ module Playmo
2
+ module Generators
3
+ #extend Rails::Generators::AppGenerator
4
+
5
+ class InstallGenerator < Rails::Generators::Base
6
+ desc "Creates a Playmo initializer and copy files to your application."
7
+ source_root File.expand_path('../templates', __FILE__)
8
+ attr_accessor :framework
9
+
10
+ def use_gems
11
+ gem "devise", "~> 1.2.0"
12
+ gem "cancan"
13
+ gem "compass", :group => :development
14
+ gem "jammit"
15
+
16
+ gsub_file 'Gemfile', "# gem 'capistrano'", :verbose => false do
17
+ "gem 'capistrano'"
18
+ end
19
+ end
20
+
21
+ def generate_home_controller
22
+ generate :controller, :home, :index, '--quiet'
23
+
24
+ gsub_file 'app/views/home/index.html.erb', '<h1>Home#index</h1>', :verbose => false do
25
+ '<%= heading_with_title("Home#index") %>'
26
+ end
27
+ end
28
+
29
+ def remove_rails_files
30
+ remove_file 'app/controllers/application_controller.rb'
31
+ remove_file 'app/helpers/application_helper.rb'
32
+ remove_file 'app/views/layouts/application.html.erb'
33
+ remove_file 'public/favicon.ico'
34
+ remove_file 'public/robots.txt'
35
+ remove_file 'public/404.html'
36
+ remove_file 'public/422.html'
37
+ remove_file 'public/500.html'
38
+ remove_file 'public/index.html'
39
+ remove_file 'public/javascripts/controls.js'
40
+ remove_file 'public/javascripts/dragdrop.js'
41
+ remove_file 'public/javascripts/effects.js'
42
+ remove_file 'public/javascripts/prototype.js'
43
+ remove_file 'public/javascripts/rails.js'
44
+ remove_file 'public/images/rails.png'
45
+ run 'touch README'
46
+ end
47
+
48
+ def install_js_framework
49
+ say "\nPlease choose JS framework you prefer to install:", :white
50
+ say "\n"
51
+ say "1. JQuery 1.5.2", :white
52
+ say "2. Mootools Core 1.3.1", :white
53
+ say "3. Mootools Core 1.3.1 with More 1.3.1.1", :white
54
+
55
+ @framework = ask("\nPlease enter item number:").to_i
56
+
57
+ case @framework
58
+ when 1, 0
59
+ copy_file "jquery/jquery-1.5.2.min.js", "public/javascripts/lib/jquery-1.5.2.min.js"
60
+ copy_file "jquery/rails.js", "public/javascripts/rails.js"
61
+ when 2
62
+ copy_file "mootools/mootools-core-1.3.1.js", "public/javascripts/lib/mootools-core-1.3.1.min.js"
63
+ copy_file "mootools/rails.js", "public/javascripts/rails.js"
64
+ when 3
65
+ copy_file "mootools/mootools-core-1.3.1.js", "public/javascripts/lib/mootools-core-1.3.1.min.js"
66
+ copy_file "mootools/rails.js", "public/javascripts/rails.js"
67
+ copy_file "mootools/mootools-more-1.3.1.1.js", "public/javascripts/lib/mootools-more-1.3.1.1.min.js"
68
+ end
69
+ end
70
+
71
+ def copy_files
72
+ template "application.html.erb", "app/views/layouts/application.html.erb"
73
+ copy_file "application_helper.rb", "app/helpers/application_helper.rb"
74
+ copy_file "application_controller.rb", "app/controllers/application_controller.rb"
75
+ end
76
+
77
+ def setup_routes
78
+ route 'root :to => "home#index"'
79
+ gsub_file 'config/routes.rb', 'get "home/index"', :verbose => false do
80
+ ''
81
+ end
82
+ end
83
+
84
+ def run_gems_generators
85
+ generate "devise:install"
86
+ generate "devise User"
87
+ generate "devise:views"
88
+ generate "cancan:ability"
89
+
90
+ # Add :name accessor to default accessors
91
+ # Also add some specific methods
92
+ gsub_file 'app/models/user.rb', ' attr_accessible :email, :password, :password_confirmation, :remember_me', :verbose => false do
93
+ <<-CONTENT.gsub(/^ {10}/, '')
94
+ attr_accessible :email, :password, :password_confirmation, :remember_me, :name
95
+ cattr_accessor :current
96
+
97
+ # Return user name or user name from email address
98
+ def username
99
+ name.blank? ? email.match(/^[^@]+/)[0] : name
100
+ end
101
+ CONTENT
102
+ end
103
+ end
104
+
105
+ def initialize_compass
106
+ sass_dir = 'public/stylesheets'
107
+ css_dir = 'public/assets/compiled/stylesheets'
108
+ using = 'playmo'
109
+
110
+ run "compass init rails --quiet -r #{using} -u #{using} --sass-dir=#{sass_dir} \
111
+ --css-dir=#{css_dir}", :verbose => false, :capture => true
112
+
113
+ append_to_file 'config/compass.rb' do
114
+ 'output_style = :compact'
115
+ end
116
+ end
117
+
118
+ def copy_tasks
119
+ copy_file "tasks/sass.rake", "lib/tasks/sass.rake"
120
+ copy_file "tasks/assets.rake", "lib/tasks/assets.rake"
121
+ end
122
+
123
+ def copy_assets_config
124
+ template "assets.yml", "config/assets.yml"
125
+ end
126
+
127
+ def capify
128
+ capify!
129
+ remove_file 'config/deploy.rb'
130
+ copy_file "deploy.rb", "config/deploy.rb"
131
+ end
132
+
133
+ def setup_git_repo
134
+ create_file '.gitignore', <<-CONTENT.gsub(/^ {10}/, '')
135
+ .DS_Store
136
+ log/*.log
137
+ tmp/**/*
138
+ db/*.sqlite3
139
+ nbproject/
140
+ .idea/
141
+ CONTENT
142
+
143
+ git :init
144
+ git :submodule => "init"
145
+ git :add => '.'
146
+ git :commit => "-a -m 'Initial commit'"
147
+ end
148
+
149
+ def congrats
150
+ say "\n"
151
+ say "*******************************************************************"
152
+ say "Congratulations! All files has been installed successfully."
153
+ say "You can read some docs on https://github.com/tanraya/playmo"
154
+ say "\n"
155
+ say "Don't forget to configure config/initializers/devise.rb and config/deploy.rb!"
156
+ say "\n"
157
+ end
158
+
159
+ private
160
+
161
+ def framework
162
+ @framework
163
+ end
164
+ end
165
+ end
166
+ end
@@ -0,0 +1,56 @@
1
+ <!DOCTYPE html>
2
+ <%%= ie_html :class => 'no-js', :lang => :en do %>
3
+
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
7
+ <%%= csrf_meta_tag %>
8
+
9
+ <title><%%= page_title "Default title" %></title>
10
+ <meta name="description" content="<%%= yield :description %>">
11
+ <meta name="author" content="<%%= yield :author %>">
12
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
13
+
14
+ <link rel="shortcut icon" href="/favicon.ico">
15
+ <%%= raw include_stylesheets :default, :media => 'all' %>
16
+ <style><%%= yield :styles %></style>
17
+
18
+ <%%= raw include_javascripts :modernizr %>
19
+ </head>
20
+ <body>
21
+
22
+ <div id="container">
23
+ <header>
24
+ <h1><%%= link_to 'Welcome abroad!', root_path %></h1>
25
+ </header>
26
+
27
+ <div id="main">
28
+
29
+ <%% flash.each do |name, msg| %>
30
+ <%%= content_tag :div, msg, :id => "flash_#{name}" %>
31
+ <%% end %>
32
+
33
+ <article class="article">
34
+ <%%= yield %>
35
+ </article>
36
+
37
+ <aside>
38
+ <%% yield :sidebar %>
39
+ </aside>
40
+
41
+ </div>
42
+
43
+ <footer></footer>
44
+ </div>
45
+
46
+
47
+ <%%= raw include_javascripts :default %>
48
+ <script><%%= yield :javascripts %></script>
49
+
50
+ <!--[if lt IE 7 ]>
51
+ <%%= raw include_javascripts :bb_delated_png %>
52
+ <script>DD_belatedPNG.fix('img, .png_bg');</script>
53
+ <![endif]-->
54
+
55
+ </body>
56
+ <%% end %>
@@ -0,0 +1,9 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ before_filter :set_current_user
4
+
5
+ private
6
+ def set_current_user
7
+ User.current = current_user
8
+ end
9
+ end
@@ -0,0 +1,21 @@
1
+ module ApplicationHelper
2
+ attr_accessor :page_title
3
+
4
+ # Set page title. Use this method in your views
5
+ def title(page_title)
6
+ @page_title = page_title
7
+ end
8
+
9
+ # This prints page title. Call this helper
10
+ # inside title tag of your layout
11
+ def page_title(default_title = '')
12
+ @page_title || default_title
13
+ end
14
+
15
+ # Print heading (h1 by default) and set page title
16
+ # at the same time. Use this method in your views
17
+ def heading_with_title(heading, tag=:h1)
18
+ title(heading)
19
+ content_tag tag, heading
20
+ end
21
+ end
@@ -0,0 +1,32 @@
1
+ package_assets: on # (on, off, always)
2
+ embed_assets: off # (on, off, datauri)
3
+ compress_assets: on # (on, off)
4
+ gzip_assets: on # (on, off)
5
+ package_path: assets # (defaults to assets)
6
+ javascript_compressor: yui # (yui, closure)
7
+
8
+ javascripts:
9
+ default:
10
+ <% if framework == 1 %>
11
+ - public/javascripts/lib/jquery-1.5.2.min.js
12
+ <% elsif [2,3].include?(framework) %>
13
+ - public/javascripts/lib/mootools-core-1.3.1.min.js
14
+ <% if framework == 3 %>
15
+ - public/javascripts/lib/mootools-more-1.3.1.1.min.js
16
+ <% end %>
17
+ <% end %>
18
+ - public/javascripts/rails.js
19
+ - public/javascripts/application.js
20
+ modernizr:
21
+ - public/javascripts/lib/modernizr-1.7.min.js
22
+ bb_delated_png:
23
+ - public/javascripts/lib/dd_belatedpng.js
24
+
25
+ stylesheets:
26
+ default:
27
+ - public/assets/compiled/stylesheets/boilerplate/css/style.css
28
+ - public/assets/compiled/stylesheets/playmo/playmo.css
29
+ - public/assets/compiled/stylesheets/playmo/article.css
30
+ - public/assets/compiled/stylesheets/rails/layout.css
31
+ - public/assets/compiled/stylesheets/rails/screen.css
32
+ - public/assets/compiled/stylesheets/rails/print.css
@@ -0,0 +1,50 @@
1
+ # Uncomment line below if you are using thinking_sphinx
2
+ # require 'thinking_sphinx/deploy/capistrano'
3
+
4
+ set :application, "<app_name>"
5
+
6
+ set :repository, '<ssh+git://git@example.com:yourproject.git>'
7
+ set :scm, :git
8
+ set :deploy_via, :remote_cache
9
+ set :branch, :master
10
+ set :scm_username, '<scm_username_here>'
11
+
12
+ # Uncomment line below if you are using username in your scm
13
+ # set :scm_passphrase, ''
14
+
15
+ ssh_options[:forward_agent] = true
16
+
17
+ set :user, "root" # Username on the remote server
18
+ set :use_sudo, false
19
+ server "example.com", :app, :web, :db, :primary => true
20
+
21
+ set :deploy_to, "</var/www/#{application}>" # Path to your on the remote server
22
+ set :rails_env, "production"
23
+
24
+ namespace :deploy do
25
+ task :restart do
26
+ run "touch #{current_path}/tmp/restart.txt"
27
+ end
28
+
29
+ desc 'Bundle and minify javascripts and stylesheets'
30
+ task :precache_assets, :roles => :app do
31
+ run_locally "rake assets:compile"
32
+ #root_path = File.expand_path(File.dirname(__FILE__) + '/..')
33
+ #assets_path = "#{root_path}/public/assets"
34
+ #gem_path = ENV['GEM_PATH']
35
+ #run_locally "jammit"
36
+ #top.upload assets_path, "#{current_release}/public", :via => :scp, :recursive => true
37
+ end
38
+ end
39
+
40
+ namespace :bundle do
41
+ task :install do
42
+ run "cd #{deploy_to}/current && RAILS_ENV=#{rails_env} bundle install"
43
+ end
44
+ end
45
+
46
+ # Uncomment line below if you are using thinking_sphinx
47
+ # after 'deploy:setup', 'thinking_sphinx:shared_sphinx_folder'
48
+ after 'deploy:symlink', 'deploy:precache_assets'
49
+ after 'deploy:symlink', 'bundle:install'
50
+ after 'bundle:install', 'deploy:migrate'