squeezer 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/.bundle/config +2 -0
  2. data/.document +5 -0
  3. data/Gemfile +24 -0
  4. data/Gemfile.lock +119 -0
  5. data/LICENSE.txt +20 -0
  6. data/README +0 -0
  7. data/README.rdoc +19 -0
  8. data/Rakefile +53 -0
  9. data/VERSION +1 -0
  10. data/config/routes.rb +26 -0
  11. data/lib/app/controllers/application_controller.rb +25 -0
  12. data/lib/app/controllers/blogs_controller.rb +19 -0
  13. data/lib/app/controllers/comments_controller.rb +37 -0
  14. data/lib/app/controllers/pages_controller.rb +3 -0
  15. data/lib/app/controllers/posts_controller.rb +23 -0
  16. data/lib/app/controllers/roles_controller.rb +3 -0
  17. data/lib/app/controllers/sites_controller.rb +70 -0
  18. data/lib/app/controllers/users_controller.rb +22 -0
  19. data/lib/app/helpers/squeezer_helper.rb +80 -0
  20. data/lib/app/models/ability.rb +17 -0
  21. data/lib/app/models/blog.rb +5 -0
  22. data/lib/app/models/comment.rb +4 -0
  23. data/lib/app/models/page.rb +3 -0
  24. data/lib/app/models/post.rb +13 -0
  25. data/lib/app/models/role.rb +4 -0
  26. data/lib/app/models/site.rb +17 -0
  27. data/lib/app/models/user.rb +37 -0
  28. data/lib/app/views/blogs/_entry.haml +26 -0
  29. data/lib/app/views/blogs/_form.html.haml +15 -0
  30. data/lib/app/views/blogs/edit.html.haml +8 -0
  31. data/lib/app/views/blogs/index.html.haml +8 -0
  32. data/lib/app/views/blogs/new.html.haml +5 -0
  33. data/lib/app/views/blogs/show.html.haml +4 -0
  34. data/lib/app/views/comments/_form.html.haml +19 -0
  35. data/lib/app/views/comments/_index.html.haml +26 -0
  36. data/lib/app/views/comments/_post.html.haml +20 -0
  37. data/lib/app/views/comments/show.js.erb +1 -0
  38. data/lib/app/views/layouts/_footer.html.haml +5 -0
  39. data/lib/app/views/layouts/_login.haml +9 -0
  40. data/lib/app/views/layouts/_menu.html.haml +9 -0
  41. data/lib/app/views/layouts/_msn.haml +12 -0
  42. data/lib/app/views/layouts/_sidebar.html.haml +1 -0
  43. data/lib/app/views/layouts/application.html.erb +14 -0
  44. data/lib/app/views/layouts/ice/squeezer/_ice.haml +27 -0
  45. data/lib/app/views/layouts/ice/squeezer/ice/_ice.haml +6 -0
  46. data/lib/app/views/layouts/ice/squeezer/ice/squeezer/_ice.haml +27 -0
  47. data/lib/app/views/layouts/ice/squeezer/ice/squeezer/ice/_ice.haml +6 -0
  48. data/lib/app/views/layouts/ice/squeezer/ice/squeezer/ice/squeezer/_ice.haml +7 -0
  49. data/lib/app/views/layouts/squeezer/ice/_ice.haml +6 -0
  50. data/lib/app/views/layouts/squeezer/ice/squeezer/_ice.haml +28 -0
  51. data/lib/app/views/layouts/squeezer/ice/squeezer/ice/_ice.haml +6 -0
  52. data/lib/app/views/layouts/squeezer/ice/squeezer/ice/squeezer/_ice.haml +7 -0
  53. data/lib/app/views/layouts/squeezer/squeezer.css +252 -0
  54. data/lib/app/views/pages/_form.html.haml +17 -0
  55. data/lib/app/views/pages/edit.html.haml +8 -0
  56. data/lib/app/views/pages/index.html.haml +22 -0
  57. data/lib/app/views/pages/new.html.haml +5 -0
  58. data/lib/app/views/pages/show.html.haml +13 -0
  59. data/lib/app/views/roles/_form.html.haml +9 -0
  60. data/lib/app/views/roles/edit.html.haml +7 -0
  61. data/lib/app/views/roles/index.html.haml +19 -0
  62. data/lib/app/views/roles/new.html.haml +5 -0
  63. data/lib/app/views/roles/show.html.haml +13 -0
  64. data/lib/app/views/sites/_form.html.haml +42 -0
  65. data/lib/app/views/sites/edit.html.haml +1 -0
  66. data/lib/app/views/sites/index.html.haml +165 -0
  67. data/lib/app/views/sites/new.html.haml +1 -0
  68. data/lib/app/views/sites/show.html.haml +18 -0
  69. data/lib/app/views/users/index.haml +5 -0
  70. data/lib/app/views/users/roles.haml +14 -0
  71. data/lib/app/views/users/show.haml +1 -0
  72. data/lib/blogs_controller.rb +19 -0
  73. data/lib/squeezer/engine.rb +0 -0
  74. data/lib/squeezer.rb +3 -0
  75. data/pkg/squeezer-0.1.0.gem +0 -0
  76. data/pkg/squeezer-0.1.1.gem +0 -0
  77. data/pkg/squeezer-0.1.2.gem +0 -0
  78. data/pkg/squeezer-0.1.3.gem +0 -0
  79. data/squeezer.gemspec +168 -0
  80. data/test/helper.rb +18 -0
  81. data/test/test_squeezer.rb +7 -0
  82. metadata +350 -0
data/.bundle/config ADDED
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_DISABLE_SHARED_GEMS: "1"
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,24 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.5.1"
12
+ gem "rcov", ">= 0"
13
+ gem "will_paginate", "~> 3.0.pre2"
14
+ gem 'haml'
15
+ gem 'devise',"~>1.1.rc2"
16
+ gem 'paperclip'
17
+ gem 'cancan'
18
+ gem 'nifty-generators'
19
+ gem 'jquery-rails'
20
+ gem 'inherited_resources'
21
+ gem 'mysql'
22
+ gem "meta_search"
23
+ gem "rails_helpers_fix"
24
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,119 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ abstract (1.0.0)
5
+ actionmailer (3.0.3)
6
+ actionpack (= 3.0.3)
7
+ mail (~> 2.2.9)
8
+ actionpack (3.0.3)
9
+ activemodel (= 3.0.3)
10
+ activesupport (= 3.0.3)
11
+ builder (~> 2.1.2)
12
+ erubis (~> 2.6.6)
13
+ i18n (~> 0.4)
14
+ rack (~> 1.2.1)
15
+ rack-mount (~> 0.6.13)
16
+ rack-test (~> 0.5.6)
17
+ tzinfo (~> 0.3.23)
18
+ activemodel (3.0.3)
19
+ activesupport (= 3.0.3)
20
+ builder (~> 2.1.2)
21
+ i18n (~> 0.4)
22
+ activerecord (3.0.3)
23
+ activemodel (= 3.0.3)
24
+ activesupport (= 3.0.3)
25
+ arel (~> 2.0.2)
26
+ tzinfo (~> 0.3.23)
27
+ activeresource (3.0.3)
28
+ activemodel (= 3.0.3)
29
+ activesupport (= 3.0.3)
30
+ activesupport (3.0.3)
31
+ arel (2.0.4)
32
+ bcrypt-ruby (2.1.2)
33
+ builder (2.1.2)
34
+ cancan (1.4.1)
35
+ devise (1.1.3)
36
+ bcrypt-ruby (~> 2.1.2)
37
+ warden (~> 0.10.7)
38
+ erubis (2.6.6)
39
+ abstract (>= 1.0.0)
40
+ git (1.2.5)
41
+ haml (3.0.24)
42
+ has_scope (0.5.0)
43
+ i18n (0.4.2)
44
+ inherited_resources (1.1.2)
45
+ has_scope (~> 0.5.0)
46
+ responders (~> 0.6.0)
47
+ jeweler (1.5.1)
48
+ bundler (~> 1.0.0)
49
+ git (>= 1.2.5)
50
+ rake
51
+ jquery-rails (0.2.4)
52
+ rails (~> 3.0)
53
+ mail (2.2.10)
54
+ activesupport (>= 2.3.6)
55
+ i18n (~> 0.4.1)
56
+ mime-types (~> 1.16)
57
+ treetop (~> 1.4.8)
58
+ meta_search (0.9.10)
59
+ actionpack (~> 3.0.2)
60
+ activerecord (~> 3.0.2)
61
+ activesupport (~> 3.0.2)
62
+ arel (~> 2.0.2)
63
+ mime-types (1.16)
64
+ mysql (2.8.1)
65
+ nifty-generators (0.4.2)
66
+ paperclip (2.3.6)
67
+ activerecord
68
+ activesupport
69
+ polyglot (0.3.1)
70
+ rack (1.2.1)
71
+ rack-mount (0.6.13)
72
+ rack (>= 1.0.0)
73
+ rack-test (0.5.6)
74
+ rack (>= 1.0)
75
+ rails (3.0.3)
76
+ actionmailer (= 3.0.3)
77
+ actionpack (= 3.0.3)
78
+ activerecord (= 3.0.3)
79
+ activeresource (= 3.0.3)
80
+ activesupport (= 3.0.3)
81
+ bundler (~> 1.0)
82
+ railties (= 3.0.3)
83
+ rails_helpers_fix (0.1.1)
84
+ railties (3.0.3)
85
+ actionpack (= 3.0.3)
86
+ activesupport (= 3.0.3)
87
+ rake (>= 0.8.7)
88
+ thor (~> 0.14.4)
89
+ rake (0.8.7)
90
+ rcov (0.9.9)
91
+ responders (0.6.2)
92
+ shoulda (2.11.3)
93
+ thor (0.14.6)
94
+ treetop (1.4.9)
95
+ polyglot (>= 0.3.1)
96
+ tzinfo (0.3.23)
97
+ warden (0.10.7)
98
+ rack (>= 1.0.0)
99
+ will_paginate (3.0.pre2)
100
+
101
+ PLATFORMS
102
+ ruby
103
+
104
+ DEPENDENCIES
105
+ bundler (~> 1.0.0)
106
+ cancan
107
+ devise (~> 1.1.rc2)
108
+ haml
109
+ inherited_resources
110
+ jeweler (~> 1.5.1)
111
+ jquery-rails
112
+ meta_search
113
+ mysql
114
+ nifty-generators
115
+ paperclip
116
+ rails_helpers_fix
117
+ rcov
118
+ shoulda
119
+ will_paginate (~> 3.0.pre2)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Oldani Pablo
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 ADDED
File without changes
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = squeezer
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to squeezer
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 Oldani Pablo. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "squeezer"
16
+ gem.homepage = "http://github.com/olvap/squeezer"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{i have to learn the meaning of summary}
19
+ gem.description = %Q{an appliaction ready to run}
20
+ gem.email = "magicche@hotmail.com"
21
+ gem.authors = ["Oldani Pablo"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rake/testtask'
30
+ Rake::TestTask.new(:test) do |test|
31
+ test.libs << 'lib' << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+
36
+ require 'rcov/rcovtask'
37
+ Rcov::RcovTask.new do |test|
38
+ test.libs << 'test'
39
+ test.pattern = 'test/**/test_*.rb'
40
+ test.verbose = true
41
+ end
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 = "squeezer #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.3
data/config/routes.rb ADDED
@@ -0,0 +1,26 @@
1
+ Rails.application.routes.draw do |map|
2
+
3
+ resources :blogs
4
+
5
+ resources :comments do
6
+ member do
7
+ get :crear
8
+ get :open
9
+ get :close
10
+ get :remove
11
+ end
12
+ end
13
+
14
+ resources :users do
15
+ member do
16
+ get :roles
17
+ end
18
+ end
19
+
20
+ resources :roles
21
+
22
+ resources :posts
23
+
24
+ resources :pages
25
+
26
+ end
@@ -0,0 +1,25 @@
1
+ # Filters added to this controller apply to all controllers in the application.
2
+ # Likewise, all the methods added will be available for all controllers.
3
+
4
+ class ApplicationController < ActionController::Base
5
+
6
+ protect_from_forgery
7
+ layout 'application'
8
+
9
+ helper_method :site
10
+ helper_method :latests
11
+ helper :squeezer_helper
12
+ def latests
13
+ Blog.paginate :page =>1,:per_page=>5, :order => 'created_at DESC'
14
+ end
15
+
16
+ def site
17
+ return Site.last
18
+ end
19
+
20
+ rescue_from CanCan::AccessDenied do |exception|
21
+ flash[:error] = "Acceso no permitido!"
22
+ redirect_to root_url
23
+ end
24
+
25
+ end
@@ -0,0 +1,19 @@
1
+ class BlogsController < InheritedResources::Base
2
+ load_and_authorize_resource
3
+
4
+ def index
5
+ @blogs = Blog.find(:all,:order=>'created_at desc')
6
+ end
7
+
8
+ def create
9
+ @blog = Blog.new(params[:blog])
10
+ @blog.user =current_user
11
+ if @blog.save
12
+ flash[:notice] = "Successfully created blog."
13
+ redirect_to @blog
14
+ else
15
+ render :action => 'new'
16
+ end
17
+ end
18
+
19
+ end
@@ -0,0 +1,37 @@
1
+ class CommentsController < ApplicationController
2
+ load_and_authorize_resource
3
+
4
+ def show
5
+ time = Time.at(params[:after].to_i + 1)
6
+ @post = Post.where("comment_id = ? and created_at > ?",@comment.id,time)
7
+ end
8
+
9
+ def open
10
+ @comment = Comment.find(params[:id])
11
+ @comment.open=1
12
+ @comment.save
13
+ redirect_to :back
14
+ end
15
+
16
+ def close
17
+ @comment = Comment.find(params[:id])
18
+ @comment.open = false
19
+ @comment.save
20
+ redirect_to :back
21
+ end
22
+
23
+ def new
24
+ @comment = Comment.new
25
+ @comment.commentable_id = params[:id]
26
+ @comment.open = true
27
+ @comment.commentable_type = params[:type]
28
+ @comment.save
29
+ redirect_to :back
30
+ end
31
+
32
+ def remove
33
+ @comment = Comment.find(params[:id])
34
+ @comment.destroy
35
+ redirect_to :back
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ class PagesController < InheritedResources::Base
2
+
3
+ end
@@ -0,0 +1,23 @@
1
+ class PostsController < InheritedResources::Base
2
+ load_and_authorize_resource
3
+
4
+ def edit
5
+ @post = Post.find(params[:id])
6
+ render "comments/edit"
7
+ end
8
+ def create
9
+ @post = Post.new(params[:post])
10
+ @post.user =current_user
11
+ if @post.save
12
+ redirect_to(@post.comment.commentable, :notice => 'Post was successfully created.')
13
+ else
14
+ redirect_to :back
15
+ flash[:error]="Completa todos los datos"
16
+ end
17
+ end
18
+
19
+ def destroy
20
+ @post.destroy
21
+ redirect_to @post.comment.commentable
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ class RolesController < InheritedResources::Base
2
+ load_and_authorize_resource
3
+ end
@@ -0,0 +1,70 @@
1
+ class SitesController < InheritedResources::Base
2
+ load_and_authorize_resource
3
+
4
+ def new
5
+ @files = Dir.open("public/stylesheets/ice")
6
+ @site=site
7
+ if(!@site)
8
+ @site = Site.new
9
+
10
+ respond_to do |format|
11
+ format.html # new.html.erb
12
+ format.xml { render :xml => @site }
13
+ end
14
+ else
15
+ flash[:notice]="el sitio ya fue creado"
16
+
17
+ end
18
+ end
19
+
20
+ # GET /sites/1/edit
21
+ def edit
22
+ if site
23
+ @site = site
24
+ @files = Dir.open("public/stylesheets/ice")
25
+ else
26
+ redirect_to({:action=>new})
27
+ end
28
+ end
29
+
30
+ # POST /sites
31
+ # POST /sites.xml
32
+ def create
33
+ @site = Site.new(params[:site])
34
+ respond_to do |format|
35
+ if @site.save
36
+ flash[:notice] = 'El sitio fue creado'
37
+ format.html { redirect_to(:controller=>"users",:action=>'sign_up') }
38
+ format.xml { render :xml => @site, :status => :created, :location => @site }
39
+ else
40
+ format.html { render :action => "new" }
41
+ format.xml { render :xml => @site.errors, :status => :unprocessable_entity }
42
+ end
43
+ end
44
+ end
45
+
46
+ # PUT /sites/1
47
+ # PUT /sites/1.xml
48
+ def update
49
+ @site = Site.find(params[:id])
50
+
51
+ respond_to do |format|
52
+ if @site.update_attributes(params[:site])
53
+ files = Dir.open("public/stylesheets/ice/#{@site.style}/ice")
54
+ FileUtils.cp_r files ,"app/views/layouts/ice/#{@site.style}"
55
+ flash[:notice] = 'Site was successfully updated.'
56
+ format.html { redirect_to(@site) }
57
+ format.xml { head :ok }
58
+ else
59
+ format.html { render :action => "edit" }
60
+ format.xml { render :xml => @site.errors, :status => :unprocessable_entity }
61
+ end
62
+ end
63
+ end
64
+
65
+ def destroy
66
+ @site = Site.last
67
+ @site.destroy
68
+ redirect_to(@site)
69
+ end
70
+ end
@@ -0,0 +1,22 @@
1
+ class UsersController < ApplicationController
2
+ load_and_authorize_resource
3
+
4
+ def index
5
+ @users = User.all
6
+ end
7
+
8
+ def roles
9
+ end
10
+
11
+ def update
12
+ if !params[:user]
13
+ roles = []
14
+ else
15
+ roles = params[:user][:role_ids]
16
+ end
17
+ flash[:notice]=params[:id]
18
+ @user.update_attributes({:role_ids =>roles})
19
+ redirect_to roles_path
20
+ end
21
+
22
+ end
@@ -0,0 +1,80 @@
1
+ # These helper methods can be called in your template to set variables to be used in the layout
2
+ # This module should be included in all views globally,
3
+ # to do so you may need to add this line to your ApplicationController
4
+ # helper :layout
5
+ module SqueezerHelper
6
+
7
+ require 'digest/md5'
8
+
9
+ def gravatar_url_for(email, options = {})
10
+ image_tag("http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(email)}")
11
+ end
12
+
13
+ def wysiwug
14
+ content_for(:head) { javascript_include_tag('jquery.cleditor.min')}
15
+ content_for(:head) { stylesheet_link_tag('CLEditor1_3_0/jquery.cleditor')}
16
+ raw "<script>$(function(){$('.wysiwyg').cleditor();});</script>"
17
+ end
18
+
19
+ def title(page_title, show_title = true)
20
+ @content_for_title = page_title.to_s
21
+ @show_title = show_title
22
+ end
23
+
24
+ def show_title?
25
+ @show_title
26
+ end
27
+
28
+ def stylesheet(*args)
29
+ content_for(:head) { stylesheet_link_tag(*args) }
30
+ end
31
+
32
+ def javascript(*args)
33
+ content_for(:head) { javascript_include_tag(*args) }
34
+ end
35
+
36
+
37
+
38
+ def link_to(*args, &block)
39
+ if block_given?
40
+ options = args.first || {}
41
+ html_options = args.second
42
+ link_to(capture(&block), options, html_options)
43
+ else
44
+ name = args[0]
45
+ options = args[1] || {}
46
+ html_options = args[2]
47
+
48
+ html_options = convert_options_to_data_attributes(options, html_options)
49
+ url = url_for(options)
50
+
51
+ if (url.split('/').last == url.split('/')[1])
52
+ action ="index"
53
+ else
54
+ action = url.split('/').last
55
+ if action.to_i > 0
56
+ action = "show"
57
+ if args[2]
58
+ if args[2][:method]
59
+ action = "destroy"
60
+ end
61
+ end
62
+ end
63
+ end
64
+ #controller = url.split('/')[1].chop.capitalize
65
+
66
+ href = html_options['href']
67
+ tag_options = tag_options(html_options)
68
+
69
+ href_attr = "href=\"#{ERB::Util.html_escape(url)}\"" unless href
70
+ classes="class='sq-#{action}'"
71
+
72
+ #if(can?(action.to_sym, controller) || controller >="User")
73
+ "<a #{classes} #{href_attr}#{tag_options}>#{ERB::Util.html_escape( name || url)}</a>".html_safe
74
+ #end
75
+
76
+
77
+ end
78
+ end
79
+
80
+ end
@@ -0,0 +1,17 @@
1
+ class Ability
2
+ include CanCan::Ability
3
+
4
+ def initialize(user)
5
+ user ||= User.new # Guest user
6
+ if (user.role?("Admin"))
7
+ can :manage, :all
8
+ else
9
+ can :read, :all
10
+ can :create, Post
11
+ can :update, Post do |comment|
12
+ comment.try(:user) == user
13
+ end
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,5 @@
1
+ class Blog < ActiveRecord::Base
2
+ attr_accessible :title, :body, :user_id
3
+ belongs_to :user
4
+ has_one :comment, :as=>:commentable,:dependent => :destroy
5
+ end
@@ -0,0 +1,4 @@
1
+ class Comment < ActiveRecord::Base
2
+ belongs_to :commentable, :polymorphic =>true
3
+ has_many :posts,:dependent => :destroy
4
+ end
@@ -0,0 +1,3 @@
1
+ class Page < ActiveRecord::Base
2
+ attr_accessible :title, :menu, :body, :user_id
3
+ end
@@ -0,0 +1,13 @@
1
+ class Post < ActiveRecord::Base
2
+ belongs_to :comment
3
+ belongs_to :user
4
+
5
+ validates_presence_of :body
6
+ validates_presence_of :name, :if => :user?
7
+
8
+ def user?
9
+ !user
10
+ end
11
+
12
+ default_scope order("created_at desc")
13
+ end
@@ -0,0 +1,4 @@
1
+ class Role < ActiveRecord::Base
2
+ has_and_belongs_to_many :users
3
+ end
4
+
@@ -0,0 +1,17 @@
1
+ class Site < ActiveRecord::Base
2
+ #validates_attachment_presence :logo
3
+ #validates_attachment_size :logo, :less_than => 5.megabytes
4
+ #validates_attachment_content_type :logo, :content_type => ['image/jpeg', 'image/png']
5
+
6
+ #validates_attachment_presence :icon
7
+ #validates_attachment_size :icon, :less_than => 5.megabytes
8
+ #validates_attachment_content_type :icon, :content_type => ['image/jpeg', 'image/png']
9
+ validates_presence_of :name
10
+ has_attached_file :logo, :styles => { :thumb => "100x100>" },
11
+ :url => "/assets/sites/:id/:style/:basename.:extension",
12
+ :path => ":rails_root/public/assets/sites/:id/:style/:basename.:extension"
13
+
14
+ has_attached_file :icon, :styles => { :small => "10x10>", :thumb => "10x10>" },
15
+ :url => "/assets/sites/:id/:style/:basename.:extension",
16
+ :path => ":rails_root/public/assets/sites/:id/:style/:basename.:extension"
17
+ end
@@ -0,0 +1,37 @@
1
+ class User < ActiveRecord::Base
2
+
3
+ # Include default devise modules. Others available are:
4
+ # :token_authenticatable, :confirmable, :lockable and :timeoutable
5
+ devise :database_authenticatable, :registerable,
6
+ :recoverable, :rememberable, :trackable, :validatable
7
+
8
+ # Setup accessible (or protected) attributes for your model
9
+ attr_accessible :email, :password, :password_confirmation,:username
10
+ # Include default devise modules. Others available are:
11
+ # :token_authenticatable, :confirmable, :lockable and :timeoutable
12
+ devise :database_authenticatable, :registerable,
13
+ :recoverable, :rememberable, :trackable, :validatable
14
+
15
+ # Setup accessible (or protected) attributes for your model
16
+ attr_accessible :email, :password, :password_confirmation,:role_ids,:username
17
+ has_and_belongs_to_many :roles
18
+
19
+ def role #array con los roles del usuario
20
+ roles.map do |role|
21
+ role.name
22
+ end
23
+ end
24
+
25
+ def role?(rol) #true si el usuario tiene el rol
26
+ role.include?(rol)
27
+ end
28
+
29
+ def role_symbols
30
+ roles.map do |role|
31
+ role.name.underscore.to_sym
32
+ end
33
+ end
34
+
35
+ has_many :eventos
36
+
37
+ end