Skip to content

Commit

Permalink
c
Browse files Browse the repository at this point in the history
  • Loading branch information
Stepan Boltalin committed Mar 13, 2012
1 parent 739b2c0 commit 8d77cf6
Show file tree
Hide file tree
Showing 38 changed files with 744 additions and 7 deletions.
76 changes: 76 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,79 @@
# Ignore all logfiles and tempfiles.
/log/*.log
/tmp
# Rails
.bundle
db/*.sqlite3
db/*.sqlite3-journal
*.log
tmp
tmp/**/*

# Documentation
doc/api
doc/app
.yardoc
.yardopts
coverage

# Public Uploads
public/system/*
public/themes/*

# Public Cache
public/javascripts/cache
public/stylesheets/cache

# Vendor Cache
vendor/cache

# Acts as Indexed
index/**/*

# Refinery Specific
*.tmproj
*.autobackupbyrefinery.*
refinerycms-*.gem

# Mac
.DS_Store

# Windows
Thumbs.db

# NetBeans
nbproject

# Eclipse
.project

# Redcar
.redcar

# Rubinius
*.rbc

# Vim
*.swp
*.swo

# RubyMine
.idea

# E-texteditor
.eprj

# Backup
*~

# Capybara Bug
capybara-*html

# sass
.sass-cache
.sass-cache/*

#rvm
.rvmrc
.rvmrc.*

12 changes: 11 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@ gem 'rails', '3.2.2'
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'

gem 'devise'
gem 'refinerycms-core'#, :git => 'git://github.com/resolve/refinerycms.git'
gem 'refinerycms-dashboard'#, :git => 'git://github.com/resolve/refinerycms.git'
gem 'refinerycms-images'#, :git => 'git://github.com/resolve/refinerycms.git'
gem 'refinerycms-pages'#, :git => 'git://github.com/resolve/refinerycms.git'
gem 'refinerycms-resources'#, :git => 'git://github.com/resolve/refinerycms.git'
gem 'refinerycms-settings'#, :git => 'git://github.com/parndt/refinerycms-settings.git'
# gem 'refinerycms-generators'#, :git

group :development, :test do
# gem 'refinerycms-testing', :git => 'git://github.com/resolve/refinerycms.git'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
Expand Down
52 changes: 52 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ GEM
activesupport (3.2.2)
i18n (~> 0.6)
multi_json (~> 1.0)
acts_as_indexed (0.7.7)
arel (3.0.2)
awesome_nested_set (2.1.2)
activerecord (>= 3.0.0)
babosa (0.3.7)
bcrypt-ruby (3.0.1)
builder (3.0.0)
coffee-rails (3.2.2)
Expand All @@ -43,9 +47,16 @@ GEM
orm_adapter (~> 0.0.3)
railties (~> 3.1)
warden (~> 1.1.1)
dragonfly (0.9.11)
rack
erubis (2.7.0)
execjs (1.3.0)
multi_json (~> 1.0)
friendly_id (4.0.2)
globalize3 (0.2.0)
activemodel (>= 3.0.0)
activerecord (>= 3.0.0)
paper_trail (~> 2)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.3)
Expand All @@ -60,6 +71,8 @@ GEM
mime-types (1.17.2)
multi_json (1.1.0)
orm_adapter (0.0.6)
paper_trail (2.6.2)
rails (~> 3)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
Expand All @@ -86,11 +99,42 @@ GEM
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
refinerycms-core (2.0.1)
acts_as_indexed (~> 0.7.7)
awesome_nested_set (~> 2.1.0)
coffee-rails (~> 3.2.1)
friendly_id (~> 4.0.1)
globalize3 (~> 0.2.0)
jquery-rails (~> 2.0.0)
rails (>= 3.1.3, < 3.3)
sass-rails (~> 3.2.3)
truncate_html (~> 0.5)
uglifier (>= 1.0.3)
will_paginate (~> 3.0.2)
refinerycms-dashboard (2.0.1)
refinerycms-core (= 2.0.1)
refinerycms-images (2.0.1)
dragonfly (~> 0.9.8)
rack-cache (>= 0.5.3)
refinerycms-core (= 2.0.1)
refinerycms-pages (2.0.1)
awesome_nested_set (~> 2.1.0)
babosa (!= 0.3.6)
refinerycms-core (= 2.0.1)
seo_meta (~> 1.2.0)
refinerycms-resources (2.0.1)
dragonfly (~> 0.9.8)
rack-cache (>= 0.5.3)
refinerycms-core (= 2.0.1)
refinerycms-settings (2.0.1)
refinerycms-core (~> 2.0.1)
sass (3.1.15)
sass-rails (3.2.4)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
seo_meta (1.2.0)
railties (>= 3.0.0)
sprockets (2.1.2)
hike (~> 1.2)
rack (~> 1.0)
Expand All @@ -101,12 +145,14 @@ GEM
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
truncate_html (0.5.4)
tzinfo (0.3.32)
uglifier (1.2.3)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
warden (1.1.1)
rack (>= 1.0)
will_paginate (3.0.3)

PLATFORMS
ruby
Expand All @@ -116,6 +162,12 @@ DEPENDENCIES
devise
jquery-rails
rails (= 3.2.2)
refinerycms-core
refinerycms-dashboard
refinerycms-images
refinerycms-pages
refinerycms-resources
refinerycms-settings
sass-rails (~> 3.2.3)
sqlite3
uglifier (>= 1.0.3)
6 changes: 6 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
class ApplicationController < ActionController::Base
protect_from_forgery

def show_welcome_page?
#overriding refinery initialization wizard behavior, so unpopulated test
#database will successfully run.
false
end
end
2 changes: 2 additions & 0 deletions app/controllers/passwords_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class PasswordsController < Devise::SessionsController
end
2 changes: 2 additions & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class SessionsController < Devise::SessionsController
end
2 changes: 2 additions & 0 deletions app/controllers/users/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Users::UsersController < Devise::UsersController
end
2 changes: 2 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class UsersController < Devise::SessionsController
end
Empty file.
Empty file.
15 changes: 15 additions & 0 deletions app/models/role.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Role < Refinery::Core::BaseModel
# TODO: This works around a bug in rails habtm with namespaces.
has_and_belongs_to_many :users, :join_table => :roles_users

before_validation :camelize_title
validates :title, :uniqueness => true

def camelize_title(role_title = self.title)
self.title = role_title.to_s.camelize
end

def self.[](title)
find_or_create_by_title(title.to_s.camelize)
end
end
4 changes: 4 additions & 0 deletions app/models/roles_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class RolesUsers < Refinery::Core::BaseModel
belongs_to :role
belongs_to :user
end
37 changes: 35 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,42 @@
class User < ActiveRecord::Base
class User < Refinery::Core::BaseModel
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable

# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
end
has_and_belongs_to_many :roles, :join_table => :roles_users
has_many :plugins, :class_name => "UserPlugin", :order => "position ASC", :dependent => :destroy

def plugins=(plugin_names)
if persisted? # don't add plugins when the user_id is nil.
UserPlugin.delete_all(:user_id => id)

plugin_names.each_with_index do |plugin_name, index|
plugins.create(:name => plugin_name, :position => index) if plugin_name.is_a?(String)
end
end
end

def authorized_plugins
plugins.collect { |p| p.name } | ::Refinery::Plugins.always_allowed.names
end

def add_role(title)
raise ArgumentException, "Role should be the title of the role not a role object." if title.is_a?(::Role)
roles << ::Role[title] unless has_role?(title)
end

def has_role?(title)
raise ArgumentException, "Role should be the title of the role not a role object." if title.is_a?(::Role)
roles.any?{|r| r.title == title.to_s.camelize}
end

def can_delete?(user_to_delete = self)
user_to_delete.persisted? and
id != user_to_delete.id and
!user_to_delete.has_role?(:superuser) and
Role[:refinery].users.count > 1
end
end
4 changes: 4 additions & 0 deletions app/models/user_plugin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class UserPlugin < Refinery::Core::BaseModel
belongs_to :user
attr_accessible :user_id, :name, :position
end
25 changes: 25 additions & 0 deletions app/views/sitemap/index.xml.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
xml.instruct!

xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do

@locales.each do |locale|
::I18n.locale = locale
::Refinery::Page.live.in_menu.includes(:parts).each do |page|
# exclude sites that are external to our own domain.
page_url = if page.url.is_a?(Hash)
# This is how most pages work without being overriden by link_url
page.url.merge({:only_path => false})
elsif page.url.to_s !~ /^http/
# handle relative link_url addresses.
[request.protocol, request.host_with_port, page.url].join
end

# Add XML entry only if there is a valid page_url found above.
xml.url do
xml.loc url_for(page_url)
xml.lastmod page.updated_at.to_date
end if page_url.present? and page.show_in_menu?
end
end

end
18 changes: 16 additions & 2 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,19 @@ class Application < Rails::Application

# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
end
end
config.autoload_paths += Dir["#{config.root}/lib/**/"] # to load files from lib directory, including subfolders
config.before_initialize do
require 'refinery_patch'
require 'restrict_refinery_to_refinery_users'
end

config.to_prepare do
[::Refinery::ApplicationController, ApplicationHelper].each do |c|
c.send :include, ::RefineryPatch
end

::Refinery::AdminController.send :include, ::RestrictRefineryToRefineryUsers
::Refinery::AdminController.send :before_filter, :restrict_refinery_to_refinery_users
end
end
end
20 changes: 20 additions & 0 deletions config/database.yml.mysql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
development: &development
adapter: mysql2
host: localhost
username: root
password:
database: your_local_database

test: &test
adapter: mysql2
host: localhost
username: root
password:
database: your_test_database

production: &production
adapter: mysql2
host: localhost
database: your_production_database
username: your_production_database_login
password: your_production_database_password
Loading

0 comments on commit 8d77cf6

Please sign in to comment.