Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
futurechimp committed May 25, 2011
0 parents commit b10f625
Show file tree
Hide file tree
Showing 60 changed files with 5,217 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .components
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
:admin_renderer: erb
:test: shoulda
:script: jquery
:mock: rr
:renderer: erb
:stylesheet: none
:orm: mongoid
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
log/**/*
tmp/**/*
bin/*
vendor/gems/*
!vendor/gems/cache/
.sass-cache/*
30 changes: 30 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
source :rubygems

# Server requirements
# gem 'thin' or mongrel

# Project requirements
gem 'rake'
gem 'rack-flash'
gem 'httparty'

# Component requirements
gem 'bcrypt-ruby', :require => "bcrypt"
gem 'erubis', "~> 2.7.0"
gem 'SystemTimer', :require => "system_timer"
gem 'mongoid'
gem 'bson_ext', :require => "mongo"

# Test requirements
gem 'faker', :group => "test"
gem 'machinist', :group => "test"
gem 'rack-test', :require => "rack/test", :group => "test"
gem 'rr', :group => "test"
gem 'shoulda', :group => "test"
gem 'shoulda-activemodel', :group => "test"


# Padrino
gem 'padrino', "0.9.29"
# Padrino EDGE
# gem 'padrino', :git => "git://github.com/padrino/padrino-framework.git"
109 changes: 109 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
GEM
remote: http://rubygems.org/
specs:
SystemTimer (1.2.3)
activemodel (3.0.7)
activesupport (= 3.0.7)
builder (~> 2.1.2)
i18n (~> 0.5.0)
activesupport (3.0.7)
bcrypt-ruby (2.1.4)
bson (1.3.1)
bson_ext (1.3.1)
builder (2.1.2)
crack (0.1.8)
diff-lcs (1.1.2)
erubis (2.7.0)
faker (0.9.5)
i18n (~> 0.4)
grit (2.4.1)
diff-lcs (~> 1.1)
mime-types (~> 1.15)
http_router (0.7.9)
rack (>= 1.0.0)
url_mount (~> 0.2.1)
httparty (0.6.1)
crack (= 0.1.8)
i18n (0.5.0)
machinist (1.0.6)
mail (2.2.19)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
mongo (1.3.1)
bson (>= 1.3.1)
mongoid (2.0.2)
activemodel (~> 3.0)
mongo (~> 1.3)
tzinfo (~> 0.3.22)
padrino (0.9.29)
padrino-admin (= 0.9.29)
padrino-cache (= 0.9.29)
padrino-core (= 0.9.29)
padrino-gen (= 0.9.29)
padrino-helpers (= 0.9.29)
padrino-mailer (= 0.9.29)
padrino-admin (0.9.29)
padrino-core (= 0.9.29)
padrino-helpers (= 0.9.29)
padrino-cache (0.9.29)
padrino-core (= 0.9.29)
padrino-core (0.9.29)
activesupport (>= 3.0.0)
http_router (~> 0.7.8)
sinatra (~> 1.2.6)
thor (>= 0.14.3)
tilt (~> 1.3.0)
padrino-gen (0.9.29)
bundler (>= 1.0.2)
grit
padrino-core (= 0.9.29)
padrino-helpers (0.9.29)
i18n (>= 0.4.1)
padrino-core (= 0.9.29)
padrino-mailer (0.9.29)
mail (>= 2.2.0)
padrino-core (= 0.9.29)
polyglot (0.3.1)
rack (1.3.0)
rack-flash (0.1.1)
rack
rack-test (0.5.7)
rack (>= 1.0)
rake (0.9.0)
rr (1.0.2)
shoulda (2.11.3)
shoulda-activemodel (0.0.2)
shoulda (>= 2.11.0)
sinatra (1.2.6)
rack (~> 1.1)
tilt (>= 1.2.2, < 2.0)
thor (0.14.6)
tilt (1.3.1)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.27)
url_mount (0.2.1)
rack

PLATFORMS
ruby

DEPENDENCIES
SystemTimer
bcrypt-ruby
bson_ext
erubis (~> 2.7.0)
faker
httparty
machinist
mongoid
padrino (= 0.9.29)
rack-flash
rack-test
rake
rr
shoulda
shoulda-activemodel
37 changes: 37 additions & 0 deletions admin/app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
class Admin < Padrino::Application
register Padrino::Mailer
register Padrino::Helpers
register Padrino::Admin::AccessControl

##
# Application configuration options
#
# set :raise_errors, true # Raise exceptions (will stop application) (default for test)
# set :dump_errors, true # Exception backtraces are written to STDERR (default for production/development)
# set :show_exceptions, true # Shows a stack trace in browser (default for development)
# set :logging, true # Logging in STDOUT for development and file for production (default only for development)
# set :public, "foo/bar" # Location for static assets (default root/public)
# set :reload, false # Reload application files (default in development)
# set :default_builder, "foo" # Set a custom form builder (default 'StandardFormBuilder')
# set :locale_path, "bar" # Set path for I18n translations (default your_app/locales)
# disable :sessions # Disabled sessions by default (enable if needed)
# disable :flash # Disables rack-flash (enabled by default if Rack::Flash is defined)
# layout :my_layout # Layout can be in views/layouts/foo.ext or views/foo.ext (default :application)
#

set :login_page, "/admin/sessions/new"

enable :sessions
disable :store_location

access_control.roles_for :any do |role|
role.protect "/"
role.allow "/sessions"
end

access_control.roles_for :admin do |role|
role.project_module :wires, "/wires"
role.project_module :feeds, "/feeds"
role.project_module :accounts, "/accounts"
end
end
47 changes: 47 additions & 0 deletions admin/controllers/accounts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Admin.controllers :accounts do

get :index do
@accounts = Account.all
render 'accounts/index'
end

get :new do
@account = Account.new
render 'accounts/new'
end

post :create do
@account = Account.new(params[:account])
if @account.save
flash[:notice] = 'Account was successfully created.'
redirect url(:accounts, :edit, :id => @account.id)
else
render 'accounts/new'
end
end

get :edit, :with => :id do
@account = Account.find(params[:id])
render 'accounts/edit'
end

put :update, :with => :id do
@account = Account.find(params[:id])
if @account.update_attributes(params[:account])
flash[:notice] = 'Account was successfully updated.'
redirect url(:accounts, :edit, :id => @account.id)
else
render 'accounts/edit'
end
end

delete :destroy, :with => :id do
account = Account.find(params[:id])
if account != current_account && account.destroy
flash[:notice] = 'Account was successfully destroyed.'
else
flash[:error] = 'Impossible destroy Account!'
end
redirect url(:accounts, :index)
end
end
6 changes: 6 additions & 0 deletions admin/controllers/base.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Admin.controllers :base do

get :index, :map => "/" do
render "base/index"
end
end
47 changes: 47 additions & 0 deletions admin/controllers/feeds.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Admin.controllers :feeds do

get :index do
@feeds = Feed.all
render 'feeds/index'
end

get :new do
@feed = Feed.new
render 'feeds/new'
end

post :create do
@feed = Feed.new(params[:feed])
if @feed.save
flash[:notice] = 'Feed was successfully created.'
redirect url(:feeds, :edit, :id => @feed.id)
else
render 'feeds/new'
end
end

get :edit, :with => :id do
@feed = Feed.find(params[:id])
render 'feeds/edit'
end

put :update, :with => :id do
@feed = Feed.find(params[:id])
if @feed.update_attributes(params[:feed])
flash[:notice] = 'Feed was successfully updated.'
redirect url(:feeds, :edit, :id => @feed.id)
else
render 'feeds/edit'
end
end

delete :destroy, :with => :id do
feed = Feed.find(params[:id])
if feed.destroy
flash[:notice] = 'Feed was successfully destroyed.'
else
flash[:error] = 'Impossible destroy Feed!'
end
redirect url(:feeds, :index)
end
end
25 changes: 25 additions & 0 deletions admin/controllers/sessions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Admin.controllers :sessions do

get :new do
render "/sessions/new", nil, :layout => false
end

post :create do
if account = Account.authenticate(params[:email], params[:password])
set_current_account(account)
redirect url(:base, :index)
elsif Padrino.env == :development && params[:bypass]
account = Account.first
set_current_account(account)
redirect url(:base, :index)
else
flash[:warning] = "Login or password wrong."
redirect url(:sessions, :new)
end
end

delete :destroy do
set_current_account(nil)
redirect url(:sessions, :new)
end
end
47 changes: 47 additions & 0 deletions admin/controllers/wires.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Admin.controllers :wires do

get :index do
@wires = Wire.all
render 'wires/index'
end

get :new do
@wire = Wire.new
render 'wires/new'
end

post :create do
@wire = Wire.new(params[:wire])
if @wire.save
flash[:notice] = 'Wire was successfully created.'
redirect url(:wires, :edit, :id => @wire.id)
else
render 'wires/new'
end
end

get :edit, :with => :id do
@wire = Wire.find(params[:id])
render 'wires/edit'
end

put :update, :with => :id do
@wire = Wire.find(params[:id])
if @wire.update_attributes(params[:wire])
flash[:notice] = 'Wire was successfully updated.'
redirect url(:wires, :edit, :id => @wire.id)
else
render 'wires/edit'
end
end

delete :destroy, :with => :id do
wire = Wire.find(params[:id])
if wire.destroy
flash[:notice] = 'Wire was successfully destroyed.'
else
flash[:error] = 'Impossible destroy Wire!'
end
redirect url(:wires, :index)
end
end
Loading

0 comments on commit b10f625

Please sign in to comment.