Permalink
Browse files

Init.

  • Loading branch information...
0 parents commit 6ed90d05b161911a10d20510e468bd96c51281b5 @ugisozols ugisozols committed Feb 23, 2012
Showing with 2,250 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +16 −0 .travis.yml
  3. +72 −0 Gemfile
  4. +19 −0 Rakefile
  5. +69 −0 app/controllers/refinery/admin/settings_controller.rb
  6. 0 app/decorators/controllers/refinery/.gitkeep
  7. 0 app/decorators/models/refinery/.gitkeep
  8. +29 −0 app/helpers/refinery/admin/settings_helper.rb
  9. +210 −0 app/models/refinery/setting.rb
  10. +8 −0 app/views/refinery/admin/settings/_actions.html.erb
  11. +54 −0 app/views/refinery/admin/settings/_form.html.erb
  12. +21 −0 app/views/refinery/admin/settings/_records.html.erb
  13. +23 −0 app/views/refinery/admin/settings/_setting.html.erb
  14. +4 −0 app/views/refinery/admin/settings/_settings.html.erb
  15. +1 −0 app/views/refinery/admin/settings/edit.html.erb
  16. +15 −0 app/views/refinery/admin/settings/index.html.erb
  17. +1 −0 app/views/refinery/admin/settings/new.html.erb
  18. +25 −0 app/views/sitemap/index.xml.builder
  19. +20 −0 config/database.yml.mysql
  20. +58 −0 config/database.yml.postgresql
  21. +18 −0 config/database.yml.sqlite3
  22. +229 −0 config/initializers/devise.rb
  23. +48 −0 config/initializers/refinery/core.rb
  24. +41 −0 config/initializers/refinery/images.rb
  25. +44 −0 config/initializers/refinery/pages.rb
  26. +26 −0 config/initializers/refinery/resources.rb
  27. +29 −0 config/locales/bg.yml
  28. +29 −0 config/locales/cs.yml
  29. +29 −0 config/locales/da.yml
  30. +30 −0 config/locales/de.yml
  31. +29 −0 config/locales/el.yml
  32. +29 −0 config/locales/en.yml
  33. +38 −0 config/locales/es.yml
  34. +29 −0 config/locales/fi.yml
  35. +29 −0 config/locales/fr.yml
  36. +21 −0 config/locales/it.yml
  37. +30 −0 config/locales/ja.yml
  38. +29 −0 config/locales/ko.yml
  39. +28 −0 config/locales/lolcat.yml
  40. +30 −0 config/locales/lt.yml
  41. +29 −0 config/locales/lv.yml
  42. +30 −0 config/locales/nb.yml
  43. +29 −0 config/locales/nl.yml
  44. +30 −0 config/locales/pl.yml
  45. +29 −0 config/locales/pt-BR.yml
  46. +29 −0 config/locales/rs.yml
  47. +29 −0 config/locales/ru.yml
  48. +29 −0 config/locales/sk.yml
  49. +27 −0 config/locales/sl.yml
  50. +29 −0 config/locales/sv.yml
  51. +29 −0 config/locales/vi.yml
  52. +29 −0 config/locales/zh-CN.yml
  53. +29 −0 config/locales/zh-TW.yml
  54. +5 −0 config/routes.rb
  55. +17 −0 db/migrate/20100913234710_create_refinerycms_settings_schema.rb
  56. +3 −0 db/seeds.rb
  57. +19 −0 lib/refinery/settings.rb
  58. +28 −0 lib/refinery/settings/engine.rb
  59. +1 −0 lib/refinerycms-settings.rb
  60. +21 −0 license.md
  61. +76 −0 readme.md
  62. +20 −0 refinerycms-settings.gemspec
  63. +5 −0 spec/factories/settings.rb
  64. +103 −0 spec/models/refinery/setting_spec.rb
  65. +52 −0 spec/requests/refinery/admin/settings_spec.rb
  66. +56 −0 spec/spec_helper.rb
  67. +4 −0 tasks/rspec.rake
@@ -0,0 +1,3 @@
+.DS_Store
+Gemfile.lock
+spec/dummy
@@ -0,0 +1,16 @@
+before_script:
+ - "bundle exec rake refinery:testing:dummy_app > /dev/null"
+script: "bundle exec rspec ./spec"
+notifications:
+ email:
+ - parndt@gmail.com
+ - ugis.ozolss@gmail.com
+env:
+ - DB=postgresql
+ - DB=mysql
+rvm:
+ - 1.8.7
+ - 1.9.2
+ - 1.9.3
+ - rbx
+ - jruby
@@ -0,0 +1,72 @@
+source 'http://rubygems.org'
+
+gemspec
+
+git 'git://github.com/resolve/refinerycms.git' do
+ gem 'refinerycms'
+
+ group :development, :test do
+ gem 'refinerycms-testing'
+ end
+end
+
+group :development, :test do
+ require 'rbconfig'
+
+ platforms :jruby do
+ gem 'activerecord-jdbcsqlite3-adapter'
+ gem 'activerecord-jdbcmysql-adapter'
+ gem 'activerecord-jdbcpostgresql-adapter'
+ gem 'jruby-openssl'
+ end
+
+ unless defined?(JRUBY_VERSION)
+ gem 'sqlite3'
+ gem 'mysql2'
+ gem 'pg'
+ end
+
+ platforms :mswin, :mingw do
+ gem 'win32console'
+ gem 'rb-fchange', '~> 0.0.5'
+ gem 'rb-notifu', '~> 0.0.4'
+ end
+
+ platforms :ruby do
+ gem 'spork', '0.9.0.rc9'
+ gem 'guard-spork'
+
+ unless ENV['TRAVIS']
+ if RbConfig::CONFIG['target_os'] =~ /darwin/i
+ gem 'rb-fsevent', '>= 0.3.9'
+ gem 'growl', '~> 1.0.3'
+ end
+ if RbConfig::CONFIG['target_os'] =~ /linux/i
+ gem 'rb-inotify', '>= 0.5.1'
+ gem 'libnotify', '~> 0.1.3'
+ gem 'therubyracer', '~> 0.9.9'
+ end
+ end
+ end
+
+ platforms :jruby do
+ unless ENV['TRAVIS']
+ if RbConfig::CONFIG['target_os'] =~ /darwin/i
+ gem 'growl', '~> 1.0.3'
+ end
+ if RbConfig::CONFIG['target_os'] =~ /linux/i
+ gem 'rb-inotify', '>= 0.5.1'
+ gem 'libnotify', '~> 0.1.3'
+ end
+ end
+ end
+end
+
+# Refinery/rails should pull in the proper versions of these
+group :assets do
+ gem 'sass-rails'
+ gem 'coffee-rails'
+ gem 'uglifier'
+end
+
+gem 'jquery-rails'
@@ -0,0 +1,19 @@
+#!/usr/bin/env rake
+begin
+ require 'bundler/setup'
+rescue LoadError
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
+end
+
+ENGINE_PATH = File.dirname(__FILE__)
+APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
+
+if File.exists?(APP_RAKEFILE)
+ load 'rails/tasks/engine.rake'
+end
+
+require "refinerycms-testing"
+Refinery::Testing::Railtie.load_tasks
+Refinery::Testing::Railtie.load_dummy_tasks(ENGINE_PATH)
+
+load File.expand_path('../tasks/rspec.rake', __FILE__)
@@ -0,0 +1,69 @@
+module ::Refinery
+ module Admin
+ class SettingsController < ::Refinery::AdminController
+
+ helper "refinery/admin/settings"
+
+ crudify :'refinery/setting',
+ :order => "name ASC",
+ :redirect_to_url => :redirect_to_where?,
+ :xhr_paging => true
+
+ before_filter :sanitise_params, :only => [:create, :update]
+ after_filter :fire_setting_callback, :only => [:update]
+
+ def new
+ form_value_type = ((current_refinery_user.has_role?(:superuser) && params[:form_value_type]) || 'text_area')
+ @setting = ::Refinery::Setting.new(:form_value_type => form_value_type)
+ end
+
+ def edit
+ @setting = ::Refinery::Setting.find(params[:id])
+
+ render :layout => false if request.xhr?
+ end
+
+ protected
+ def find_all_settings
+ @settings = ::Refinery::Setting.order('name ASC')
+
+ unless current_refinery_user.has_role?(:superuser)
+ @settings = @settings.where("restricted <> ? ", true)
+ end
+
+ @settings
+ end
+
+ def search_all_settings
+ # search for settings that begin with keyword
+ term = "^" + params[:search].to_s.downcase.gsub(' ', '_')
+
+ # First find normal results, then weight them with the query.
+ @settings = find_all_settings.with_query(term)
+ end
+
+ private
+ def redirect_to_where?
+ (from_dialog? && session[:return_to].present?) ? session[:return_to] : refinery.admin_settings_path
+ end
+
+ # this fires before an update or create to remove any attempts to pass sensitive arguments.
+ def sanitise_params
+ params.delete(:callback_proc_as_string)
+ params.delete(:scoping)
+ end
+
+ def fire_setting_callback
+ begin
+ @setting.callback_proc.call
+ rescue
+ logger.warn('Could not fire callback proc. Details:')
+ logger.warn(@setting.inspect)
+ logger.warn($!.message)
+ logger.warn($!.backtrace)
+ end unless @setting.callback_proc.nil?
+ end
+
+ end
+ end
+end
No changes.
@@ -0,0 +1,29 @@
+module ::Refinery
+ module Admin
+ module SettingsHelper
+ def form_value_type
+ @setting.form_value_type.presence || 'text_area'
+ end
+
+ def setting_title(f)
+ if @setting.form_value_type == 'check_box'
+ raw "<h3>#{@setting.name.to_s.titleize}?</h3>"
+ else
+ f.label :value
+ end
+ end
+
+ def setting_field(f, help)
+ case form_value_type
+ when 'check_box'
+ raw "#{f.check_box :value, :value => @setting.form_value}
+ #{f.label :value, help.presence || t('enabled', :scope => 'refinery.admin.settings.form'),
+ :class => 'stripped'}"
+ else
+ f.text_area :value, :value => @setting.form_value,
+ :class => 'widest', :rows => 5
+ end
+ end
+ end
+ end
+end
Oops, something went wrong.

0 comments on commit 6ed90d0

Please sign in to comment.