cms-rails 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5e9762779f5a9eac202736ef9429e8d78897cfd
4
- data.tar.gz: 150f265b7daed9f82a1d8416264a4f914c4320be
3
+ metadata.gz: 0314fe9ee9744d0024e0edf723d769d289205a90
4
+ data.tar.gz: a6d29bab16c98b7de212ca33975c38b11e32ae1c
5
5
  SHA512:
6
- metadata.gz: 063cf9a33ecf09632bfa121fab8e4c8ae5826f59f665b29f722aed26d91c3e60d763c6bab628f953b19ff44e6a8c9e11277a17f0a6824323fd270f3c688f6430
7
- data.tar.gz: eaefee813240d3e71f7b7f75c1c94207ed7097d0c31b13bd440313ce83beb9da046ee53824b41772d04b150a7a19c1c445ebd705df1ee9f1c969e13322d7dd53
6
+ metadata.gz: 648757d38228246cf091647d0fdfa244b1187825c421db57a3c12021105f75f8fdd4a4756c558d5a859274b37c85239330aa991a324e64ed5a13120bc6971cb0
7
+ data.tar.gz: ea10a992cb474eb899a89ccd9cde2b463504d6cf406efb2479ffffb9d6bf1f6c45a6e81c3b39d70dead59e369639a9f242b2f0ed9309a8baabea825e72720331
@@ -0,0 +1,20 @@
1
+ class CmsRailsController < ::ApplicationController
2
+ before_filter :is_login!, except: [:index]
3
+ helper_method :current_user, :menu, :find_page
4
+
5
+ def is_login!
6
+ redirect_to '/login', notice: 'You need login to load this section' if current_user.nil?
7
+ end
8
+
9
+ def current_user
10
+ User.find(session[:user_id]) unless session[:user_id].nil?
11
+ end
12
+
13
+ def menu(parent)
14
+ Menu.find_by_page_id(find_page(parent.humanize).id)
15
+ end
16
+
17
+ def find_page(wanted)
18
+ Page.find_by_name(wanted)
19
+ end
20
+ end
@@ -1,7 +1,4 @@
1
- class PagesController < ApplicationController
2
- before_filter :is_login!
3
- include Cms::Rails::RenderPage
4
- helper Cms::Rails::RenderPage
1
+ class PagesController < CmsRailsController
5
2
 
6
3
  def index
7
4
  end
@@ -14,9 +11,10 @@ class PagesController < ApplicationController
14
11
 
15
12
  def create
16
13
  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)
14
+ @page = Page.create(page_params)
15
+ @parent = params[:page][:parent]
16
+ if @page.save and create_type.save
17
+ redirection(@page.name.parameterize.underscore)
20
18
  else
21
19
  redirect_to new_page_path(type: params[:type])
22
20
  end
@@ -25,8 +23,8 @@ class PagesController < ApplicationController
25
23
  private
26
24
 
27
25
  def redirection(page)
28
- unless params[:page][:parent].nil?
29
- redirect_to "/#{params[:page][:parent]}/#{page}"
26
+ unless @parent.nil?
27
+ redirect_to "/#{@parent}/#{page}"
30
28
  else
31
29
  redirect_to "/#{page}"
32
30
  end
@@ -42,18 +40,18 @@ class PagesController < ApplicationController
42
40
  position
43
41
  end
44
42
 
45
- def create_type(page)
43
+ def create_type
46
44
  type = case params[:page][:type]
47
- when 'Menu'
48
- page.menus.create
49
- when 'Navigation'
50
- navigations.create(page_id: page.id)
51
- end
45
+ when 'Menu'
46
+ @page.menus.create
47
+ when 'Navigation'
48
+ navigations.create(page_id: @page.id)
49
+ end
52
50
  type
53
51
  end
54
52
 
55
53
  def navigations
56
- menu(params[:page][:parent]).navigations
54
+ menu(@parent).navigations
57
55
  end
58
56
 
59
57
  def page_params
@@ -0,0 +1,49 @@
1
+ module RenderHelper
2
+ def cms_render_page
3
+ @page = params[:parent]
4
+ content = case @page
5
+ when 'login'
6
+ 'sessions/new'
7
+ when 'register'
8
+ 'users/new'
9
+ else
10
+ @page = select_page unless is_basic_page?
11
+ unless @page.nil?
12
+ 'pages/container'
13
+ else
14
+ 'main'
15
+ end
16
+ end
17
+ content
18
+ end
19
+
20
+ def cms_render_menu
21
+ Menu.all.map {|menu| Page.send_name(menu.page_id)}
22
+ end
23
+
24
+ def cms_render_navigation
25
+ unless is_basic_page?
26
+ navigations.map {|nav| Page.send_name(nav.page_id)}
27
+ end
28
+ end
29
+
30
+ private
31
+
32
+ def select_page
33
+ unless params[:child].nil?
34
+ find_page(params[:child].humanize)
35
+ else
36
+ find_page(@page.humanize)
37
+ end
38
+ end
39
+
40
+ def navigations
41
+ menu(params[:parent]).navigations
42
+ end
43
+
44
+ def is_basic_page?
45
+ basic_pages = ['','login','register',nil]
46
+ basic_pages.include?(params[:parent])
47
+ end
48
+
49
+ end
@@ -9,4 +9,8 @@ class Page < ActiveRecord::Base
9
9
  validates :titulo, presence: true, length: { minimum: 3, maximum: 50 }, format: { with: /[a-zA-Z\s\d]/ }
10
10
  validates :active, presence: true, numericality: true
11
11
  validates :position, presence: true, numericality: true
12
+
13
+ def self.send_name(id)
14
+ Page.find(id).name
15
+ end
12
16
  end
@@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
8
8
  gem.version = Cms::Rails::VERSION
9
9
  gem.authors = ["Oscar Hugo Cardenas Lopez"]
10
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}
11
+ gem.description = %q{This gem provide a group form and methods to create a cms this provide a rails g cms:migrations and rails g cms:load to initialize the process function to create new content in your application}
12
12
  gem.summary = %q{Provide a forms and methods to have a cms into rails app}
13
13
  gem.homepage = "https://github.com/sorsucrel/cms-rails"
14
14
  gem.license = "MIT"
@@ -21,6 +21,8 @@ Gem::Specification.new do |gem|
21
21
  gem.add_runtime_dependency "rails", ">= 3.2"
22
22
  gem.add_runtime_dependency "pg", ">= 0.15.0"
23
23
  gem.add_runtime_dependency "bundler", "~> 1.3"
24
+ gem.add_runtime_dependency "anything-slider"
25
+ gem.add_runtime_dependency "tinymce-rails4"
24
26
  gem.add_development_dependency "compass", ">= 0.12.0"
25
27
  gem.add_development_dependency 'bcrypt-ruby', '~> 3.0.0'
26
28
  gem.add_development_dependency "rake"
@@ -1,6 +1,3 @@
1
- require "cms/rails/version"
2
- require 'cms/rails/render_page'
3
-
4
1
  module Cms
5
2
  module Rails
6
3
  class Engine < ::Rails::Engine
@@ -1,5 +1,5 @@
1
1
  module Cms
2
2
  module Rails
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -15,8 +15,16 @@ module Cms
15
15
  copy_file 'mailers/notifier.rb', 'app/mailers/notifier.rb'
16
16
  end
17
17
 
18
- def copy_application_layout
19
- copy_file 'layouts/application.html.haml'
18
+ def copy_layouts_files
19
+ dir = 'layouts'
20
+ copy_file "#{dir}/application.html.haml", 'app/views/layouts/application.html.haml'
21
+ copy_file "#{dir}/_actions.html.haml", 'app/views/layouts/_actions.html.haml'
22
+ end
23
+
24
+ def js_dependency_load
25
+ copy_file 'assets/cms.rails.js', 'app/assets/javascripts/cms.rails.js'
26
+ inject_into_file "app/assets/javascripts/application.js", "//= require tinymce.min\n//= require jquery.anythingslider\n//= require cms.rails\n", before: "//= require_tree"
27
+ inject_into_file "app/assets/stylesheets/application.css", "\n*= require anythingslider.sass", after: "*= require_tree ."
20
28
  end
21
29
 
22
30
  def load_config_to_send_mail
@@ -33,39 +41,30 @@ module Cms
33
41
 
34
42
  def load_initial
35
43
  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"
44
+ "\n helper :render\n
45
+ def init_twitter\n
46
+ end\n
47
+ def init_github\n
48
+ end\n
49
+ def nit_facebook\n
50
+ end\n
51
+ def nit_linkedin\n
52
+ end\n"
50
53
  end
51
54
  end
52
55
 
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
56
  def load_routes
62
57
  inject_into_file 'config/routes.rb', after: 'Application.routes.draw do' do
63
58
  "
64
59
  post 'sessions/new', to: 'sessions#create'
65
60
  get 'sessions/destroy', to: 'sessions#logout'
66
61
  resources :users, only: [:create]
62
+ resources :pages, only: [:create, :new]
67
63
  get '/auth/:provider/callback', to: 'sessions#create'
68
- get '/auth/failure', to: 'sessions#failure'"
64
+ get '/auth/failure', to: 'sessions#failure'
65
+ get '/:parent', to: 'pages#index'
66
+ get '/:parent/:child', to: 'pages#index'
67
+ root to: 'pages#index'"
69
68
  end
70
69
  end
71
70
 
@@ -0,0 +1,56 @@
1
+ $(function(){
2
+ $('#slider').anythingSlider({
3
+ resizeContents : true,
4
+ theme : "default",
5
+ autoPlay : true,
6
+ addWmodeToObject : false,
7
+ buildNavigation : false,
8
+ hashTags : false
9
+ }); // add any non-default options here
10
+
11
+ tinymce.init({
12
+ selector: ".full",
13
+ inline: true,
14
+ plugins: [
15
+ "advlist autolink autosave link image lists charmap hr anchor pagebreak spellchecker",
16
+ "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
17
+ "table contextmenu directionality textcolor fullpage textcolor save"
18
+ ],
19
+ toolbar1: "bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | styleselect formatselect fontselect fontsizeselect",
20
+ toolbar2: "searchreplace | bullist numlist | outdent indent | undo redo | link unlink image media code | inserttime | forecolor backcolor",
21
+ toolbar3: "table | hr removeformat | subscript superscript | charmap | fullscreen | pagebreak save",
22
+ menubar: false,
23
+ toolbar_items_size: 'small',
24
+ save_enablewhendirty: true,
25
+ save_onsavecallback: function() {console.log("Save");}
26
+ });
27
+
28
+ tinymce.init({
29
+ selector: ".editable",
30
+ inline: true,
31
+ plugins: "save",
32
+ toolbar: "undo redo save",
33
+ save_enablewhendirty: true,
34
+ save_onsavecallback: function() {console.log("Save");},
35
+ menubar: false
36
+ });
37
+
38
+ tinymce.init({
39
+ selector: ".imagen",
40
+ inline: true,
41
+ setup: function(editor) {
42
+ editor.addButton('mybutton', {
43
+ text: 'My button',
44
+ icon: false,
45
+ onclick: function() {
46
+ editor.insertContent('Main button');
47
+ }
48
+ });
49
+ },
50
+ plugins: "image save",
51
+ toolbar: "undo redo image mybutton save",
52
+ save_enablewhendirty: true,
53
+ save_onsavecallback: function() {console.log("Save");},
54
+ menubar: false
55
+ });
56
+ });
@@ -0,0 +1,8 @@
1
+ - unless current_user.nil?
2
+ - parent||= ""
3
+ .inline
4
+ = link_to new_page_path(type: action, parent: parent ) do
5
+ %img{src: image_path('add_bar.png'), alt: "#{action}add"}
6
+ %img{src: image_path('del_bar.png'), alt: "#{action}del"}
7
+ - content_for :edit_header do
8
+ %img{src: image_path('update_bar.png'), alt: "Headerupdate"}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cms-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Hugo Cardenas Lopez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-04 00:00:00.000000000 Z
11
+ date: 2013-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -52,6 +52,34 @@ dependencies:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: anything-slider
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: tinymce-rails4
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: compass
57
85
  requirement: !ruby/object:Gem::Requirement
@@ -94,8 +122,9 @@ dependencies:
94
122
  - - '>='
95
123
  - !ruby/object:Gem::Version
96
124
  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
125
+ description: This gem provide a group form and methods to create a cms this provide
126
+ a rails g cms:migrations and rails g cms:load to initialize the process function
127
+ to create new content in your application
99
128
  email:
100
129
  - ohcl87@hotmail.com
101
130
  executables: []
@@ -107,9 +136,14 @@ files:
107
136
  - LICENSE.txt
108
137
  - README.md
109
138
  - Rakefile
139
+ - app/assets/images/add_bar.png
140
+ - app/assets/images/del_bar.png
141
+ - app/assets/images/update_bar.png
142
+ - app/controllers/cms_rails_controller.rb
110
143
  - app/controllers/pages_controller.rb
111
144
  - app/controllers/sessions_controller.rb
112
145
  - app/controllers/users_controller.rb
146
+ - app/helpers/render_helper.rb
113
147
  - app/models/footer.rb
114
148
  - app/models/menu.rb
115
149
  - app/models/navigation.rb
@@ -124,12 +158,13 @@ files:
124
158
  - app/views/users/_new.html.haml
125
159
  - cms-rails.gemspec
126
160
  - lib/cms/rails.rb
127
- - lib/cms/rails/render_page.rb
128
161
  - lib/cms/rails/version.rb
129
162
  - lib/generators/cms/load/load_generator.rb
130
163
  - lib/generators/cms/migrations/migrations_generator.rb
164
+ - lib/generators/cms/templates/assets/cms.rails.js
131
165
  - lib/generators/cms/templates/config/initializers/mail.rb
132
166
  - lib/generators/cms/templates/config/initializers/omniauth.rb
167
+ - lib/generators/cms/templates/layouts/_actions.html.haml
133
168
  - lib/generators/cms/templates/layouts/application.html.haml
134
169
  - lib/generators/cms/templates/mailers/notifier.rb
135
170
  - lib/generators/cms/templates/migrations/create_footers.rb
@@ -160,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
195
  version: '0'
161
196
  requirements: []
162
197
  rubyforge_project:
163
- rubygems_version: 2.1.10
198
+ rubygems_version: 2.0.3
164
199
  signing_key:
165
200
  specification_version: 4
166
201
  summary: Provide a forms and methods to have a cms into rails app
@@ -1,59 +0,0 @@
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