Skip to content
This repository has been archived by the owner on Aug 14, 2018. It is now read-only.

Commit

Permalink
First pass at turning bumble into a rails 3 engine
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew committed Jun 5, 2011
1 parent fcfc699 commit 2bc156a
Show file tree
Hide file tree
Showing 156 changed files with 293 additions and 6,772 deletions.
19 changes: 3 additions & 16 deletions Gemfile
@@ -1,17 +1,4 @@
source :rubygems
source "http://rubygems.org"

gem 'rails', '3.0.4'
gem 'will_paginate', '~>3.0.pre2'
gem 'gravtastic', '~>2.1.3'
gem 'authlogic', '~>2.1.1'
gem 'rdiscount'
gem 'haml', '~>3.0.0'
gem 'texticle'
gem 'paperclip', '2.3.4'
gem 'pg'
gem 'aws-s3'
gem 'permalink_fu'

group :production do
gem 'hassle', :git => 'git://github.com/koppen/hassle.git'
end
# Specify your gem's dependencies in bumble.gemspec
gemspec
107 changes: 0 additions & 107 deletions Gemfile.lock

This file was deleted.

25 changes: 0 additions & 25 deletions README

This file was deleted.

8 changes: 1 addition & 7 deletions Rakefile
@@ -1,7 +1 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)
require 'rake'

Bumble::Application.load_tasks
require 'bundler/gem_tasks'
3 changes: 3 additions & 0 deletions Readme.mdown
@@ -0,0 +1,3 @@
# Bumble

Blogging plugin provided as a rails engine
@@ -1,4 +1,4 @@
class ApplicationController < ActionController::Base
class BumbleController < ActionController::Base
protect_from_forgery

helper_method :current_user_session, :current_user, :iphone?
Expand Down
128 changes: 80 additions & 48 deletions app/controllers/comments_controller.rb
@@ -1,67 +1,99 @@
class CommentsController < ApplicationController
class CommentsController < BumbleController

before_filter :require_user, :only => [:edit, :update, :destroy]

make_resourceful do
actions :all
belongs_to :post
before :create do
current_object.user = current_user
end

response_for :index do |format|
format.html { redirect_to post_path(parent_object, :anchor => 'comments') }
format.atom {}
format.js { render current_objects }
end
def create
@post = Post.find(params[:post_id])
@comment = Comment.new(params[:comment])
@comment.user = current_user
@comment.request = request
@comment.post = @post

response_for :show do |format|
format.html { redirect_to post_path(parent_object, :anchor => dom_id(current_object)) }
end

response_for :destroy do |format|
format.html do
flash[:notice] = 'Record deleted!'
redirect_to post_path(parent_object)
end
end

response_for :update do |format|
format.html do
flash[:notice] = 'Save successful!'
redirect_to post_path(parent_object, :anchor => dom_id(current_object))
if @comment.save
respond_to do |format|
format.html do
if @comment.approved?
flash[:notice] = 'Create successful!'
else
flash[:notice] = "Your comment looks like spam, it will show up once it's been approved."
end
redirect_to post_path(@post, :anchor => dom_id(@comment))
end
format.js do
if @comment.approved?
render @comment, :content_type => :html
else
render :text => "Your comment looks like spam, it will show up once it's been approved.", :status => 406, :content_type => :html
end
end
end
end

response_for :create do |format|
format.html do
flash[:notice] = 'Create successful!'
redirect_to post_path(parent_object, :anchor => dom_id(current_object))
else
respond_to do |format|
format.html { render :action => "new" }
format.js { render :text => @comment.errors.full_messages.join(', ').capitalize, :status => 403, :content_type => :html }
end
format.js { render current_object, :content_type => :html }
end

response_for :create_fails do |format|
format.html { render :action => "new" }
format.js { render :text => current_object.errors.full_messages.join(', ').capitalize, :status => 403, :content_type => :html }
end

def index
@post = Post.find(params[:post_id])
@comments = @post.comments
respond_to do |format|
format.html { redirect_to post_path(@post, :anchor => 'comments') }
format.atom {}
format.js { render @comments }
end

response_for :destroy do |format|
end

def destroy
@comment = Comment.find(params[:id])
@comment.destroy
respond_to do |format|
format.html do
flash[:notice] = 'Record deleted!'
redirect_to post_path(current_object.post)
redirect_to post_path(@comment.post)
end
format.js { render :nothing => true }
end
end

def update
@post = Post.find(params[:post_id])
@comment = Comment.find(params[:id])
if @comment.update_attributes(params[:comment])
respond_to do |format|
format.html do
flash[:notice] = 'Save successful!'
redirect_to post_path(@post, :anchor => dom_id(@comment))
end
end
else
render :action => 'edit'
end
end

def edit
@comment = Comment.find(params[:id])
end

def new
@comment = Comment.new
end

private
def show
@comment = Comment.find(params[:id])
redirect_to post_path(@comment.post, :anchor => dom_id(@comment))
end

def parent_model
current_user ? super : Post.published.all_public
def approve
@comment = Comment.find(params[:id])
@comment.mark_as_ham!
redirect_to post_path(@comment.post, :anchor => dom_id(@comment))
end

def parent_object
@parent_object ||= parent_model.find_by_permalink_or_id(params["#{parent_name}_id"])
def reject
@comment = Comment.find(params[:id])
@comment.mark_as_spam!
redirect_to post_path(@comment.post, :anchor => dom_id(@comment))
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/password_resets_controller.rb
@@ -1,4 +1,4 @@
class PasswordResetsController < ApplicationController
class PasswordResetsController < BumbleController
before_filter :load_user_using_perishable_token, :only => [:edit, :update]

def create
Expand Down

0 comments on commit 2bc156a

Please sign in to comment.