wheels 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. data/VERSION +1 -1
  2. data/app/controllers/blogs_controller.rb +17 -0
  3. data/app/controllers/galleries_controller.rb +60 -0
  4. data/app/controllers/images_controller.rb +30 -0
  5. data/app/controllers/profiles_controller.rb +16 -0
  6. data/app/controllers/users_controller.rb +4 -0
  7. data/app/models/ability.rb +23 -0
  8. data/app/models/blog.rb +8 -0
  9. data/app/models/gallery.rb +5 -0
  10. data/app/models/image.rb +8 -0
  11. data/app/models/profile.rb +11 -0
  12. data/app/models/role.rb +8 -0
  13. data/app/models/user.rb +43 -0
  14. data/app/views/blogs/_form.html.haml +28 -0
  15. data/app/views/blogs/edit.html.haml +8 -0
  16. data/app/views/blogs/index.html.haml +19 -0
  17. data/app/views/blogs/index.xml.builder +27 -0
  18. data/app/views/blogs/new.html.haml +6 -0
  19. data/app/views/blogs/show.html.haml +10 -0
  20. data/app/views/galleries/_form.html.haml +29 -0
  21. data/app/views/galleries/_show.html.haml +21 -0
  22. data/app/views/galleries/edit.html.haml +7 -0
  23. data/app/views/galleries/index.html.haml +15 -0
  24. data/app/views/galleries/new.html.haml +5 -0
  25. data/app/views/galleries/show.html.haml +4 -0
  26. data/app/views/images/_form.html.haml +10 -0
  27. data/app/views/images/create.js.haml +3 -0
  28. data/app/views/images/destroy.js.haml +3 -0
  29. data/app/views/images/edit.html.haml +7 -0
  30. data/app/views/images/edit.js.haml +3 -0
  31. data/app/views/images/index.html.haml +17 -0
  32. data/app/views/images/index.js.haml +3 -0
  33. data/app/views/images/new.html.haml +5 -0
  34. data/app/views/images/new.js.haml +3 -0
  35. data/app/views/images/show.html.haml +5 -0
  36. data/app/views/images/show.js.haml +3 -0
  37. data/app/views/images/update.js.haml +3 -0
  38. data/app/views/layouts/image_dialog.html.haml +18 -0
  39. data/app/views/profiles/_form.html.haml +26 -0
  40. data/app/views/profiles/edit.html.haml +7 -0
  41. data/app/views/profiles/index.html.haml +25 -0
  42. data/app/views/profiles/new.html.haml +5 -0
  43. data/app/views/profiles/show.html.haml +21 -0
  44. data/app/views/users/index.html.haml +19 -0
  45. data/config/amazon_s3.yml +15 -0
  46. data/db/migrate/add_fields_to_users.rb +28 -0
  47. data/db/migrate/create_blogs.rb +16 -0
  48. data/db/migrate/create_galleries.rb +15 -0
  49. data/db/migrate/create_images.rb +17 -0
  50. data/db/migrate/create_profiles.rb +24 -0
  51. data/db/migrate/create_roles.rb +16 -0
  52. data/lib/generators/wheels/recipes/wheels.rb +0 -1
  53. data/lib/generators/wheels/wheels_generator.rb +1 -1
  54. data/lib/wheels.rb +1 -0
  55. data/public/404.html +26 -0
  56. data/public/422.html +26 -0
  57. data/public/500.html +26 -0
  58. data/public/favicon.ico +0 -0
  59. data/public/images/dreamy/Thumbs.db +0 -0
  60. data/public/images/dreamy/bg-ad-top.png +0 -0
  61. data/public/images/dreamy/bg-body.png +0 -0
  62. data/public/images/dreamy/bg-feed.gif +0 -0
  63. data/public/images/dreamy/bg-footer.jpg +0 -0
  64. data/public/images/dreamy/bg-header.jpg +0 -0
  65. data/public/images/dreamy/bg-menu-hover.png +0 -0
  66. data/public/images/dreamy/bg-menu.png +0 -0
  67. data/public/images/dreamy/bg-sidebar-bottom.gif +0 -0
  68. data/public/images/dreamy/button-feed.png +0 -0
  69. data/public/images/dreamy/icon-comment.png +0 -0
  70. data/public/images/growl/error.png +0 -0
  71. data/public/images/growl/growl_bottom.png +0 -0
  72. data/public/images/growl/growl_repeat.png +0 -0
  73. data/public/images/growl/growl_top.png +0 -0
  74. data/public/images/growl/info.png +0 -0
  75. data/public/images/menu/item-pointer-mover.gif +0 -0
  76. data/public/images/menu/item-pointer.gif +0 -0
  77. data/public/images/menu/lava.gif +0 -0
  78. data/public/images/menu/lava.png +0 -0
  79. data/public/images/menu/main-bg.png +0 -0
  80. data/public/images/menu/main-delimiter.png +0 -0
  81. data/public/javascripts/jquery.growl.js +143 -0
  82. data/public/javascripts/loadbehind.js +0 -0
  83. data/public/javascripts/menu.js +247 -0
  84. data/public/stylesheets/.gitkeep +0 -0
  85. data/public/stylesheets/dreamy.css +181 -0
  86. data/public/stylesheets/menu.css +101 -0
  87. data/public/stylesheets/sass/dreamy.sass +195 -0
  88. data/public/stylesheets/sass/menu.sass +105 -0
  89. data/public/stylesheets/scaffold.css +56 -0
  90. data/public/stylesheets/ui-lightness/images/ui-anim_basic_16x16.gif +0 -0
  91. data/public/stylesheets/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  92. data/public/stylesheets/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  93. data/public/stylesheets/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
  94. data/public/stylesheets/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  95. data/public/stylesheets/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  96. data/public/stylesheets/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  97. data/public/stylesheets/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  98. data/public/stylesheets/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  99. data/public/stylesheets/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  100. data/public/stylesheets/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
  101. data/public/stylesheets/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
  102. data/public/stylesheets/ui-lightness/images/ui-icons_ef8c08_256x240.png +0 -0
  103. data/public/stylesheets/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
  104. data/public/stylesheets/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
  105. data/public/stylesheets/ui-lightness/jquery-ui-1.8.2.custom.css +359 -0
  106. data/wheels.gemspec +102 -1
  107. metadata +104 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.0.8
@@ -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
+
@@ -0,0 +1,3 @@
1
+ $('##{@container}').#{@ajax_function}(#{raw render_js('show')});
2
+ = render :partial => "loadbehind/view"
3
+
@@ -0,0 +1,3 @@
1
+ $('##{@container}').#{@ajax_function}(#{raw render_js('show')});
2
+ = render :partial => "loadbehind/view"
3
+
@@ -0,0 +1,18 @@
1
+ !!! 5
2
+ %html
3
+ %head
4
+ = csrf_meta_tag
5
+ /[if lt IE 9]
6
+ = javascript_include_tag 'html5'
7
+ = javascript_include_tag :defaults
8
+ :javascript
9
+ $(function(){
10
+ $('#image_dialog').find('img').click(function(){
11
+ url = $(this).attr('src');
12
+ window.opener.CKEDITOR.tools.callFunction( #{params[:CKEditorFuncNum]}, url);
13
+ window.close();
14
+ });
15
+ });
16
+ %body
17
+ #image_dialog= yield
18
+
@@ -0,0 +1,26 @@
1
+ = form_for @profile, :url=>{:action=>"update"}, :html=>{:multipart=>true} do |f|
2
+ -if @profile.errors.any?
3
+ #errorExplanation
4
+ %h2= "#{pluralize(@profile.errors.count, "error")} prohibited this profile from being saved:"
5
+ %ul
6
+ - @profile.errors.full_messages.each do |msg|
7
+ %li= msg
8
+
9
+ .field
10
+ = f.label :first_name
11
+ = f.text_field :first_name
12
+ .field
13
+ = f.label :last_name
14
+ = f.text_field :last_name
15
+ .field
16
+ = f.label :alias
17
+ = f.text_field :alias
18
+ .field
19
+ = f.label :about_me
20
+ = f.text_area :about_me
21
+ .field
22
+ = f.label :image
23
+ = f.file_field :image
24
+ .actions
25
+ = f.submit 'Save'
26
+
@@ -0,0 +1,7 @@
1
+ %h1 Editing profile
2
+
3
+ = render 'form'
4
+
5
+ = link_to 'Show', @profile
6
+ \|
7
+ = link_to 'Back', profiles_path
@@ -0,0 +1,25 @@
1
+ %h1 Listing profiles
2
+
3
+ %table
4
+ %tr
5
+ %th First name
6
+ %th Last name
7
+ %th Alias
8
+ %th About me
9
+ %th
10
+ %th
11
+ %th
12
+
13
+ - @profiles.each do |profile|
14
+ %tr
15
+ %td= profile.first_name
16
+ %td= profile.last_name
17
+ %td= profile.alias
18
+ %td= profile.about_me
19
+ %td= link_to 'Show', profile
20
+ %td= link_to 'Edit', edit_profile_path(profile)
21
+ %td= link_to 'Destroy', profile, :confirm => 'Are you sure?', :method => :delete
22
+
23
+ %br
24
+
25
+ = link_to 'New profile', new_profile_path
@@ -0,0 +1,5 @@
1
+ %h1 New profile
2
+
3
+ = render 'form'
4
+
5
+ = link_to 'Back', profiles_path
@@ -0,0 +1,21 @@
1
+ - if @profile.image_file_name
2
+ = image_tag @profile.image.url(:thumb)
3
+ - else
4
+ - if can? :edit, @profile
5
+ - link_to 'Upload a photo', user_profile_path(@user)
6
+ %p
7
+ %b First name:
8
+ = @profile.first_name
9
+ %p
10
+ %b Last name:
11
+ = @profile.last_name
12
+ %p
13
+ %b Alias:
14
+ = @profile.alias
15
+ %p
16
+ %b About me:
17
+ = @profile.about_me
18
+
19
+ - if current_user.try(:id) == @user.id
20
+ = link_to 'Edit', edit_user_profile_path(@user)
21
+