cms-rails 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +29 -0
  6. data/Rakefile +1 -0
  7. data/app/controllers/pages_controller.rb +62 -0
  8. data/app/controllers/sessions_controller.rb +45 -0
  9. data/app/controllers/users_controller.rb +26 -0
  10. data/app/models/footer.rb +7 -0
  11. data/app/models/menu.rb +4 -0
  12. data/app/models/navigation.rb +4 -0
  13. data/app/models/page.rb +12 -0
  14. data/app/models/post.rb +7 -0
  15. data/app/models/session_user.rb +3 -0
  16. data/app/models/slider.rb +4 -0
  17. data/app/models/tag.rb +3 -0
  18. data/app/views/pages/_container.html.haml +1 -0
  19. data/app/views/pages/new.html.haml +19 -0
  20. data/app/views/sessions/_new.html.haml +28 -0
  21. data/app/views/users/_new.html.haml +29 -0
  22. data/cms-rails.gemspec +27 -0
  23. data/lib/cms/rails.rb +9 -0
  24. data/lib/cms/rails/render_page.rb +59 -0
  25. data/lib/cms/rails/version.rb +5 -0
  26. data/lib/generators/cms/load/load_generator.rb +82 -0
  27. data/lib/generators/cms/migrations/migrations_generator.rb +32 -0
  28. data/lib/generators/cms/templates/config/initializers/mail.rb +7 -0
  29. data/lib/generators/cms/templates/config/initializers/omniauth.rb +34 -0
  30. data/lib/generators/cms/templates/layouts/application.html.haml +16 -0
  31. data/lib/generators/cms/templates/mailers/notifier.rb +9 -0
  32. data/lib/generators/cms/templates/migrations/create_footers.rb +12 -0
  33. data/lib/generators/cms/templates/migrations/create_menus.rb +7 -0
  34. data/lib/generators/cms/templates/migrations/create_navigations.rb +8 -0
  35. data/lib/generators/cms/templates/migrations/create_pages.rb +13 -0
  36. data/lib/generators/cms/templates/migrations/create_pages_tags.rb +11 -0
  37. data/lib/generators/cms/templates/migrations/create_posts.rb +8 -0
  38. data/lib/generators/cms/templates/migrations/create_sliders.rb +10 -0
  39. data/lib/generators/cms/templates/migrations/create_tags.rb +7 -0
  40. metadata +167 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e5e9762779f5a9eac202736ef9429e8d78897cfd
4
+ data.tar.gz: 150f265b7daed9f82a1d8416264a4f914c4320be
5
+ SHA512:
6
+ metadata.gz: 063cf9a33ecf09632bfa121fab8e4c8ae5826f59f665b29f722aed26d91c3e60d763c6bab628f953b19ff44e6a8c9e11277a17f0a6824323fd270f3c688f6430
7
+ data.tar.gz: eaefee813240d3e71f7b7f75c1c94207ed7097d0c31b13bd440313ce83beb9da046ee53824b41772d04b150a7a19c1c445ebd705df1ee9f1c969e13322d7dd53
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cms-rails.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Oscar Hugo Cardenas Lopez
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Cms::Rails
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'cms-rails'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install cms-rails
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,62 @@
1
+ class PagesController < ApplicationController
2
+ before_filter :is_login!
3
+ include Cms::Rails::RenderPage
4
+ helper Cms::Rails::RenderPage
5
+
6
+ def index
7
+ end
8
+
9
+ def new
10
+ flash[:notice] = 'Select a especific type of page' if params[:type].nil?
11
+ @page = Page.new
12
+ @position = give_position
13
+ end
14
+
15
+ def create
16
+ params[:page][:name] = params[:page][:name].humanize
17
+ page = Page.create(page_params)
18
+ if page.save and create_type(page).save
19
+ redirection(page.name.parameterize.underscore)
20
+ else
21
+ redirect_to new_page_path(type: params[:type])
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def redirection(page)
28
+ unless params[:page][:parent].nil?
29
+ redirect_to "/#{params[:page][:parent]}/#{page}"
30
+ else
31
+ redirect_to "/#{page}"
32
+ end
33
+ end
34
+
35
+ def give_position
36
+ position = case params[:type]
37
+ when 'Menu'
38
+ Menu.count
39
+ when 'Navigation'
40
+ Navigation.count
41
+ end
42
+ position
43
+ end
44
+
45
+ def create_type(page)
46
+ type = case params[:page][:type]
47
+ when 'Menu'
48
+ page.menus.create
49
+ when 'Navigation'
50
+ navigations.create(page_id: page.id)
51
+ end
52
+ type
53
+ end
54
+
55
+ def navigations
56
+ menu(params[:page][:parent]).navigations
57
+ end
58
+
59
+ def page_params
60
+ params.require(:page).permit(:id, :name,:titulo,:content,:position,:active)
61
+ end
62
+ end
@@ -0,0 +1,45 @@
1
+ class SessionsController < ApplicationController
2
+ require 'session_user'
3
+
4
+ def create
5
+ if params[:commit] === 'Sign in'
6
+ $user = User.find_by_email(params[:email])
7
+ if $user and $user.authenticate(params[:password])
8
+ session[:user_id] = $user.id
9
+ redirect_to root_path,
10
+ notice: 'Sign in successfully'
11
+ else
12
+ redirect_to :back,
13
+ notice: 'User or password error'
14
+ end
15
+ else
16
+ request.env['omniauth'].nil? ? (redirect_to :back) : set_omniauth_user
17
+ end
18
+ end
19
+
20
+ def logout
21
+ $current_user = nil
22
+ session[:user_id] = nil
23
+ redirect_to root_path
24
+ end
25
+
26
+ def failure
27
+ end
28
+
29
+ private
30
+
31
+ def set_omniauth_user
32
+ $current_user = SessionUser.new
33
+ $current_user.provider = params['provider']
34
+ session[:user_id] = request.env['omniauth.auth']['extra']['raw_info']['id']
35
+ $current_user.name = request.env['omniauth.auth']['extra']['raw_info']['name']
36
+ if $current_user.provider === 'twitter'
37
+ $current_user.screen_name = request.env['omniauth.auth']['extra']['raw_info']['screen_name']
38
+ $current_user.followers = request.env['omniauth.auth']['extra']['raw_info']['followers_count']
39
+ $current_user.friends = request.env['omniauth.auth']['extra']['raw_info']['friends_count']
40
+ elsif $current_user.provider === 'github'
41
+ $current_user.screen_name = request.env['omniauth.auth']['extra']['raw_info']['login']
42
+ end
43
+ redirect_to root_path
44
+ end
45
+ end
@@ -0,0 +1,26 @@
1
+ class UsersController < ApplicationController
2
+
3
+ def index
4
+
5
+ end
6
+
7
+ def create
8
+ if params[:commit] === 'Sign up'
9
+ $user = User.create(user_params)
10
+ if $user.save
11
+ session[:user_id] = $user.id
12
+ redirect_to root_path,
13
+ notice: 'Sign in successfull'
14
+ else
15
+ redirect_to :back,
16
+ notice: 'Problems creeting a user'
17
+ end
18
+ else
19
+ redirect_to :back
20
+ end
21
+ end
22
+
23
+ def user_params
24
+ params.permit(:name, :email, :password, :password_confirmation)
25
+ end
26
+ end
@@ -0,0 +1,7 @@
1
+ class Footer < ActiveRecord::Base
2
+ belongs_to :page
3
+ validates :block_1, presence: true
4
+ validates :block_2, presence: true
5
+ validates :block_3, presence: true
6
+ validates :active, presence: true, numericality: true
7
+ end
@@ -0,0 +1,4 @@
1
+ class Menu < ActiveRecord::Base
2
+ belongs_to :page
3
+ has_many :navigations
4
+ end
@@ -0,0 +1,4 @@
1
+ class Navigation < ActiveRecord::Base
2
+ belongs_to :page
3
+ belongs_to :menu
4
+ end
@@ -0,0 +1,12 @@
1
+ class Page < ActiveRecord::Base
2
+ has_many :menus
3
+ has_and_belongs_to_many :tags
4
+ has_many :posts
5
+ has_many :navigations
6
+ validates :content, presence: true
7
+ validates :name, presence: true, format: { with: /[a-zA-Z\s\d]/ }
8
+ validates_length_of :name, minimum: 3, maximum: 18
9
+ validates :titulo, presence: true, length: { minimum: 3, maximum: 50 }, format: { with: /[a-zA-Z\s\d]/ }
10
+ validates :active, presence: true, numericality: true
11
+ validates :position, presence: true, numericality: true
12
+ end
@@ -0,0 +1,7 @@
1
+ class Post < ActiveRecord::Base
2
+ belongs_to :page
3
+ belongs_to :user
4
+ validates :titulo, presence: true, format: { with: /[a-zA-Z\s]/}
5
+ validates :name, presence: true
6
+ validates :active, presence: true
7
+ end
@@ -0,0 +1,3 @@
1
+ class SessionUser
2
+ attr_accessor :provider, :name, :screen_name, :followers, :friends
3
+ end
@@ -0,0 +1,4 @@
1
+ class Slider < ActiveRecord::Base
2
+ validates :active, presence: true, numericality: true
3
+ validates :list, presence: true
4
+ end
@@ -0,0 +1,3 @@
1
+ class Tag < ActiveRecord::Base
2
+ has_and_belongs_to_many :pages
3
+ end
@@ -0,0 +1 @@
1
+ = @page.content.html_safe
@@ -0,0 +1,19 @@
1
+ %h3 put you information to create a new page
2
+ = form_for(@page) do |f|
3
+ = f.label :name, "#{params[:type]} Name:"
4
+ %br
5
+ = f.text_field :name
6
+ %br
7
+ = f.label :titulo, 'Titulo:'
8
+ %br
9
+ = f.text_field :titulo
10
+ %br
11
+ = f.label :content, 'Content:'
12
+ %br
13
+ = f.text_area :content
14
+ %br
15
+ = f.hidden_field :active, value: 1
16
+ = f.hidden_field :parent, value: params[:parent] if params[:parent] != ''
17
+ = f.hidden_field :position, value: @position
18
+ = f.hidden_field :type, value: params[:type]
19
+ = f.submit
@@ -0,0 +1,28 @@
1
+ = link_to 'Twitter', '/auth/twitter' unless @init_twitter.nil?
2
+ = link_to 'Github', '/auth/github' unless @init_github.nil?
3
+ = link_to 'Facebook', '/auth/facebook' unless @init_facebook.nil?
4
+ = link_to 'Linked_in', '/auth/linked_in' unless @init_linkedin.nil?
5
+ %h1 Sign in
6
+ %p Put you information to login
7
+ = form_tag sessions_new_path, method: 'POST' do |f|
8
+ %table{width: '25%'}
9
+ %tr
10
+ %td
11
+ = label_tag :email, 'You user email'
12
+ %td
13
+ = text_field_tag :email
14
+ %tr
15
+ %td
16
+ = label_tag :password, 'Password'
17
+ %td
18
+ = password_field_tag :password
19
+ %tr
20
+ %td
21
+ = label_tag :password_confirmation, 'Password Confirmation'
22
+ %td
23
+ = password_field_tag :password_confirmation
24
+ %tr
25
+ %td
26
+ = submit_tag 'Sign in'
27
+ %td
28
+ = submit_tag 'Cancel'
@@ -0,0 +1,29 @@
1
+ %h1 Sign up
2
+ %p put information to complete your register
3
+ = form_tag users_path, method: "POST" do |f|
4
+ %table{width: "25%"}
5
+ %tr
6
+ %td
7
+ = label_tag :name, "You user name"
8
+ %td
9
+ = text_field_tag :name
10
+ %tr
11
+ %td
12
+ = label_tag :email, "You user email"
13
+ %td
14
+ = text_field_tag :email
15
+ %tr
16
+ %td
17
+ = label_tag :password
18
+ %td
19
+ = password_field_tag :password
20
+ %tr
21
+ %td
22
+ = label_tag :password_confirmation
23
+ %td
24
+ = password_field_tag :password_confirmation
25
+ %tr
26
+ %td
27
+ = submit_tag "Sign up"
28
+ %td
29
+ = submit_tag "Cancel"
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cms/rails/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "cms-rails"
8
+ gem.version = Cms::Rails::VERSION
9
+ gem.authors = ["Oscar Hugo Cardenas Lopez"]
10
+ gem.email = ["ohcl87@hotmail.com"]
11
+ gem.description = %q{This gem provide a group form and methods to create a cms function to create new content in your application}
12
+ gem.summary = %q{Provide a forms and methods to have a cms into rails app}
13
+ gem.homepage = "https://github.com/sorsucrel/cms-rails"
14
+ gem.license = "MIT"
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(spec|test|gem|features)/})
19
+ gem.require_paths = ["lib"]
20
+
21
+ gem.add_runtime_dependency "rails", ">= 3.2"
22
+ gem.add_runtime_dependency "pg", ">= 0.15.0"
23
+ gem.add_runtime_dependency "bundler", "~> 1.3"
24
+ gem.add_development_dependency "compass", ">= 0.12.0"
25
+ gem.add_development_dependency 'bcrypt-ruby', '~> 3.0.0'
26
+ gem.add_development_dependency "rake"
27
+ end
@@ -0,0 +1,9 @@
1
+ require "cms/rails/version"
2
+ require 'cms/rails/render_page'
3
+
4
+ module Cms
5
+ module Rails
6
+ class Engine < ::Rails::Engine
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,59 @@
1
+ module Cms
2
+ module Rails
3
+ module RenderPage
4
+ def cms_render_page
5
+ @parent = params[:parent]
6
+ content = case @parent
7
+ when 'login'
8
+ 'sessions/new'
9
+ when 'register'
10
+ 'users/new'
11
+ else
12
+ @page = select_page unless @parent.nil?
13
+ unless @page.nil?
14
+ 'pages/container'
15
+ else
16
+ 'main'
17
+ end
18
+ end
19
+ content
20
+ end
21
+
22
+ def select_page
23
+ unless child_exist!
24
+ Page.find_by_name(@parent.humanize)
25
+ else
26
+ find_child
27
+ end
28
+ end
29
+
30
+ def find_child
31
+ Page.find_by_name(params[:child].humanize)
32
+ end
33
+
34
+ def child_exist!
35
+ child = params[:child]
36
+ !child.nil?
37
+ end
38
+
39
+ def cms_render_menu
40
+ Menu.all.map {|menu| Page.select(:name).find(menu.page_id).name}
41
+ end
42
+
43
+ def cms_render_navigation
44
+ navigations = menu(params[:parent]).navigations
45
+ navigations.map {|nav| Page.select(:name).find(nav.page_id).name}
46
+ end
47
+
48
+ def menu(parent)
49
+ page = Page.find_by_name(parent.humanize)
50
+ menu = Menu.find_by_page_id(page.id)
51
+ end
52
+
53
+ def is_basic_page!
54
+ basic_pages = ['','login','register',nil]
55
+ basic_pages.include?(params[:parent])
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,5 @@
1
+ module Cms
2
+ module Rails
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,82 @@
1
+ require 'rails/generators'
2
+
3
+ module Cms
4
+ module Generators
5
+ class LoadGenerator < ::Rails::Generators::Base
6
+ source_root File.expand_path('../../templates', __FILE__)
7
+ desc 'This generator prepare application with routes a basic methods to correcly functionality of cms-rails'
8
+ def copy_initializers_files
9
+ initial_route = 'config/initializers/'
10
+ copy_file "#{initial_route}mail.rb", "#{initial_route}mail.rb"
11
+ copy_file "#{initial_route}omniauth.rb", "#{initial_route}omniauth.rb"
12
+ end
13
+
14
+ def copy_mailers_file
15
+ copy_file 'mailers/notifier.rb', 'app/mailers/notifier.rb'
16
+ end
17
+
18
+ def copy_application_layout
19
+ copy_file 'layouts/application.html.haml'
20
+ end
21
+
22
+ def load_config_to_send_mail
23
+ inject_into_file 'config/environments/development.rb', after: 'config.action_mailer.raise_delivery_errors = false' do
24
+ "\n #change raise_delivery_errors false with true
25
+ config.action_mailer.delivery_method = :smtp
26
+ config.action_mailer.perform_deliveries = true"
27
+ end
28
+ end
29
+
30
+ def create_notifier_folder
31
+ create_file 'app/notifier/mail_method.html.rb'
32
+ end
33
+
34
+ def load_initial
35
+ inject_into_file 'app/controllers/application_controller.rb', after: 'protect_from_forgery with: :exception' do
36
+ "\n before_filter :load_initial\n
37
+ def load_initial
38
+ @init_twitter = nil
39
+ @init_github = nil
40
+ @init_facebook = nil
41
+ @init_linkedin = nil
42
+ end\n
43
+ def is_login!
44
+ if session[:user_id].nil?
45
+ redirect_to '/login', notice: 'You need login to load this section'
46
+ elsif $current_user.nil?
47
+ $current_user = User.find_by_id(session[:user_id])
48
+ end
49
+ end"
50
+ end
51
+ end
52
+
53
+ def create_helper_methods
54
+ inject_into_file 'app/helpers/application_helper.rb', after: 'ApplicationHelper' do
55
+ "\n def render_page
56
+ cms_render_page
57
+ end"
58
+ end
59
+ end
60
+
61
+ def load_routes
62
+ inject_into_file 'config/routes.rb', after: 'Application.routes.draw do' do
63
+ "
64
+ post 'sessions/new', to: 'sessions#create'
65
+ get 'sessions/destroy', to: 'sessions#logout'
66
+ resources :users, only: [:create]
67
+ get '/auth/:provider/callback', to: 'sessions#create'
68
+ get '/auth/failure', to: 'sessions#failure'"
69
+ end
70
+ end
71
+
72
+ def load_user_validates
73
+ inject_into_file 'app/models/user.rb', after: 'Base' do
74
+ "\n has_secure_password
75
+ validates :name, presence: true, uniqueness: true, length: { minimum: 5, maximum: 18}, format: {with: /[a-zA-Z\\s]/}
76
+ validates :password, presence: true, length: { minimum: 8, maximum: 24}
77
+ validates :email, presence: true, uniqueness: true, format: {with: /\\A([^@\\s]+)@((?:[-a-z0-9]+\\.)+[a-z]{2,})\\Z/i}"
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,32 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+ module Cms
5
+ module Generators
6
+ class MigrationsGenerator < ::Rails::Generators::Base
7
+ include ::Rails::Generators::Migration
8
+ source_root File.expand_path('../../templates', __FILE__)
9
+ desc 'load a migrations into the applications'
10
+
11
+ def self.next_migration_number(path)
12
+ unless @prev_migration_number
13
+ @prev_migration_number = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
14
+ else
15
+ @prev_migration_number += 1
16
+ end
17
+ @prev_migration_number.to_s
18
+ end
19
+
20
+ def copy_migrations
21
+ migration_template 'migrations/create_sliders.rb', 'db/migrate/create_sliders.rb'
22
+ migration_template 'migrations/create_pages.rb', 'db/migrate/create_pages.rb'
23
+ migration_template 'migrations/create_posts.rb', 'db/migrate/create_posts.rb'
24
+ migration_template 'migrations/create_menus.rb', 'db/migrate/create_menus.rb'
25
+ migration_template 'migrations/create_navigations.rb', 'db/migrate/create_navigations.rb'
26
+ migration_template 'migrations/create_footers.rb', 'db/migrate/create_footers.rb'
27
+ migration_template 'migrations/create_tags.rb', 'db/migrate/create_tags.rb'
28
+ migration_template 'migrations/create_pages_tags.rb', 'db/migrate/create_pages_tags.rb'
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,7 @@
1
+ ActionMailer::Base.smtp_settings = {
2
+ user_name: 'example@example.com',
3
+ password: 'example',
4
+ address: 'smtp_settings',
5
+ port: 587,
6
+ enable_starttls: true
7
+ }
@@ -0,0 +1,34 @@
1
+ Rails.application.config.middleware.use OmniAuth::Builder do
2
+ #provider :twitter, 'CONSUMER_KEY', 'CONSUMER_SECRET'
3
+ #provider :github, 'Client ID', 'Client Secret'
4
+ #provider :facebook, 'APP_ID', 'APP_SECRET'
5
+ #provider :linked_in, 'CONSUMER_KEY', 'CONSUMER_SECRET'
6
+ end
7
+
8
+ class NonExplodingFailureEndpoint
9
+ attr_reader :env
10
+
11
+ def self.call(env)
12
+ new(env).call
13
+ end
14
+
15
+ def initialize(env)
16
+ @env = env
17
+ end
18
+
19
+ def call
20
+ redirect_to_failure
21
+ end
22
+
23
+ def raise_out!
24
+ raise env['omniauth.error'] || OmniAuth::Error.new(env['omniauth.error.type'])
25
+ end
26
+
27
+ def redirect_to_failure
28
+ message_key = env['omniauth.error.type']
29
+ new_path = "#{env['SCRIPT_NAME']}#{OmniAuth.config.path_prefix}/failure?message=#{message_key}"
30
+ Rack::Response.new(["302 Moved"], 302, 'Location' => new_path).finish
31
+ end
32
+ end
33
+
34
+ OmniAuth.config.on_failure = NonExplodingFailureEndpoint
@@ -0,0 +1,16 @@
1
+ %html!
2
+ %head
3
+ %title Tickets
4
+ = stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true
5
+ = javascript_include_tag "application", "data-turbolinks-track" => true
6
+ = csrf_meta_tags
7
+ %body
8
+ .row
9
+ .span4
10
+ - unless @user.nil?
11
+ - @user.errors.full_messages.each do |message|
12
+ = message
13
+ .span4
14
+ - unless session[:user_id].nil?
15
+ = link_to 'Logout', 'sessions/destroy'
16
+ = yield
@@ -0,0 +1,9 @@
1
+ class Notifier < ActionMailer::Base
2
+ from_address = ActionMailer::Base.smtp_settings[:user_name]
3
+ default from: "App Name <#{from_address}"
4
+
5
+ def mail_method(mail)
6
+ subject = "#{mail.subject} from App name"
7
+ mail(to: mail.email, subject: subject)
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ class CreateFooters < ActiveRecord::Migration
2
+ def change
3
+ create_table :footers do |t|
4
+ t.string :block_1
5
+ t.string :block_2
6
+ t.string :block_3
7
+ t.integer :active
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ class CreateMenus < ActiveRecord::Migration
2
+ def change
3
+ create_table :menus do |t|
4
+ t.belongs_to :page, index: true
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ class CreateNavigations < ActiveRecord::Migration
2
+ def change
3
+ create_table :navigations do |t|
4
+ t.belongs_to :page, index: true
5
+ t.belongs_to :menu, index: true
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,13 @@
1
+ class CreatePages < ActiveRecord::Migration
2
+ def change
3
+ create_table :pages do |t|
4
+ t.string :name
5
+ t.string :titulo
6
+ t.text :content
7
+ t.integer :position
8
+ t.integer :active
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ class CreatePagesTags < ActiveRecord::Migration
2
+ def change
3
+ create_table :pages_tags, id: false do |t|
4
+ t.references :page
5
+ t.references :tag
6
+
7
+ end
8
+ add_index :pages_tags, :page_id
9
+ add_index :pages_tags, :tag_id
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ class CreatePosts < ActiveRecord::Migration
2
+ def change
3
+ create_table :posts do |t|
4
+ t.belongs_to :page, index: true
5
+ t.belongs_to :user, index: true
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ class CreateSliders < ActiveRecord::Migration
2
+ def change
3
+ create_table :sliders do |t|
4
+ t.string :list
5
+ t.integer :active
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ class CreateTags < ActiveRecord::Migration
2
+ def change
3
+ create_table :tag do |t|
4
+ t.string :name
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,167 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cms-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Oscar Hugo Cardenas Lopez
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '3.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pg
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.15.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.15.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: compass
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.12.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.12.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: bcrypt-ruby
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 3.0.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 3.0.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: This gem provide a group form and methods to create a cms function to
98
+ create new content in your application
99
+ email:
100
+ - ohcl87@hotmail.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - .gitignore
106
+ - Gemfile
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - app/controllers/pages_controller.rb
111
+ - app/controllers/sessions_controller.rb
112
+ - app/controllers/users_controller.rb
113
+ - app/models/footer.rb
114
+ - app/models/menu.rb
115
+ - app/models/navigation.rb
116
+ - app/models/page.rb
117
+ - app/models/post.rb
118
+ - app/models/session_user.rb
119
+ - app/models/slider.rb
120
+ - app/models/tag.rb
121
+ - app/views/pages/_container.html.haml
122
+ - app/views/pages/new.html.haml
123
+ - app/views/sessions/_new.html.haml
124
+ - app/views/users/_new.html.haml
125
+ - cms-rails.gemspec
126
+ - lib/cms/rails.rb
127
+ - lib/cms/rails/render_page.rb
128
+ - lib/cms/rails/version.rb
129
+ - lib/generators/cms/load/load_generator.rb
130
+ - lib/generators/cms/migrations/migrations_generator.rb
131
+ - lib/generators/cms/templates/config/initializers/mail.rb
132
+ - lib/generators/cms/templates/config/initializers/omniauth.rb
133
+ - lib/generators/cms/templates/layouts/application.html.haml
134
+ - lib/generators/cms/templates/mailers/notifier.rb
135
+ - lib/generators/cms/templates/migrations/create_footers.rb
136
+ - lib/generators/cms/templates/migrations/create_menus.rb
137
+ - lib/generators/cms/templates/migrations/create_navigations.rb
138
+ - lib/generators/cms/templates/migrations/create_pages.rb
139
+ - lib/generators/cms/templates/migrations/create_pages_tags.rb
140
+ - lib/generators/cms/templates/migrations/create_posts.rb
141
+ - lib/generators/cms/templates/migrations/create_sliders.rb
142
+ - lib/generators/cms/templates/migrations/create_tags.rb
143
+ homepage: https://github.com/sorsucrel/cms-rails
144
+ licenses:
145
+ - MIT
146
+ metadata: {}
147
+ post_install_message:
148
+ rdoc_options: []
149
+ require_paths:
150
+ - lib
151
+ required_ruby_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - '>='
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ required_rubygems_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - '>='
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ requirements: []
162
+ rubyforge_project:
163
+ rubygems_version: 2.1.10
164
+ signing_key:
165
+ specification_version: 4
166
+ summary: Provide a forms and methods to have a cms into rails app
167
+ test_files: []