mcms_pages 0.0.1 → 0.0.2

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 (84) hide show
  1. data/app/assets/images/layouts/default.png +0 -0
  2. data/app/assets/javascripts/pageFormAdmin.js +50 -15
  3. data/app/assets/stylesheets/mcms_pages/images/back_ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
  4. data/app/assets/stylesheets/mcms_pages/images/spellayt.gif +0 -0
  5. data/app/assets/stylesheets/mcms_pages/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  6. data/app/assets/stylesheets/mcms_pages/images/ui-bg_flat_55_fbec88_40x100.png +0 -0
  7. data/app/assets/stylesheets/mcms_pages/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  8. data/app/assets/stylesheets/mcms_pages/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  9. data/app/assets/stylesheets/mcms_pages/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  10. data/app/assets/stylesheets/mcms_pages/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  11. data/app/assets/stylesheets/mcms_pages/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  12. data/app/assets/stylesheets/mcms_pages/images/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
  13. data/app/assets/stylesheets/mcms_pages/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  14. data/app/assets/stylesheets/mcms_pages/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  15. data/app/assets/stylesheets/mcms_pages/images/ui-bg_glass_85_dfeffc_1x400.png +0 -0
  16. data/app/assets/stylesheets/mcms_pages/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  17. data/app/assets/stylesheets/mcms_pages/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  18. data/app/assets/stylesheets/mcms_pages/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
  19. data/app/assets/stylesheets/mcms_pages/images/ui-bg_green.png +1 -0
  20. data/app/assets/stylesheets/mcms_pages/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  21. data/app/assets/stylesheets/mcms_pages/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  22. data/app/assets/stylesheets/mcms_pages/images/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
  23. data/app/assets/stylesheets/mcms_pages/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
  24. data/app/assets/stylesheets/mcms_pages/images/ui-icons_217bc0_256x240.png +0 -0
  25. data/app/assets/stylesheets/mcms_pages/images/ui-icons_222222_256x240.png +0 -0
  26. data/app/assets/stylesheets/mcms_pages/images/ui-icons_2e83ff_256x240.png +0 -0
  27. data/app/assets/stylesheets/mcms_pages/images/ui-icons_454545_256x240.png +0 -0
  28. data/app/assets/stylesheets/mcms_pages/images/ui-icons_469bdd_256x240.png +0 -0
  29. data/app/assets/stylesheets/mcms_pages/images/ui-icons_6da8d5_256x240.png +0 -0
  30. data/app/assets/stylesheets/mcms_pages/images/ui-icons_888888_256x240.png +0 -0
  31. data/app/assets/stylesheets/mcms_pages/images/ui-icons_cd0a0a_256x240.png +0 -0
  32. data/app/assets/stylesheets/mcms_pages/images/ui-icons_d8e7f3_256x240.png +0 -0
  33. data/app/assets/stylesheets/mcms_pages/images/ui-icons_f9bd01_256x240.png +0 -0
  34. data/app/assets/stylesheets/mcms_pages/layout.css.scss +5 -5
  35. data/app/assets/stylesheets/mcms_pages/page_form.css.scss +64 -0
  36. data/app/assets/stylesheets/mcms_pages/page_styles.css +92 -15
  37. data/app/assets/stylesheets/mcms_pages/pages.css.scss +37 -24
  38. data/app/assets/stylesheets/mcms_pages/tabs.css +573 -0
  39. data/app/controllers/admin/layouts_controller.rb +1 -1
  40. data/app/controllers/admin/pages_controller.rb +54 -28
  41. data/app/controllers/admin_controller.rb +36 -2
  42. data/app/controllers/pages_controller.rb +23 -11
  43. data/app/helpers/pages_helper.rb +52 -44
  44. data/app/models/ckeditor/asset.rb +2 -1
  45. data/app/models/page.rb +5 -1
  46. data/app/models/page_part.rb +25 -44
  47. data/app/views/mcms_pages/admin/layouts/index.html.erb +9 -6
  48. data/app/views/mcms_pages/admin/pages/_action.html.erb +22 -3
  49. data/app/views/mcms_pages/admin/pages/_form.html.erb +8 -8
  50. data/app/views/mcms_pages/admin/pages/_form.js.erb +12 -11
  51. data/app/views/mcms_pages/admin/pages/_page_part_edit_form.html.erb +18 -45
  52. data/app/views/mcms_pages/admin/pages/_page_part_edit_form.html.erb~ +113 -0
  53. data/app/views/mcms_pages/admin/pages/_page_part_form.html.erb +5 -5
  54. data/app/views/mcms_pages/admin/pages/_page_part_form.html.erb~ +133 -0
  55. data/app/views/mcms_pages/admin/pages/_page_part_form_field.html.erb +36 -6
  56. data/app/views/mcms_pages/admin/pages/_page_part_page_form_field.html.erb +9 -19
  57. data/app/views/mcms_pages/admin/pages/add_page_part.js.erb +26 -4
  58. data/app/views/mcms_pages/admin/pages/edit.html.erb +2 -0
  59. data/app/views/mcms_pages/admin/pages/index.html.erb +4 -2
  60. data/app/views/mcms_pages/admin/pages/new.html.erb +2 -0
  61. data/app/views/mcms_pages/layouts/_footer.html.erb +3 -2
  62. data/app/views/mcms_pages/layouts/_head.html.erb +18 -0
  63. data/app/views/mcms_pages/layouts/_header.html.erb +3 -2
  64. data/app/views/mcms_pages/layouts/_javascript.html.erb +1 -1
  65. data/app/views/mcms_pages/layouts/_stylesheets.html.erb +2 -3
  66. data/app/views/mcms_pages/layouts/mcms_layout.html.erb +2 -3
  67. data/app/views/mcms_pages/pages/_left_side_body.html.erb +1 -4
  68. data/app/views/mcms_pages/pages/_main_body.html.erb +8 -3
  69. data/app/views/mcms_pages/pages/_menu.html.erb +6 -2
  70. data/app/views/mcms_pages/pages/_menubar.html.erb +16 -6
  71. data/app/views/mcms_pages/pages/_one_column_layout.html.erb +5 -2
  72. data/app/views/mcms_pages/pages/_right_side_body.html.erb +1 -4
  73. data/app/views/mcms_pages/pages/_three_column_layout.html.erb +17 -6
  74. data/app/views/mcms_pages/pages/_two_column_layout.html.erb +21 -9
  75. data/app/views/mcms_pages/pages/home.html.erb +10 -8
  76. data/app/views/mcms_pages/pages/show.html.erb +14 -6
  77. data/db/migrate/20120718115449_add_depth_to_pages.rb +5 -0
  78. data/db/seeds.rb +5 -3
  79. data/lib/generators/mcms_pages/mcms_pages_generator.rb +1 -1
  80. data/lib/generators/mcms_pages/templates/{asset_manager.rb → asset.rb} +28 -25
  81. data/lib/mcms_pages/engine.rb +1 -0
  82. metadata +42 -6
  83. data/app/assets/javascripts/menuPage.js +0 -45
  84. data/app/controllers/application_controller.rb +0 -20
@@ -17,6 +17,7 @@ class Admin::PagesController < AdminController
17
17
 
18
18
  # loading controller specific assets
19
19
  before_filter :load_assets
20
+ after_filter :clean_pages, :only => [:update]
20
21
 
21
22
  # GET /pages
22
23
  # GET /pages.json
@@ -85,15 +86,20 @@ class Admin::PagesController < AdminController
85
86
  #@page = Page.find(params[:id])
86
87
  @page = Page.find_by_slug_or_id(params[:path], params[:id])
87
88
 
88
- #retrieving layout id from params and assigning to a variable
89
- @layout = @page["layout_id"]
89
+ if @page.nil?
90
+
91
+ raise ActiveRecord::RecordNotFound
92
+
93
+ else
94
+
95
+ #retrieving layout id from params and assigning to a variable
96
+ @layout = @page["layout_id"]
97
+
98
+ end # end if
90
99
 
91
100
  # calling method to find all pages and page parts
92
101
  find_pages_and_parts(@layout)
93
102
 
94
- # calling method to define parts of the page
95
- define_parts
96
-
97
103
  #sends data in different formats
98
104
  respond_to do |format|
99
105
 
@@ -135,7 +141,7 @@ class Admin::PagesController < AdminController
135
141
 
136
142
  else #page saving failed, re-render the form
137
143
 
138
- format.html { render action: "new" }
144
+ format.html { render action: "new", :template => 'mcms_pages/admin/pages/new' }
139
145
  format.json { render json: @page.errors, status: :unprocessable_entity }
140
146
 
141
147
  end # end if
@@ -153,15 +159,16 @@ class Admin::PagesController < AdminController
153
159
  #find the page with given id
154
160
  @page = Page.find(params[:id])
155
161
 
162
+ #use updated_at manually, it will update the page table if user hits update button.
163
+ # This may not be trivial, so it may change.
164
+ @page.updated_at = Time.now
165
+
156
166
  #retrieving layout id from params and assigning to a variable
157
167
  @layout = @page[:layout_id]
158
168
 
159
169
  # calling method to find all pages and page parts
160
170
  find_pages_and_parts(@layout)
161
171
 
162
- # calling method to define parts of the page
163
- define_parts
164
-
165
172
  #sends in data in different format
166
173
  respond_to do |format|
167
174
 
@@ -169,7 +176,7 @@ class Admin::PagesController < AdminController
169
176
  format.html { redirect_to admin_pages_path, notice: 'Page was successfully updated.' }
170
177
  format.json { head :no_content }
171
178
  else #page saving failed, re-renders edit template
172
- format.html { render action: "edit" }
179
+ format.html { render action: "edit", :template => 'mcms_pages/admin/pages/edit' }
173
180
  format.json { render json: @page.errors, status: :unprocessable_entity }
174
181
 
175
182
  end # end if
@@ -187,6 +194,8 @@ class Admin::PagesController < AdminController
187
194
  # find the page with with
188
195
  @page = Page.find(params[:id])
189
196
 
197
+ PagePart.delete_page_parts(@page)
198
+
190
199
  #destroy the page
191
200
  @page.destroy
192
201
 
@@ -209,18 +218,26 @@ class Admin::PagesController < AdminController
209
218
  @page = Page.find_by_slug(params[:path])
210
219
 
211
220
  logger.debug @page
212
- render :layout => false
221
+
222
+ #sends in data in different format to index action
223
+ respond_to do |format|
224
+
225
+ format.html { render :template => 'mcms_pages/admin/pages/find_child', :layout => false }
226
+ format.json { head :no_content }
227
+
228
+ end # end respond_to block
213
229
 
214
230
  end
215
231
 
216
- # @param : Object(as a string)
232
+ # @param : string
217
233
  # @return : None
218
- # @purpose : To render a page part dynamically
234
+ # @purpose : To render a page part pages dynamically
219
235
  def add_page_part
220
236
 
221
237
  #retrieve parameters and assign these to instance variables
222
238
  @title = params[:title]
223
239
  @index = params[:index]
240
+ @part = params[:part]
224
241
 
225
242
  # render js.erb
226
243
  respond_to do |format|
@@ -239,10 +256,10 @@ class Admin::PagesController < AdminController
239
256
  def load_assets
240
257
 
241
258
  # class method call to include js files
242
- AssetManager.include_local_library [:application, :pageFormAdmin, "ckeditor/init"]
259
+ Asset.include_local_library [:application, :pageFormAdmin, "ckeditor/init"]
243
260
 
244
261
  # class method call to include css files
245
- AssetManager.include_css ["mcms_pages/pages", "mcms_pages/page_styles"]
262
+ Asset.include_css ["mcms_pages/pages", "mcms_pages/page_form", "mcms_pages/tabs"]
246
263
 
247
264
  end # end method
248
265
 
@@ -254,7 +271,7 @@ class Admin::PagesController < AdminController
254
271
  #renders the form field for each part of layout
255
272
  parts.each_with_index do |page_part, index|
256
273
 
257
- fragment = get_fragments(index, page_part)
274
+ fragment = get_fragments(page_part)
258
275
 
259
276
  # check if same type of fragment is already created
260
277
  if fragment.nil? or fragment.blank? or fragment.empty?
@@ -275,29 +292,38 @@ class Admin::PagesController < AdminController
275
292
 
276
293
  def find_pages_and_parts layout
277
294
 
278
- #calling find_all_pages method from Page model
279
- @pages = Page.find_all_pages
280
-
281
295
  # storing the array returned by helper method to
282
296
  # decide the page parts in a layout
283
297
  @parts = Layout.find_page_parts(layout)
284
298
 
285
- end
299
+ end # end method
286
300
 
287
- def define_parts
301
+ # @param : None
302
+ # @return : None
303
+ # @purpose : To delete orphan record
304
+ def clean_pages
288
305
 
289
- # declare an empty hash
290
- @part_title = Hash.new
306
+ # find all records in the table mcms_page_parts
307
+ page_parts = PagePart.all
291
308
 
292
- # loop through each part of the page
293
- @parts.each_with_index do |part,index|
309
+ # loop through all page_parts array
310
+ page_parts.each do |page_part|
294
311
 
295
- # retrieve the id of page parts of the page based on title and store it as a hash element
296
- @part_title[part] = @page.page_parts.select("mcms_page_parts.id").find_by_title(part).id
312
+ # find page_part_page corresponding to a page_part
313
+ page_part_page = PagePartsPage.where("page_part_id = ?", page_part.id).first
314
+
315
+ # check if there is no page_part_page corresponding to a page_part
316
+ if page_part_page.nil? or page_part_page.blank?
317
+
318
+ # find page part with relevent id and delete it
319
+ part = PagePart.find(page_part.id)
320
+ part.destroy
321
+
322
+ end # end if
297
323
 
298
324
  end # end loop
299
325
 
300
- end
326
+ end # end method
301
327
 
302
328
  end #end class
303
329
 
@@ -13,10 +13,44 @@
13
13
  class AdminController < ApplicationController
14
14
 
15
15
  #admin part
16
- layout "mcms_pages/layouts/mcms_layout"
16
+ # check if mcms core layout exists
17
+ if Gem.available?('mcms')
17
18
 
19
+ #if yes then use core layout
20
+ layout "mcms/main_layout"
21
+
22
+ else # if not
23
+
24
+ # use page's default layout
25
+ layout "mcms_pages/layouts/mcms_layout"
26
+
27
+ end # end if
28
+
29
+ # use before filter to authenticate user
18
30
  prepend_before_filter :authenticate_user!
31
+
32
+ # check authorization for a user
19
33
  load_and_authorize_resource
20
34
 
21
- end
35
+ # rescue from record not found exception
36
+ rescue_from ActiveRecord::RecordNotFound, :with => :render_404
37
+
38
+
39
+ # @params : None
40
+ # @return : None
41
+ # @purpose : To render 404.html from public folder
42
+ def render_404
43
+
44
+ # render data in different format
45
+ respond_to do |format|
46
+
47
+ format.html { render :file => "#{Rails.root}/public/404.html", :status => :not_found }
48
+ format.xml { head :not_found }
49
+ format.any { head :not_found }
50
+
51
+ end # end respond_to block
52
+
53
+ end # end method
54
+
55
+ end # end class
22
56
 
@@ -13,8 +13,6 @@
13
13
 
14
14
  class PagesController < ApplicationController
15
15
 
16
- # loading controller specific assets
17
- before_filter :load_assets
18
16
  layout "mcms_pages/layouts/mcms_layout"
19
17
 
20
18
  #finding page based on url
@@ -85,6 +83,19 @@ class PagesController < ApplicationController
85
83
  # Preview a non-persisted page
86
84
  @page = Page.new(params[:page])
87
85
 
86
+ # initializing a loop variable
87
+ i = @page.page_parts.length
88
+
89
+ # looping through page_parts_pages to retrieve all page_parts
90
+ params[:page]["page_parts_pages_attributes"].each do |k,v|
91
+
92
+ # retrieve existing page_parts from DB and assign it to @page array
93
+ @page.page_parts[i] = PagePart.find_by_id(v["page_part_id"]);
94
+
95
+ i = i + 1 # incrementing the loop variable
96
+
97
+ end # end loop
98
+
88
99
  end # end if
89
100
 
90
101
  # send data in different format
@@ -100,20 +111,12 @@ class PagesController < ApplicationController
100
111
  #defining controller specific method as protected
101
112
  protected
102
113
 
103
- #calling library class AssetManager's methods to include specific js and css files
104
- def load_assets
105
-
106
- # class method call to include css files
107
- AssetManager.include_css ["mcms_pages/pages", "mcms_pages/page_styles"]
108
-
109
- end # end method
110
-
111
114
  # @param : boolean(optional)
112
115
  # @return : none
113
116
  # @purpose : To find a page if it exists or show the page not found error
114
117
  def get_page(page_not_found = true)
115
118
 
116
- @menu_pages = Page.where(:published => true)
119
+ @menu_pages = Page.where("published = ? and show_in_menu = ?", true, true)
117
120
 
118
121
  # case statement based on current action and assign the result to instance variable
119
122
  case action_name
@@ -145,6 +148,15 @@ class PagesController < ApplicationController
145
148
  # find page based on link_url and assign it to an instance variable
146
149
  @page = Page.where(:link_url => "/404").first
147
150
 
151
+ # send data in different format
152
+ respond_to do |format|
153
+
154
+ format.html{ render :template => 'mcms_pages/pages/show'}# show.html.erb
155
+ format.json { render json: @page }
156
+
157
+ end # end respond_to block
158
+
159
+
148
160
  end # end method
149
161
 
150
162
  end #end class
@@ -11,7 +11,7 @@
11
11
  =end
12
12
 
13
13
  module PagesHelper
14
-
14
+
15
15
  # @Parameters : integer(column count of a layout)
16
16
  # @Return : Array
17
17
  # @purpose : To give layout a name on the basis of parameter
@@ -23,19 +23,19 @@ module PagesHelper
23
23
  when 2
24
24
 
25
25
  return "two_column_layout"
26
-
26
+
27
27
  when 3
28
28
 
29
29
  return "three_column_layout"
30
-
30
+
31
31
  when 1
32
32
 
33
33
  return "one_column_layout"
34
34
 
35
35
  else
36
-
36
+
37
37
  return "default_layout"
38
-
38
+
39
39
  end # end case statement
40
40
 
41
41
  end #end method
@@ -49,70 +49,78 @@ module PagesHelper
49
49
 
50
50
  end
51
51
 
52
-
53
52
  # @param : Integer
54
53
  # @return : Array
55
54
  # @purpose : To find page parts according to param
56
- def get_fragments(part, title)
55
+ def get_fragments title
57
56
 
58
- #using case statement to get fragments
59
- case part
57
+ if title != "main body"
60
58
 
61
- when 0
59
+ # get page body fragment with title
60
+ part = PagePart.find_page_parts_with_title(title)
62
61
 
63
- if title == "header"
64
-
65
- # get header fragment
66
- part = PagePart.find_page_parts_with_title_header
62
+ end
67
63
 
68
- end
69
-
70
- when 1
71
-
72
- # get footer fragment
73
- part = PagePart.find_page_parts_with_title_footer
64
+ end # end method
74
65
 
75
- when 2
66
+ # @param : Integer(part_index of page part)
67
+ # @return : Object
68
+ # @purpose : To build a form object for dynamic creating the page part
69
+ def build_page_part index
76
70
 
77
- if title == "left body"
78
-
79
- # get left body fragment
80
- part = PagePart.find_page_parts_with_title_left_body
81
-
82
- elsif title == "right body"
83
-
84
- # get right body fragment
85
- part = PagePart.find_page_parts_with_title_right_body
86
-
87
- end
88
-
89
- when 3
90
-
91
- if title == "right body"
71
+ # create a PagePart object and assign it to a variable
72
+ page = PagePart.new
92
73
 
93
- # get right body fragment
94
- part = PagePart.find_page_parts_with_title_right_body
74
+ #make the page part form
75
+ builder = ActionView::Helpers::FormBuilder.new( "page[page_parts_attributes][#{index}]", page, self, {}, proc {})
95
76
 
96
- end
97
-
98
- end # end case
77
+ #return form object
78
+ return builder
99
79
 
100
80
  end # end method
101
81
 
102
82
  # @param : Integer(part_index of page part)
103
83
  # @return : Object
104
84
  # @purpose : To build a form object for dynamic creating the page part
105
- def build_page_part index
85
+ def build_page_part_page index
106
86
 
107
87
  # create a PagePart object and assign it to a variable
108
- page = PagePart.new
88
+ page = PagePartsPage.new
109
89
 
110
90
  #make the page part form
111
- builder = ActionView::Helpers::FormBuilder.new( "page[page_parts_attributes][#{index}]", page, self, {}, proc {})
91
+ builder = ActionView::Helpers::FormBuilder.new( "page[page_parts_pages_attributes][#{index}]", page, self, {}, proc {})
112
92
 
113
93
  #return form object
114
94
  return builder
115
95
 
116
96
  end # end method
117
97
 
98
+ # @param : Array(page array to be arranged)
99
+ # @return : Hash
100
+ # @purpose : To arrange the result and store it in a hash to display the value properly
101
+ def arrange_page_part page
102
+
103
+ # find the length of page_parts of current page
104
+ part_length = page.page_parts.length
105
+
106
+ # create an empty hash
107
+ part_pages = Hash.new
108
+
109
+ #loop through the length of page_part
110
+ for i in 0..part_length-1
111
+
112
+ #find each page_part array and assign it in a variable
113
+ part = page.page_parts[i]
114
+
115
+ #assign page_part array to hash
116
+ part_pages[part.title] = part
117
+
118
+ end # end loop
119
+
120
+ # return hash
121
+ part_pages
122
+
123
+ end # end method
124
+
118
125
  end # end module
126
+
@@ -1,6 +1,7 @@
1
1
  class Ckeditor::Asset < ActiveRecord::Base
2
2
 
3
- self.table_name = "mcms_assets"
3
+ #self.table_name = "mcms_assets"
4
+ set_table_name "mcms_assets"
4
5
 
5
6
  include Ckeditor::Orm::ActiveRecord::AssetBase
6
7
  include Ckeditor::Backend::Paperclip
data/app/models/page.rb CHANGED
@@ -32,8 +32,12 @@ class Page < ActiveRecord::Base
32
32
  #include rails standard validation for title
33
33
  validates :title, :presence => true, :uniqueness => true
34
34
 
35
+ # validating link url using rails standard validator with regular expression
36
+ validates_format_of :link_url,
37
+ :with => /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/ix unless :link_url.length > 0
38
+
35
39
  # Nested pages, i.e. page underneath another page
36
- #acts_as_nested_set :dependent => :destroy
40
+ acts_as_nested_set :dependent => :destroy
37
41
 
38
42
  #Associating table "mcms_pages" with table "mcms_page_parts" using has_many relation
39
43
  # has_many :page_parts,
@@ -28,72 +28,53 @@ class PagePart < ActiveRecord::Base
28
28
  #validating title field to have non-blank value
29
29
  validates :title, :presence => true
30
30
 
31
- # @param : none
31
+ # @param : string(title of the page part)
32
32
  # @return : array
33
- # @purpose : To find all page_parts with title header
34
- def self.find_page_parts_with_title_header
33
+ # @purpose : To find all page_parts with given title
34
+ def self.find_page_parts_with_title title
35
35
 
36
36
  #find all page parts with title header and assign it to a variable
37
- header_part = self.find_all_by_title("header")
37
+ part_body = self.find_all_by_title(title)
38
38
 
39
39
  # calling method to find unique pages and assigning them to an array
40
- page_title = PagePartsPage.find_unique_page_parts_pages(header_part)
40
+ page_title = PagePartsPage.find_unique_page_parts_pages(part_body)
41
41
 
42
42
  # returning the array
43
43
  return page_title
44
-
44
+
45
45
  end # end method
46
46
 
47
47
  # @param : none
48
48
  # @return : array
49
- # @purpose : To find all page_parts with title header
50
- def self.find_page_parts_with_title_footer
51
-
52
- #find all page parts with title header and assign it to a variable
53
- footer_part = self.find_all_by_title("footer")
54
-
55
- # calling method to find unique pages and assigning them to an array
56
- page_title = PagePartsPage.find_unique_page_parts_pages(footer_part)
49
+ # @purpose : It will just return the title of page part
50
+ def self.find_page_parts_with_title_main_body
57
51
 
58
- # returning the array
59
- return page_title
52
+ return "main body"
60
53
 
61
54
  end # end method
62
55
 
63
- # @param : none
64
- # @return : array
65
- # @purpose : To find all page_parts with title right body
66
- def self.find_page_parts_with_title_right_body
67
-
68
- #find all page parts with title header and assign it to a variable
69
- right_body = self.find_all_by_title("right body")
56
+ # @param : Object
57
+ # @return : none
58
+ # @purpose : To find all independent page_parts and delete it
59
+ def self.delete_page_parts page
70
60
 
71
- # calling method to find unique pages and assigning them to an array
72
- page_title = PagePartsPage.find_unique_page_parts_pages(right_body)
61
+ # loop through page_parts_pages of page and check its page part
62
+ page.page_parts_pages.each do |page_part_page|
73
63
 
74
- # returning the array
75
- return page_title
64
+ # find page_part by its id and assign it to a variable
65
+ page_part = self.find_by_id(page_part_page.page_part_id)
76
66
 
77
- end # end method
67
+ # if there is only one page_part for a page then delete it
68
+ if page_part.pages.count == 1 and page_part.pages.first.title == page.title
78
69
 
79
- # @param : none
80
- # @return : array
81
- # @purpose : To find all page_parts with title left body
82
- def self.find_page_parts_with_title_left_body
70
+ # delete page_part
71
+ page_part.destroy
83
72
 
84
- #find all page parts with title header and assign it to a variable
85
- left_body = self.find_all_by_title("left body")
73
+ end # end if
86
74
 
87
- # calling method to find unique pages and assigning them to an array
88
- page_title = PagePartsPage.find_unique_page_parts_pages(left_body)
89
-
90
- # returning the array
91
- return page_title
75
+ end # end loop
92
76
 
93
77
  end # end method
94
78
 
95
- def self.find_page_parts_with_title_main_body
96
- return "main body"
97
- end
98
-
99
- end # end class
79
+ end # end class
80
+
@@ -4,7 +4,7 @@
4
4
  @Company Name : Mindfire Solutions Private Limited
5
5
  @Creator Name : Vikram Kumar Mishra
6
6
  @Date Created : 2012-06-15
7
- @Date Modified :
7
+ @Date Modified :
8
8
  @Last Modification Details :
9
9
  @Purpose : To display all the layouts and respective image and let the user choose the specific layout.
10
10
 
@@ -30,19 +30,19 @@
30
30
  <div class="layout-image">
31
31
 
32
32
  <%= image_tag("layouts/#{layout.name.tr(' ', '-')}.png", :size => "400x400", :alt => "#{layout.name}", :title => "click to view large") %>
33
-
33
+
34
34
  </div>
35
35
  <div class="layout-link">
36
36
 
37
37
  <!-- if parent_id is not 0 then send parent_id through url -->
38
38
  <% if not @page_parent_id == 0 %>
39
-
39
+
40
40
  <%= link_to("Use This Layout", new_admin_page_path(:layout_id => "#{layout.id}", :parent_id => "#{@page_parent_id}")) %>
41
41
 
42
42
  <% else %>
43
-
43
+
44
44
  <%= link_to("Use This Layout", new_admin_page_path(:layout_id => "#{layout.id}")) %>
45
-
45
+
46
46
  <% end %>
47
47
 
48
48
  </div>
@@ -51,4 +51,7 @@
51
51
 
52
52
  <% end %>
53
53
 
54
- </div>
54
+ </div>
55
+
56
+ <%= render :partial => "mcms_pages/layouts/head" %>
57
+
@@ -11,9 +11,28 @@
11
11
  -->
12
12
 
13
13
 
14
- <section id="application-actions">
14
+ <div class="repos application-actions">
15
15
 
16
- <%= link_to "Add a New Page", new_admin_page_path, :id => "page-new" %>
16
+ <div class="top-bar">
17
17
 
18
- </section>
18
+ <h2>Quick tasks </h2>
19
+ <%= link_to "Add a New Page", new_admin_page_path, :id => "page-new", :class =>"button new-repo" %>
20
+
21
+ </div>
22
+
23
+ <ul class="repo-list">
24
+
25
+ <li class="public source">
26
+ <a href="/" target="_blank">
27
+ <span class="mini-icon"></span>
28
+ <span class="owner">Switch to Website</span><span class="repo"></span>
29
+ <span class="arrow"></span>
30
+ </a>
31
+ </li>
32
+ </ul>
33
+
34
+ <div class="bottom-bar">
35
+ </div>
36
+
37
+ </div>
19
38