wheels 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +17 -0
  5. data/Rakefile +53 -0
  6. data/VERSION +1 -0
  7. data/app/controllers/application_controller.rb +17 -0
  8. data/app/controllers/blogs_controller.rb +17 -0
  9. data/app/controllers/galleries_controller.rb +60 -0
  10. data/app/controllers/images_controller.rb +30 -0
  11. data/app/controllers/profiles_controller.rb +16 -0
  12. data/app/controllers/users_controller.rb +4 -0
  13. data/app/models/ability.rb +23 -0
  14. data/app/models/blog.rb +8 -0
  15. data/app/models/gallery.rb +5 -0
  16. data/app/models/image.rb +8 -0
  17. data/app/models/profile.rb +11 -0
  18. data/app/models/role.rb +8 -0
  19. data/app/models/user.rb +43 -0
  20. data/app/views/blogs/_form.html.haml +28 -0
  21. data/app/views/blogs/edit.html.haml +8 -0
  22. data/app/views/blogs/index.html.haml +19 -0
  23. data/app/views/blogs/index.xml.builder +27 -0
  24. data/app/views/blogs/new.html.haml +6 -0
  25. data/app/views/blogs/show.html.haml +10 -0
  26. data/app/views/galleries/_form.html.haml +29 -0
  27. data/app/views/galleries/_show.html.haml +21 -0
  28. data/app/views/galleries/edit.html.haml +7 -0
  29. data/app/views/galleries/index.html.haml +15 -0
  30. data/app/views/galleries/new.html.haml +5 -0
  31. data/app/views/galleries/show.html.haml +4 -0
  32. data/app/views/images/_form.html.haml +10 -0
  33. data/app/views/images/create.js.haml +3 -0
  34. data/app/views/images/destroy.js.haml +3 -0
  35. data/app/views/images/edit.html.haml +7 -0
  36. data/app/views/images/edit.js.haml +3 -0
  37. data/app/views/images/index.html.haml +17 -0
  38. data/app/views/images/index.js.haml +3 -0
  39. data/app/views/images/new.html.haml +5 -0
  40. data/app/views/images/new.js.haml +3 -0
  41. data/app/views/images/show.html.haml +5 -0
  42. data/app/views/images/show.js.haml +3 -0
  43. data/app/views/images/update.js.haml +3 -0
  44. data/app/views/layouts/image_dialog.html.haml +18 -0
  45. data/app/views/profiles/_form.html.haml +26 -0
  46. data/app/views/profiles/edit.html.haml +7 -0
  47. data/app/views/profiles/index.html.haml +25 -0
  48. data/app/views/profiles/new.html.haml +5 -0
  49. data/app/views/profiles/show.html.haml +21 -0
  50. data/app/views/users/index.html.haml +19 -0
  51. data/config/amazon_s3.yml +15 -0
  52. data/db/migrate/add_fields_to_users.rb +28 -0
  53. data/db/migrate/create_blogs.rb +16 -0
  54. data/db/migrate/create_galleries.rb +15 -0
  55. data/db/migrate/create_images.rb +17 -0
  56. data/db/migrate/create_profiles.rb +24 -0
  57. data/db/migrate/create_roles.rb +16 -0
  58. data/init.rb +2 -0
  59. data/lib/generators/wheels/LICENCE +20 -0
  60. data/lib/generators/wheels/USAGE +8 -0
  61. data/lib/generators/wheels/core_extensions.rb +56 -0
  62. data/lib/generators/wheels/install_generator.rb +25 -0
  63. data/lib/generators/wheels/recipes/cancan.rb +6 -0
  64. data/lib/generators/wheels/recipes/cucumber.rb +39 -0
  65. data/lib/generators/wheels/recipes/default.rb +18 -0
  66. data/lib/generators/wheels/recipes/design.rb +16 -0
  67. data/lib/generators/wheels/recipes/devise.rb +8 -0
  68. data/lib/generators/wheels/recipes/factory_girl.rb +5 -0
  69. data/lib/generators/wheels/recipes/haml.rb +8 -0
  70. data/lib/generators/wheels/recipes/jquery.rb +6 -0
  71. data/lib/generators/wheels/recipes/mongoid.rb +7 -0
  72. data/lib/generators/wheels/recipes/postgresql.rb +11 -0
  73. data/lib/generators/wheels/recipes/remarkable.rb +9 -0
  74. data/lib/generators/wheels/recipes/rspec.rb +23 -0
  75. data/lib/generators/wheels/recipes/wheels.rb +34 -0
  76. data/lib/generators/wheels/snippets/cucumber/database_config +3 -0
  77. data/lib/generators/wheels/templater.rb +29 -0
  78. data/lib/generators/wheels/templates/cancan/ability.rb +13 -0
  79. data/lib/generators/wheels/templates/database/postgresql.yml +19 -0
  80. data/lib/generators/wheels/templates/git/gitignore +8 -0
  81. data/lib/generators/wheels/templates/haml/app/views/layouts/application.html.haml +9 -0
  82. data/lib/generators/wheels/templates/mongoid/features/step_definitions/mongoid_steps.rb +4 -0
  83. data/lib/generators/wheels/templates/mongoid/features/support/hooks.rb +3 -0
  84. data/lib/generators/wheels/wheels_generator.rb +69 -0
  85. data/lib/wheels/routes.rb +25 -0
  86. data/lib/wheels.rb +2 -0
  87. data/public/404.html +26 -0
  88. data/public/422.html +26 -0
  89. data/public/500.html +26 -0
  90. data/public/favicon.ico +0 -0
  91. data/public/images/dreamy/Thumbs.db +0 -0
  92. data/public/images/dreamy/bg-ad-top.png +0 -0
  93. data/public/images/dreamy/bg-body.png +0 -0
  94. data/public/images/dreamy/bg-feed.gif +0 -0
  95. data/public/images/dreamy/bg-footer.jpg +0 -0
  96. data/public/images/dreamy/bg-header.jpg +0 -0
  97. data/public/images/dreamy/bg-menu-hover.png +0 -0
  98. data/public/images/dreamy/bg-menu.png +0 -0
  99. data/public/images/dreamy/bg-sidebar-bottom.gif +0 -0
  100. data/public/images/dreamy/button-feed.png +0 -0
  101. data/public/images/dreamy/icon-comment.png +0 -0
  102. data/public/images/growl/error.png +0 -0
  103. data/public/images/growl/growl_bottom.png +0 -0
  104. data/public/images/growl/growl_repeat.png +0 -0
  105. data/public/images/growl/growl_top.png +0 -0
  106. data/public/images/growl/info.png +0 -0
  107. data/public/images/menu/item-pointer-mover.gif +0 -0
  108. data/public/images/menu/item-pointer.gif +0 -0
  109. data/public/images/menu/lava.gif +0 -0
  110. data/public/images/menu/lava.png +0 -0
  111. data/public/images/menu/main-bg.png +0 -0
  112. data/public/images/menu/main-delimiter.png +0 -0
  113. data/public/javascripts/jquery.growl.js +143 -0
  114. data/public/javascripts/loadbehind.js +0 -0
  115. data/public/javascripts/menu.js +247 -0
  116. data/public/stylesheets/.gitkeep +0 -0
  117. data/public/stylesheets/dreamy.css +181 -0
  118. data/public/stylesheets/menu.css +101 -0
  119. data/public/stylesheets/sass/dreamy.sass +195 -0
  120. data/public/stylesheets/sass/menu.sass +105 -0
  121. data/public/stylesheets/scaffold.css +56 -0
  122. data/public/stylesheets/ui-lightness/images/ui-anim_basic_16x16.gif +0 -0
  123. data/public/stylesheets/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  124. data/public/stylesheets/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  125. data/public/stylesheets/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
  126. data/public/stylesheets/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  127. data/public/stylesheets/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  128. data/public/stylesheets/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  129. data/public/stylesheets/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  130. data/public/stylesheets/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  131. data/public/stylesheets/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  132. data/public/stylesheets/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
  133. data/public/stylesheets/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
  134. data/public/stylesheets/ui-lightness/images/ui-icons_ef8c08_256x240.png +0 -0
  135. data/public/stylesheets/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
  136. data/public/stylesheets/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
  137. data/public/stylesheets/ui-lightness/jquery-ui-1.8.2.custom.css +359 -0
  138. data/test/helper.rb +10 -0
  139. data/test/test_wheels.rb +7 -0
  140. metadata +220 -0
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Tyler Gannon
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,17 @@
1
+ = wheels
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 Tyler Gannon. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "wheels"
8
+ gem.summary = "Generator builds a web site with blog, user profile, etc."
9
+ gem.description = "Call rails generate wheels."
10
+ gem.email = "tgannon@gmail.com"
11
+ gem.homepage = "http://github.com/tylergannon/wheels"
12
+ gem.authors = ["Tyler Gannon"]
13
+ gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
+ end
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:test) do |test|
23
+ test.libs << 'lib' << 'test'
24
+ test.pattern = 'test/**/test_*.rb'
25
+ test.verbose = true
26
+ end
27
+
28
+ begin
29
+ require 'rcov/rcovtask'
30
+ Rcov::RcovTask.new do |test|
31
+ test.libs << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+ rescue LoadError
36
+ task :rcov do
37
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
38
+ end
39
+ end
40
+
41
+ task :test => :check_dependencies
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "wheels #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.3
@@ -0,0 +1,17 @@
1
+ class ApplicationController < ActionController::Base
2
+
3
+ def self.authorized
4
+ class_eval do
5
+ def resource
6
+ authorize_this
7
+ super
8
+ end
9
+ end
10
+ end
11
+
12
+ def authorize_this
13
+ authorize! resource, params[:action] unless @authorized
14
+ @authorized = true
15
+ end
16
+ end
17
+
@@ -0,0 +1,17 @@
1
+ class BlogsController < InheritedResources::Base
2
+ respond_to :html, :xml
3
+ belongs_to :user, :optional=>true
4
+ before_filter :load_current_user
5
+
6
+ def collection
7
+ @blogs ||= end_of_association_chain.
8
+ paginate(:page => params[:page], :order => 'created_at DESC' )
9
+ end
10
+
11
+ def load_current_user
12
+ unless params[:user_id]
13
+ @user ||= (current_user ? User.find(current_user.id) : User.super_user)
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,60 @@
1
+ class GalleriesController < InheritedResources::Base
2
+ belongs_to :user, :optional=>true
3
+ before_filter :load_user
4
+
5
+ def index
6
+ index! do |format|
7
+ if params[:CKEditorFuncNum]
8
+ format.html{
9
+ render :action=>:index, :layout=>"image_dialog"
10
+ }
11
+ end
12
+ end
13
+ end
14
+
15
+ def edit
16
+ edit! do |format|
17
+ if params[:CKEditorFuncNum]
18
+ format.html{
19
+ render :action=>:edit, :layout=>"image_dialog"
20
+ }
21
+ end
22
+ end
23
+ end
24
+
25
+ def show
26
+ show! do |format|
27
+ images = paginated_images_for(@gallery)
28
+ if params[:CKEditorFuncNum]
29
+ format.html{
30
+ render :action=>:show, :layout=>"image_dialog", :locals=>{:images=>images}
31
+ }
32
+ end
33
+ end
34
+ end
35
+
36
+ def new
37
+ @gallery = Gallery.create(:user=>@user)
38
+ new!
39
+ end
40
+
41
+ def create
42
+ create! {images_path(params.slice(:CKEditor, :CKEditorFuncNum, :langCode))}
43
+ end
44
+
45
+ def load_user
46
+ unless params[:user_id]
47
+ @user ||= (current_user ? User.find(current_user.id) : User.super_user)
48
+ end
49
+ end
50
+ helper_method :ckeditor_params, :paginated_images_for
51
+
52
+ def paginated_images_for(gallery)
53
+ @images ||= Image.where(:gallery_id=>gallery.id).paginate(:page => params[:page], :order => 'created_at DESC' )
54
+ end
55
+
56
+ def ckeditor_params
57
+ params.slice(:CKEditor, :CKEditorFuncNum, :langCode)
58
+ end
59
+ end
60
+
@@ -0,0 +1,30 @@
1
+ class ImagesController < InheritedResources::Base
2
+ respond_to :html, :js, :xml
3
+ belongs_to :gallery
4
+
5
+ def index
6
+ index! do |format|
7
+ if params[:CKEditorFuncNum]
8
+ format.html {render :action=>:index, :layout=>"image_dialog"}
9
+ end
10
+ end
11
+ end
12
+
13
+ def create
14
+ create! {edit_gallery_path(@gallery, params.slice(:CKEditor, :CKEditorFuncNum, :langCode))}
15
+ end
16
+
17
+ def show
18
+ show! do |format|
19
+ if params[:CKEditorFuncNum]
20
+ format.html {render :layout=>"image_dialog"}
21
+ end
22
+ end
23
+ end
24
+
25
+ def collection
26
+ @images ||= end_of_association_chain.
27
+ paginate(:page => params[:page], :order => 'created_at DESC' )
28
+ end
29
+ end
30
+
@@ -0,0 +1,16 @@
1
+ class ProfilesController < InheritedResources::Base
2
+ respond_to :html
3
+ before_filter :load_current_user
4
+ belongs_to :user, :optional => true, :singleton=>true
5
+
6
+ def load_current_user
7
+ unless params[:user_id]
8
+ @user ||= (current_user ? User.find(current_user.id) : User.super_user)
9
+ end
10
+ end
11
+
12
+ def resource
13
+ @profile ||= Profile.find_by_user_id(@user.id)
14
+ end
15
+ end
16
+
@@ -0,0 +1,4 @@
1
+ class UsersController < InheritedResources::Base
2
+
3
+ end
4
+
@@ -0,0 +1,23 @@
1
+ class Ability
2
+ include CanCan::Ability
3
+
4
+ def initialize(user)
5
+ can :read, :all
6
+ return cannot :read, User unless user
7
+ user ||= User.new
8
+ case user.role_id
9
+ when Role::SUPER
10
+ can :manage, :all
11
+ when Role::ADMIN
12
+ can :manage, :all
13
+ when Role::USER
14
+ can :manage, Gallery, :user_id => user.id
15
+ can :manage, Blog, :user_id => user.id
16
+ can :edit, Profile, :user_id => user.id
17
+ cannot :read, User
18
+ end
19
+ can :read, :all
20
+
21
+ end
22
+ end
23
+
@@ -0,0 +1,8 @@
1
+ class Blog < ActiveRecord::Base
2
+ belongs_to :user
3
+ validates_presence_of :user_id
4
+ has_many :images
5
+ cattr_reader :per_page
6
+ @@per_page = 5
7
+ end
8
+
@@ -0,0 +1,5 @@
1
+ class Gallery < ActiveRecord::Base
2
+ belongs_to :user
3
+ has_many :images, :dependent=>:destroy
4
+ end
5
+
@@ -0,0 +1,8 @@
1
+ class Image < ActiveRecord::Base
2
+ belongs_to :gallery
3
+ has_attached_file :image,
4
+ :storage => :s3,
5
+ :s3_credentials => "#{Rails.root}/config/amazon_s3.yml",
6
+ :path => "/:style/:filename"
7
+ end
8
+
@@ -0,0 +1,11 @@
1
+ class Profile < ActiveRecord::Base
2
+ belongs_to :user
3
+ validates_uniqueness_of :alias
4
+ has_attached_file :image,
5
+ :storage => :s3,
6
+ :s3_credentials => "#{Rails.root}/config/amazon_s3.yml",
7
+ :path => "/:style/:filename",
8
+ :styles => { :medium => "300x300>", :thumb => "100x100>" }
9
+
10
+ end
11
+
@@ -0,0 +1,8 @@
1
+ class Role < ActiveRecord::Base
2
+ has_many :users
3
+
4
+ SUPER = 1
5
+ ADMIN = 2
6
+ USER = 3
7
+ end
8
+
@@ -0,0 +1,43 @@
1
+ class User < ActiveRecord::Base
2
+ before_create :create_profile
3
+ belongs_to :role
4
+
5
+ # Include default devise modules. Others available are:
6
+ # :token_authenticatable, :confirmable, :lockable and :timeoutable
7
+ devise :database_authenticatable, :registerable, :confirmable, :token_authenticatable,
8
+ :recoverable, :rememberable, :trackable, :validatable
9
+
10
+ def self.super_user
11
+ @@super_user ||= User.where(:role_id=>Role::SUPER).first
12
+ end
13
+
14
+ has_many :blogs, :dependent => :destroy
15
+ has_one :profile, :dependent => :destroy
16
+ has_many :galleries, :dependent => :destroy
17
+
18
+ def create_profile
19
+ self.profile ||= Profile.create(:user => self)
20
+ end
21
+
22
+ def role=(role)
23
+ if role.kind_of? Role
24
+ self.role_id = role.id
25
+ else
26
+ if role.is_numeric?
27
+ self.role_id= role
28
+ else
29
+ self.role_id= Role.find_by_name(role).id
30
+ end
31
+ end
32
+ end
33
+
34
+ def confirm!
35
+ self.confirmed_at = DateTime::now
36
+ save
37
+ end
38
+
39
+ # Setup accessible (or protected) attributes for your model
40
+ attr_accessible :email, :password, :password_confirmation,
41
+ :blogs, :profile, :role, :galleries
42
+ end
43
+
@@ -0,0 +1,28 @@
1
+ = content_for(:head) do
2
+ = javascript_include_tag '/ckeditor/ckeditor.js'
3
+ = javascript_include_tag '/ckeditor/adapters/jquery.js'
4
+ :javascript
5
+ $(function(){
6
+ config = {
7
+ filebrowserBrowseUrl : '#{galleries_path}'
8
+ };
9
+ $('.ckeditor_textarea').ckeditor(config);
10
+ });
11
+
12
+ = form_for [@blog.user, @blog], :html=>{:multipart=>true} do |f|
13
+ -if @blog.errors.any?
14
+ #errorExplanation
15
+ %h2= "#{pluralize(@blog.errors.count, "error")} prohibited this blog from being saved:"
16
+ %ul
17
+ - @blog.errors.full_messages.each do |msg|
18
+ %li= msg
19
+
20
+ .field
21
+ = f.label :title
22
+ = f.text_field :title
23
+ .field
24
+ = f.label :body
25
+ = f.text_area :body, :class=>'ckeditor_textarea'
26
+ .actions
27
+ = f.submit 'Save'
28
+
@@ -0,0 +1,8 @@
1
+ %h1 Editing blog
2
+
3
+ = render 'form'
4
+
5
+ = link_to 'Show', resource_url
6
+ \|
7
+ = link_to 'Back', collection_url
8
+
@@ -0,0 +1,19 @@
1
+ %h1 Someone's Blog
2
+
3
+ - @blogs.each do |blog|
4
+ #ad-top
5
+ / Insert 468x60 banner advertisement
6
+ .entry
7
+ .entry-title= link_to blog.title, resource_url(blog)
8
+
9
+ .date Posted on #{blog.created_at}
10
+ .blog_body!= blog.body
11
+ .comments
12
+ %a{:href => "#"} 3 comments
13
+
14
+
15
+ - if current_user.try(:id) == @user.id
16
+ = link_to 'New Blog Post', new_user_blog_path(@user)
17
+
18
+ = will_paginate @blogs
19
+
@@ -0,0 +1,27 @@
1
+ xml.instruct!
2
+
3
+ xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
4
+
5
+ xml.title "Feed Name"
6
+ xml.link "rel" => "self", "href" => user_blogs_path(@user, :only_path=>false, :format=>:xml)
7
+ # xml.link "rel" => "alternate", "href" => url_for(:only_path => false, :controller => 'posts')
8
+ xml.id user_blogs_path(@user, :only_path => false)
9
+ xml.updated @blogs.first.updated_at.strftime "%Y-%m-%dT%H:%M:%SZ" if @blogs.any?
10
+ xml.author { xml.name @blogs.first }
11
+
12
+ @blogs.each do |post|
13
+ xml.entry do
14
+ xml.title post.title
15
+ xml.link "rel" => "alternate", "href" => user_blogs_path(@user, post, :only_path => false)
16
+ xml.id user_blog_path(@user, post, :only_path => false)
17
+ xml.updated post.updated_at.strftime "%Y-%m-%dT%H:%M:%SZ"
18
+ xml.author { xml.name post.user.email }
19
+ xml.summary "Post summary"
20
+ xml.content "type" => "html" do
21
+ xml.cdata! post.body
22
+ end
23
+ end
24
+ end
25
+
26
+ end
27
+
@@ -0,0 +1,6 @@
1
+ %h1 New blog
2
+
3
+ = render 'form'
4
+
5
+ = link_to 'Back', collection_url
6
+
@@ -0,0 +1,10 @@
1
+ %p
2
+ %b Title:
3
+ = @blog.title
4
+ %p
5
+ %b Body:
6
+ = raw @blog.body
7
+ = link_to 'Edit', edit_resource_url
8
+ \|
9
+ = link_to 'Back', collection_url
10
+
@@ -0,0 +1,29 @@
1
+ :css
2
+ #image_gallery li {
3
+ display: inline;
4
+ list-style: none;
5
+ width: 300px;
6
+ min-height: 300px;
7
+ float: left;
8
+ margin: 0 10px 10px 0;
9
+ text-align: center;
10
+ }
11
+ = form_for @gallery do |f|
12
+ %h2 Gallery Name:
13
+ = f.text_field :name
14
+ = f.submit "Save Gallery"
15
+
16
+ %ul#image_gallery
17
+ - paginated_images_for(@gallery).each do |image|
18
+ %li
19
+ = image_tag image.image.url(:medium)
20
+
21
+ = will_paginate paginated_images_for(@gallery)
22
+
23
+ #upload_form
24
+ = form_for [@gallery, Image.new(:gallery=>@gallery)], :html=>{:id=>'upload', :multipart=>true} do |f|
25
+ - params.slice(:CKEditor, :CKEditorFuncNum, :langCode).each do |key, val|
26
+ = hidden_field_tag key, val
27
+ = f.file_field :image
28
+ = f.submit :disable_with=>"Uploading..."
29
+
@@ -0,0 +1,21 @@
1
+ :css
2
+ #image_gallery li {
3
+ display: inline;
4
+ list-style: none;
5
+ width: 300px;
6
+ min-height: 300px;
7
+ float: left;
8
+ margin: 0 10px 10px 0;
9
+ text-align: center;
10
+ }
11
+
12
+ %h1= gallery.name.empty? ? "Name your gallery" : gallery.name
13
+ - if can? :update, gallery
14
+ = link_to 'Edit', edit_gallery_path(gallery)
15
+ - if can? :manage, gallery
16
+ = link_to 'Destroy', gallery, "data-confirm"=>"You'll shoot your eye out!", :method=>"delete"
17
+ %ul#image_gallery
18
+ - images.each do |image|
19
+ %li
20
+ = image_tag image.image.url(:medium)
21
+
@@ -0,0 +1,7 @@
1
+ %h1 Editing gallery
2
+
3
+ = render 'form'
4
+
5
+ = link_to 'Show', @gallery
6
+ \|
7
+ = link_to 'Back', galleries_path
@@ -0,0 +1,15 @@
1
+ %h1 #{@user.profile.alias}'s Galleries
2
+ %ul
3
+ - @galleries.each do |gallery|
4
+ %li
5
+ %h2= link_to (gallery.name || "No name"), gallery_path(gallery, ckeditor_params)
6
+ - unless gallery.images.empty?
7
+ = image_tag gallery.images[0].image.url(:medium)
8
+ - if can? :update, gallery
9
+ = link_to 'Edit', edit_gallery_path(gallery, ckeditor_params)
10
+ - if can? :manage, gallery
11
+ = link_to 'Destroy', gallery_path(gallery, ckeditor_params), "data-confirm"=>"Sure? All the images from this gallery will be gone...", :method=>"delete"
12
+
13
+
14
+ = link_to 'New gallery', new_gallery_path
15
+
@@ -0,0 +1,5 @@
1
+ %h1 New gallery
2
+
3
+ = render 'form'
4
+
5
+ = link_to 'Back', galleries_path
@@ -0,0 +1,4 @@
1
+ = render :partial => "show", :locals=>{:images=>images, :gallery=>@gallery}
2
+
3
+ = will_paginate images
4
+
@@ -0,0 +1,10 @@
1
+ = form_for @image do |f|
2
+ -if @image.errors.any?
3
+ #errorExplanation
4
+ %h2= "#{pluralize(@image.errors.count, "error")} prohibited this image from being saved:"
5
+ %ul
6
+ - @image.errors.full_messages.each do |msg|
7
+ %li= msg
8
+
9
+ .actions
10
+ = f.submit 'Save'
@@ -0,0 +1,3 @@
1
+ $('##{@container}').#{@ajax_function}(#{raw render_js('show')});
2
+ = render :partial => "loadbehind/view"
3
+
@@ -0,0 +1,3 @@
1
+ $('##{@container}').remove;
2
+ = render :partial => "loadbehind/destroy"
3
+
@@ -0,0 +1,7 @@
1
+ %h1 Editing image
2
+
3
+ = render 'form'
4
+
5
+ = link_to 'Show', @image
6
+ \|
7
+ = link_to 'Back', images_path
@@ -0,0 +1,3 @@
1
+ $('##{@container}').#{@ajax_function}(#{raw render_js('form')});
2
+ = render :partial => "loadbehind/edit"
3
+
@@ -0,0 +1,17 @@
1
+ %h1 Listing images
2
+
3
+ %table
4
+ %tr
5
+ %th
6
+ %th
7
+ %th
8
+
9
+ - @images.each do |image|
10
+ %tr
11
+ %td= link_to 'Show', image
12
+ %td= link_to 'Edit', edit_image_path(image)
13
+ %td= link_to 'Destroy', image, :confirm => 'Are you sure?', :method => :delete
14
+
15
+ %br
16
+
17
+ = link_to 'New image', new_image_path
@@ -0,0 +1,3 @@
1
+ $('##{@container}').#{@ajax_function}(#{raw render_js('index')});
2
+ = render :partial => "loadbehind/view"
3
+
@@ -0,0 +1,5 @@
1
+ %h1 New image
2
+
3
+ = render 'form'
4
+
5
+ = link_to 'Back', images_path
@@ -0,0 +1,3 @@
1
+ $('##{@container}').#{@ajax_function}(#{raw render_js('form')});
2
+ = render :partial => "loadbehind/edit"
3
+
@@ -0,0 +1,5 @@
1
+
2
+ = image_tag @image.image.url
3
+ \|
4
+ = link_to 'Back', collection_path
5
+