refinerycms 0.9.3 → 0.9.4

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.
@@ -0,0 +1,7 @@
1
+ # Methods added to this helper will be available to all templates in the application.
2
+
3
+ # You can extend refinery with your own functions here and they will likely not get overriden in an update.
4
+ module ApplicationHelper
5
+ include Refinery::ApplicationHelper # leave this line in to include all of Refinery's core helper methods.
6
+
7
+ end
@@ -1,5 +1,5 @@
1
1
  [{:name => "site_name", :value => "Company Name"},
2
- {:name => "new_page_parts", :value => true},
2
+ {:name => "new_page_parts", :value => false},
3
3
  {:name => "activity_show_limit", :value => 10},
4
4
  {:name => "preferred_image_view", :value => :grid},
5
5
  {:name => "analytics_page_code", :value => "UA-xxxxxx-x"},
@@ -1,154 +1,154 @@
1
1
  jQuery.noConflict();
2
2
  var wymeditor_inputs = [];
3
- jQuery(function()
4
- {
5
- var wym_editors_loaded = 0;
6
- wymeditor_inputs = jQuery('.wymeditor');
7
- wymeditor_inputs.hide();
8
- wymeditor_inputs.wymeditor(
9
- {
10
- skin: 'refinery'
11
- , basePath: "/javascripts/wymeditor/"
12
- , wymPath: "/javascripts/wymeditor/jquery.refinery.wymeditor.js"
13
- , cssSkinPath: "/stylesheets/wymeditor/skins/"
14
- , jsSkinPath: "/javascripts/wymeditor/skins/"
15
- , langPath: "/javascripts/wymeditor/lang/"
16
- , iframeBasePath: '/'
17
- , toolsItems: [
18
- {'name': 'Bold', 'title': 'Bold', 'css': 'wym_tools_strong'}
19
- ,{'name': 'Italic', 'title': 'Emphasis', 'css': 'wym_tools_emphasis'}
20
- ,{'name': 'InsertOrderedList', 'title': 'Ordered_List', 'css': 'wym_tools_ordered_list'}
21
- ,{'name': 'InsertUnorderedList', 'title': 'Unordered_List', 'css': 'wym_tools_unordered_list'}
22
- ,{'name': 'CreateLink', 'title': 'Link', 'css': 'wym_tools_link'}
23
- ,{'name': 'Unlink', 'title': 'Unlink', 'css': 'wym_tools_unlink'}
24
- ,{'name': 'InsertImage', 'title': 'Image', 'css': 'wym_tools_image'}
25
- ,{'name': 'InsertTable', 'title': 'Table', 'css': 'wym_tools_table'}
26
- ,{'name': 'ToggleHtml', 'title': 'HTML', 'css': 'wym_tools_html'}
27
- ,{'name': 'Paste', 'title': 'Paste_From_Word', 'css': 'wym_tools_paste'}
28
- ]
29
-
30
- ,toolsHtml: "<ul class='wym_tools wym_section'>" + WYMeditor.TOOLS_ITEMS + WYMeditor.CLASSES + "</ul>"
31
-
32
- ,toolsItemHtml:
33
- "<li class='" + WYMeditor.TOOL_CLASS + "'>"
34
- + "<a href='#' name='" + WYMeditor.TOOL_NAME + "' title='" + WYMeditor.TOOL_TITLE + "'>" + WYMeditor.TOOL_TITLE + "</a>"
3
+ var wymeditors_loaded = 0;
4
+ var wymeditor_boot_options = {
5
+ skin: 'refinery'
6
+ , basePath: "/javascripts/wymeditor/"
7
+ , wymPath: "/javascripts/wymeditor/jquery.refinery.wymeditor.js"
8
+ , cssSkinPath: "/stylesheets/wymeditor/skins/"
9
+ , jsSkinPath: "/javascripts/wymeditor/skins/"
10
+ , langPath: "/javascripts/wymeditor/lang/"
11
+ , iframeBasePath: '/'
12
+ , toolsItems: [
13
+ {'name': 'Bold', 'title': 'Bold', 'css': 'wym_tools_strong'}
14
+ ,{'name': 'Italic', 'title': 'Emphasis', 'css': 'wym_tools_emphasis'}
15
+ ,{'name': 'InsertOrderedList', 'title': 'Ordered_List', 'css': 'wym_tools_ordered_list'}
16
+ ,{'name': 'InsertUnorderedList', 'title': 'Unordered_List', 'css': 'wym_tools_unordered_list'}
17
+ ,{'name': 'CreateLink', 'title': 'Link', 'css': 'wym_tools_link'}
18
+ ,{'name': 'Unlink', 'title': 'Unlink', 'css': 'wym_tools_unlink'}
19
+ ,{'name': 'InsertImage', 'title': 'Image', 'css': 'wym_tools_image'}
20
+ ,{'name': 'InsertTable', 'title': 'Table', 'css': 'wym_tools_table'}
21
+ ,{'name': 'ToggleHtml', 'title': 'HTML', 'css': 'wym_tools_html'}
22
+ ,{'name': 'Paste', 'title': 'Paste_From_Word', 'css': 'wym_tools_paste'}
23
+ ]
24
+
25
+ ,toolsHtml: "<ul class='wym_tools wym_section'>" + WYMeditor.TOOLS_ITEMS + WYMeditor.CLASSES + "</ul>"
26
+
27
+ ,toolsItemHtml:
28
+ "<li class='" + WYMeditor.TOOL_CLASS + "'>"
29
+ + "<a href='#' name='" + WYMeditor.TOOL_NAME + "' title='" + WYMeditor.TOOL_TITLE + "'>" + WYMeditor.TOOL_TITLE + "</a>"
30
+ + "</li>"
31
+
32
+ //containersItems will be appended after tools in postInit.
33
+ , containersItems: [
34
+ {'name': 'h1', 'title':'Heading_1', 'css':'wym_containers_h1'}
35
+ ,{'name': 'h2', 'title':'Heading_2', 'css':'wym_containers_h2'}
36
+ ,{'name': 'h3', 'title':'Heading_3', 'css':'wym_containers_h3'}
37
+ ,{'name': 'p', 'title':'Paragraph', 'css':'wym_containers_p'}
38
+ ]
39
+
40
+ , classesHtml: "<li class='wym_tools_class'><a href='#' name='" + WYMeditor.APPLY_CLASS + "' title='"+ titleize(WYMeditor.APPLY_CLASS) +"'></a><ul class='wym_classes wym_classes_hidden'>" + WYMeditor.CLASSES_ITEMS + "</ul></li>"
41
+
42
+ , classesItemHtml: "<li><a href='#' name='"+ WYMeditor.CLASS_NAME + "'>"+ WYMeditor.CLASS_TITLE+ "</a></li>"
43
+ , classesItemHtmlMultiple: "<li class='wym_tools_class_multiple_rules'><span>" + WYMeditor.CLASS_TITLE + "</span><ul>{classesItemHtml}</ul></li>"
44
+
45
+ , classesItems: [{name:'text-align', rules:['left', 'center', 'right', 'justify'], join: '-'}, {name: 'image-align', rules:['left', 'right'], join: '-'}, {name: 'font-size', rules:['small','normal','large'], join: '-'}]
46
+
47
+ , containersHtml: "<ul class='wym_containers wym_section'>" + WYMeditor.CONTAINERS_ITEMS + "</ul>"
48
+
49
+ , containersItemHtml:
50
+ "<li class='" + WYMeditor.CONTAINER_CLASS + "'>"
51
+ + "<a href='#' name='" + WYMeditor.CONTAINER_NAME + "' title='" + WYMeditor.CONTAINER_TITLE + "'></a>"
35
52
  + "</li>"
36
-
37
- //containersItems will be appended after tools in postInit.
38
- , containersItems: [
39
- {'name': 'h1', 'title':'Heading_1', 'css':'wym_containers_h1'}
40
- ,{'name': 'h2', 'title':'Heading_2', 'css':'wym_containers_h2'}
41
- ,{'name': 'h3', 'title':'Heading_3', 'css':'wym_containers_h3'}
42
- ,{'name': 'p', 'title':'Paragraph', 'css':'wym_containers_p'}
43
- ]
44
-
45
- , classesHtml: "<li class='wym_tools_class'><a href='#' name='" + WYMeditor.APPLY_CLASS + "' title='"+ titleize(WYMeditor.APPLY_CLASS) +"'></a><ul class='wym_classes wym_classes_hidden'>" + WYMeditor.CLASSES_ITEMS + "</ul></li>"
46
-
47
- , classesItemHtml: "<li><a href='#' name='"+ WYMeditor.CLASS_NAME + "'>"+ WYMeditor.CLASS_TITLE+ "</a></li>"
48
- , classesItemHtmlMultiple: "<li class='wym_tools_class_multiple_rules'><span>" + WYMeditor.CLASS_TITLE + "</span><ul>{classesItemHtml}</ul></li>"
49
-
50
- , classesItems: [{name:'text-align', rules:['left', 'center', 'right', 'justify'], join: '-'}, {name: 'image-align', rules:['left', 'right'], join: '-'}, {name: 'font-size', rules:['small','normal','large'], join: '-'}]
51
-
52
- , containersHtml: "<ul class='wym_containers wym_section'>" + WYMeditor.CONTAINERS_ITEMS + "</ul>"
53
-
54
- , containersItemHtml:
55
- "<li class='" + WYMeditor.CONTAINER_CLASS + "'>"
56
- + "<a href='#' name='" + WYMeditor.CONTAINER_NAME + "' title='" + WYMeditor.CONTAINER_TITLE + "'></a>"
57
- + "</li>"
58
-
59
- , boxHtml:
60
- "<div class='wym_box'>"
61
- + "<div class='wym_area_top'>"
62
- + WYMeditor.TOOLS
63
- + WYMeditor.CONTAINERS
64
- + "</div>"
65
- + "<div class='wym_area_main'>"
66
- + WYMeditor.HTML
67
- + WYMeditor.IFRAME
68
- + WYMeditor.STATUS
69
- + "</div>"
53
+
54
+ , boxHtml:
55
+ "<div class='wym_box'>"
56
+ + "<div class='wym_area_top'>"
57
+ + WYMeditor.TOOLS
58
+ + WYMeditor.CONTAINERS
70
59
  + "</div>"
71
-
72
- , iframeHtml:
73
- "<div class='wym_iframe wym_section'>"
74
- + "<iframe src='" + WYMeditor.IFRAME_BASE_PATH + "wymiframe' frameborder='0'"
75
- + "onload='this.contentWindow.parent.WYMeditor.INSTANCES[" + WYMeditor.INDEX + "].initIframe(this); init_tooltips();'>"
76
- + "</iframe>"
77
- +"</div>"
78
-
79
- , dialogImageHtml: ""
80
-
81
- , dialogLinkHtml: ""
82
-
83
- , dialogTableHtml:
84
- "<div class='wym_dialog wym_dialog_table'>"
85
- + "<form>"
86
- + "<input type='hidden' id='wym_dialog_type' class='wym_dialog_type' value='"+ WYMeditor.DIALOG_TABLE + "' />"
87
- + "<div class='field'>"
88
- + "<label for='wym_caption'>{Caption}</label>"
89
- + "<input type='text' id='wym_caption' class='wym_caption' value='' size='40' />"
90
- + "</div>"
91
- + "<div class='field'>"
92
- + "<label for='wym_rows'>{Number_Of_Rows}</label>"
93
- + "<input type='text' id='wym_rows' class='wym_rows' value='3' size='3' />"
94
- + "</div>"
95
- + "<div class='field'>"
96
- + "<label for='wym_cols'>{Number_Of_Cols}</label>"
97
- + "<input type='text' id='wym_cols' class='wym_cols' value='2' size='3' />"
98
- + "</div>"
99
- + "<div id='dialog-form-actions' class='form-actions'>"
100
- + "<input class='wym_submit' type='button' value='{Insert}' />"
101
- + " or "
102
- + "<a class='wym_cancel close_dialog' type='button' href=''>{Cancel}</a>"
103
- + "</div>"
104
- + "</form>"
105
- + "</div>"
106
-
107
- , dialogPasteHtml:
108
- "<div class='wym_dialog wym_dialog_paste'>"
109
- + "<form>"
110
- + "<input type='hidden' id='wym_dialog_type' class='wym_dialog_type' value='" + WYMeditor.DIALOG_PASTE + "' />"
111
- + "<div class='field'>"
112
- + "<label for='wym_text'>{Text_From_Word}</label"
113
- + "<textarea class='wym_text' rows='10' cols='50'></textarea>"
114
- + "</div>"
115
- + "<div id='dialog-form-actions' class='form-actions'>"
116
- + "<input class='wym_submit' type='button' value='{Insert}' />"
117
- + " or "
118
- + "<a class='wym_cancel close_dialog' type='button' href=''>{Cancel}</a>"
119
- + "</div>"
120
- + "</form>"
121
- + "</div>"
122
-
123
- , dialogPath: "/admin/dialogs/"
124
- , dialogFeatures: "?width=958&height=460&modal=true&titlebar=true&auto_size_content=true&draggable=true"
125
- , dialogInlineFeatures: "?width=600&height=320&modal=true&titlebar=true&auto_size_content=true&draggable=true"
126
-
127
- , dialogId: 'TB_window'
128
-
129
- , dialogHtml:
130
- "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>"
131
- + "<html dir='" + WYMeditor.DIRECTION + "'>"
132
- + "<head>"
133
- + "<link rel='stylesheet' type='text/css' media='screen' href='" + WYMeditor.CSS_PATH + "' />"
134
- + "<title>" + WYMeditor.DIALOG_TITLE + "</title>"
135
- + "<script type='text/javascript' src='" + WYMeditor.JQUERY_PATH + "'></script>"
136
- + "<script type='text/javascript' src='" + WYMeditor.WYM_PATH + "'></script>"
137
- + "</head>"
138
- + "<div id='page'>" + WYMeditor.DIALOG_BODY + "</div>"
139
- + "</html>"
140
-
141
- , postInit: function(wym)
142
- {
143
- wym._iframe.style.height = wym._element.height() + "px";
144
- wym_editors_loaded += 1;
145
- if(WYMeditor.INSTANCES.length == wym_editors_loaded){
146
- WYMeditor.loaded();
147
- }
148
- }
149
- });
60
+ + "<div class='wym_area_main'>"
61
+ + WYMeditor.HTML
62
+ + WYMeditor.IFRAME
63
+ + WYMeditor.STATUS
64
+ + "</div>"
65
+ + "</div>"
66
+
67
+ , iframeHtml:
68
+ "<div class='wym_iframe wym_section'>"
69
+ + "<iframe src='" + WYMeditor.IFRAME_BASE_PATH + "wymiframe' frameborder='0'"
70
+ + "onload='this.contentWindow.parent.WYMeditor.INSTANCES[" + WYMeditor.INDEX + "].initIframe(this); init_tooltips();'>"
71
+ + "</iframe>"
72
+ +"</div>"
150
73
 
151
- });
74
+ , dialogImageHtml: ""
75
+
76
+ , dialogLinkHtml: ""
77
+
78
+ , dialogTableHtml:
79
+ "<div class='wym_dialog wym_dialog_table'>"
80
+ + "<form>"
81
+ + "<input type='hidden' id='wym_dialog_type' class='wym_dialog_type' value='"+ WYMeditor.DIALOG_TABLE + "' />"
82
+ + "<div class='field'>"
83
+ + "<label for='wym_caption'>{Caption}</label>"
84
+ + "<input type='text' id='wym_caption' class='wym_caption' value='' size='40' />"
85
+ + "</div>"
86
+ + "<div class='field'>"
87
+ + "<label for='wym_rows'>{Number_Of_Rows}</label>"
88
+ + "<input type='text' id='wym_rows' class='wym_rows' value='3' size='3' />"
89
+ + "</div>"
90
+ + "<div class='field'>"
91
+ + "<label for='wym_cols'>{Number_Of_Cols}</label>"
92
+ + "<input type='text' id='wym_cols' class='wym_cols' value='2' size='3' />"
93
+ + "</div>"
94
+ + "<div id='dialog-form-actions' class='form-actions'>"
95
+ + "<input class='wym_submit' type='button' value='{Insert}' />"
96
+ + " or "
97
+ + "<a class='wym_cancel close_dialog' type='button' href=''>{Cancel}</a>"
98
+ + "</div>"
99
+ + "</form>"
100
+ + "</div>"
101
+
102
+ , dialogPasteHtml:
103
+ "<div class='wym_dialog wym_dialog_paste'>"
104
+ + "<form>"
105
+ + "<input type='hidden' id='wym_dialog_type' class='wym_dialog_type' value='" + WYMeditor.DIALOG_PASTE + "' />"
106
+ + "<div class='field'>"
107
+ + "<label for='wym_text'>{Text_From_Word}</label"
108
+ + "<textarea class='wym_text' rows='10' cols='50'></textarea>"
109
+ + "</div>"
110
+ + "<div id='dialog-form-actions' class='form-actions'>"
111
+ + "<input class='wym_submit' type='button' value='{Insert}' />"
112
+ + " or "
113
+ + "<a class='wym_cancel close_dialog' type='button' href=''>{Cancel}</a>"
114
+ + "</div>"
115
+ + "</form>"
116
+ + "</div>"
117
+
118
+ , dialogPath: "/admin/dialogs/"
119
+ , dialogFeatures: "?width=958&height=460&modal=true&titlebar=true&auto_size_content=true&draggable=true"
120
+ , dialogInlineFeatures: "?width=600&height=320&modal=true&titlebar=true&auto_size_content=true&draggable=true"
121
+
122
+ , dialogId: 'TB_window'
123
+
124
+ , dialogHtml:
125
+ "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>"
126
+ + "<html dir='" + WYMeditor.DIRECTION + "'>"
127
+ + "<head>"
128
+ + "<link rel='stylesheet' type='text/css' media='screen' href='" + WYMeditor.CSS_PATH + "' />"
129
+ + "<title>" + WYMeditor.DIALOG_TITLE + "</title>"
130
+ + "<script type='text/javascript' src='" + WYMeditor.JQUERY_PATH + "'></script>"
131
+ + "<script type='text/javascript' src='" + WYMeditor.WYM_PATH + "'></script>"
132
+ + "</head>"
133
+ + "<div id='page'>" + WYMeditor.DIALOG_BODY + "</div>"
134
+ + "</html>"
135
+
136
+ , postInit: function(wym)
137
+ {
138
+ wym._iframe.style.height = wym._element.height() + "px";
139
+ wymeditors_loaded += 1;
140
+ if(WYMeditor.INSTANCES.length == wymeditors_loaded){
141
+ WYMeditor.loaded();
142
+ }
143
+ }
144
+ };
152
145
 
153
146
  // custom function added by us to hook into when all wymeditor instances on the page have finally loaded:
154
- WYMeditor.loaded = function(){}
147
+ WYMeditor.loaded = function(){}
148
+
149
+ jQuery(function()
150
+ {
151
+ wymeditor_inputs = jQuery('.wymeditor');
152
+ wymeditor_inputs.hide();
153
+ wymeditor_inputs.wymeditor(wymeditor_boot_options);
154
+ });
@@ -888,8 +888,13 @@ a img {
888
888
  /* page parts */
889
889
 
890
890
  ul#page_parts {
891
- margin: 20px 0 0 0;
892
- padding: 0;
891
+ float: left;
892
+ width: 95%;
893
+ }
894
+
895
+ ul#page_parts, ul#page_parts_controls {
896
+ margin: 20px 0 0 0;
897
+ padding: 0;
893
898
  }
894
899
 
895
900
  ul#page_parts li {
@@ -899,30 +904,36 @@ ul#page_parts li {
899
904
  }
900
905
 
901
906
  ul#page_parts li a {
907
+ float: left;
902
908
  line-height: 27px;
903
- display: block;
904
909
  background: #c2c3b3;
905
910
  padding: 0px 8px;
906
911
  border-bottom: none;
907
912
  margin-top: 6px;
908
913
  }
909
914
 
910
- ul#page_parts li a.active {
915
+ ul#page_parts li.active a {
911
916
  background: #808080;
912
917
  line-height: 33px;
913
918
  color: white;
914
919
  margin-top: 0px;
915
920
  }
921
+ ul#page_parts_controls {
922
+ float: right;
923
+ width: 5%;
924
+ }
916
925
 
917
- #add_page_part {
918
- background: #8A8A72;
919
- padding: 5px 8px 3px 8px;
920
- border-bottom: none;
921
- margin-top: 9px;
922
- display: block;
923
- float: left;
926
+ ul#page_parts_controls li {
927
+ list-style: none;
928
+ float: right;
929
+ margin: 12px 3px 0px 3px;
924
930
  }
925
- #add_page_part img {
931
+
932
+ ul#page_parts_controls li a {
933
+ border: 0px none;
934
+ }
935
+
936
+ ul#page_parts_controls img {
926
937
  vertical-align: middle;
927
938
  }
928
939
 
@@ -24,5 +24,22 @@ namespace :images do
24
24
 
25
25
  puts "Image regeneration complete."
26
26
  end
27
-
27
+
28
+ desc "Update thumbnails. Useful for when you have added new thumbnail sizes and you just need to regenerate those without regenerating all the thumbnails again."
29
+ task :update => :environment do
30
+ originals = Image.originals
31
+
32
+ puts "Preparing to update #{originals.size} images. This may take a few minutes. Please wait..."
33
+
34
+ originals.each do |image|
35
+ begin
36
+ image.save
37
+ rescue Exception => e
38
+ puts "--> ERROR image #{image.id} could not be saved because #{e.message}"
39
+ end
40
+ end
41
+
42
+ puts "Thumbnail update complete."
43
+ end
44
+
28
45
  end
@@ -8,4 +8,7 @@ Refinery::Plugin.register do |plugin|
8
8
  {:class => Inquiry, :title => "name", :url_prefix => "", :created_image => "user_comment.png", :updated_image => "user_edit.png"},
9
9
  {:class => InquirySetting, :url_prefix => "edit", :title => 'name', :url_prefix => 'edit', :created_image => "user_comment.png", :updated_image => "user_edit.png"}
10
10
  ]
11
- end
11
+ end
12
+
13
+ # Set the actionmailer root so that it'll work for delivering emails from this plugin.
14
+ ActionMailer::Base.template_root = "#{REFINERY_ROOT}/vendor/plugins/inquiries/app/views"
@@ -1,34 +1,15 @@
1
1
  class Admin::PagePartsController < Admin::BaseController
2
-
3
- layout 'admin_dialog'
4
-
5
- crudify :page_part, :order => "position ASC"
6
2
 
7
3
  def new
8
- @page = Page.find(params[:page_id], :include => [:parts, :slugs])
9
- @page_part = @page.parts.new
4
+ render :partial => "/admin/pages/page_part_field", :locals => {:title => params[:title], :body => params[:body], :new_part => true, :part_index => params[:part_index]}
10
5
  end
11
6
 
12
- def create
13
- @page = Page.find(params[:page_id], :include => [:parts, :slugs])
14
- @page_part = @page.parts.new(params[:page_part])
15
- @page_part.title = @page_part.title.downcase.gsub(" ", "_")
16
-
17
- saved = @page_part.save
18
- flash[:error] = "You must enter a title for the part to be added to this page" unless saved
19
-
20
- unless request.xhr?
21
- redirect_to edit_admin_page_url(@page)
7
+ def destroy
8
+ part = PagePart.find(params[:id])
9
+ if part.destroy
10
+ render :text => "'#{part.title}' deleted."
22
11
  else
23
- if saved
24
- flash.now[:notice] = "The new content section was added. Please close this dialog and reload the page to use it. Make sure you save any changes you have made."
25
- end
26
-
27
- render :update do |page|
28
- page.replace_html 'flash_container', :partial => "/shared/message"
29
- page[:flash].appear
30
- end
31
- flash.discard # Get rid of the flash message, we don't need it anymore.. otherwise it'll show up on next page load.
12
+ render :text => "'#{part.title}' not deleted."
32
13
  end
33
14
  end
34
15
 
@@ -9,22 +9,29 @@
9
9
  <div class='clearfix'>
10
10
  <ul id='page_parts'>
11
11
  <% @page.parts.each do |p| %>
12
- <li class='tab'>
13
- <%= link_to p.title.titleize, "#part_#{p.title}", :class => ((@page.parts.index(p) == 0) ? "active" : nil) %>
12
+ <li class='tab<%= " active" if @page.parts.index(p) == 0 %>'>
13
+ <%= link_to p.title.titleize, "#part_#{p.title}" %>
14
14
  </li>
15
15
  <% end %>
16
16
  </ul>
17
17
  <% if RefinerySetting.find_or_set(:new_page_parts, false) and not @page.new_record? %>
18
- <%= link_to image_tag("/images/refinery/add.png"), new_admin_page_page_part_url(@page, {:dialog => true, :width => 600, :height => 300}), :id => "add_page_part", :title => "Create Content Section", :name => "Create Content Section" %>
18
+ <ul id='page_parts_controls'>
19
+ <li>
20
+ <%= link_to refinery_icon_tag("add.png"), "#", :id => "add_page_part", :title => "Create Content Section" %>
21
+ </li>
22
+ <li>
23
+ <%= link_to(refinery_icon_tag("delete.png"), "#", :title => 'Delete content section', :class => 'delete_page_part', :name => "Delete Content Section", :id => "delete_page_part") %>
24
+ </li>
25
+ </ul>
19
26
  <% end %>
20
27
  </div>
21
28
 
22
- <% f.fields_for :parts do |p| %>
23
- <div class='field' id='part_<%= p.object.title.downcase.gsub(" ", "_") %>'>
24
- <%= p.hidden_field :title if @page.new_record? %>
25
- <%= p.text_area :body, :rows => 20, :cols => 140, :class => 'wymeditor' %>
26
- </div>
27
- <% end %>
29
+ <div id='page_part_editors'>
30
+ <% part_index = -1 %>
31
+ <% f.fields_for :parts do |p| %>
32
+ <%= render :partial => "page_part_field", :locals => {:title => p.object.title, :body => p.object.body, :part_index => (part_index += 1), :new_part => false} %>
33
+ <% end %>
34
+ </div>
28
35
  </div>
29
36
  <p>
30
37
  <%= link_to "&raquo; Hide/Show Advanced Options", "", :id => "toggle_advanced_options",
@@ -34,10 +41,10 @@
34
41
  <div class='field'>
35
42
  <%= label_tag :custom_title %>
36
43
  <%= label_tag "", 'Type:', :class => "stripped" %>
37
- <% ["none", "text", "image"].each do |type| %>
38
- <%= f.radio_button :custom_title_type, "#{type}" %>
39
- <%= label_tag "page_custom_title_type_#{type}", "#{type.titleize}", :class => "stripped" %>
40
- <% end %>
44
+ <% ["none", "text", "image"].each do |type| %>
45
+ <%= f.radio_button :custom_title_type, "#{type}" %>
46
+ <%= label_tag "page_custom_title_type_#{type}", "#{type.titleize}", :class => "stripped" %>
47
+ <% end %>
41
48
  <br/>
42
49
  <div id='custom_title_none'></div>
43
50
  <div id='custom_title_text' style='display: <%= @page.custom_title_type == 'text' ? 'block' : 'none' %>'>
@@ -52,19 +59,17 @@
52
59
  <%= f.hidden_field :custom_title_image_id %>
53
60
  <div>
54
61
  <a id='current_image_link' href="<%= insert_admin_images_url %>?thickbox=true&amp;modal=true&amp;titlebar=true&amp;field=page_custom_title_image_id&amp;update_image=current_custom_title_image&amp;callback=custom_title_image_changed&amp;thumbnail=&amp;KeepThis=true&amp;TB_iframe=true&amp;width=950&amp;height=510" style='border: 0px' title='Change Image' name='Change Image' class='thickbox'>
55
- <% unless @page.custom_title_image.nil? %>
56
- <%= image_fu @page.custom_title_image, nil, {:class => "brown_border", :id => "current_custom_title_image"} %>
57
- <% else %>
58
- <img id="current_custom_title_image" class="" src="" alt="" />
59
- <% end %>
60
- <span id='no_custom_title_image_selected' style='display: <%= @page.custom_title_image.nil? ? '' : 'none' %>'>
61
- There is currently no image selected. Click here to add one
62
- </span>
62
+ <% unless @page.custom_title_image.nil? %>
63
+ <%= image_fu @page.custom_title_image, nil, {:class => "brown_border", :id => "current_custom_title_image"} %>
64
+ <% else %>
65
+ <img id="current_custom_title_image" class="" src="" alt="" />
66
+ <% end %>
67
+ <span id='no_custom_title_image_selected' <%= "style='display: none;'" unless @page.custom_title_image.nil? %>>
68
+ There is currently no image selected. Click here to add one
69
+ </span>
63
70
  </a>
64
71
  <br/>
65
- <a id='remove_custom_title_image' href="" style='margin-top: 8px;display:inline-block;width: auto<%= ";display:none;" if @page.custom_title_image.nil? %>'>
66
- Remove Current Image
67
- </a>
72
+ <%= link_to "Remove Current Image", "", :id => "remove_custom_title_image", :style => "margin-top:8px;display:inline-block;width:auto;#{"display:none;" if @page.custom_title_image.nil?}" %>
68
73
  </div>
69
74
  </div>
70
75
  </div>
@@ -122,6 +127,18 @@
122
127
  or
123
128
  <%= link_to "Cancel", admin_pages_url, :title => "Cancelling will lose all changes you've made to this page"%>
124
129
  </div>
130
+ <div id='new_page_part_dialog' style='display: none'>
131
+ <div class='field'>
132
+ <label for='new_page_part_title'>Title</label>
133
+ <input id='new_page_part_title' value='' class='larger' size='40' />
134
+ <input id='new_page_part_index' type='hidden' value='<%= @page.parts.size %>' />
135
+ </div>
136
+ <div id='dialog-form-actions' class='form-actions'>
137
+ <%= f.submit 'Save', :id => "new_page_part_save" %>
138
+ or
139
+ <%= link_to "Cancel", "#", :id => "new_page_part_cancel" %>
140
+ </div>
141
+ </div>
125
142
  <% end %>
126
143
  <% content_for :head do %>
127
144
  <script type='text/javascript'>
@@ -160,6 +177,80 @@
160
177
  this.hide();
161
178
  e.stop();
162
179
  });
180
+
181
+ $('add_page_part').observe('click', function(e) {
182
+ tb_show('Create Content Section', '#?auto_size_content=true&draggable=true&titlebar=true&inlineId=new_page_part_dialog&TB_inline=true&modal=true');
183
+
184
+ e.stop();
185
+ });
186
+
187
+ $('new_page_part_save').observe('click', function(e) {
188
+ if ((part_title = $('new_page_part_title').value).length > 0) {
189
+ tab_title = part_title.toLowerCase().gsub(" ", "_");
190
+ if ($$('#part_' + tab_title).size() == 0) {
191
+ // first get the response from the server
192
+ new Ajax.Request("<%= new_admin_page_part_url %>", {
193
+ asynchronous: true
194
+ , method: 'get'
195
+ , parameters: {
196
+ title: tab_title
197
+ , part_index: $('new_page_part_index').value
198
+ , body: ''
199
+ }
200
+ , onComplete: function(e){
201
+ $('page_part_editors').insert(e.transport.responseText , {position: 'bottom'});
202
+ // Add a new tab for the new content section.
203
+ $$('#page_parts').first().insert((new Element("li").addClassName("tab").insert(new Element("a", {href: "#part_" + tab_title}).update(part_title))));
204
+
205
+ // turn the new textarea into a wymeditor.
206
+ jQuery('#page_parts_attributes_' + $('new_page_part_index').value + "_body").wymeditor(wymeditor_boot_options);
207
+
208
+ // Wipe the title and increment the index counter by one.
209
+ $('new_page_part_index').value = (parseInt($('new_page_part_index').value) + 1);
210
+ $('new_page_part_title').value = "";
211
+ }
212
+ });
213
+
214
+ tb_remove();
215
+ } else {
216
+ alert("A content section with that title already exists, please choose another.");
217
+ }
218
+ } else {
219
+ alert("You have not entered a title for the content section, please enter one.");
220
+ }
221
+ });
222
+
223
+ $('new_page_part_cancel').observe('click', function(e) {
224
+ $('new_page_part_title').value = "";
225
+ tb_remove();
226
+ e.stop();
227
+ });
228
+
229
+ $('delete_page_part').observe('click', function(e) {
230
+ selected_part_link = $$('#page_parts li.active a').first();
231
+ part_container = $(selected_part_link.getAttribute('href').gsub("#", ""));
232
+ result = confirm("This will remove the content section '" + selected_part_link.innerHTML + "' when the page is saved and erase all content that has been entered into it, Are you sure?");
233
+ if (result) {
234
+ if ((part_id = $(part_container.down('textarea').id.gsub('_body', '_id'))) != null) {
235
+ new Ajax.Request("<%= admin_page_parts_url %>/" + part_id.value, {
236
+ asynchronous: true
237
+ , method: "DELETE"
238
+ , parameters:
239
+ {
240
+ authenticity_token: $$('input[name=authenticity_token]').first().value
241
+ }
242
+ });
243
+ }
244
+
245
+ // remove actual elements from DOM.
246
+ part_container.remove();
247
+ selected_part_link.up('li').remove();
248
+
249
+ WYMeditor.loaded();
250
+ }
251
+
252
+ e.stop();
253
+ });
163
254
  });
164
255
 
165
256
  custom_title_image_changed = function()
@@ -172,8 +263,8 @@
172
263
  // Hook into the loaded function. This will be called when WYMeditor has done its thing.
173
264
  WYMeditor.loaded = function()
174
265
  {
175
- new Control.Tabs('page_parts').first();
266
+ new Control.Tabs('page_parts', {setClassOnContainer: true}).first();
176
267
  }
177
268
 
178
269
  </script>
179
- <% end %>
270
+ <% end %>
@@ -0,0 +1,4 @@
1
+ <div class='page_part field' id='part_<%= title.downcase.gsub(" ", "_") %>'>
2
+ <%= hidden_field_tag "page[parts_attributes][#{part_index}][title]", title if new_part %>
3
+ <%= text_area_tag "page[parts_attributes][#{part_index}][body]", body, :rows => 20, :cols => 140, :class => 'wymeditor' %>
4
+ </div>
@@ -2,9 +2,8 @@ ActionController::Routing::Routes.draw do |map|
2
2
  map.resources :pages
3
3
 
4
4
  map.namespace(:admin) do |admin|
5
- admin.resources :pages do |page|
6
- page.resources :page_parts
7
- end
5
+ admin.resources :pages
6
+ admin.resources :page_parts
8
7
 
9
8
  admin.resources :pages_dialogs, :as => "pages/dialogs", :controller => :page_dialogs,
10
9
  :collection => {:link_to => :get, :test_url => :get, :test_email => :get}
@@ -79,7 +79,10 @@ module Crud
79
79
  module_eval %(
80
80
  def index
81
81
  if searching?
82
- @#{plural_name} = #{class_name}.paginate_search params[:search], :page => params[:page]
82
+ @#{plural_name} = #{class_name}.paginate_search params[:search],
83
+ :page => params[:page],
84
+ :order => "#{options[:order]}",
85
+ :conditions => "#{options[:conditions]}"
83
86
  else
84
87
  @#{plural_name} = #{class_name}.paginate :page => params[:page],
85
88
  :order => "#{options[:order]}",
@@ -1,4 +1,4 @@
1
- class Admin::BaseController < ApplicationController
1
+ class Refinery::AdminBaseController < ApplicationController
2
2
 
3
3
  layout proc { |controller| "admin#{"_dialog" if controller.from_dialog?}" }
4
4
 
@@ -1,5 +1,5 @@
1
1
  # Methods added to this helper will be available to all templates in the application.
2
- module ApplicationHelper
2
+ module Refinery::ApplicationHelper
3
3
 
4
4
  def add_meta_tags
5
5
  content_for :head, "<meta name=\"keywords\" content=\"#{@page.meta_keywords}\" />" unless @page.meta_keywords.blank?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Resolve Digital
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2009-10-12 00:00:00 +13:00
14
+ date: 2009-10-16 00:00:00 +13:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -446,9 +446,9 @@ files:
446
446
  - vendor/plugins/pages/app/models/page_part.rb
447
447
  - vendor/plugins/pages/app/views/admin/page_dialogs/_page_link.html.erb
448
448
  - vendor/plugins/pages/app/views/admin/page_dialogs/link_to.html.erb
449
- - vendor/plugins/pages/app/views/admin/page_parts/new.html.erb
450
449
  - vendor/plugins/pages/app/views/admin/pages/_form.html.erb
451
450
  - vendor/plugins/pages/app/views/admin/pages/_list.html.erb
451
+ - vendor/plugins/pages/app/views/admin/pages/_page_part_field.html.erb
452
452
  - vendor/plugins/pages/app/views/admin/pages/_sortable_list.html.erb
453
453
  - vendor/plugins/pages/app/views/admin/pages/edit.html.erb
454
454
  - vendor/plugins/pages/app/views/admin/pages/index.html.erb
@@ -457,9 +457,10 @@ files:
457
457
  - vendor/plugins/pages/app/views/pages/show.html.erb
458
458
  - vendor/plugins/pages/config/routes.rb
459
459
  - vendor/plugins/pages/init.rb
460
- - vendor/plugins/refinery/app/controllers/admin/base_controller.rb
461
460
  - vendor/plugins/refinery/app/controllers/admin/refinery_core_controller.rb
462
- - vendor/plugins/refinery/app/helpers/application_helper.rb
461
+ - app/helpers/application_helper.rb
462
+ - vendor/plugins/refinery/lib/refinery/application_helper.rb
463
+ - vendor/plugins/refinery/lib/refinery/admin_base_controller.rb
463
464
  - vendor/plugins/refinery/app/views/admin/_head.html.erb
464
465
  - vendor/plugins/refinery/app/views/admin/_menu.html.erb
465
466
  - vendor/plugins/refinery/app/views/layouts/admin.html.erb
@@ -1,11 +0,0 @@
1
- <% send :"form_#{'remote_' if from_dialog?}for", [:admin, @page, @page_part] do |f| %>
2
- <div class='field'>
3
- <%= f.label :title %>
4
- <%= f.text_field :title %>
5
- </div>
6
- <div class='form-actions'>
7
- <%= f.submit 'Save', :id => "submit_button" %>
8
- or
9
- <%= link_to "Cancel", edit_admin_page_url(@page), :class => "close_dialog" %>
10
- </div>
11
- <% end %>