Skip to content

Commit 73d1a8a

Browse files
committed
initial robbin site project
0 parents  commit 73d1a8a

File tree

125 files changed

+11766
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+11766
-0
lines changed

.components

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
:orm: activerecord
3+
:test: minitest
4+
:mock: none
5+
:script: jquery
6+
:renderer: erb
7+
:stylesheet: none
8+
:admin_renderer: erb

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.DS_Store
2+
log
3+
log/**/*
4+
tmp/**/*
5+
bin/*
6+
vendor/gems/*
7+
!vendor/gems/cache/
8+
.sass-cache/*
9+
db/*.db

Gemfile

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
source :rubygems
2+
3+
# Server requirements
4+
gem 'unicorn'
5+
gem 'rainbows'
6+
7+
# Project requirements
8+
gem 'rake'
9+
gem 'padrino', :git => 'git://github.com/padrino/padrino-framework.git'
10+
11+
# Component requirements
12+
gem 'bcrypt-ruby', :require => 'bcrypt'
13+
gem 'erubis', '~> 2.7.0'
14+
gem 'activerecord', :require => 'active_record'
15+
gem 'mysql2'
16+
gem 'dalli'
17+
gem 'kgio'
18+
gem "second_level_cache", :git => "git://github.com/csdn-dev/second_level_cache.git"
19+
gem 'acts-as-taggable-on', :git => "git://github.com/robbin/acts-as-taggable-on.git"
20+
21+
# Development requirements
22+
group :development do
23+
gem 'thin'
24+
gem 'pry'
25+
end
26+
27+
# Test requirements
28+
group :test do
29+
gem 'minitest', "~>2.6.0", :require => "minitest/autorun"
30+
gem 'rack-test', :require => "rack/test"
31+
gem 'factory_girl'
32+
end

Gemfile.lock

+143
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
GIT
2+
remote: git://github.com/csdn-dev/second_level_cache.git
3+
revision: 97005df106c7c41b8af827ed3cb71d478ef23294
4+
specs:
5+
second_level_cache (1.6.0)
6+
activesupport (~> 3.2.0)
7+
8+
GIT
9+
remote: git://github.com/padrino/padrino-framework.git
10+
revision: ff1a437d5b51359d58ae5636adbd73568d97d293
11+
specs:
12+
padrino (0.10.7)
13+
padrino-admin (= 0.10.7)
14+
padrino-cache (= 0.10.7)
15+
padrino-core (= 0.10.7)
16+
padrino-gen (= 0.10.7)
17+
padrino-helpers (= 0.10.7)
18+
padrino-mailer (= 0.10.7)
19+
padrino-admin (0.10.7)
20+
padrino-core (= 0.10.7)
21+
padrino-helpers (= 0.10.7)
22+
padrino-cache (0.10.7)
23+
padrino-core (= 0.10.7)
24+
padrino-core (0.10.7)
25+
activesupport (~> 3.2.0)
26+
http_router (~> 0.10.2)
27+
sinatra (~> 1.3.1)
28+
thor (~> 0.16.0)
29+
tilt (~> 1.3.0)
30+
padrino-gen (0.10.7)
31+
bundler (~> 1.0)
32+
padrino-core (= 0.10.7)
33+
padrino-helpers (0.10.7)
34+
i18n (~> 0.6)
35+
padrino-core (= 0.10.7)
36+
padrino-mailer (0.10.7)
37+
mail (~> 2.5.3)
38+
padrino-core (= 0.10.7)
39+
40+
GIT
41+
remote: git://github.com/robbin/acts-as-taggable-on.git
42+
revision: f52d2b9347a30ce2bdbf4c2d8ad1a7ced7e50d86
43+
specs:
44+
acts-as-taggable-on (2.3.3)
45+
activerecord (~> 3.0)
46+
47+
GEM
48+
remote: http://rubygems.org/
49+
specs:
50+
activemodel (3.2.11)
51+
activesupport (= 3.2.11)
52+
builder (~> 3.0.0)
53+
activerecord (3.2.11)
54+
activemodel (= 3.2.11)
55+
activesupport (= 3.2.11)
56+
arel (~> 3.0.2)
57+
tzinfo (~> 0.3.29)
58+
activesupport (3.2.11)
59+
i18n (~> 0.6)
60+
multi_json (~> 1.0)
61+
arel (3.0.2)
62+
bcrypt-ruby (3.0.1)
63+
builder (3.0.4)
64+
coderay (1.0.8)
65+
daemons (1.1.9)
66+
dalli (2.6.0)
67+
erubis (2.7.0)
68+
eventmachine (1.0.0)
69+
factory_girl (4.1.0)
70+
activesupport (>= 3.0.0)
71+
http_router (0.10.2)
72+
rack (>= 1.0.0)
73+
url_mount (~> 0.2.1)
74+
i18n (0.6.1)
75+
kgio (2.7.4)
76+
mail (2.5.3)
77+
i18n (>= 0.4.0)
78+
mime-types (~> 1.16)
79+
treetop (~> 1.4.8)
80+
method_source (0.8.1)
81+
mime-types (1.19)
82+
minitest (2.6.2)
83+
multi_json (1.5.0)
84+
mysql2 (0.3.11)
85+
polyglot (0.3.3)
86+
pry (0.9.10)
87+
coderay (~> 1.0.5)
88+
method_source (~> 0.8)
89+
slop (~> 3.3.1)
90+
rack (1.4.3)
91+
rack-protection (1.3.2)
92+
rack
93+
rack-test (0.6.2)
94+
rack (>= 1.0)
95+
rainbows (4.4.2)
96+
kgio (~> 2.5)
97+
rack (~> 1.1)
98+
unicorn (~> 4.1)
99+
raindrops (0.10.0)
100+
rake (10.0.3)
101+
sinatra (1.3.3)
102+
rack (~> 1.3, >= 1.3.6)
103+
rack-protection (~> 1.2)
104+
tilt (~> 1.3, >= 1.3.3)
105+
slop (3.3.3)
106+
thin (1.5.0)
107+
daemons (>= 1.0.9)
108+
eventmachine (>= 0.12.6)
109+
rack (>= 1.0.0)
110+
thor (0.16.0)
111+
tilt (1.3.3)
112+
treetop (1.4.12)
113+
polyglot
114+
polyglot (>= 0.3.1)
115+
tzinfo (0.3.35)
116+
unicorn (4.5.0)
117+
kgio (~> 2.6)
118+
rack
119+
raindrops (~> 0.7)
120+
url_mount (0.2.1)
121+
rack
122+
123+
PLATFORMS
124+
ruby
125+
126+
DEPENDENCIES
127+
activerecord
128+
acts-as-taggable-on!
129+
bcrypt-ruby
130+
dalli
131+
erubis (~> 2.7.0)
132+
factory_girl
133+
kgio
134+
minitest (~> 2.6.0)
135+
mysql2
136+
padrino!
137+
pry
138+
rack-test
139+
rainbows
140+
rake
141+
second_level_cache!
142+
thin
143+
unicorn

Rakefile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require File.expand_path('../config/boot.rb', __FILE__)
2+
require 'padrino-core/cli/rake'
3+
PadrinoTasks.init

admin/app.rb

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
class Admin < Padrino::Application
2+
use ActiveRecord::ConnectionAdapters::ConnectionManagement
3+
register Padrino::Rendering
4+
register Padrino::Mailer
5+
register Padrino::Helpers
6+
register Padrino::Admin::AccessControl
7+
8+
##
9+
# Application configuration options
10+
#
11+
# set :raise_errors, true # Raise exceptions (will stop application) (default for test)
12+
# set :dump_errors, true # Exception backtraces are written to STDERR (default for production/development)
13+
# set :show_exceptions, true # Shows a stack trace in browser (default for development)
14+
# set :logging, true # Logging in STDOUT for development and file for production (default only for development)
15+
# set :public_folder, "foo/bar" # Location for static assets (default root/public)
16+
# set :reload, false # Reload application files (default in development)
17+
# set :default_builder, "foo" # Set a custom form builder (default 'StandardFormBuilder')
18+
# set :locale_path, "bar" # Set path for I18n translations (default your_app/locales)
19+
# disable :sessions # Disabled sessions by default (enable if needed)
20+
# disable :flash # Disables sinatra-flash (enabled by default if Sinatra::Flash is defined)
21+
# layout :my_layout # Layout can be in views/layouts/foo.ext or views/foo.ext (default :application)
22+
#
23+
24+
set :admin_model, 'Account'
25+
set :login_page, "/admin/sessions/new"
26+
27+
enable :sessions
28+
disable :store_location
29+
30+
access_control.roles_for :any do |role|
31+
role.protect '/'
32+
role.allow '/sessions'
33+
end
34+
35+
access_control.roles_for :admin do |role|
36+
role.project_module :accounts, '/accounts'
37+
end
38+
39+
breadcrumbs = Padrino::Helpers::Breadcrumb.new
40+
breadcrumbs.set_home '/admin', 'Admin'
41+
set :breadcrumbs, breadcrumbs
42+
43+
end

admin/controllers/accounts.rb

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
Admin.controllers :accounts do
2+
before do
3+
settings.breadcrumbs.reset
4+
settings.breadcrumbs.add :account, url(:accounts, :index), :account
5+
end
6+
7+
get :index do
8+
@accounts = Account.all
9+
render 'accounts/index'
10+
end
11+
12+
get :new do
13+
settings.breadcrumbs.add :account_new , url(:accounts, :new), :new
14+
@account = Account.new
15+
render 'accounts/new'
16+
end
17+
18+
post :create do
19+
@account = Account.new(params[:account])
20+
if @account.save
21+
flash[:notice] = 'Account was successfully created.'
22+
params[:save_and_continue] ? redirect(url(:accounts, :index)) : redirect(url(:accounts, :edit, :id => @account.id))
23+
else
24+
render 'accounts/new'
25+
end
26+
end
27+
28+
get :edit, :with => :id do
29+
settings.breadcrumbs.add :account_edit, params[:id], :edit
30+
@account = Account.find(params[:id])
31+
if @account
32+
render 'accounts/edit'
33+
else
34+
halt 404
35+
end
36+
end
37+
38+
put :update, :with => :id do
39+
@account = Account.find(params[:id])
40+
if @account
41+
if @account.update_attributes(params[:account])
42+
flash[:notice] = 'Account was successfully updated.'
43+
params[:save_and_continue] ? redirect(url(:accounts, :index)) : redirect(url(:accounts, :edit, :id => @account.id))
44+
else
45+
render 'accounts/edit'
46+
end
47+
else
48+
halt 404
49+
end
50+
end
51+
52+
delete :destroy, :with => :id do
53+
account = Account.find(params[:id])
54+
if account
55+
if account != current_account && account.destroy
56+
flash[:notice] = 'Account was successfully destroyed.'
57+
else
58+
flash[:error] = 'Unable to destroy Account!'
59+
end
60+
redirect url(:accounts, :index)
61+
else
62+
halt 404
63+
end
64+
end
65+
66+
delete :delete_multiple do
67+
unless params[:account_ids]
68+
flash[:error] = 'You must select at least one account '
69+
redirect(url(:accounts, :index))
70+
end
71+
accounts = Account.find(params[:account_ids])
72+
if Account.destroy accounts
73+
flash[:notice] = 'accounts have been successfully destroyed.'
74+
end
75+
redirect url(:accounts, :index)
76+
end
77+
end

admin/controllers/base.rb

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Admin.controllers :base do
2+
3+
before do
4+
settings.breadcrumbs.reset
5+
end
6+
7+
get :index, :map => "/" do
8+
render "base/index"
9+
end
10+
end

admin/controllers/sessions.rb

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Admin.controllers :sessions do
2+
3+
get :new do
4+
render "/sessions/new", nil, :layout => false
5+
end
6+
7+
post :create do
8+
if account = Account.authenticate(params[:email], params[:password])
9+
set_current_account(account)
10+
redirect url(:base, :index)
11+
elsif Padrino.env == :development && params[:bypass]
12+
account = Account.first
13+
set_current_account(account)
14+
redirect url(:base, :index)
15+
else
16+
params[:email], params[:password] = h(params[:email]), h(params[:password])
17+
flash[:error] = "Login or password wrong."
18+
redirect url(:sessions, :new)
19+
end
20+
end
21+
22+
delete :destroy do
23+
set_current_account(nil)
24+
redirect url(:sessions, :new)
25+
end
26+
end

0 commit comments

Comments
 (0)