mcms_pages 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -149,7 +149,7 @@
149
149
  }
150
150
 
151
151
  #default-page-main-body, #one-column-main-body {
152
- width: 100%;
152
+ width: 99%;
153
153
  text-align: left;
154
154
  }
155
155
  #two-column-main-body {
@@ -173,9 +173,12 @@ class Admin::PagesController < AdminController
173
173
  respond_to do |format|
174
174
 
175
175
  if @page.update_attributes(params[:page]) #page updated successfully
176
+
176
177
  format.html { redirect_to admin_pages_path, notice: 'Page was successfully updated.' }
177
178
  format.json { head :no_content }
179
+
178
180
  else #page saving failed, re-renders edit template
181
+
179
182
  format.html { render action: "edit", :template => 'mcms_pages/admin/pages/edit' }
180
183
  format.json { render json: @page.errors, status: :unprocessable_entity }
181
184
 
@@ -194,6 +197,7 @@ class Admin::PagesController < AdminController
194
197
  # find the page with with
195
198
  @page = Page.find(params[:id])
196
199
 
200
+ # calling class method of PagePart model to delete page parts of a page
197
201
  PagePart.delete_page_parts(@page)
198
202
 
199
203
  #destroy the page
@@ -215,10 +219,9 @@ class Admin::PagesController < AdminController
215
219
  # @purpose : To find a child page
216
220
  def find_child
217
221
 
222
+ # find page based on path or slug
218
223
  @page = Page.find_by_slug(params[:path])
219
224
 
220
- logger.debug @page
221
-
222
225
  #sends in data in different format to index action
223
226
  respond_to do |format|
224
227
 
@@ -13,6 +13,7 @@
13
13
 
14
14
  class PagesController < ApplicationController
15
15
 
16
+ # define layout to be used by controller
16
17
  layout "mcms_pages/layouts/mcms_layout"
17
18
 
18
19
  #finding page based on url
@@ -24,6 +25,7 @@ class PagesController < ApplicationController
24
25
  # @purpose : To show the home page
25
26
  def home
26
27
 
28
+ # send data in different format
27
29
  respond_to do |format|
28
30
 
29
31
  format.html{ render :template => 'mcms_pages/pages/home'}# home.html.erb
@@ -116,27 +118,35 @@ class PagesController < ApplicationController
116
118
  # @purpose : To find a page if it exists or show the page not found error
117
119
  def get_page(page_not_found = true)
118
120
 
119
- @menu_pages = Page.where("published = ? and show_in_menu = ?", true, true)
121
+ if params[:path] == "mcms" or params[:id] == "mcms"
122
+
123
+ redirect_to mcms_users_login_path
124
+
125
+ else
126
+
127
+ @menu_pages = Page.where("published = ? and show_in_menu = ?", true, true)
128
+
129
+ # case statement based on current action and assign the result to instance variable
130
+ case action_name
120
131
 
121
- # case statement based on current action and assign the result to instance variable
122
- case action_name
132
+ # when action is home
133
+ when "home"
123
134
 
124
- # when action is home
125
- when "home"
135
+ # find page bbased on link url
136
+ @page = Page.where(:link_url => '/').first
126
137
 
127
- # find page bbased on link url
128
- @page = Page.where(:link_url => '/').first
138
+ # when action is show or preview
139
+ when "show", "preview"
129
140
 
130
- # when action is show or preview
131
- when "show", "preview"
141
+ # find page using path or id of page
142
+ @page = Page.find_by_slug_or_id(params[:path], params[:id])
132
143
 
133
- # find page using path or id of page
134
- @page = Page.find_by_slug_or_id(params[:path], params[:id])
144
+ end # end case statement
135
145
 
136
- end # end case statement
146
+ # return page or page not found error
147
+ @page || ( page_404_error if page_not_found)
137
148
 
138
- # return page or page not found error
139
- @page || ( page_404_error if page_not_found)
149
+ end
140
150
 
141
151
  end # end method
142
152
 
@@ -87,7 +87,7 @@ module PagesHelper
87
87
  # create a PagePart object and assign it to a variable
88
88
  page = PagePartsPage.new
89
89
 
90
- #make the page part form
90
+ #make the page part pages form
91
91
  builder = ActionView::Helpers::FormBuilder.new( "page[page_parts_pages_attributes][#{index}]", page, self, {}, proc {})
92
92
 
93
93
  #return form object
data/app/models/page.rb CHANGED
@@ -39,13 +39,6 @@ class Page < ActiveRecord::Base
39
39
  # Nested pages, i.e. page underneath another page
40
40
  acts_as_nested_set :dependent => :destroy
41
41
 
42
- #Associating table "mcms_pages" with table "mcms_page_parts" using has_many relation
43
- # has_many :page_parts,
44
- # :foreign_key => :page_id,
45
- # :class_name => 'PagePart',
46
- # :inverse_of => :page,
47
- # :dependent => :destroy
48
-
49
42
  #defining has_many :through relationship
50
43
  has_many :page_parts_pages, :class_name => 'PagePartsPage'
51
44
 
@@ -29,7 +29,8 @@
29
29
  </div>
30
30
  <div class="layout-image">
31
31
 
32
- <%= image_tag("layouts/#{layout.name.tr(' ', '-')}.png", :size => "400x400", :alt => "#{layout.name}", :title => "click to view large") %>
32
+ <%= image_tag("layouts/#{layout.name.tr(' ', '-')}.png", :size => "400x400",
33
+ :alt => "#{layout.name}", :title => "click to view large") %>
33
34
 
34
35
  </div>
35
36
  <div class="layout-link">
@@ -53,5 +54,6 @@
53
54
 
54
55
  </div>
55
56
 
57
+ <!-- render partial _head.html.erb to include JS and CSS for specific page-->
56
58
  <%= render :partial => "mcms_pages/layouts/head" %>
57
59
 
@@ -23,12 +23,17 @@
23
23
  <ul class="repo-list">
24
24
 
25
25
  <li class="public source">
26
+
26
27
  <a href="/" target="_blank">
28
+
27
29
  <span class="mini-icon"></span>
28
30
  <span class="owner">Switch to Website</span><span class="repo"></span>
29
31
  <span class="arrow"></span>
32
+
30
33
  </a>
34
+
31
35
  </li>
36
+
32
37
  </ul>
33
38
 
34
39
  <div class="bottom-bar">
@@ -14,7 +14,7 @@
14
14
  <!-- displaying form for creating pages -->
15
15
  <%= form_for [:admin, @page] do |f| %>
16
16
 
17
- <!-- render partial for error messages -->
17
+ <!-- render partial for error messages with some locals -->
18
18
  <%= render :partial => "mcms_pages/admin/pages/error_messages",
19
19
  :locals => {
20
20
  :object => f.object,
@@ -45,7 +45,7 @@
45
45
  <%= link_to image_tag("mcms_pages/icons/page_add.png", :title => "add a child page", :alt => "add a child"),
46
46
  new_admin_page_path(:parent_id => page.id) %>
47
47
  <%= link_to image_tag("mcms_pages/icons/application_go.png", :title => "preview this page", :alt => "preview this page"),
48
- page_path(page), :target => "_blank" %>
48
+ preview_page_path(page.nested_url), :target => "_blank" %>
49
49
 
50
50
  </span>
51
51
 
@@ -10,6 +10,7 @@
10
10
 
11
11
  -->
12
12
 
13
+ <!-- calling helper method to arrange page part of a page -->
13
14
  <% page = arrange_page_part(@page) %>
14
15
 
15
16
  <div id='page-tabs' class="page-tabs clearfix ui-tabs ui-widget ui-widget-content ui-corner-all" >
@@ -91,14 +92,18 @@
91
92
  :title => title[loop_index]
92
93
  %>
93
94
 
94
- <%= p.hidden_field :id , :value => "#{page[title[loop_index]].page_parts_pages.where(:page_id => @page.id).first.id}" unless loop_index.nil? %>
95
+ <%= p.hidden_field :id ,
96
+ :value => "#{page[title[loop_index]].page_parts_pages.where(:page_id => @page.id).first.id}" unless loop_index.nil?
97
+ %>
95
98
 
96
99
  <!-- increment loop_index by 1 -->
97
100
  <% loop_index += 1 %>
98
101
 
99
102
  <% else %>
100
103
 
101
- <%= p.hidden_field :id , :value => "#{page[title[loop_index]].page_parts_pages.where(:page_id => @page.id).first.id}" unless loop_index.nil? %>
104
+ <%= p.hidden_field :id ,
105
+ :value => "#{page[title[loop_index]].page_parts_pages.where(:page_id => @page.id).first.id}" unless loop_index.nil?
106
+ %>
102
107
 
103
108
  <!-- increment loop_index by 1 -->
104
109
  <% loop_index += 1 %>
@@ -38,14 +38,14 @@
38
38
 
39
39
  <% unless title == "main body" %>
40
40
 
41
- OR
41
+ OR
42
42
 
43
- <%= link_to "Choose Existing #{title}",
44
- {:controller=>"pages", :action => 'add_page_part', :title => "#{title}", :index => "#{part_index}"},
45
- :remote => true, :id => "create-page-part-page-link-#{part_index}", :class => "create-page-part-page-link"
46
- %>
43
+ <%= link_to "Choose Existing #{title}",
44
+ {:controller=>"pages", :action => 'add_page_part', :title => "#{title}", :index => "#{part_index}"},
45
+ :remote => true, :id => "create-page-part-page-link-#{part_index}", :class => "create-page-part-page-link"
46
+ %>
47
47
 
48
- <% end %>
48
+ <% end %>
49
49
 
50
50
  </div>
51
51
 
@@ -19,7 +19,10 @@ $(document).ready(function(){
19
19
  builder = build_page_part(@index)
20
20
  %>
21
21
 
22
+ // remove html element with given id
22
23
  $("#page_page_parts_pages_attributes_<%= @index %>__destroy").remove();
24
+
25
+ // insert a hidden field for destroying the page part page with default value 1.
23
26
  $("#page-part-fields-<%= @index %>").after('<%= hidden_field_tag "page[page_parts_pages_attributes][#{@index}][_destroy]", "1" %>');
24
27
 
25
28
  var html = "<%= escape_javascript(render 'mcms_pages/admin/pages/page_part_form_field',
@@ -37,11 +40,13 @@ $(document).ready(function(){
37
40
  var html = "<%= escape_javascript(render 'mcms_pages/admin/pages/page_part_page_form_field',
38
41
  :part_index => @index, :f => builder, :title => @title, :fragment => fragment) %>";
39
42
 
43
+ // reset the value in hidden field for destroying page part pages to 0.
40
44
  $("#page_page_parts_pages_attributes_<%= @index %>__destroy").val("0");
41
45
 
42
46
  <% end %>
43
47
 
48
+ // change the html content of div page-part-fields
44
49
  $("#page-part-fields-<%= @index %>").html(html);
45
50
 
46
- });
51
+ }); // end ready function
47
52
 
@@ -13,5 +13,6 @@
13
13
  <!-- render partial form.html.erb -->
14
14
  <%= render 'mcms_pages/admin/pages/form' %>
15
15
 
16
+ <!-- render partial _head.html.erb to include JS and CSS for specific page-->
16
17
  <%= render :partial => "mcms_pages/layouts/head" %>
17
18
 
@@ -24,5 +24,6 @@
24
24
  <!-- render partial _action.html.erb -->
25
25
  <%= render 'mcms_pages/admin/pages/action' %>
26
26
 
27
+ <!-- render partial _head.html.erb to include JS and CSS for specific page-->
27
28
  <%= render :partial => "mcms_pages/layouts/head" %>
28
29
 
@@ -13,5 +13,6 @@
13
13
  <!-- render partial form.html.erb -->
14
14
  <%= render 'mcms_pages/admin/pages/form' %>
15
15
 
16
+ <!-- render partial _head.html.erb to include JS and CSS for specific page-->
16
17
  <%= render :partial => "mcms_pages/layouts/head" %>
17
18
 
@@ -14,7 +14,9 @@
14
14
  <ul class="pages-menu-ul">
15
15
 
16
16
  <!-- include menubar page for the application-->
17
- <%= render :partial => 'mcms_pages/pages/menubar', :collection => @menu_pages.select{|p| p.parent_id.nil? and p.link_url != '/404'} %>
17
+ <%=
18
+ render :partial => 'mcms_pages/pages/menubar', :collection => @menu_pages.select{|p| p.parent_id.nil? and p.link_url != '/404'}
19
+ %>
18
20
 
19
21
  </ul>
20
22
 
@@ -13,21 +13,25 @@
13
13
 
14
14
  <% if controller.action_name == "preview" %>
15
15
 
16
- <%= link_to menubar.title, preview_page_path(menubar.slug) %>
16
+ <%= link_to menubar.title, preview_page_path(menubar.nested_url) %>
17
17
 
18
18
  <% else %>
19
19
 
20
- <%= link_to menubar.title, menubar.slug %>
20
+ <%= link_to menubar.title, show_page_path(menubar.nested_url) %>
21
21
 
22
22
  <% end %>
23
23
 
24
24
  <% if menubar.children.present? and menubar.link_url != "/" %>
25
- <ul class="pages-nested-menu-ul">
26
- <!-- render partial _menubar.html.erb if pages have children -->
25
+
26
+ <ul class="pages-nested-menu-ul">
27
+
28
+ <!-- render partial _menubar.html.erb if pages have children -->
27
29
  <%=
28
30
  render(:partial => 'mcms_pages/pages/menubar', :collection => menubar.children.select{|p| p.show_in_menu? and p.published?})
29
31
  %>
30
- </ul>
32
+
33
+ </ul>
34
+
31
35
  <% end %>
32
36
 
33
37
  </li>
@@ -8,7 +8,7 @@
8
8
  @Purpose : To show the home page to the user.
9
9
 
10
10
  -->
11
-
11
+ <!-- calling helper method to arrange page part of a page -->
12
12
  <% page = arrange_page_part(@page) %>
13
13
 
14
14
  <!-- render notice/alert -->
@@ -9,6 +9,7 @@
9
9
 
10
10
  -->
11
11
 
12
+ <!-- calling helper method to arrange page part of a page -->
12
13
  <% page = arrange_page_part(@page) %>
13
14
 
14
15
  <% if @page.layout.name == "default" %>
data/config/routes.rb CHANGED
@@ -14,7 +14,7 @@ Rails.application.routes.draw do
14
14
 
15
15
  mount Ckeditor::Engine => '/ckeditor'
16
16
 
17
- resources :pages
17
+ #resources :pages
18
18
 
19
19
  # defining root path for the application
20
20
  #root :to => "pages#home"
@@ -25,8 +25,6 @@ Rails.application.routes.draw do
25
25
  # match pages/**/preview to action preview of pages controller
26
26
  match 'pages/*path/preview' => 'pages#preview', :as => :preview_page, :via => [:get, :put]
27
27
 
28
- match '/:path', :to=> 'pages#show'
29
-
30
28
  # define route for namespace admin for different resources to have
31
29
  # path prefixed with "mcms"
32
30
  namespace :admin, :path => "mcms" do
@@ -53,5 +51,9 @@ Rails.application.routes.draw do
53
51
 
54
52
  end # end namespace
55
53
 
54
+ match '/:path' => "pages#show"
55
+
56
+ match '*path', :to=> 'pages#show', :as => :show_page unless Gem.available?("mcms")
57
+
56
58
  end
57
59
 
@@ -30,7 +30,7 @@ module McmsPages
30
30
  # @Purpose : To copy stylesheets
31
31
  def copy_assets
32
32
 
33
- view_directory :mcms_pages
33
+ asset_directory :mcms_pages
34
34
 
35
35
  end # end method
36
36
 
@@ -39,7 +39,7 @@ module McmsPages
39
39
  # @Params : None
40
40
  # @Returns : None
41
41
  # @Purpose : To define the source path to copy views
42
- def view_directory(name, _target_path = nil)
42
+ def asset_directory(name, _target_path = nil)
43
43
 
44
44
  directory name.to_s, _target_path || "#{target_path}/#{name}"
45
45
 
@@ -6,7 +6,8 @@
6
6
  @Date Created : 2012-07-09
7
7
  @Date Modified :
8
8
  @Last Modification Details :
9
- @Purpose : This file is responsible to install assets and views for mcms_pages module in other application/module
9
+ @Purpose : This file is responsible to install assets and views for mcms_pages
10
+ module in other application/module
10
11
 
11
12
  =end
12
13
 
@@ -30,7 +31,7 @@ module McmsPages
30
31
  # @Purpose : To copy views
31
32
  def copy_views
32
33
 
33
- view_directory :mcms_pages
34
+ view_directory "mcms_pages/pages"
34
35
 
35
36
  end # end method
36
37
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mcms_pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-31 00:00:00.000000000 Z
12
+ date: 2012-08-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -27,22 +27,6 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: jquery-rails
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
30
  - !ruby/object:Gem::Dependency
47
31
  name: ckeditor
48
32
  requirement: !ruby/object:Gem::Requirement
@@ -292,7 +276,6 @@ files:
292
276
  - db/migrate/20120614125619_create_layouts.rb
293
277
  - db/migrate/20120606150656_add_title_position_to_page_parts.rb
294
278
  - db/seeds.rb
295
- - lib/tasks/mcms_pages_tasks.rake
296
279
  - lib/mcms_pages.rb
297
280
  - lib/mcms_pages/engine.rb
298
281
  - lib/mcms_pages/version.rb
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :mcms_pages do
3
- # # Task goes here
4
- # end