Permalink
Browse files

Removed assets and added new ones plus apt of features

Blogs, Comments and a vast amount of work on authentication,
authorisation, cancan 2.0 and sorcery, and cleaning up my mess to get
it working
  • Loading branch information...
safarista committed May 27, 2012
1 parent aa8bbe1 commit 6d05d59aac5727e98721035b5c26fbdeb0f415fb
Showing with 1,287 additions and 696 deletions.
  1. +1 −1 Gemfile
  2. +8 −2 Gemfile.lock
  3. +3 −0 app/assets/javascripts/comments.js.coffee
  4. +3 −0 app/assets/javascripts/posts.js.coffee
  5. +30 −4 app/assets/stylesheets/bootstrap_and_overrides.css.less
  6. +3 −0 app/assets/stylesheets/posts.css.scss
  7. +4 −1 app/controllers/application_controller.rb
  8. +102 −0 app/controllers/comments_controller.rb
  9. +0 −1 app/controllers/destinations_controller.rb
  10. +1 −2 app/controllers/home_controller.rb
  11. +92 −0 app/controllers/posts_controller.rb
  12. +11 −0 app/controllers/safaris_controller.rb
  13. +1 −1 app/controllers/sessions_controller.rb
  14. +8 −1 app/controllers/welcome_controller.rb
  15. +2 −0 app/helpers/comments_helper.rb
  16. +2 −0 app/helpers/posts_helper.rb
  17. +17 −18 app/models/ability.rb
  18. +8 −0 app/models/album.rb
  19. +10 −0 app/models/beach.rb
  20. +7 −0 app/models/comment.rb
  21. +9 −0 app/models/day_trip.rb
  22. +9 −0 app/models/destination.rb
  23. +11 −0 app/models/photo.rb
  24. +25 −0 app/models/post.rb
  25. +10 −0 app/models/safari.rb
  26. +11 −0 app/models/trek.rb
  27. +16 −9 app/models/user.rb
  28. +2 −0 app/views/albums/index.html.erb
  29. +16 −14 app/views/albums/show.html.erb
  30. +6 −3 app/views/beaches/index.html.erb
  31. +47 −40 app/views/beaches/show.html.erb
  32. +44 −0 app/views/comments/_form.html.erb
  33. +3 −0 app/views/comments/edit.html.erb
  34. +36 −0 app/views/comments/index.html.erb
  35. +4 −0 app/views/comments/new.html.erb
  36. +25 −0 app/views/comments/show.html.erb
  37. +6 −3 app/views/day_trips/index.html.erb
  38. +46 −37 app/views/day_trips/show.html.erb
  39. +74 −1 app/views/home/index.html.erb
  40. +5 −0 app/views/layouts/_footer.html.erb
  41. +35 −19 app/views/layouts/_header.html.erb
  42. +12 −13 app/views/layouts/application.html.erb
  43. +6 −3 app/views/photos/index.html.erb
  44. +13 −10 app/views/photos/show.html.erb
  45. +47 −0 app/views/posts/_form.html.erb
  46. +4 −0 app/views/posts/edit.html.erb
  47. +21 −0 app/views/posts/index.html.erb
  48. +4 −0 app/views/posts/new.html.erb
  49. +106 −0 app/views/posts/show.html.erb
  50. +6 −3 app/views/safaris/index.html.erb
  51. +47 −38 app/views/safaris/show.html.erb
  52. +19 −0 app/views/sessions/new.html.erb
  53. +6 −4 app/views/treks/index.html.erb
  54. +48 −38 app/views/treks/show.html.erb
  55. +33 −14 app/views/users/_form.html.erb
  56. +7 −3 app/views/users/index.html.erb
  57. +15 −27 app/views/users/show.html.erb
  58. +6 −1 config/routes.rb
  59. +1 −1 db/migrate/20120525134514_sorcery_core.rb
  60. +14 −0 db/migrate/20120526105427_create_posts.rb
  61. +18 −0 db/migrate/20120526112714_add_slug_and_index_to_safaris.rb
  62. +18 −0 db/migrate/20120526115216_create_friendly_id_slugs.rb
  63. +18 −0 db/migrate/20120526225413_create_comments.rb
  64. +53 −2 db/schema.rb
  65. +1 −1 ...pplication-e8c6a40e993ef6eb6203621f6d3c3c58.js → application-4c366c2cf1e575e9339376f8afa673e0.js}
  66. BIN public/assets/{application.js.gz → application-4c366c2cf1e575e9339376f8afa673e0.js.gz}
  67. +1 −1 ...lication-b6e11ac4d2aa1a1d20f0a17990d75070.css → application-929f265990534495556f2ff82fbac689.css}
  68. BIN ...on-b6e11ac4d2aa1a1d20f0a17990d75070.css.gz → application-929f265990534495556f2ff82fbac689.css.gz}
  69. BIN public/assets/application-e8c6a40e993ef6eb6203621f6d3c3c58.js.gz
  70. +0 −1 public/assets/application.css
  71. BIN public/assets/application.css.gz
  72. +0 −19 public/assets/application.js
  73. +0 −175 public/assets/fontawesome-webfont-8276485587c7ff2e54d7422809134349.svg
  74. BIN public/assets/fontawesome-webfont-a01aacd973fb4d032729f9c498683caa.ttf
  75. BIN public/assets/fontawesome-webfont-b6a0f80a39a7f60a250fad1e8e2ecf8b.woff
  76. BIN public/assets/fontawesome-webfont-d5b0cb5aed6480abcf670ba04f391ad3.svgz
  77. BIN public/assets/fontawesome-webfont-eeecec082197cc0255b0c549b4e612ea.eot
  78. BIN public/assets/fontawesome-webfont.eot
  79. +0 −175 public/assets/fontawesome-webfont.svg
  80. BIN public/assets/fontawesome-webfont.svgz
  81. BIN public/assets/fontawesome-webfont.ttf
  82. BIN public/assets/fontawesome-webfont.woff
  83. +0 −10 public/assets/manifest.yml
  84. BIN public/assets/twitter/bootstrap/glyphicons-halflings-2ed0cba6eca0f44737ab78f1e58bc11e.png
  85. BIN public/assets/twitter/bootstrap/glyphicons-halflings-white-4fbb6a0b9b4e61912f486ac494a858f1.png
  86. BIN public/assets/twitter/bootstrap/glyphicons-halflings-white.png
  87. BIN public/assets/twitter/bootstrap/glyphicons-halflings.png
  88. +10 −0 test/unit/ability_test.rb
View
@@ -44,7 +44,7 @@ gem 'bcrypt-ruby', '~> 3.0.0'
# Authentication and Authorisation
gem 'sorcery'
-gem 'cancan'
+gem "cancan", git: "git://github.com/ryanb/cancan.git", branch: "2.0"
# SEO and text formatting
gem 'friendly_id'
View
@@ -1,3 +1,10 @@
+GIT
+ remote: git://github.com/ryanb/cancan.git
+ revision: ccd24ab30fdd0b48ac0ad71080445f5366788208
+ branch: 2.0
+ specs:
+ cancan (2.0.0.alpha)
+
GIT
remote: git://github.com/seyhunak/twitter-bootstrap-rails.git
revision: eb348d89373bd3828848887bc0f7c3a6aed236d9
@@ -41,7 +48,6 @@ GEM
arel (3.0.2)
bcrypt-ruby (3.0.1)
builder (3.0.0)
- cancan (1.6.7)
carrierwave (0.6.2)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
@@ -174,7 +180,7 @@ PLATFORMS
DEPENDENCIES
bcrypt-ruby (~> 3.0.0)
- cancan
+ cancan!
carrierwave
coffee-rails (~> 3.2.1)
fog
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
@@ -114,13 +114,39 @@ color: #999;
font-weight: 300;
}
+// @media (max-width: 1015px) amd (min-width: 980px){
+// .jumbotron h1{
+// font-size: 42px;
+// }
+// .jumbotron p {
+// margin-right: 0;
+// margin-left: 0;
+// font-size:18px;
+// line-height:24px;
+// }
+// .jumbotron .btn {
+// margin-bottom: 10px;
+// font-size: 18px;
+// padding: 10px 14px;
+// margin: 0 auto 10px;
+// }
+// }
@media (max-width: 980px) and (min-width: 768px) {
.jumbotron h1{
- font-size: 62px;
+ font-size: 52px;
+ }
+ .jumbotron p {
+ margin-right: 0;
+ margin-left: 0;
+ font-size:18px;
+ line-height:24px;
}
.jumbotron .btn {
margin-bottom: 10px;
+ font-size: 18px;
+ padding: 10px 14px;
+ margin: 0 auto 10px;
}
}
@@ -141,18 +167,18 @@ color: #999;
@media (max-width: 480px){
.jumbotron h1{
- font-size: 45px;
+ font-size: 35px;
margin-right: 0;
}
.jumbotron p{
margin-right:0;
margin-left:0;
- font-size:18px;
+ font-size:16px;
line-height:24px;
}
.jumbotron .btn {
display: block;
- font-size: 18px;
+ font-size: 16px;
padding: 10px 14px;
margin: 0 auto 10px;
}
@@ -0,0 +1,3 @@
+// Place all the styles related to the posts controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
@@ -1,10 +1,13 @@
class ApplicationController < ActionController::Base
protect_from_forgery
+
before_filter :require_login
- load_and_authorize_resource
+ enable_authorization
+
protected
def not_authenticated
redirect_to root_path, :alert => "Please login first."
end
+
end
@@ -0,0 +1,102 @@
+class CommentsController < ApplicationController
+ skip_before_filter :require_login
+ # load_and_authorize_resource :post
+ # load_and_authorize_resource :comments, :through => :post
+ #
+ # skip_load_and_authorize_resource :only => :show
+ # skip_load_and_authorize_resource :post, :only => :show
+
+ # GET /comments
+ # GET /comments.json
+ def index
+ @post = Post.try(:find, params[:post_id])
+ @comments = @post.comments
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @comments }
+ end
+ end
+
+ # GET /comments/1
+ # GET /comments/1.json
+ def show
+ @post = Post.try(:find, params[:post_id])
+ @comment = @post.comments.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @comment }
+ end
+ end
+
+ # GET /comments/new
+ # GET /comments/new.json
+ def new
+ @post = Post.try(:find, params[:post_id])
+ @comment = @post.comments.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @comment }
+ end
+ end
+
+ # GET /comments/1/edit
+ def edit
+ @post = Post.try(:find, params[:post_id])
+ @comment = @post.comments.find(params[:id])
+ end
+
+ # POST /comments
+ # POST /comments.json
+ def create
+ @post = Post.try(:find, params[:post_id])
+ @comment = @post.comments.create!(params[:comment])
+ @comment.ip_address_info = request.remote_ip
+
+ if logged_in?
+ @comment.commenter = current_user.full_name
+ @comment.comment_email = current_user.email
+ end
+
+ respond_to do |format|
+ if @comment.save
+ format.html { redirect_to @post, notice: 'Comment was successfully created.' }
+ format.json { render json: @comment, status: :created, location: @comment }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @comment.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /comments/1
+ # PUT /comments/1.json
+ def update
+ @post = Post.try(:find, params[:post_id])
+ @comment = @post.comments.find(params[:id])
+
+ respond_to do |format|
+ if @comment.update_attributes(params[:comment])
+ format.html { redirect_to @post, notice: 'Comment was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @comment.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /comments/1
+ # DELETE /comments/1.json
+ def destroy
+ @comment = Comment.find(params[:id])
+ @comment.destroy
+
+ respond_to do |format|
+ format.html { redirect_to comments_url }
+ format.json { head :no_content }
+ end
+ end
+end
@@ -1,5 +1,4 @@
class DestinationsController < ApplicationController
- skip_load_and_authorize_resource :only => [:index, :show]
before_filter :find_destineable
respond_to :html
# GET /destinations
@@ -1,8 +1,7 @@
class HomeController < ApplicationController
skip_before_filter :require_login
- skip_load_and_authorize_resource :only => :index
def index
@title = 'Welcome to Bless Africa Safaris and Tours Tanzania'
- @album = Album.try(:first)
+ @album = Album.try(:find, 2)
end
end
@@ -0,0 +1,92 @@
+class PostsController < ApplicationController
+ skip_before_filter :require_login
+ # GET /posts
+ # GET /posts.json
+ def index
+ if can? :access, :posts
+ @posts = Post.order("posts.published DESC")
+ else
+ @posts = Post.where("posts.published IS NOT NULL" ).order("posts.published DESC")
+ end
+
+ respond_to do |format|
+ format.html # index.html.erb
+ end
+ end
+
+ # GET /posts/1
+ # GET /posts/1.json
+ def show
+ @post = Post.find(params[:id])
+ @comments = @post.comments
+ @comment = Comment.new
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @post }
+ end
+ end
+
+ # GET /posts/new
+ # GET /posts/new.json
+ def new
+ @post = Post.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @post }
+ end
+ end
+
+ # GET /posts/1/edit
+ def edit
+ @post = Post.try(:find, params[:id])
+ end
+
+ # POST /posts
+ # POST /posts.json
+ def create
+ @post = current_user.posts.new(params[:post])
+ @post.ip_address_info = request.remote_ip
+ @post.published = Time.now unless !params[:post][:published] == '1'
+ respond_to do |format|
+ if @post.save
+ format.html { redirect_to @post, notice: 'Post was successfully created.' }
+ format.json { render json: @post, status: :created, location: @post }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @post.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /posts/1
+ # PUT /posts/1.json
+ def update
+ @post = Post.try(:find, params[:id])
+ @post.published = Time.now # if !params[:post][:published].blank?
+
+
+ respond_to do |format|
+ if @post.update_attributes(params[:post])
+ format.html { redirect_to @post, notice: 'Post was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @post.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /posts/1
+ # DELETE /posts/1.json
+ def destroy
+ @post = Post.find(params[:id])
+ @post.destroy
+
+ respond_to do |format|
+ format.html { redirect_to posts_url }
+ format.json { head :no_content }
+ end
+ end
+end
@@ -1,5 +1,11 @@
class SafarisController < ApplicationController
+ # # Filters and Authorization
skip_before_filter :require_login, :only => [:index, :show]
+
+ # load_and_authorize_resource :safari # no customization needed here
+ # load_and_authorize_resource :destination, :through => :safari
+ # before_filter :authorize_parent
+
# GET /safaris
# GET /safaris.json
def index
@@ -81,4 +87,9 @@ def destroy
format.json { head :no_content }
end
end
+
+ private
+ # def authorize_parent
+ # authorize! :read, @safari
+ # end
end
@@ -19,6 +19,6 @@ def create
def destroy
logout
- redirect_to(:users, :notice => 'Logged out!')
+ redirect_to(:root, :notice => 'Logged out!')
end
end
Oops, something went wrong.

0 comments on commit 6d05d59

Please sign in to comment.